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);
            }
          }
        });
  }
Пример #2
0
  Intern_Chat() {

    frame = new JFrame("Guide ME");
    frame.setSize(480, 550);
    frame.setResizable(false);
    frame.setVisible(true);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().setBackground(new Color(211, 211, 211));
    frame.getContentPane().setLayout(null);

    // getContentPane().addMouseListener(new action2());
    JLabel lblGuideMe = new JLabel("Guide ME");
    lblGuideMe.setFont(new Font("Tahoma", Font.BOLD, 16));
    lblGuideMe.setBounds(10, 11, 85, 21);
    frame.getContentPane().add(lblGuideMe);

    textField = new JTextField();
    textField.setBounds(105, 11, 135, 21);
    frame.getContentPane().add(textField);
    textField.setColumns(10);

    ImageIcon search = new ImageIcon("list.PNG");
    btnNewButton = new JButton(search);
    btnNewButton.addActionListener(new Intern_Chat_action());
    btnNewButton.setBackground(new Color(255, 255, 255));
    btnNewButton.setFont(new Font("Tahoma", Font.BOLD, 11));
    btnNewButton.setBounds(240, 11, 20, 21);
    frame.getContentPane().add(btnNewButton);

    btnNewButton_1 = new JButton("Home");
    btnNewButton_1.addActionListener(new Intern_Chat_action());
    btnNewButton_1.setForeground(new Color(0, 0, 0));
    btnNewButton_1.setBackground(new Color(65, 105, 225));
    btnNewButton_1.setBounds(265, 12, 78, 21);
    frame.getContentPane().add(btnNewButton_1);

    ImageIcon list = new ImageIcon("Capture.PNG");
    btnNewButton_2 = new JButton(list);
    btnNewButton_2.setBounds(350, 11, 22, 23);
    btnNewButton_2.setForeground(new Color(0, 0, 0));
    btnNewButton_2.setBackground(new Color(65, 105, 225));
    frame.getContentPane().add(btnNewButton_2);
    btnNewButton_2.addActionListener(new Intern_Chat_action());

    btnNewButton_3 = new JButton(list);
    btnNewButton_3.addActionListener(new Intern_Chat_action());
    btnNewButton_3.setBounds(380, 11, 22, 23);
    frame.getContentPane().add(btnNewButton_3);

    String content[] = {
      "Friends",
      "Places",
      "Brands",
      "Notifications",
      "Tastes",
      "Rates",
      "Message",
      "settings",
      "Log out"
    };

    // for view frinds and palces and brands
    lists = new JList(content);
    lists.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    lists.setBackground(new Color(65, 105, 225));
    frame.getContentPane().add(lists);
    lists.setBounds(295, 35, 74, 171);
    lists.hide();

    String content2[] = {
      "Chick In",
      "Add Friend",
      "Add Place",
      "Add Brand",
      "Give Rate",
      "Remove Friend",
      "Remove Brand",
      "Remove Place",
      "chat"
    };
    lists1 = new JList(content2);
    lists1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    lists1.setBackground(new Color(65, 105, 225));
    frame.getContentPane().add(lists1);
    lists1.setBounds(379, 35, 95, 171);
    lists1.hide();

    lists.addListSelectionListener(new Intern_Chat_action());
    lists1.addListSelectionListener(new Intern_Chat_action());

    JPanel panel_1 = new JPanel();
    panel_1.setBackground(new Color(0, 191, 255));
    panel_1.setBounds(0, 0, 560, 50);
    frame.getContentPane().add(panel_1);

    panel = new JPanel();
    panel.setBounds(0, 101, 185, 418);
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    JScrollPane scr1 = new JScrollPane(panel);
    scr1.setBounds(0, 101, 185, 418);
    JLabel Users[] = new JLabel[20];
    JLabel message[] = new JLabel[20];
    for (int i = 0; i < 20; i++) {
      if (i % 2 == 0) {
        Users[i] = new JLabel("12:52 : alaa");
        message[i] = new JLabel("how are you bitch ?");
      } else {
        Users[i] = new JLabel("12:52: You");
        message[i] = new JLabel("f**k you");
      }
      panel.add(Users[i]);
      panel.add(message[i]);
    }
    frame.getContentPane().add(scr1);

    lblChat = new JLabel("Chat");
    lblChat.setFont(new Font("Tahoma", Font.BOLD, 14));
    lblChat.setBounds(23, 61, 72, 29);
    frame.getContentPane().add(lblChat);

    textArea = new JTextArea();
    textArea.setBounds(230, 120, 173, 69);
    JScrollPane scr = new JScrollPane(textArea);
    scr.setBounds(230, 120, 173, 69);
    frame.getContentPane().add(scr);

    JButton btnSend = new JButton("Send");
    btnSend.setFont(new Font("Tahoma", Font.BOLD, 14));
    btnSend.setBounds(264, 197, 78, 23);
    frame.getContentPane().add(btnSend);
  }
