コード例 #1
0
 /**
  * Returns an enum indicating how the baseline of the component changes as the size changes.
  *
  * @throws NullPointerException {@inheritDoc}
  * @see javax.swing.JComponent#getBaseline(int, int)
  * @since 1.6
  */
 public Component.BaselineResizeBehavior getBaselineResizeBehavior(JComponent c) {
   super.getBaselineResizeBehavior(c);
   if (progressBar.isStringPainted() && progressBar.getOrientation() == JProgressBar.HORIZONTAL) {
     return Component.BaselineResizeBehavior.CENTER_OFFSET;
   }
   return Component.BaselineResizeBehavior.OTHER;
 }
コード例 #2
0
  /**
   * Paints the progress string.
   *
   * @param g Graphics used for drawing.
   * @param x x location of bounding box
   * @param y y location of bounding box
   * @param width width of bounding box
   * @param height height of bounding box
   * @param fillStart start location, in x or y depending on orientation, of the filled portion of
   *     the progress bar.
   * @param amountFull size of the fill region, either width or height depending upon orientation.
   * @param b Insets of the progress bar.
   */
  private void paintString(
      Graphics g, int x, int y, int width, int height, int fillStart, int amountFull, Insets b) {
    if (!(g instanceof Graphics2D)) {
      return;
    }

    Graphics2D g2 = (Graphics2D) g;
    String progressString = progressBar.getString();
    g2.setFont(progressBar.getFont());
    Point renderLocation = getStringPlacement(g2, progressString, x, y, width, height);
    Rectangle oldClip = g2.getClipBounds();

    if (progressBar.getOrientation() == JProgressBar.HORIZONTAL) {
      g2.setColor(getSelectionBackground());
      SwingUtilities2.drawString(
          progressBar, g2, progressString, renderLocation.x, renderLocation.y);
      g2.setColor(getSelectionForeground());
      g2.clipRect(fillStart, y, amountFull, height);
      SwingUtilities2.drawString(
          progressBar, g2, progressString, renderLocation.x, renderLocation.y);
    } else { // VERTICAL
      g2.setColor(getSelectionBackground());
      AffineTransform rotate = AffineTransform.getRotateInstance(Math.PI / 2);
      g2.setFont(progressBar.getFont().deriveFont(rotate));
      renderLocation = getStringPlacement(g2, progressString, x, y, width, height);
      SwingUtilities2.drawString(
          progressBar, g2, progressString, renderLocation.x, renderLocation.y);
      g2.setColor(getSelectionForeground());
      g2.clipRect(x, fillStart, width, amountFull);
      SwingUtilities2.drawString(
          progressBar, g2, progressString, renderLocation.x, renderLocation.y);
    }
    g2.setClip(oldClip);
  }
コード例 #3
0
  /**
   * Sets the index of the current animation frame to the specified value and requests that the
   * progress bar be repainted. Subclasses that don't use the default painting code might need to
   * override this method to change the way that the <code>repaint</code> method is invoked.
   *
   * @param newValue the new animation index; no checking is performed on its value
   * @see #incrementAnimationIndex
   * @since 1.4
   */
  protected void setAnimationIndex(int newValue) {
    if (animationIndex != newValue) {
      if (sizeChanged()) {
        animationIndex = newValue;
        maxPosition = 0; // needs to be recalculated
        delta = 0.0; // needs to be recalculated
        progressBar.repaint();
        return;
      }

      // Get the previous box drawn.
      nextPaintRect = getBox(nextPaintRect);

      // Update the frame number.
      animationIndex = newValue;

      // Get the next box to draw.
      if (nextPaintRect != null) {
        boxRect = getBox(boxRect);
        if (boxRect != null) {
          nextPaintRect.add(boxRect);
        }
      }
    } else { // animationIndex == newValue
      return;
    }

    if (nextPaintRect != null) {
      progressBar.repaint(nextPaintRect);
    } else {
      progressBar.repaint();
    }
  }
コード例 #4
0
  protected void installListeners() {
    // Listen for changes in the progress bar's data.
    changeListener = getHandler();
    progressBar.addChangeListener(changeListener);

    // Listen for changes between determinate and indeterminate state.
    progressBar.addPropertyChangeListener(getHandler());
  }
コード例 #5
0
 /**
  * Returns the baseline.
  *
  * @throws NullPointerException {@inheritDoc}
  * @throws IllegalArgumentException {@inheritDoc}
  * @see javax.swing.JComponent#getBaseline(int, int)
  * @since 1.6
  */
 public int getBaseline(JComponent c, int width, int height) {
   super.getBaseline(c, width, height);
   if (progressBar.isStringPainted() && progressBar.getOrientation() == JProgressBar.HORIZONTAL) {
     FontMetrics metrics = progressBar.getFontMetrics(progressBar.getFont());
     Insets insets = progressBar.getInsets();
     int y = insets.top;
     height = height - insets.top - insets.bottom;
     return y + (height + metrics.getAscent() - metrics.getLeading() - metrics.getDescent()) / 2;
   }
   return -1;
 }
コード例 #6
0
ファイル: Notepad.java プロジェクト: ArcherSys/ArcherSysRuby
    @Override
    @SuppressWarnings("SleepWhileHoldingLock")
    public void run() {
      try {
        // initialize the statusbar
        status.removeAll();
        JProgressBar progress = new JProgressBar();
        progress.setMinimum(0);
        progress.setMaximum(doc.getLength());
        status.add(progress);
        status.revalidate();

        // start writing
        Writer out = new FileWriter(f);
        Segment text = new Segment();
        text.setPartialReturn(true);
        int charsLeft = doc.getLength();
        int offset = 0;
        while (charsLeft > 0) {
          doc.getText(offset, Math.min(4096, charsLeft), text);
          out.write(text.array, text.offset, text.count);
          charsLeft -= text.count;
          offset += text.count;
          progress.setValue(offset);
          try {
            Thread.sleep(10);
          } catch (InterruptedException e) {
            Logger.getLogger(FileSaver.class.getName()).log(Level.SEVERE, null, e);
          }
        }
        out.flush();
        out.close();
      } catch (IOException e) {
        final String msg = e.getMessage();
        SwingUtilities.invokeLater(
            new Runnable() {

              public void run() {
                JOptionPane.showMessageDialog(
                    getFrame(),
                    "Could not save file: " + msg,
                    "Error saving file",
                    JOptionPane.ERROR_MESSAGE);
              }
            });
      } catch (BadLocationException e) {
        System.err.println(e.getMessage());
      }
      // we are done... get rid of progressbar
      status.removeAll();
      status.revalidate();
    }
コード例 #7
0
ファイル: Notepad.java プロジェクト: ArcherSys/ArcherSysRuby
    @Override
    public void run() {
      try {
        // initialize the statusbar
        status.removeAll();
        JProgressBar progress = new JProgressBar();
        progress.setMinimum(0);
        progress.setMaximum((int) f.length());
        status.add(progress);
        status.revalidate();

        // try to start reading
        Reader in = new FileReader(f);
        char[] buff = new char[4096];
        int nch;
        while ((nch = in.read(buff, 0, buff.length)) != -1) {
          doc.insertString(doc.getLength(), new String(buff, 0, nch), null);
          progress.setValue(progress.getValue() + nch);
        }
      } catch (IOException e) {
        final String msg = e.getMessage();
        SwingUtilities.invokeLater(
            new Runnable() {

              public void run() {
                JOptionPane.showMessageDialog(
                    getFrame(),
                    "Could not open file: " + msg,
                    "Error opening file",
                    JOptionPane.ERROR_MESSAGE);
              }
            });
      } catch (BadLocationException e) {
        System.err.println(e.getMessage());
      }
      doc.addUndoableEditListener(undoHandler);
      // we are done... get rid of progressbar
      status.removeAll();
      status.revalidate();

      resetUndoManager();

      if (elementTreePanel != null) {
        SwingUtilities.invokeLater(
            new Runnable() {

              public void run() {
                elementTreePanel.setEditor(getEditor());
              }
            });
      }
    }
コード例 #8
0
  /**
   * This determines the amount of the progress bar that should be filled based on the percent done
   * gathered from the model. This is a common operation so it was abstracted out. It assumes that
   * your progress bar is linear. That is, if you are making a circular progress indicator, you will
   * want to override this method.
   */
  protected int getAmountFull(Insets b, int width, int height) {
    int amountFull = 0;
    BoundedRangeModel model = progressBar.getModel();

    if ((model.getMaximum() - model.getMinimum()) != 0) {
      if (progressBar.getOrientation() == JProgressBar.HORIZONTAL) {
        amountFull = (int) Math.round(width * progressBar.getPercentComplete());
      } else {
        amountFull = (int) Math.round(height * progressBar.getPercentComplete());
      }
    }
    return amountFull;
  }
コード例 #9
0
  /**
   * Stores the position and size of the bouncing box that would be painted for the current
   * animation index in <code>r</code> and returns <code>r</code>. Subclasses that add to the
   * painting performed in this class's implementation of <code>paintIndeterminate</code> -- to draw
   * an outline around the bouncing box, for example -- can use this method to get the location of
   * the bouncing box that was just painted. By overriding this method, you have complete control
   * over the size and position of the bouncing box, without having to reimplement <code>
   * paintIndeterminate</code>.
   *
   * @param r the Rectangle instance to be modified; may be <code>null</code>
   * @return <code>null</code> if no box should be drawn; otherwise, returns the passed-in rectangle
   *     (if non-null) or a new rectangle
   * @see #setAnimationIndex
   * @since 1.4
   */
  protected Rectangle getBox(Rectangle r) {
    int currentFrame = getAnimationIndex();
    int middleFrame = numFrames / 2;

    if (sizeChanged() || delta == 0.0 || maxPosition == 0.0) {
      updateSizes();
    }

    r = getGenericBox(r);

    if (r == null) {
      return null;
    }
    if (middleFrame <= 0) {
      return null;
    }

    // assert currentFrame >= 0 && currentFrame < numFrames
    if (progressBar.getOrientation() == JProgressBar.HORIZONTAL) {
      if (currentFrame < middleFrame) {
        r.x = componentInnards.x + (int) Math.round(delta * (double) currentFrame);
      } else {
        r.x = maxPosition - (int) Math.round(delta * (currentFrame - middleFrame));
      }
    } else { // VERTICAL indeterminate progress bar
      if (currentFrame < middleFrame) {
        r.y = componentInnards.y + (int) Math.round(delta * currentFrame);
      } else {
        r.y = maxPosition - (int) Math.round(delta * (currentFrame - middleFrame));
      }
    }
    return r;
  }
コード例 #10
0
 /**
  * Returns the width (if HORIZONTAL) or height (if VERTICAL) of each of the individual cells/units
  * to be rendered in the progress bar. However, for text rendering simplification and aesthetic
  * considerations, this function will return 1 when the progress string is being rendered.
  *
  * @return the value representing the spacing between cells
  * @see #setCellLength
  * @see JProgressBar#isStringPainted
  */
 protected int getCellLength() {
   if (progressBar.isStringPainted()) {
     return 1;
   } else {
     return cellLength;
   }
 }
コード例 #11
0
  /** Assumes that the component innards, max position, etc. are up-to-date. */
  private Rectangle getGenericBox(Rectangle r) {
    if (r == null) {
      r = new Rectangle();
    }

    if (progressBar.getOrientation() == JProgressBar.HORIZONTAL) {
      r.width = getBoxLength(componentInnards.width, componentInnards.height);
      if (r.width < 0) {
        r = null;
      } else {
        r.height = componentInnards.height;
        r.y = componentInnards.y;
      }
      // end of HORIZONTAL

    } else { // VERTICAL progress bar
      r.height = getBoxLength(componentInnards.height, componentInnards.width);
      if (r.height < 0) {
        r = null;
      } else {
        r.width = componentInnards.width;
        r.x = componentInnards.x;
      }
    } // end of VERTICAL

    return r;
  }
コード例 #12
0
  /** Invoked by PropertyChangeHandler. */
  private void cleanUpIndeterminateValues() {
    // stop the animation thread if necessary
    if (progressBar.isDisplayable()) {
      stopAnimationTimer();
    }

    cycleTime = repaintInterval = 0;
    numFrames = animationIndex = 0;
    maxPosition = 0;
    delta = 0.0;

    boxRect = nextPaintRect = null;
    componentInnards = oldComponentInnards = null;

    progressBar.removeHierarchyListener(getHandler());
  }
コード例 #13
0
 /** Delegates painting to one of two methods: paintDeterminate or paintIndeterminate. */
 public void paint(Graphics g, JComponent c) {
   if (progressBar.isIndeterminate()) {
     paintIndeterminate(g, c);
   } else {
     paintDeterminate(g, c);
   }
 }
コード例 #14
0
 /**
  * Returns the spacing between each of the cells/units in the progress bar. However, for text
  * rendering simplification and aesthetic considerations, this function will return 0 when the
  * progress string is being rendered.
  *
  * @return the value representing the spacing between cells
  * @see #setCellSpacing
  * @see JProgressBar#isStringPainted
  */
 protected int getCellSpacing() {
   if (progressBar.isStringPainted()) {
     return 0;
   } else {
     return cellSpacing;
   }
 }
コード例 #15
0
 public void installUI(JComponent c) {
   progressBar = (JProgressBar) c;
   installDefaults();
   installListeners();
   if (progressBar.isIndeterminate()) {
     initIndeterminateValues();
   }
 }
コード例 #16
0
 public void uninstallUI(JComponent c) {
   if (progressBar.isIndeterminate()) {
     cleanUpIndeterminateValues();
   }
   uninstallDefaults();
   uninstallListeners();
   progressBar = null;
 }
コード例 #17
0
 public Dimension getMaximumSize(JComponent c) {
   Dimension pref = getPreferredSize(progressBar);
   if (progressBar.getOrientation() == JProgressBar.HORIZONTAL) {
     pref.width = Short.MAX_VALUE;
   } else {
     pref.height = Short.MAX_VALUE;
   }
   return pref;
 }
コード例 #18
0
  /**
   * Designate the place where the progress string will be painted. This implementation places it at
   * the center of the progress bar (in both x and y). Override this if you want to right, left,
   * top, or bottom align the progress string or if you need to nudge it around for any reason.
   */
  protected Point getStringPlacement(
      Graphics g, String progressString, int x, int y, int width, int height) {
    FontMetrics fontSizer = SwingUtilities2.getFontMetrics(progressBar, g, progressBar.getFont());
    int stringWidth = SwingUtilities2.stringWidth(progressBar, fontSizer, progressString);

    if (progressBar.getOrientation() == JProgressBar.HORIZONTAL) {
      return new Point(
          x + Math.round(width / 2 - stringWidth / 2),
          y
              + ((height + fontSizer.getAscent() - fontSizer.getLeading() - fontSizer.getDescent())
                  / 2));
    } else { // VERTICAL
      return new Point(
          x
              + ((width - fontSizer.getAscent() + fontSizer.getLeading() + fontSizer.getDescent())
                  / 2),
          y + Math.round(height / 2 - stringWidth / 2));
    }
  }
コード例 #19
0
 // Called from initIndeterminateValues to initialize the animation index.
 // This assumes that numFrames is set to a correct value.
 private void initAnimationIndex() {
   if ((progressBar.getOrientation() == JProgressBar.HORIZONTAL)
       && (BasicGraphicsUtils.isLeftToRight(progressBar))) {
     // If this is a left-to-right progress bar,
     // start at the first frame.
     setAnimationIndex(0);
   } else {
     // If we go right-to-left or vertically, start at the right/bottom.
     setAnimationIndex(numFrames / 2);
   }
 }
コード例 #20
0
  /**
   * Invoked by PropertyChangeHandler.
   *
   * <p>NOTE: This might not be invoked until after the first paintIndeterminate call.
   */
  private void initIndeterminateValues() {
    initIndeterminateDefaults();
    // assert cycleTime/repaintInterval is a whole multiple of 2.
    numFrames = cycleTime / repaintInterval;
    initAnimationIndex();

    boxRect = new Rectangle();
    nextPaintRect = new Rectangle();
    componentInnards = new Rectangle();
    oldComponentInnards = new Rectangle();

    // we only bother installing the HierarchyChangeListener if we
    // are indeterminate
    progressBar.addHierarchyListener(getHandler());

    // start the animation thread if necessary
    if (progressBar.isDisplayable()) {
      startAnimationTimer();
    }
  }
コード例 #21
0
    public void run() {
      try {
        // initialize the statusbar
        status.removeAll();
        JProgressBar progress = new JProgressBar();
        progress.setMinimum(0);
        progress.setMaximum((int) f2.length());
        status.add(progress);
        status.revalidate();

        // try to start reading
        Reader in = new FileReader(f2);
        char[] buff = new char[4096];
        int nch;
        while ((nch = in.read(buff, 0, buff.length)) != -1) {
          doc2.insertString(doc2.getLength(), new String(buff, 0, nch), null);
          progress.setValue(progress.getValue() + nch);
        }

        // we are done... get rid of progressbar
        // doc2.addUndoableEditListener(undoHandler);
        status.removeAll();
        status.revalidate();

        // resetUndoManager();
      } catch (IOException e) {
        System.err.println("TextViewer:FileLoader " + e.toString());
      } catch (BadLocationException e) {
        System.err.println("TextViewer:FileLoader " + e.getMessage());
      }
      /* aa
         if (elementTreePanel != null) {
         SwingUtilities.invokeLater(new Runnable() {
         public void run() {
         elementTreePanel.setEditor(getEditor());
         }
         });
         }
      */
    }