Пример #3
0
  private void initializeComponents() {
    this.setTitle("Synchro - Kopierassistent");
    this.setBounds(0, 0, 550, 600);

    this.setResizable(true);
    this.setLayout(null);
    this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    this.addWindowListener(this);

    mainPanel = new JPanel();
    mainPanel.setBounds(0, 0, this.getWidth() - 20, 25);
    // fcPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    mainPanel.setLayout(null);

    btnBackup = new JButton("Backup");
    btnBackup.setBounds(this.getWidth() / 2, 0, this.getWidth() / 2 - 20, mainPanel.getHeight());
    btnBackup.addActionListener(this);
    mainPanel.add(btnBackup);

    this.add(mainPanel);

    fcPanel = new JPanel();
    fcPanel.setBounds(10, 40, this.getWidth(), 260);
    // fcPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    fcPanel.setLayout(null);

    quellLabel = new JLabel("Bitte Quellverzeichnis auswählen");
    quellLabel.setBounds(10, 5, 320, 20);
    fcPanel.add(quellLabel);

    quellListModel = new DefaultListModel<>();
    quellJList = new JList<ListItem>(quellListModel);
    quellJList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    quellJList.setLayoutOrientation(JList.VERTICAL);
    quellJList.addListSelectionListener(this);

    listBoxScroller = new JScrollPane(quellJList);
    listBoxScroller.setBounds(0, 30, 315, 100);
    fcPanel.add(listBoxScroller);

    btnQAuswahl = new JButton("Quellverz. hinzufügen");
    btnQAuswahl.setBounds(320, 30, 200, 25);
    btnQAuswahl.addActionListener(this);
    fcPanel.add(btnQAuswahl);
    btnQEntfernen = new JButton("Quellverz. entfernen");
    btnQEntfernen.setBounds(320, 60, 200, 25);
    btnQEntfernen.addActionListener(this);
    fcPanel.add(btnQEntfernen);

    zielLabel = new JLabel("Bitte Zielverzeichnis auswählen");
    zielLabel.setBounds(10, 135, 320, 20);
    fcPanel.add(zielLabel);

    zielListModel = new DefaultListModel<>();
    zielJList = new JList<ListItem>(zielListModel);
    zielJList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    zielJList.setLayoutOrientation(JList.VERTICAL);
    zielJList.addListSelectionListener(this);

    listBoxScroller2 = new JScrollPane(zielJList);
    listBoxScroller2.setBounds(0, 160, 315, 100);
    fcPanel.add(listBoxScroller2);

    btnZAuswahl = new JButton("Zielverz. hinzufügen");
    btnZAuswahl.setBounds(320, 160, 200, 25);
    btnZAuswahl.addActionListener(this);
    fcPanel.add(btnZAuswahl);
    btnZEntfernen = new JButton("Zielverz. entfernen");
    btnZEntfernen.setBounds(320, 190, 200, 25);
    btnZEntfernen.addActionListener(this);
    fcPanel.add(btnZEntfernen);
    this.add(fcPanel);

    ButtonGroup bGrp = new ButtonGroup();

    optionPanel = new JPanel();
    optionPanel.setBounds(10, 300 + 10, this.getWidth() - 40, 90);
    optionPanel.setPreferredSize(new Dimension(this.getWidth() - 40, 90));
    // optionPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    optionPanel.setLayout(new GridLayout(3, 1));

    nUebSchr = new JRadioButton("Keine Dateien überschreiben");
    nUebSchr.addItemListener(this);
    bGrp.add(nUebSchr);
    optionPanel.add(nUebSchr);

    ueSchr = new JRadioButton("Neuere Dateien überschreiben");
    ueSchr.addItemListener(this);
    bGrp.add(ueSchr);
    optionPanel.add(ueSchr);

    aUeSchr = new JRadioButton("Alle Dateien überschreiben");
    aUeSchr.addItemListener(this);
    bGrp.add(aUeSchr);
    optionPanel.add(aUeSchr);

    this.add(optionPanel);

    syncPanel = new JPanel();
    syncPanel.setBounds(
        10, optionPanel.getY() + optionPanel.getHeight() + 10, this.getWidth() - 30, 25);
    // syncPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    syncPanel.setLayout(new BorderLayout());

    btnSync = new JButton("Sync it!");
    btnSync.setBounds(0, 0, 150, (syncPanel.getHeight() / 3));
    btnSync.addActionListener(this);
    btnSync.setPreferredSize(new Dimension(150, (syncPanel.getHeight() / 3)));
    btnSync.setMaximumSize(new Dimension(150, (syncPanel.getHeight() / 3)));
    syncPanel.add(btnSync, BorderLayout.LINE_START);

    btnAbbruch = new JButton("Abbrechen");
    btnAbbruch.setBounds(0, 0, 150, (syncPanel.getHeight() / 3));
    btnAbbruch.addActionListener(this);
    btnAbbruch.setPreferredSize(new Dimension(150, (syncPanel.getHeight() / 3)));
    btnAbbruch.setMaximumSize(new Dimension(150, (syncPanel.getHeight() / 3)));
    btnAbbruch.setVisible(false);
    syncPanel.add(btnAbbruch, BorderLayout.LINE_END);

    progressBar = new JProgressBar(JProgressBar.HORIZONTAL);
    progressBar.setBorderPainted(true);
    progressBar.setPreferredSize(new Dimension(300, (syncPanel.getHeight() / 3)));
    progressBar.setForeground(Color.RED);
    progressBar.setStringPainted(true);
    progressBar.setVisible(true);
    syncPanel.add(progressBar, BorderLayout.CENTER);
    this.add(syncPanel);

    logPanel = new JPanel();
    logPanel.setBounds(
        10, syncPanel.getY() + syncPanel.getHeight() + 10, this.getWidth() - 30, 105);
    logPanel.setLayout(new BorderLayout());

    textArea = new JTextArea();
    textArea.setMargin(new Insets(3, 3, 3, 3));
    textArea.setBackground(Color.black);
    textArea.setForeground(Color.LIGHT_GRAY);
    textArea.setAutoscrolls(true);
    textArea.setFocusable(false);
    textAreaScroller = new JScrollPane(textArea);
    DefaultCaret caret = (DefaultCaret) textArea.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
    textAreaScroller.setBounds(0, 0, syncPanel.getWidth(), 50);

    logPanel.add(textAreaScroller, BorderLayout.CENTER);
    this.add(logPanel, BorderLayout.SOUTH);
  }