コード例 #22
0
  /**
   * All purpose paint method that should do the right thing for all linear bouncing-box progress
   * bars. Override this if you are making another kind of progress bar.
   *
   * @see #paintDeterminate
   * @since 1.4
   */
  protected void paintIndeterminate(Graphics g, JComponent c) {
    if (!(g instanceof Graphics2D)) {
      return;
    }

    Insets b = progressBar.getInsets(); // area for border
    int barRectWidth = progressBar.getWidth() - (b.right + b.left);
    int barRectHeight = progressBar.getHeight() - (b.top + b.bottom);

    if (barRectWidth <= 0 || barRectHeight <= 0) {
      return;
    }

    Graphics2D g2 = (Graphics2D) g;

    // Paint the bouncing box.
    boxRect = getBox(boxRect);
    if (boxRect != null) {
      g2.setColor(progressBar.getForeground());
      g2.fillRect(boxRect.x, boxRect.y, boxRect.width, boxRect.height);
    }

    // Deal with possible text painting
    if (progressBar.isStringPainted()) {
      if (progressBar.getOrientation() == JProgressBar.HORIZONTAL) {
        paintString(g2, b.left, b.top, barRectWidth, barRectHeight, boxRect.x, boxRect.width, b);
      } else {
        paintString(g2, b.left, b.top, barRectWidth, barRectHeight, boxRect.y, boxRect.height, b);
      }
    }
  }
コード例 #23
0
 protected void paintString(
     Graphics g, int x, int y, int width, int height, int amountFull, Insets b) {
   if (progressBar.getOrientation() == JProgressBar.HORIZONTAL) {
     if (BasicGraphicsUtils.isLeftToRight(progressBar)) {
       if (progressBar.isIndeterminate()) {
         boxRect = getBox(boxRect);
         paintString(g, x, y, width, height, boxRect.x, boxRect.width, b);
       } else {
         paintString(g, x, y, width, height, x, amountFull, b);
       }
     } else {
       paintString(g, x, y, width, height, x + width - amountFull, amountFull, b);
     }
   } else {
     if (progressBar.isIndeterminate()) {
       boxRect = getBox(boxRect);
       paintString(g, x, y, width, height, boxRect.y, boxRect.height, b);
     } else {
       paintString(g, x, y, width, height, y + height - amountFull, amountFull, b);
     }
   }
 }
コード例 #24
0
  /**
   * Updates delta, max position. Assumes componentInnards is correct (e.g. call after
   * sizeChanged()).
   */
  private void updateSizes() {
    int length = 0;

    if (progressBar.getOrientation() == JProgressBar.HORIZONTAL) {
      length = getBoxLength(componentInnards.width, componentInnards.height);
      maxPosition = componentInnards.x + componentInnards.width - length;

    } else { // VERTICAL progress bar
      length = getBoxLength(componentInnards.height, componentInnards.width);
      maxPosition = componentInnards.y + componentInnards.height - length;
    }

    // If we're doing bouncing-box animation, update delta.
    delta = 2.0 * (double) maxPosition / (double) numFrames;
  }
コード例 #25
0
  public Dimension getPreferredSize(JComponent c) {
    Dimension size;
    Insets border = progressBar.getInsets();
    FontMetrics fontSizer = progressBar.getFontMetrics(progressBar.getFont());

    if (progressBar.getOrientation() == JProgressBar.HORIZONTAL) {
      size = new Dimension(getPreferredInnerHorizontal());
      // Ensure that the progress string will fit
      if (progressBar.isStringPainted()) {
        // I'm doing this for completeness.
        String progString = progressBar.getString();
        int stringWidth = SwingUtilities2.stringWidth(progressBar, fontSizer, progString);
        if (stringWidth > size.width) {
          size.width = stringWidth;
        }
        // This uses both Height and Descent to be sure that
        // there is more than enough room in the progress bar
        // for everything.
        // This does have a strange dependency on
        // getStringPlacememnt() in a funny way.
        int stringHeight = fontSizer.getHeight() + fontSizer.getDescent();
        if (stringHeight > size.height) {
          size.height = stringHeight;
        }
      }
    } else {
      size = new Dimension(getPreferredInnerVertical());
      // Ensure that the progress string will fit.
      if (progressBar.isStringPainted()) {
        String progString = progressBar.getString();
        int stringHeight = fontSizer.getHeight() + fontSizer.getDescent();
        if (stringHeight > size.width) {
          size.width = stringHeight;
        }
        // This is also for completeness.
        int stringWidth = SwingUtilities2.stringWidth(progressBar, fontSizer, progString);
        if (stringWidth > size.height) {
          size.height = stringWidth;
        }
      }
    }

    size.width += border.left + border.right;
    size.height += border.top + border.bottom;
    return size;
  }
コード例 #26
0
ファイル: MainFrame.java プロジェクト: gaurav/taxref
  /**
   * Create a new, empty, not-visible TaxRef window. Really just activates the setup frame and setup
   * memory monitor components, then starts things off.
   */
  public MainFrame() {
    setupMemoryMonitor();

    // Set up the main frame.
    mainFrame = new JFrame(basicTitle);
    mainFrame.setJMenuBar(setupMenuBar());
    mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Set up the JTable.
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.setSelectionBackground(COLOR_SELECTION_BACKGROUND);
    table.setShowGrid(true);

    // Add a blank table model so that the component renders properly on
    // startup.
    table.setModel(blankDataModel);

    // Add a list selection listener so we can tell the matchInfoPanel
    // that a new name was selected.
    table
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              @Override
              public void valueChanged(ListSelectionEvent e) {
                if (currentCSV == null) return;

                int row = table.getSelectedRow();
                int column = table.getSelectedColumn();

                columnInfoPanel.columnChanged(column);

                Object o = table.getModel().getValueAt(row, column);
                if (Name.class.isAssignableFrom(o.getClass())) {
                  matchInfoPanel.nameSelected(currentCSV.getRowIndex(), (Name) o, row, column);
                } else {
                  matchInfoPanel.nameSelected(currentCSV.getRowIndex(), null, -1, -1);
                }
              }
            });

    // Set up the left panel (table + matchInfoPanel)
    JPanel leftPanel = new JPanel();

    matchInfoPanel = new MatchInformationPanel(this);
    leftPanel.setLayout(new BorderLayout());
    leftPanel.add(matchInfoPanel, BorderLayout.SOUTH);
    leftPanel.add(new JScrollPane(table));

    // Set up the right panel (columnInfoPanel)
    JPanel rightPanel = new JPanel();

    columnInfoPanel = new ColumnInformationPanel(this);

    progressBar.setStringPainted(true);

    rightPanel.setLayout(new BorderLayout());
    rightPanel.add(columnInfoPanel);
    rightPanel.add(progressBar, BorderLayout.SOUTH);

    // Set up a JSplitPane to split the panels up.
    JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, false, leftPanel, rightPanel);
    split.setResizeWeight(1);
    mainFrame.add(split);
    mainFrame.pack();

    // Set up a drop target so we can pick up files
    mainFrame.setDropTarget(
        new DropTarget(
            mainFrame,
            new DropTargetAdapter() {
              @Override
              public void dragEnter(DropTargetDragEvent dtde) {
                // Accept any drags.
                dtde.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE);
              }

              @Override
              public void dragOver(DropTargetDragEvent dtde) {}

              @Override
              public void dropActionChanged(DropTargetDragEvent dtde) {}

              @Override
              public void dragExit(DropTargetEvent dte) {}

              @Override
              public void drop(DropTargetDropEvent dtde) {
                // Accept a drop as long as its File List.

                if (dtde.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
                  dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);

                  Transferable t = dtde.getTransferable();

                  try {
                    java.util.List<File> files =
                        (java.util.List<File>) t.getTransferData(DataFlavor.javaFileListFlavor);

                    // If we're given multiple files, pick up only the last file and load that.
                    File f = files.get(files.size() - 1);
                    loadFile(f, DarwinCSV.FILE_CSV_DELIMITED);

                  } catch (UnsupportedFlavorException ex) {
                    dtde.dropComplete(false);

                  } catch (IOException ex) {
                    dtde.dropComplete(false);
                  }
                }
              }
            }));
  }
コード例 #27
0
  /**
   * All purpose paint method that should do the right thing for almost all linear, determinate
   * progress bars. By setting a few values in the defaults table, things should work just fine to
   * paint your progress bar. Naturally, override this if you are making a circular or semi-circular
   * progress bar.
   *
   * @see #paintIndeterminate
   * @since 1.4
   */
  protected void paintDeterminate(Graphics g, JComponent c) {
    if (!(g instanceof Graphics2D)) {
      return;
    }

    Insets b = progressBar.getInsets(); // area for border
    int barRectWidth = progressBar.getWidth() - (b.right + b.left);
    int barRectHeight = progressBar.getHeight() - (b.top + b.bottom);

    if (barRectWidth <= 0 || barRectHeight <= 0) {
      return;
    }

    int cellLength = getCellLength();
    int cellSpacing = getCellSpacing();
    // amount of progress to draw
    int amountFull = getAmountFull(b, barRectWidth, barRectHeight);

    Graphics2D g2 = (Graphics2D) g;
    g2.setColor(progressBar.getForeground());

    if (progressBar.getOrientation() == JProgressBar.HORIZONTAL) {
      // draw the cells
      if (cellSpacing == 0 && amountFull > 0) {
        // draw one big Rect because there is no space between cells
        g2.setStroke(
            new BasicStroke((float) barRectHeight, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
      } else {
        // draw each individual cell
        g2.setStroke(
            new BasicStroke(
                (float) barRectHeight,
                BasicStroke.CAP_BUTT,
                BasicStroke.JOIN_BEVEL,
                0.f,
                new float[] {cellLength, cellSpacing},
                0.f));
      }

      if (BasicGraphicsUtils.isLeftToRight(c)) {
        g2.drawLine(
            b.left, (barRectHeight / 2) + b.top, amountFull + b.left, (barRectHeight / 2) + b.top);
      } else {
        g2.drawLine(
            (barRectWidth + b.left),
            (barRectHeight / 2) + b.top,
            barRectWidth + b.left - amountFull,
            (barRectHeight / 2) + b.top);
      }

    } else { // VERTICAL
      // draw the cells
      if (cellSpacing == 0 && amountFull > 0) {
        // draw one big Rect because there is no space between cells
        g2.setStroke(
            new BasicStroke((float) barRectWidth, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
      } else {
        // draw each individual cell
        g2.setStroke(
            new BasicStroke(
                (float) barRectWidth,
                BasicStroke.CAP_BUTT,
                BasicStroke.JOIN_BEVEL,
                0f,
                new float[] {cellLength, cellSpacing},
                0f));
      }

      g2.drawLine(
          barRectWidth / 2 + b.left,
          b.top + barRectHeight,
          barRectWidth / 2 + b.left,
          b.top + barRectHeight - amountFull);
    }

    // Deal with possible text painting
    if (progressBar.isStringPainted()) {
      paintString(g, b.left, b.top, barRectWidth, barRectHeight, amountFull, b);
    }
  }
コード例 #28
0
 /** Removes all listeners installed by this object. */
 protected void uninstallListeners() {
   progressBar.removeChangeListener(changeListener);
   progressBar.removePropertyChangeListener(getHandler());
   handler = null;
 }
コード例 #29
0
  protected void setLayout(final Editor editor, boolean activateErrorPanel, boolean isLoading) {
    if (progressBar == null) {
      progressBar = new JProgressBar();
      progressBar.setVisible(false);

      createComponents();
      buildErrorPanel();

      loaderLabel = new JLabel(Toolkit.getLibIcon("manager/loader.gif"));
      loaderLabel.setOpaque(false);
      loaderLabel.setBackground(Color.WHITE);
    }

    int scrollBarWidth =
        contributionListPanel.scrollPane.getVerticalScrollBar().getPreferredSize().width;

    GroupLayout layout = new GroupLayout(this);
    setLayout(layout);
    //    layout.setAutoCreateContainerGaps(true);
    //    layout.setAutoCreateGaps(true);
    layout.setHorizontalGroup(
        layout
            .createParallelGroup(GroupLayout.Alignment.CENTER)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addGap(ContributionManagerDialog.STATUS_WIDTH)
                    .addComponent(
                        filterField,
                        ContributionManagerDialog.FILTER_WIDTH,
                        ContributionManagerDialog.FILTER_WIDTH,
                        ContributionManagerDialog.FILTER_WIDTH)
                    //                  .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
                    .addPreferredGap(
                        LayoutStyle.ComponentPlacement.RELATED,
                        GroupLayout.PREFERRED_SIZE,
                        Short.MAX_VALUE)
                    .addComponent(
                        categoryChooser,
                        ContributionManagerDialog.AUTHOR_WIDTH,
                        ContributionManagerDialog.AUTHOR_WIDTH,
                        ContributionManagerDialog.AUTHOR_WIDTH)
                    .addGap(scrollBarWidth))
            .addComponent(loaderLabel)
            .addComponent(contributionListPanel)
            .addComponent(errorPanel)
            .addComponent(statusPanel));

    layout.setVerticalGroup(
        layout
            .createSequentialGroup()
            .addContainerGap()
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.CENTER)
                    .addComponent(categoryChooser)
                    .addComponent(filterField))
            .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.CENTER)
                    .addComponent(loaderLabel)
                    .addComponent(contributionListPanel))
            .addComponent(errorPanel)
            .addComponent(
                statusPanel,
                GroupLayout.PREFERRED_SIZE,
                GroupLayout.DEFAULT_SIZE,
                GroupLayout.PREFERRED_SIZE));
    layout.linkSize(SwingConstants.VERTICAL, categoryChooser, filterField);

    // these will occupy space even if not visible
    layout.setHonorsVisibility(contributionListPanel, false);
    layout.setHonorsVisibility(categoryChooser, false);

    setBackground(Color.WHITE);
    setBorder(null);
  }