Пример #4
0
  static String[] input(int d, int m, int y) { // input frame for schedule
    String[] out = new String[4]; // appointment info storage

    final String[] doctors = {"Dr. Whitehead", "Dr. Namie", "Dr. Liddell"};

    final JFrame input = new JFrame("Make Appointment");
    Container pane1;
    JPanel pan = new JPanel(null);
    JLabel doctor = new JLabel("Choose your Doctor:");
    JLabel da = new JLabel("Date:");
    /*JLabel day=new JLabel(Integer.toString(d));
    JLabel mo=new JLabel("Month:");
    JLabel month=new JLabel(Integer.toString(m));
    JLabel ye=new JLabel("Year:");
    JLabel year=new JLabel(Integer.toString(y));*/
    JLabel time = new JLabel("Appointment Time:");
    JButton submit = new JButton("Submit");
    docName = new JComboBox(doctors);

    JSpinner timeSpinner = new JSpinner(new SpinnerDateModel());
    JSpinner.DateEditor timeEditor = new JSpinner.DateEditor(timeSpinner, "hh:mm a");
    timeSpinner.setEditor(timeEditor);
    timeSpinner.setValue(new Date());

    JSpinner dateSpinner = new JSpinner(new SpinnerDateModel());
    JSpinner.DateEditor dateEditor = new JSpinner.DateEditor(dateSpinner, "MMM/dd/yyyy");
    dateSpinner.setEditor(dateEditor);
    dateSpinner.setValue(new Date());

    input.setSize(330, 375); // Set size to 400x400 pixels
    pane1 = input.getContentPane();
    pane1.setLayout(null); // Apply null layout
    pan.setLayout(new GridLayout(4, 2, 20, 50));
    pane1.setSize((int) (input.getHeight() / 2), (int) (input.getWidth() / 2));
    pane1.setLocation(
        input.getHeight() - ((int) (input.getHeight() / 2)),
        input.getWidth() - ((int) (input.getWidth() / 2))); // trying to center failed
    input.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); // Close when X is clicked
    pane1.add(pan);
    // pan.add(ye);
    // pan.add(year);
    pan.add(da);
    pan.add(dateSpinner);
    pan.add(time);
    pan.add(timeSpinner);
    pan.add(doctor);
    pan.add(docName);
    pan.add(submit);

    submit.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            fmain.setVisible(true);
            input.setVisible(false);
          }
        });

    pan.setBounds(0, 0, 320, 335);
    input.setResizable(false);
    input.setVisible(true);
    return out;
  }