コード例 #30
0
  Library() {
    super("Library Management");
    frame = this;
    try {
      UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
    } catch (Exception de) {
    }

    cp = getContentPane();
    cp.setLayout(null);

    // Adding TextArea in Panel
    jp1 = new JPanel(null, true);
    // t1=new
    // JTextField("|Name    "+"\t\t"+"  |Author"+"\t\t "+" |Publication   "+"\t"+"|Issue
    // "+"\t"+"|Return    "+"\t"+"|  Cutm. Id");
    // t1.setEditable(false);
    // t1.setBounds(0,0,600,20);
    // jp1.add(t1);

    MenuBar mb = new MenuBar();
    setMenuBar(mb);
    Menu menu2 = new Menu("Skins");
    MenuItem item4 = new MenuItem("Defualt Skin");
    MenuItem item5 = new MenuItem("Metal Skin");
    MenuItem item6 = new MenuItem("Modified Skin");
    // item5.setSelected(true);
    menu2.add(item4);
    menu2.add(item5);
    menu2.add(item6);
    mb.add(menu2);

    Menu menu21 = new Menu("Backup");
    MenuItem item61 = new MenuItem("Create Database Backup");
    menu21.add(item61);
    mb.add(menu21);

    // Menu menu1=new Menu("About");
    // MenuItem item1=new MenuItem("Help ?");
    // MenuItem item2=new MenuItem("Support ?");
    // MenuItem item3=new MenuItem("About Us ?");
    // menu1.add(item1);menu1.add(item2);menu1.add(item3);
    // mb.add(menu1);

    Menu menu212 = new Menu("Exit");
    MenuItem item612 = new MenuItem("Exit Form Library");
    menu212.add(item612);
    mb.add(menu212);

    int h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS;
    int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS;

    Color re = new Color(122, 145, 201);

    mo1 = new DefaultListModel();
    list1 = new JList(mo1);
    ml1 = new JLabel("    Book's Name");
    ml1.setForeground(Color.red);
    ml1.setBounds(15, 0, 154, 20);
    list1.setBounds(15, 20, 154, 500);
    list1.setToolTipText("NAme of Book's Present in Database");
    jp1.add(ml1);
    jp1.add(list1);

    mo2 = new DefaultListModel();
    list2 = new JList(mo2);
    ml2 = new JLabel("   Author");
    ml2.setForeground(re);
    ml2.setBounds(140 + 30, 0, 99, 20);
    list2.setToolTipText("Name of Book Author's Present in Database");
    list2.setBounds(140 + 30, 20, 99, 900);
    jp1.add(ml2);
    jp1.add(list2);

    mo3 = new DefaultListModel();
    list3 = new JList(mo3);
    ml3 = new JLabel("   Publication");
    ml3.setForeground(re);
    ml3.setBounds(240 + 30, 0, 99, 20);
    list3.setToolTipText("Name of Book's Publication Present in Database");
    list3.setBounds(240 + 30, 20, 99, 500);
    jp1.add(ml3);
    jp1.add(list3);

    mo4 = new DefaultListModel();
    list4 = new JList(mo4);
    ml4 = new JLabel("  Issue Date");
    ml4.setForeground(re);
    ml4.setBounds(340 + 30, 0, 70, 20);
    list4.setToolTipText("Date of Issue Present in Database");
    list4.setBounds(340 + 30, 20, 70, 500);
    jp1.add(ml4);
    jp1.add(list4);

    mo5 = new DefaultListModel();
    list5 = new JList(mo5);
    ml5 = new JLabel("   Return Date");
    ml5.setForeground(re);
    ml5.setBounds(411 + 30, 0, 70, 20);
    list5.setToolTipText("Date of Return Present in Database");
    list5.setBounds(411 + 30, 20, 70, 500);
    jp1.add(ml5);
    jp1.add(list5);

    mo6 = new DefaultListModel();
    list6 = new JList(mo6);
    ml6 = new JLabel("   Cust. ID");
    ml6.setForeground(re);
    ml6.setBounds(482 + 30, 0, 60, 20);
    list6.setToolTipText("ID of customer that purchase the book last time ");
    list6.setBounds(482 + 30, 20, 60, 500);
    jp1.add(ml6);
    jp1.add(list6);

    // a1=new JTextArea();
    // a1.setText("|Name    "+"\t\t\t"+"  |Author"+"\t\t\t"+" |Publication   "+"\t\t"+"|Issue
    // "+"\t\t"+"|Return    "+"\t\t"+"|  Cutm. Id");
    // a1.setEditable(false);
    // JScrollPane scroll=new JScrollPane(a1,v,h);
    // scroll.setBounds(0,20,600,578);
    // jp1.add(scroll);

    for (int x = 1; x < 100; x++) {
      sr = new JLabel(x + "\n");
      sr.setForeground(re);
      sr.setBounds(0, 20, 10, 500);
      jp1.add(sr);
    }

    // jp1.setBackground(Color.black);
    JScrollPane nm = new JScrollPane(jp1, v, h);
    nm.setBounds(10, 20, 600, 500);
    cp.add(nm);

    jp2 = new JPanel(null, true);

    b1 = new JButton("Add Book");
    b1.setBounds(10, 10, 120, 25);
    jp2.add(b1);

    b2 = new JButton("Delete Book");
    b2.setBounds(10, 45, 120, 25);
    jp2.add(b2);

    b3 = new JButton("View Book Details");
    b3.setBounds(10, 80, 120, 25);
    jp2.add(b3);

    b4 = new JButton("View All Book's");
    b4.setBounds(10, 115, 120, 25);
    jp2.add(b4);

    Color r = new Color(122, 145, 201);
    jp2.setBackground(r);
    jp2.setBounds(630, 20, 160, 145);
    cp.add(jp2);

    jp3 = new JPanel(null, true);

    t1 = new JTextField();
    t1.setBounds(10, 10, 120, 20);
    jp3.add(t1);
    t1.setToolTipText("Find The Book By Book Name. It is Advaced Search System");

    b5 = new JButton("Search Book Name");
    b5.setBounds(05, 35, 130, 20);
    jp3.add(b5);
    // b5.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N,Event.CTRL_MASK));
    b5.setMnemonic(KeyEvent.VK_N);

    JLabel lk = new JLabel("__________________________________");
    lk.setForeground(Color.black);
    lk.setBounds(0, 50, 160, 6);
    jp3.add(lk);

    t14 = new JTextField();
    t14.setBounds(10, 60, 120, 20);
    jp3.add(t14);
    t14.setToolTipText("Find The Book By Author Name. It is Advaced Search System");

    b10 = new JButton("Search Author");
    b10.setBounds(05, 85, 130, 20);
    jp3.add(b10);

    // b10.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_a,Event.CTRL_MASK));
    b10.setMnemonic(KeyEvent.VK_N);

    Color r1 = new Color(122, 145, 201);
    jp3.setBackground(r1);
    jp3.setBounds(630, 180, 160, 115);
    cp.add(jp3);

    jp4 = new JPanel(null, true);

    b15 = new JButton("Add Customer");
    b15.setBounds(10, 05, 120, 25);
    jp4.add(b15);

    b6 = new JButton("View all Cotumers");
    b6.setBounds(10, 35, 120, 25);
    jp4.add(b6);

    t2 = new JTextField();
    t2.setBounds(10, 65, 120, 20);
    t2.setToolTipText("Find The Customer Information. It is Advaced Search System");
    jp4.add(t2);

    b7 = new JButton("Search");
    b7.setBounds(05, 90, 130, 20);
    jp4.add(b7);

    b8 = new JButton("Delete Costumer");
    b8.setBounds(10, 115, 120, 25);
    jp4.add(b8);

    b9 = new JButton("View Cust. Details");
    b9.setBounds(10, 150, 120, 25);
    jp4.add(b9);

    Color r3 = new Color(122, 145, 201);
    jp4.setBackground(r3);
    jp4.setBounds(630, 305, 160, 180);
    cp.add(jp4);

    b_no = new JLabel();
    b_no.setForeground(Color.red);
    b_no.setBounds(150, 0, 150, 20);
    cp.add(b_no);

    progress1 = new JProgressBar();
    progress1.setBackground(re);
    progress1.setBounds(630, 490, 150, 25);
    cp.add(progress1);

    try {
      rd1 = new FileReader("Database/pointer.mmm");
      read1 = new JTextField();
      read1.read(rd1, null);
      int count = Integer.parseInt(read1.getText());
      int total = count - 1;
      int blk = 0;
      rd1.close();

      for (int i = 1; i < count; i++) {
        rd1 = new FileReader("Database/" + i + ".name");
        read1 = new JTextField();
        read1.read(rd1, null);
        if (!read1.getText().equals("")) {
          blk++;
          b_no.setText("Total Books = " + blk + " (Book's)");
          mo1.addElement(read1.getText() + "");
          rd1.close();

          int per = i * 100 / total;
          progress1.setValue(per);

          rd1 = new FileReader("Database/" + i + ".author");
          read1 = new JTextField();
          read1.read(rd1, null);
          mo2.addElement(read1.getText() + "");
          rd1.close();

          rd1 = new FileReader("Database/" + i + ".publication");
          read1 = new JTextField();
          read1.read(rd1, null);
          mo3.addElement(read1.getText() + "");
          rd1.close();

          rd1 = new FileReader("Database/" + i + ".issue");
          read1 = new JTextField();
          read1.read(rd1, null);
          if (!read1.getText().equals("")) {
            mo4.addElement(read1.getText() + "");
          } else {
            mo4.addElement(read1.getText() + "   -");
          }
          rd1.close();

          rd1 = new FileReader("Database/" + i + ".return");
          read1 = new JTextField();
          read1.read(rd1, null);
          mo5.addElement(read1.getText() + "");
          rd1.close();

          rd1 = new FileReader("Database/" + i + ".id");
          read1 = new JTextField();
          read1.read(rd1, null);
          mo6.addElement(read1.getText() + "");
          rd1.close();
        }
      }
    } catch (Exception der) {
      a1.setText("Error Occurs: \n" + der);
    }

    // Source code for searching the book's from Database
    // it search book by name of book,author,publication
    // it work when you don't know about any thing than press any
    // keyword to find book/
    // eg: if you have book name that publish by that publication which
    // starts from "c"
    // then you press only "c" in search it show you all Books that start
    // with "c" ,Author "c" and publication that start "c" .

    // Warning:
    // Don't Modify the code without knowledge of full source code
    // Author : Pravin Rane

    b5.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            try {
              int bs1 = 0;
              progress1.setValue(0);
              mo1.removeAllElements();
              mo2.removeAllElements();
              mo3.removeAllElements();
              mo4.removeAllElements();
              mo5.removeAllElements();
              mo6.removeAllElements();

              ml1.setText("Book Name");
              ml2.setText("Author");
              ml3.setText("Publication");
              ml4.setText("Issue Date");
              ml5.setText("Return Date");
              ml6.setText("Cust. ID.");

              if (!t1.getText().equals("")) {
                rd1 = new FileReader("Database/pointer.mmm");
                read1 = new JTextField();
                read1.read(rd1, null);
                int no = Integer.parseInt(read1.getText());
                rd1.close();

                int len = t1.getText().length();
                for (int k = 0; k < len; k++) {
                  char ch = t1.getText().charAt(k);
                  stra1 = stra1 + ch;
                  // System.out.println(stra1+"");
                }

                for (int v = 1; v < no; v++) {
                  name11 = "";
                  author11 = "";
                  publication11 = "";
                  progress1.setMaximum(no);

                  int per = v * 100 / no;
                  progress1.updateUI();
                  progress1.setValue(per);

                  FileReader re1 = new FileReader("Database/" + v + ".name");
                  JTextField jt1 = new JTextField();
                  jt1.read(re1, null);
                  String name = jt1.getText();
                  re1.close();

                  FileReader re2 = new FileReader("Database/" + v + ".author");
                  JTextField jt2 = new JTextField();
                  jt2.read(re2, null);
                  String author = jt2.getText();
                  re2.close();

                  FileReader re3 = new FileReader("Database/" + v + ".publication");
                  JTextField jt3 = new JTextField();
                  jt3.read(re3, null);
                  String publication = jt3.getText();
                  re3.close();
                  find = v;

                  try {
                    for (int z = 0; z < len; z++) {

                      name11 = name11 + name.charAt(z);

                      // author11=author11+author.charAt(z);
                      // System.out.println(author11+"");
                      publication11 = publication11 + publication.charAt(z);
                      if (z == (len - 1)) {
                        // System.out.println(name11+"");
                        // System.out.println(publication11+"");
                      }
                    }

                  } catch (Exception def) {
                  }

                  if (name.toLowerCase().equals(t1.getText())
                      || name.toUpperCase().equals(t1.getText())
                      || author.toLowerCase().equals(t1.getText())
                      || author.toUpperCase().equals(t1.getText())
                      || publication.toLowerCase().equals(t1.getText())
                      || publication.toUpperCase().equals(t1.getText())) {
                    bs1++;
                    rd1 = new FileReader("Database/" + find + ".name");
                    read1 = new JTextField();
                    read1.read(rd1, null);
                    mo1.addElement(read1.getText() + "");
                    rd1.close();

                    rd1 = new FileReader("Database/" + find + ".author");
                    read1 = new JTextField();
                    read1.read(rd1, null);
                    mo2.addElement(read1.getText() + "");
                    rd1.close();

                    rd1 = new FileReader("Database/" + find + ".publication");
                    read1 = new JTextField();
                    read1.read(rd1, null);
                    mo3.addElement(read1.getText() + "");
                    rd1.close();

                    rd1 = new FileReader("Database/" + find + ".issue");
                    read1 = new JTextField();
                    read1.read(rd1, null);
                    mo4.addElement(read1.getText() + "");
                    rd1.close();

                    rd1 = new FileReader("Database/" + find + ".return");
                    read1 = new JTextField();
                    read1.read(rd1, null);
                    mo5.addElement(read1.getText() + "");
                    rd1.close();

                    rd1 = new FileReader("Database/" + find + ".id");
                    read1 = new JTextField();
                    read1.read(rd1, null);
                    mo6.addElement(read1.getText() + "");
                    rd1.close();

                  } else if (publication11.toLowerCase().equals(t1.getText())
                      || author11.toLowerCase().equals(t1.getText())
                      || name11.toLowerCase().equals(t1.getText())
                      || publication11.toUpperCase().equals(t1.getText())
                      || author11.toUpperCase().equals(t1.getText())
                      || name11.toUpperCase().equals(t1.getText())) {
                    bs1++;

                    rd1 = new FileReader("Database/" + find + ".name");
                    read1 = new JTextField();
                    read1.read(rd1, null);
                    mo1.addElement(read1.getText() + "");
                    rd1.close();

                    rd1 = new FileReader("Database/" + find + ".author");
                    read1 = new JTextField();
                    read1.read(rd1, null);
                    mo2.addElement(read1.getText() + "");
                    rd1.close();

                    rd1 = new FileReader("Database/" + find + ".publication");
                    read1 = new JTextField();
                    read1.read(rd1, null);
                    mo3.addElement(read1.getText() + "");
                    rd1.close();

                    rd1 = new FileReader("Database/" + find + ".issue");
                    read1 = new JTextField();
                    read1.read(rd1, null);
                    mo4.addElement(read1.getText() + "");
                    rd1.close();

                    rd1 = new FileReader("Database/" + find + ".return");
                    read1 = new JTextField();
                    read1.read(rd1, null);
                    mo5.addElement(read1.getText() + "");
                    rd1.close();

                    rd1 = new FileReader("Database/" + find + ".id");
                    read1 = new JTextField();
                    read1.read(rd1, null);
                    mo6.addElement(read1.getText() + "");
                    rd1.close();
                  }

                  b_no.setText("Total Book Found =" + bs1 + " (Book's)");
                }

              } else {
                progress1.setValue(0);
                JOptionPane.showMessageDialog(
                    (Component) null,
                    "Please Enter the Book Name or Publcation",
                    "Library Management(Pravin Rane)",
                    JOptionPane.OK_OPTION);
                b_no.setText("User Input Error!");
              }

            } catch (Exception der) {
              System.out.println("Error:" + der);
            }
          }
        });

    b10.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            try {
              int bs2 = 0;
              progress1.setValue(0);
              mo1.removeAllElements();
              mo2.removeAllElements();
              mo3.removeAllElements();
              mo4.removeAllElements();
              mo5.removeAllElements();
              mo6.removeAllElements();

              ml1.setText("Book Name");
              ml2.setText("Author");
              ml3.setText("Publication");
              ml4.setText("Issue Date");
              ml5.setText("Return Date");
              ml6.setText("Cust. ID.");

              if (!t14.getText().equals("")) {

                rd1 = new FileReader("Database/pointer.mmm");
                read1 = new JTextField();
                read1.read(rd1, null);
                int no = Integer.parseInt(read1.getText());
                rd1.close();

                int len = t14.getText().length();
                for (int k = 0; k < len; k++) {
                  char ch = t14.getText().charAt(k);
                  stra1 = stra1 + ch;
                  // System.out.println(stra1+"");
                }

                for (int v = 1; v < no; v++) {
                  name11 = "";
                  author11 = "";
                  publication11 = "";
                  progress1.setMaximum(no);

                  int per = v * 100 / no;
                  progress1.updateUI();
                  progress1.setValue(per);

                  FileReader re1 = new FileReader("Database/" + v + ".name");
                  JTextField jt1 = new JTextField();
                  jt1.read(re1, null);
                  String name = jt1.getText();
                  re1.close();

                  FileReader re2 = new FileReader("Database/" + v + ".author");
                  JTextField jt2 = new JTextField();
                  jt2.read(re2, null);
                  String author = jt2.getText();
                  re2.close();

                  FileReader re3 = new FileReader("Database/" + v + ".publication");
                  JTextField jt3 = new JTextField();
                  jt3.read(re3, null);
                  String publication = jt3.getText();
                  re3.close();
                  find = v;

                  try {
                    for (int z = 0; z < len; z++) {

                      // name11=name11+name.charAt(z);

                      author11 = author11 + author.charAt(z);
                      // System.out.println(author11+"");
                      // publication11=publication11+publication.charAt(z);
                      if (z == (len - 1)) {
                        // System.out.println(name11+"");
                        // System.out.println(publication11+"");
                      }
                    }

                  } catch (Exception def) {
                  }

                  if (author.toLowerCase().equals(t14.getText())
                      || author.toUpperCase().equals(t14.getText())) {
                    bs2++;
                    rd1 = new FileReader("Database/" + find + ".name");
                    read1 = new JTextField();
                    read1.read(rd1, null);
                    mo1.addElement(read1.getText() + "");
                    rd1.close();

                    rd1 = new FileReader("Database/" + find + ".author");
                    read1 = new JTextField();
                    read1.read(rd1, null);
                    mo2.addElement(read1.getText() + "");
                    rd1.close();

                    rd1 = new FileReader("Database/" + find + ".publication");
                    read1 = new JTextField();
                    read1.read(rd1, null);
                    mo3.addElement(read1.getText() + "");
                    rd1.close();

                    rd1 = new FileReader("Database/" + find + ".issue");
                    read1 = new JTextField();
                    read1.read(rd1, null);
                    mo4.addElement(read1.getText() + "");
                    rd1.close();

                    rd1 = new FileReader("Database/" + find + ".return");
                    read1 = new JTextField();
                    read1.read(rd1, null);
                    mo5.addElement(read1.getText() + "");
                    rd1.close();

                    rd1 = new FileReader("Database/" + find + ".id");
                    read1 = new JTextField();
                    read1.read(rd1, null);
                    mo6.addElement(read1.getText() + "");
                    rd1.close();

                  } else if (author11.toLowerCase().equals(t14.getText())
                      || author11.toUpperCase().equals(t14.getText())) {
                    bs2++;

                    rd1 = new FileReader("Database/" + find + ".name");
                    read1 = new JTextField();
                    read1.read(rd1, null);
                    mo1.addElement(read1.getText() + "");
                    rd1.close();

                    rd1 = new FileReader("Database/" + find + ".author");
                    read1 = new JTextField();
                    read1.read(rd1, null);
                    mo2.addElement(read1.getText() + "");
                    rd1.close();

                    rd1 = new FileReader("Database/" + find + ".publication");
                    read1 = new JTextField();
                    read1.read(rd1, null);
                    mo3.addElement(read1.getText() + "");
                    rd1.close();

                    rd1 = new FileReader("Database/" + find + ".issue");
                    read1 = new JTextField();
                    read1.read(rd1, null);
                    mo4.addElement(read1.getText() + "");
                    rd1.close();

                    rd1 = new FileReader("Database/" + find + ".return");
                    read1 = new JTextField();
                    read1.read(rd1, null);
                    mo5.addElement(read1.getText() + "");
                    rd1.close();

                    rd1 = new FileReader("Database/" + find + ".id");
                    read1 = new JTextField();
                    read1.read(rd1, null);
                    mo6.addElement(read1.getText() + "");
                    rd1.close();
                  }

                  b_no.setText("Total Book Found =" + bs2 + " (Book's)");
                }
              } else {
                progress1.setValue(0);
                b_no.setText("User Input Error!");
                JOptionPane.showMessageDialog(
                    (Component) null,
                    "Please Enter the Book Author name",
                    "Library Management(Pravin Rane)",
                    JOptionPane.OK_OPTION);
              }
            } catch (Exception der) {
              System.out.println("Error:" + der);
            }
          }
        });

    // End of Serching Book
    // Author : Pravin Rane

    // it use to aplly the skins to UserInteface
    // there are three skins Default which is Windows Skin
    // Metal skin and modified skin.
    // apply it as oer ur requirment.
    // Author : Pravin H. Rane

    item4.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            try {
              UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
              SwingUtilities.updateComponentTreeUI(frame);
            } catch (Exception dert) {
              System.out.println(dert);
            }
          }
        });

    item5.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            try {
              UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
              SwingUtilities.updateComponentTreeUI(frame);
            } catch (Exception dert) {
              System.out.println(dert);
            }
          }
        });

    item6.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            try {
              UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
              SwingUtilities.updateComponentTreeUI(frame);
            } catch (Exception dert) {
              System.out.println(dert);
            }
          }
        });

    item61.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            try {
              Date d = new Date();
              int my1 = d.getDate();
              int my2 = d.getMonth();

              FileDialog fd =
                  new FileDialog(frame, "Save Database Backup File (Library Management )");
              fd.setMode(FileDialog.SAVE);
              fd.setFile("Database" + my1 + "." + my2 + ".rar");
              fd.setVisible(true);
              String dir = fd.getDirectory();
              String path = fd.getFile();

              String command = "jar cvf Database1.rar Database/*.*";
              Runtime r = Runtime.getRuntime();
              r.exec(command);

              String command2 = "jar cvf  Database2.rar Cust_Details/*.*";
              Runtime r2 = Runtime.getRuntime();
              r2.exec(command2);

              try {
                Thread.sleep(1000);
              } catch (Exception fr) {
              }
              String command3 = "jar cvf " + dir + path + " Database1.rar  Database2.rar";
              Runtime r3 = Runtime.getRuntime();
              r3.exec(command3);

              System.out.println("Database Backup Sucessfully!");

            } catch (Exception dert) {
              System.out.println(dert);
            }
          }
        });

    item612.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            System.exit(0);
          }
        });

    // End Of Applyinf Skin to UInterface

    // This Button show the details of Book's
    // that specified when the book is adding in the database
    // you can modify the details of book.
    // Author : Pravin H. Rane

    b3.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            try {
              // view v=new view(String str,string info,boolean val);

            } catch (Exception der) {
            }
          }
        });

    // End of book details

    b15.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            Addcust ad = new Addcust();
            ad.setVisible(true);
            ad.setSize(380, 400);
            ad.setLocation(80, 140);
          }
        });

    // it show all book's available in database
    // it dosn't sort book by sequensely
    // you can modify the code for sorting the book as per your requirement
    // Author : Pravin

    b1.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            addBook a = new addBook();
          }
        });

    b4.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {

            try {
              mo1.removeAllElements();
              mo2.removeAllElements();
              mo3.removeAllElements();
              mo4.removeAllElements();
              mo5.removeAllElements();
              mo6.removeAllElements();

              ml1.setText("Book Name");
              ml2.setText("Author");
              ml3.setText("Publication");
              ml4.setText("Issue Date");
              ml5.setText("Return Date");
              ml6.setText("Cust. ID.");
              int za = 0;

              rd1 = new FileReader("Database/pointer.mmm");
              read1 = new JTextField();
              read1.read(rd1, null);
              int count = Integer.parseInt(read1.getText());
              int total = count - 1;

              rd1.close();

              for (int i = 1; i < count; i++) {

                rd1 = new FileReader("Database/" + i + ".name");
                read1 = new JTextField();
                read1.read(rd1, null);
                if (!read1.getText().equals("")) {
                  za++;
                  b_no.setText("Total Books = " + za + " (Book's)");
                  mo1.addElement(read1.getText() + "");
                  rd1.close();

                  progress1.setMaximum(total);
                  int per = i * 100 / total;
                  progress1.setValue(per);

                  rd1 = new FileReader("Database/" + i + ".author");
                  read1 = new JTextField();
                  read1.read(rd1, null);
                  mo2.addElement(read1.getText() + "");
                  rd1.close();

                  rd1 = new FileReader("Database/" + i + ".publication");
                  read1 = new JTextField();
                  read1.read(rd1, null);
                  mo3.addElement(read1.getText() + "");
                  rd1.close();

                  rd1 = new FileReader("Database/" + i + ".issue");
                  read1 = new JTextField();
                  read1.read(rd1, null);
                  if (!read1.getText().equals("")) {
                    mo4.addElement(read1.getText() + "");
                  } else {
                    mo4.addElement(read1.getText() + "   _");
                  }
                  rd1.close();

                  rd1 = new FileReader("Database/" + i + ".return");
                  read1 = new JTextField();
                  read1.read(rd1, null);
                  mo5.addElement(read1.getText() + "");
                  rd1.close();

                  rd1 = new FileReader("Database/" + i + ".id");
                  read1 = new JTextField();
                  read1.read(rd1, null);
                  mo6.addElement(read1.getText() + "");
                  rd1.close();

                  progress1.setValue(100);
                }
              }
            } catch (Exception der) {
              a1.setText("Error Occurs: \n" + der);
            }
          }
        });
    // End of View all Book's

    // This source code is used to show information of all customers
    // Author :Pravin Rane

    b6.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            try {

              ml1.setText("Cust. ID");
              ml2.setText("Cust. Name");
              ml3.setText("Registration Date");
              ml4.setText("Book Name");
              ml5.setText("Purchase Date");
              ml6.setText("Return Date");

              int z12 = 0;

              mo1.removeAllElements();
              mo2.removeAllElements();
              mo3.removeAllElements();
              mo4.removeAllElements();
              mo5.removeAllElements();
              mo6.removeAllElements();

              rd2 = new FileReader("Cust_Details/pointer.mmm");
              jt2 = new JTextField();
              jt2.read(rd2, null);
              rd2.close();

              int no = Integer.parseInt(jt2.getText());
              int tt = no - 1;
              // b_no.setText("Total Customer's :"+tt );

              for (int v = 1; v < no; v++) {

                rd2 = new FileReader("Cust_Details/Cus" + v + ".id");
                jt2 = new JTextField();
                jt2.read(rd2, null);
                if (!jt2.getText().equals("")) {
                  z12++;
                  b_no.setText("Total Customers = " + z12);
                  mo1.addElement(jt2.getText() + "");
                  rd2.close();

                  rd2 = new FileReader("Cust_Details/Cus" + v + ".name");
                  jt2 = new JTextField();
                  jt2.read(rd2, null);
                  mo2.addElement(jt2.getText() + "");
                  rd2.close();

                  rd2 = new FileReader("Cust_Details/Cus" + v + ".date");
                  jt2 = new JTextField();
                  jt2.read(rd2, null);
                  mo3.addElement(jt2.getText() + "");
                  rd2.close();

                  rd2 = new FileReader("Cust_Details/Cus" + v + ".bname");
                  jt2 = new JTextField();
                  jt2.read(rd2, null);
                  if (!jt2.getText().equals("")) {
                    mo4.addElement(jt2.getText() + "");
                  } else {
                    mo4.addElement(jt2.getText() + "   _");
                  }
                  rd2.close();

                  rd2 = new FileReader("Cust_Details/Cus" + v + ".purchase");
                  jt2 = new JTextField();
                  jt2.read(rd2, null);
                  if (!jt2.getText().equals("")) {
                    mo5.addElement(jt2.getText() + "");
                  } else {
                    mo5.addElement(jt2.getText() + "   _");
                  }
                  rd2.close();

                  rd2 = new FileReader("Cust_Details/Cus" + v + ".return");
                  jt2 = new JTextField();
                  jt2.read(rd2, null);
                  if (!jt2.getText().equals("")) {
                    mo6.addElement(jt2.getText() + "");
                  } else {
                    mo6.addElement(jt2.getText() + "   _");
                  }
                  rd2.close();
                }
              }

            } catch (Exception ser) {
              System.out.println(ser);
            }
          }
        });
    // End of showing customer's Info.

    b9.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            try {

              int ad = list1.getSelectedIndex();
              String str = (String) mo1.getElementAt(ad);

              System.out.println(str);

              cust_detail d = new cust_detail(str);
              d.setVisible(true);
              d.setSize(300, 550);
              d.setLocation(100, 0);
            } catch (Exception fr) {
              JOptionPane.showMessageDialog(
                  (Component) null,
                  "Please Select Customer ID from List of Cust. ID. ",
                  "Library Management(Pravin Rane)",
                  JOptionPane.OK_OPTION);
              try {
                ml1.setText("Cust. ID");
                ml2.setText("Cust. Name");
                ml3.setText("Registration Date");
                ml4.setText("Book Name");
                ml5.setText("Purchase Date");
                ml6.setText("Return Date");

                mo1.removeAllElements();
                mo2.removeAllElements();
                mo3.removeAllElements();
                mo4.removeAllElements();
                mo5.removeAllElements();
                mo6.removeAllElements();

                rd2 = new FileReader("Cust_Details/pointer.mmm");
                jt2 = new JTextField();
                jt2.read(rd2, null);
                rd2.close();
                int no = Integer.parseInt(jt2.getText());

                for (int v = 1; v < no; v++) {
                  rd2 = new FileReader("Cust_Details/Cus" + v + ".id");
                  jt2 = new JTextField();
                  jt2.read(rd2, null);
                  mo1.addElement(jt2.getText() + "");
                  rd2.close();

                  rd2 = new FileReader("Cust_Details/Cus" + v + ".name");
                  jt2 = new JTextField();
                  jt2.read(rd2, null);
                  mo2.addElement(jt2.getText() + "");
                  rd2.close();

                  rd2 = new FileReader("Cust_Details/Cus" + v + ".date");
                  jt2 = new JTextField();
                  jt2.read(rd2, null);
                  mo3.addElement(jt2.getText() + "");
                  rd2.close();

                  rd2 = new FileReader("Cust_Details/Cus" + v + ".bname");
                  jt2 = new JTextField();
                  jt2.read(rd2, null);
                  if (!jt2.getText().equals("")) {
                    mo4.addElement(jt2.getText() + "");
                  } else {
                    mo4.addElement(jt2.getText() + "   _");
                  }
                  rd2.close();

                  rd2 = new FileReader("Cust_Details/Cus" + v + ".purchase");
                  jt2 = new JTextField();
                  jt2.read(rd2, null);
                  if (!jt2.getText().equals("")) {
                    mo5.addElement(jt2.getText() + "");
                  } else {
                    mo5.addElement(jt2.getText() + "   _");
                  }
                  rd2.close();

                  rd2 = new FileReader("Cust_Details/Cus" + v + ".return");
                  jt2 = new JTextField();
                  jt2.read(rd2, null);
                  if (!jt2.getText().equals("")) {
                    mo6.addElement(jt2.getText() + "");
                  } else {
                    mo6.addElement(jt2.getText() + "   _");
                  }
                  rd2.close();
                }
              } catch (Exception fg) {
              }
            }
          }
        });

    b7.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String mysearchid = t2.getText();
            try {
              ml1.setText("Cust. ID");
              ml2.setText("Cust. Name");
              ml3.setText("Registration Date");
              ml4.setText("Book Name");
              ml5.setText("Purchase Date");
              ml6.setText("Return Date");

              mo1.removeAllElements();
              mo2.removeAllElements();
              mo3.removeAllElements();
              mo4.removeAllElements();
              mo5.removeAllElements();
              mo6.removeAllElements();

              if (!t2.getText().equals("")) {
                rd2 = new FileReader("Cust_Details/pointer.mmm");
                jt2 = new JTextField();
                jt2.read(rd2, null);
                rd2.close();
                int no = Integer.parseInt(jt2.getText());

                int len3 = t2.getText().length();

                for (int v = 1; v < no; v++) {
                  name22 = "";
                  int lg = 0;
                  rd2 = new FileReader("Cust_Details/Cus" + v + ".id");
                  jt2 = new JTextField();
                  jt2.read(rd2, null);
                  // mo1.addElement(jt2.getText()+"");
                  String s1 = jt2.getText();
                  rd2.close();

                  rd2 = new FileReader("Cust_Details/Cus" + v + ".name");
                  jt2 = new JTextField();
                  jt2.read(rd2, null);
                  // mo2.addElement(jt2.getText()+"");
                  String s2 = jt2.getText();
                  rd2.close();

                  for (int z = 0; z < len3; z++) {
                    name22 = name22 + s2.charAt(z);
                  }

                  if (s1.toLowerCase().equals(mysearchid)
                      || s1.toUpperCase().equals(mysearchid)
                      || s2.toLowerCase().equals(mysearchid)
                      || s2.toUpperCase().equals(mysearchid)
                      || name22.toUpperCase().equals(mysearchid)
                      || name22.toLowerCase().equals(mysearchid)) {
                    lg++;
                    b_no.setText("Customer Found :" + lg);
                    rd2 = new FileReader("Cust_Details/Cus" + v + ".id");
                    jt2 = new JTextField();
                    jt2.read(rd2, null);
                    mo1.addElement(jt2.getText() + "");
                    rd2.close();

                    rd2 = new FileReader("Cust_Details/Cus" + v + ".name");
                    jt2 = new JTextField();
                    jt2.read(rd2, null);
                    mo2.addElement(jt2.getText() + "");
                    rd2.close();

                    rd2 = new FileReader("Cust_Details/Cus" + v + ".date");
                    jt2 = new JTextField();
                    jt2.read(rd2, null);
                    mo3.addElement(jt2.getText() + "");
                    rd2.close();

                    rd2 = new FileReader("Cust_Details/Cus" + v + ".bname");
                    jt2 = new JTextField();
                    jt2.read(rd2, null);
                    if (!jt2.getText().equals("")) {
                      mo4.addElement(jt2.getText() + "");
                    } else {
                      mo4.addElement(jt2.getText() + "   _");
                    }
                    rd2.close();

                    rd2 = new FileReader("Cust_Details/Cus" + v + ".purchase");
                    jt2 = new JTextField();
                    jt2.read(rd2, null);
                    if (!jt2.getText().equals("")) {
                      mo5.addElement(jt2.getText() + "");
                    } else {
                      mo5.addElement(jt2.getText() + "   _");
                    }
                    rd2.close();

                    rd2 = new FileReader("Cust_Details/Cus" + v + ".return");
                    jt2 = new JTextField();
                    jt2.read(rd2, null);
                    if (!jt2.getText().equals("")) {
                      mo6.addElement(jt2.getText() + "");
                    } else {
                      mo6.addElement(jt2.getText() + "   _");
                    }
                    rd2.close();
                  }
                }
              } else {
                progress1.setValue(0);
                b_no.setText("User Input Error!");
                JOptionPane.showMessageDialog(
                    (Component) null,
                    "Please Enter Customer Id or Name",
                    "Library Management(Pravin Rane)",
                    JOptionPane.OK_OPTION);
              }

            } catch (Exception de) {
            }
          }
        });

    b2.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            int ad = list1.getSelectedIndex();
            String str99 = (String) mo1.getElementAt(ad);
            try {

              rd2 = new FileReader("Database/pointer.mmm");
              jt2 = new JTextField();
              jt2.read(rd2, null);
              rd2.close();
              int nom = Integer.parseInt(jt2.getText());

              for (int count2 = 1; count2 < nom; count2++) {
                rd1 = new FileReader("Database/" + count2 + ".name");
                read1 = new JTextField();
                read1.read(rd1, null);
                rd1.close();

                if (read1.getText().equals(str99)) {
                  wr1 = new FileWriter("Database/" + count2 + ".name");
                  wr1.write("");
                  wr1.close();

                  wr1 = new FileWriter("Database/" + count2 + ".author");
                  wr1.write("");
                  wr1.close();

                  wr1 = new FileWriter("Database/" + count2 + ".publication");
                  wr1.write("");
                  wr1.close();

                  wr1 = new FileWriter("Database/" + count2 + ".issue");
                  wr1.write("");
                  wr1.close();

                  wr1 = new FileWriter("Database/" + count2 + ".return");
                  wr1.write("");
                  wr1.close();

                  wr1 = new FileWriter("Database/" + count2 + ".detail");
                  wr1.write("");
                  wr1.close();

                  wr1 = new FileWriter("Database/" + count2 + ".id");
                  wr1.write("");
                  wr1.close();
                  try {
                    Library lbc = new Library();
                    setVisible(false);
                    lbc.setVisible(true);
                    lbc.setSize(800, 600);
                  } catch (Exception de) {
                  }
                }
              }

            } catch (Exception fr) {
              System.out.println(fr);
            }
          }
        });

    b3.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            try {
              int ad = list1.getSelectedIndex();
              String str34 = (String) mo1.getElementAt(ad);

              jf55 = new JFrame("Book Details");
              jf55.setVisible(true);
              jf55.setLayout(null);
              jf55.setLocation(160, 180);

              JTextArea ak47 = new JTextArea();
              ak47.setEditable(false);
              ak47.setText(
                  "Book Details" + "\n" + "**************************************************");
              ak47.setBounds(10, 10, 250, 250);
              jf55.add(ak47);

              Button b1 = new Button("Ok");
              b1.setBounds(80, 270, 100, 25);
              jf55.add(b1);
              b1.addActionListener(
                  new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                      jf55.setVisible(false);
                    }
                  });

              jf55.setSize(285, 335);

              rd2 = new FileReader("Database/pointer.mmm");
              jt2 = new JTextField();
              jt2.read(rd2, null);
              rd2.close();
              int nov = Integer.parseInt(jt2.getText());

              for (int i = 1; i < nov; i++) {
                rd1 = new FileReader("Database/" + i + ".name");
                read1 = new JTextField();
                read1.read(rd1, null);
                String hj = read1.getText();
                rd1.close();

                if (hj.equals(str34)) {
                  rd1 = new FileReader("Database/" + i + ".name");
                  read1 = new JTextField();
                  read1.read(rd1, null);
                  if (!read1.getText().equals("")) {
                    ak47.setText(ak47.getText() + "\n" + "Book Name :" + read1.getText());
                    rd1.close();

                    rd1 = new FileReader("Database/" + i + ".author");
                    read1 = new JTextField();
                    read1.read(rd1, null);
                    ak47.setText(ak47.getText() + "\n" + "Book Author :" + read1.getText());
                    rd1.close();

                    rd1 = new FileReader("Database/" + i + ".publication");
                    read1 = new JTextField();
                    read1.read(rd1, null);
                    ak47.setText(ak47.getText() + "\n" + "Book Publication :" + read1.getText());
                    rd1.close();

                    rd1 = new FileReader("Database/" + i + ".issue");
                    read1 = new JTextField();
                    read1.read(rd1, null);
                    if (!read1.getText().equals("")) {
                      ak47.setText(ak47.getText() + "\n" + "Issue Date :" + read1.getText());
                    } else {
                      ak47.setText(ak47.getText() + "\n" + "Issue Date : None");
                    }
                    rd1.close();

                    rd1 = new FileReader("Database/" + i + ".return");
                    read1 = new JTextField();
                    read1.read(rd1, null);
                    ak47.setText(ak47.getText() + "\n" + "Return Date :" + read1.getText());
                    rd1.close();

                    rd1 = new FileReader("Database/" + i + ".id");
                    read1 = new JTextField();
                    read1.read(rd1, null);
                    ak47.setText(ak47.getText() + "\n" + "Cust. Id :" + read1.getText());
                    rd1.close();

                    rd1 = new FileReader("Database/" + i + ".detail");
                    read1 = new JTextField();
                    read1.read(rd1, null);
                    if (!read1.getText().equals("")) {
                      ak47.setText(ak47.getText() + "\n" + "Other Details : \n" + read1.getText());
                    } else {
                      ak47.setText(ak47.getText() + "\n" + "Other Details : Not Found");
                    }
                    rd1.close();
                  }
                }
              }

            } catch (Exception de) {
              JOptionPane.showMessageDialog(
                  (Component) null,
                  "Please Select Book Name from List",
                  "Library Management(Pravin Rane)",
                  JOptionPane.OK_OPTION);
            }
          }
        });
  }