Пример #5
0
  public static void main(String args[]) {
    // style that is necessary
    try {
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (ClassNotFoundException e) {
    } catch (InstantiationException e) {
    } catch (IllegalAccessException e) {
    } catch (UnsupportedLookAndFeelException e) {
    }

    // Standard preparation for a frame
    fmain = new JFrame("Schedule Appointments"); // Create and name frame
    fmain.setSize(330, 375); // Set size to 400x400 pixels
    pane = fmain.getContentPane();
    pane.setLayout(null); // Apply null layout
    fmain.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Close when X is clicked

    // controls and portions of Calendar
    lmonth = new JLabel("January");
    lyear = new JLabel("Change year:");
    cyear = new JComboBox();
    prev = new JButton("<<");
    next = new JButton(">>");
    canc = new JButton("Cancel");
    mcal =
        new DefaultTableModel() {
          public boolean isCellEditable(int rowIndex, int mColIndex) {
            return false;
          }
        };
    Cal = new JTable(mcal);
    scal = new JScrollPane(Cal);
    pcal = new JPanel(null);

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

    // action listeners for buttons and the like
    prev.addActionListener(new btnPrev_Action());
    next.addActionListener(new btnNext_Action());
    cyear.addActionListener(new cmbYear_Action());
    Cal.addMouseListener(new mouseCont());

    // Adding the elements to the pane
    pane.add(pcal);
    pcal.add(lmonth);
    pcal.add(cyear);
    pcal.add(prev);
    pcal.add(next);
    pcal.add(canc);
    pcal.add(scal);

    // Setting where the elements are on the pane
    pcal.setBounds(0, 0, 320, 335);
    lmonth.setBounds(160 - lmonth.getPreferredSize().width / 2, 25, 100, 25);
    canc.setBounds(10, 305, 80, 20);
    cyear.setBounds(215, 305, 100, 20);
    prev.setBounds(10, 25, 50, 25);
    next.setBounds(260, 25, 50, 25);
    scal.setBounds(10, 50, 300, 250);

    // Make frame visible
    fmain.setResizable(false);
    fmain.setVisible(true);

    // Inner workings for the day mechanism
    GregorianCalendar cal = new GregorianCalendar(); // Create calendar
    rday = cal.get(GregorianCalendar.DAY_OF_MONTH); // Get day
    rmonth = cal.get(GregorianCalendar.MONTH); // Get month
    ryear = cal.get(GregorianCalendar.YEAR); // Get year
    currentMonth = rmonth; // Match month and year
    currentYear = ryear;

    // Add days
    String[] days = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; // All of the days
    for (int i = 0; i < 7; i++) {
      mcal.addColumn(days[i]);
    }

    Cal.getParent().setBackground(Cal.getBackground()); // Set background

    // No resize/reorder
    Cal.getTableHeader().setResizingAllowed(false);
    Cal.getTableHeader().setReorderingAllowed(false);

    // Single cell selection
    Cal.setColumnSelectionAllowed(true);
    Cal.setRowSelectionAllowed(true);
    Cal.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    // Set row/column count
    Cal.setRowHeight(38);
    mcal.setColumnCount(7);
    mcal.setRowCount(6);

    // Placing the dates in the cells
    for (int i = ryear - 100; i <= ryear + 100; i++) {
      cyear.addItem(String.valueOf(i));
    }

    // Refresh calendar
    refreshCalendar(rmonth, ryear); // Refresh calendar
  }
  public Checkordelete_Task_Frame() {
    init();

    JLabel jlb_framename = new JLabel("删除任务", JLabel.CENTER);
    jlb_framename.setFont(new Font("SansSerif", Font.BOLD, 24));

    JLabel jlb_taskname = new JLabel("任务列表:", JLabel.LEFT);
    JLabel jlb_taskdescription = new JLabel("被选中任务的详细信息:");

    JButton jb_delete = new JButton("删除");
    JButton jb_exit = new JButton("退出");

    JPanel p1 = new JPanel();
    p1.setLayout(new FlowLayout(FlowLayout.CENTER));
    p1.add(jlb_framename);
    p1.setBounds(25, 15, 350, 40);

    JPanel p2 = new JPanel();
    p2.setLayout(new GridLayout(1, 2, 5, 5));
    p2.add(jlb_taskname);
    p2.add(jlb_taskdescription);
    p2.setBounds(25, 65, 325, 20);

    JPanel p3 = new JPanel();
    p3.setLayout(new GridLayout(1, 2, 25, 25));
    p3.add(scrollpane1);
    p3.add(scrollpane2);
    // p3.add(jta_taskdescription);
    p3.setBounds(25, 90, 325, 110);

    JPanel p4 = new JPanel();
    p4.setLayout(new GridLayout(1, 2, 25, 5));
    p4.add(jb_delete);
    p4.add(jb_exit);
    p4.setBounds(100, 225, 175, 25);

    setLayout(null);
    add(p1);
    add(p2);
    add(p3);
    add(p4);

    setTitle("删除任务");
    setSize(400, 300);
    setLocationRelativeTo(null);

    jl_taskname.addListSelectionListener(
        new ListSelectionListener() {
          public void valueChanged(ListSelectionEvent e) {
            if (jl_taskname.getSelectedIndex() >= 0) {
              jta_taskdescription.setText(
                  MainFrame.str_description[jl_taskname.getSelectedIndex() * 2]);
            }
          }
        });

    jb_delete.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            int index = jl_taskname.getSelectedIndex();

            for (int i = index; i < Runner.count_task - 1; i++) {
              Runner.task[i] = Runner.task[i + 1];
              MainFrame.str_description[i * 2] = MainFrame.str_description[(i + 1) * 2];
              MainFrame.str_description[i * 2 + 1] = MainFrame.str_description[(i + 1) * 2 + 1];
              MainFrame.str_outinfo[i * 2] = MainFrame.str_description[(i + 1) * 2];
              MainFrame.str_outinfo[i * 2 + 1] = MainFrame.str_outinfo[(i + 1) * 2 + 1];
            }
            Runner.count_task--;
            MainFrame.task_list.removeItemAt(index + 1);
            MainFrame.task_list.setSelectedIndex(0);
            Modify_Task_Frame.delete_taskname(index + 1);
            Check_Alltask_Frame.fresh_taskname();
            fresh_taskname();
            jl_taskname.setSelectedIndex(0);
            // window_close();
          }
        });

    jb_exit.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            jl_taskname.setSelectedIndex(0);
            window_close();
          }
        });
  }