@Override public void paintComponent(Graphics g) { if (selected) { g.setColor(selColor); g.fillRoundRect(0, 0, getWidth(), getHeight(), getWidth() / 10, getHeight() / 10); label.setForeground(Color.YELLOW); } else label.setForeground(Color.WHITE); super.paintComponent(g); }
public void setVisible(boolean bShow, String title) { if (bShow) { String strDir = ""; String strFreq = ""; String strTraynum = ""; m_strHelpFile = getHelpFile(title); String strSampleName = getSampleName(title); String frameBounds = getFrameBounds(title); StringTokenizer tok = new QuotedStringTokenizer(title); if (tok.hasMoreTokens()) strDir = tok.nextToken(); if (tok.hasMoreTokens()) strFreq = tok.nextToken(); if (tok.hasMoreTokens()) strTraynum = tok.nextToken(); else { try { Integer.parseInt(strDir); // if strdir is number, then strdir is empty, and the // strfreq is the number strTraynum = strFreq; strFreq = strDir; strDir = ""; } catch (Exception e) { } } try { setTitle(gettitle(strFreq)); m_lblSampleName.setText("3"); boolean bVast = isVast(strTraynum); CardLayout layout = (CardLayout) m_pnlSampleName.getLayout(); if (!bVast) { if (strSampleName == null) { strSampleName = getSampleName(strDir, strTraynum); } m_lblSampleName.setText(strSampleName); layout.show(m_pnlSampleName, OTHER); } else { m_strDir = strDir; setTrays(); layout.show(m_pnlSampleName, VAST); m_trayTimer.start(); } boolean bSample = bVast || !strSampleName.trim().equals(""); m_pnlSampleName.setVisible(bSample); m_lblLogin.setForeground(getBackground()); m_lblLogin.setVisible(false); m_passwordField.setText(""); m_passwordField.setCaretPosition(0); } catch (Exception e) { Messages.writeStackTrace(e); } setBounds(frameBounds); ExpPanel exp = Util.getActiveView(); if (exp != null) exp.waitLogin(true); } writePersistence(); setVisible(bShow); }
public SidebarOption(String labelTxt, String rsc) { label = new JLabel(labelTxt); label.setForeground(Color.WHITE); label.setFont(font); add(label); setOpaque(false); setMaximumSize(new Dimension(1000, label.getPreferredSize().height + 5)); this.rsc = ClassLoader.getSystemClassLoader().getResource(rsc); }
private void jbInit() throws Exception { this.getContentPane().setLayout(null); Bienvenue.setFont(new java.awt.Font("Garamond", 1, 24)); Bienvenue.setForeground(SystemColor.textHighlight); Bienvenue.setRequestFocusEnabled(true); Bienvenue.setVerifyInputWhenFocusTarget(true); Bienvenue.setText("Bienvenue dans JChat"); Bienvenue.setBounds(new Rectangle(125, 28, 305, 44)); Pseudo_L.setFont(new java.awt.Font("Dialog", 1, 14)); Pseudo_L.setText("Pseudonyme :"); Pseudo_L.setBounds(new Rectangle(75, 94, 128, 28)); nom.setText(""); nom.setBounds(new Rectangle(229, 95, 108, 24)); pwd.setText(""); pwd.setBounds(new Rectangle(230, 135, 108, 25)); pwd_L.setFont(new java.awt.Font("Dialog", 1, 14)); pwd_L.setText("Mot de passe :"); pwd_L.setBounds(new Rectangle(76, 133, 122, 31)); gestionnaire_B gestionnaire = new gestionnaire_B(); Connect.addActionListener(gestionnaire); Connect.setBackground(new Color(239, 240, 234)); Connect.setBounds(new Rectangle(281, 251, 142, 30)); Connect.setText("Connexion"); Connect.setIcon(new ImageIcon(image_c)); Annuler.addActionListener(gestionnaire); Annuler.setBackground(new Color(239, 240, 234)); Annuler.setBounds(new Rectangle(104, 252, 140, 29)); Annuler.setText("Annuler"); Annuler.setIcon(new ImageIcon(image_d)); this.getContentPane().setBackground(new Color(239, 240, 234)); this.setForeground(new Color(239, 240, 234)); this.setTitle("Interface de connexion des clients au serveur de chat"); jLabel1.setFont(new java.awt.Font("Dialog", 1, 14)); jLabel1.setText("Adresse du serveur :"); jLabel1.setBounds(new Rectangle(75, 176, 156, 26)); jTextField1.setBounds(new Rectangle(230, 176, 108, 25)); Icon siegle = new ImageIcon(image); siegle_L = new JLabel("", siegle, SwingConstants.LEFT); siegle_L.setBounds(new Rectangle(0, 1, 76, 105)); this.getContentPane().add(jLabel1, null); this.getContentPane().add(pwd_L, null); this.getContentPane().add(Pseudo_L, null); this.getContentPane().add(jTextField1, null); this.getContentPane().add(nom, null); this.getContentPane().add(pwd, null); this.getContentPane().add(Bienvenue, null); this.getContentPane().add(Connect, null); this.getContentPane().add(Annuler, null); this.getContentPane().add(siegle_L, null); this.setSize(new Dimension(439, 321)); this.setResizable(false); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setVisible(true); }
protected void setPref() { Color color = DisplayOptions.getColor("PlainText"); Font font = DisplayOptions.getFont("PlainText"); m_lblUsername.setForeground(color); m_lblUsername.setFont(font); m_lblPassword.setForeground(color); m_lblPassword.setFont(font); m_cmbUser.getEditor().getEditorComponent().setForeground(color); m_cmbUser.getEditor().getEditorComponent().setFont(font); m_passwordField.setForeground(color); m_passwordField.setFont(font); color = DisplayOptions.getColor("Heading3"); font = DisplayOptions.getFont("Heading3"); m_lblSampleName.setForeground(color); m_pnlTrays.setBorder( BorderDeli.createBorder("Empty", "Sample Trays", "Bottom", "Center", color, font)); VBox.setforeground(color); VBox.setfont(font); }
/** * Checks the passwords of the user * * @param e The ActionEvent for this action. */ public void actionPerformed(ActionEvent e) { String cmd = e.getActionCommand(); // checks if the user has a unix password, if it matches, then logs the user // in the interface, otherwise checks for the vnmrj password, // if neither password matches, then the user is not logged in the interface if (cmd.equalsIgnoreCase("enter")) enterLogin(); else if (cmd.equalsIgnoreCase("cancel")) { m_passwordField.setText(""); m_lblLogin.setForeground(getBackground()); // setVisible(false); } else if (cmd.equalsIgnoreCase("help")) displayHelp(); }
public IUmenu(String host) { setTitle("GUUERRA_NAVAL"); efectos = new Efectos(); try { cliente = new Cliente(host); } catch (Exception ex) { } /* Titulo */ titulo = new JLabel(" JHONMAN "); titulo.setForeground(Color.BLACK); titulo.setFont(new Font("Algerian", Font.BOLD, 24)); titulo.setBounds(120, 40, 560, 40); titulo.setHorizontalAlignment(JLabel.CENTER); /* MeEnu de Opciones */ mEnU = new JLabel("MENU DE OPCIONES"); mEnU.setForeground(Color.BLACK); mEnU.setFont(new Font("Algerian", Font.BOLD, 24)); mEnU.setBounds(40, 135, 390, 40); mEnU.setHorizontalAlignment(JLabel.LEFT); ImageIcon i = new ImageIcon("imagenes/apariencia/fondo_def.jpg"); fondo = new JLabel(new ImageIcon(i.getImage().getScaledInstance(800, 600, Image.SCALE_SMOOTH))); fondo.setBounds(0, 0, 800, 600); ImageIcon i1 = new ImageIcon("imagenes/apariencia/botRegistrar.jpg"); ImageIcon i2 = new ImageIcon("imagenes/apariencia/botPrincipiante.jpg"); ImageIcon i3 = new ImageIcon("imagenes/apariencia/botDificil.jpg"); ImageIcon i4 = new ImageIcon("imagenes/apariencia/botSalir.jpg"); ImageIcon i5 = new ImageIcon("imagenes/apariencia/botRaking.jpg"); ImageIcon i6 = new ImageIcon("imagenes/apariencia/brJuegoRed2.jpg"); ImageIcon i11 = new ImageIcon("imagenes/apariencia/botRegistrar2.jpg"); ImageIcon i22 = new ImageIcon("imagenes/apariencia/botPrincipiante2.jpg"); ImageIcon i33 = new ImageIcon("imagenes/apariencia/botDificil2.jpg"); ImageIcon i44 = new ImageIcon("imagenes/apariencia/botSalir2.jpg"); ImageIcon i55 = new ImageIcon("imagenes/apariencia/botRaking2.jpg"); ImageIcon i66 = new ImageIcon("imagenes/apariencia/brJuegoRed.jpg"); /* Boton Puntajes */ estad = new JButton(new ImageIcon(i5.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH))); estad.setBounds(98, 148, 170, 40); estad.setRolloverIcon( new ImageIcon( i55.getImage() .getScaledInstance( 170, 40, Image .SCALE_SMOOTH))); // cuando el mouse esta sobre el boton cambia a esta // imagen estad.setBorderPainted(false); // elimino los bordes de el boton estad.addActionListener(this); estad.setMnemonic(KeyEvent.VK_P); estad.setToolTipText("ver Raking ALT + P"); /* Boton Registrar */ registrar = new JButton(new ImageIcon(i1.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH))); registrar.setBounds(98, 205, 170, 40); registrar.setRolloverIcon( new ImageIcon(i11.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH))); registrar.setBorderPainted(false); registrar.addActionListener(this); registrar.setMnemonic(KeyEvent.VK_Q); registrar.setToolTipText("Registrarse ALT + Q"); /* Boton TipoFacil */ facil = new JButton(new ImageIcon(i2.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH))); facil.setBounds(97, 262, 170, 40); facil.setRolloverIcon( new ImageIcon(i22.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH))); facil.setBorderPainted(false); facil.addActionListener(this); facil.setMnemonic(KeyEvent.VK_F); facil.setToolTipText("jugar en modo principiante ALT + F"); /* Boton TipoDificil */ dific = new JButton(new ImageIcon(i3.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH))); dific.setBounds(97, 317, 170, 40); dific.setRolloverIcon( new ImageIcon(i33.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH))); dific.setBorderPainted(false); dific.addActionListener(this); dific.setMnemonic(KeyEvent.VK_D); dific.setToolTipText("jugar en modo dificil ALT + D"); /* Boton Salir */ salir = new JButton(new ImageIcon(i4.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH))); salir.setBounds(97, 430, 170, 40); salir.setRolloverIcon( new ImageIcon(i44.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH))); salir.setBorderPainted(false); salir.addActionListener(this); salir.setMnemonic(KeyEvent.VK_S); salir.setToolTipText("Salir ALT + S"); /* Boton Red */ red = new JButton(new ImageIcon(i6.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH))); red.setBounds(97, 374, 170, 40); red.setRolloverIcon( new ImageIcon(i66.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH))); red.setBorderPainted(false); red.addActionListener(this); red.setMnemonic(KeyEvent.VK_C); red.setToolTipText("Jugar con varios jugadores ALT + C"); c = getContentPane(); c.setLayout(null); c.add(titulo); c.add(estad); c.add(facil); c.add(registrar); c.add(dific); c.add(salir); c.add(red); c.add(fondo); }
/** Set the status text to an error */ public void setErrorStatus(String txt) { status_text.setForeground(Color.red); status_text.setText(" " + txt); }
/** Set the status text */ public void setStatus(String txt) { status_text.setForeground(Color.black); status_text.setText(" " + txt); }
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); } } }); }
/** Initializes this panel. */ private void init() { JPanel mainPanel = new TransparentPanel(new BorderLayout()); mainPanel.setBorder( BorderFactory.createTitledBorder( Sip2SipAccRegWizzActivator.getResources() .getI18NString("plugin.sipaccregwizz.CREATE_ACCOUNT_TITLE"))); JPanel labelsPanel = new TransparentPanel(new GridLayout(0, 1)); JPanel valuesPanel = new TransparentPanel(new GridLayout(0, 1)); JLabel usernameLabel = new JLabel( Sip2SipAccRegWizzActivator.getResources() .getI18NString("plugin.sip2sipaccregwizz.USERNAME")); JLabel displayNameLabel = new JLabel( Sip2SipAccRegWizzActivator.getResources() .getI18NString("plugin.sipaccregwizz.DISPLAY_NAME")); JLabel passLabel = new JLabel(Sip2SipAccRegWizzActivator.getResources().getI18NString("service.gui.PASSWORD")); JLabel retypePasswordLabel = new JLabel( Sip2SipAccRegWizzActivator.getResources() .getI18NString("plugin.sip2sipaccregwizz.RETYPE_PASSWORD")); JLabel emailLabel = new JLabel( Sip2SipAccRegWizzActivator.getResources() .getI18NString("plugin.sip2sipaccregwizz.EMAIL")); labelsPanel.add(displayNameLabel); labelsPanel.add(usernameLabel); labelsPanel.add(passLabel); labelsPanel.add(retypePasswordLabel); labelsPanel.add(emailLabel); valuesPanel.add(displayNameField); valuesPanel.add(usernameField); valuesPanel.add(passField); valuesPanel.add(retypePassField); valuesPanel.add(emailField); JLabel emailDescriptionLabel = new JLabel( Sip2SipAccRegWizzActivator.getResources() .getI18NString("plugin.sip2sipaccregwizz.EMAIL_NOTE"), SwingConstants.CENTER); emailDescriptionLabel.setForeground(Color.GRAY); emailDescriptionLabel.setFont(emailDescriptionLabel.getFont().deriveFont(8)); emailDescriptionLabel.setBorder(BorderFactory.createEmptyBorder(0, 10, 8, 10)); initErrorArea(); mainPanel.add(labelsPanel, BorderLayout.WEST); mainPanel.add(valuesPanel, BorderLayout.CENTER); mainPanel.add(emailDescriptionLabel, BorderLayout.SOUTH); this.add(mainPanel, BorderLayout.CENTER); JLabel infoLabel = new JLabel( Sip2SipAccRegWizzActivator.getResources() .getI18NString("plugin.sip2sipaccregwizz.INFO_NOTE"), SwingConstants.RIGHT); infoLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); infoLabel.setForeground(Color.GRAY); infoLabel.setFont(emailDescriptionLabel.getFont().deriveFont(8)); infoLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 8, 0)); infoLabel.addMouseListener( new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { Sip2SipAccRegWizzActivator.getBrowserLauncher().openURL("http://wiki.sip2sip.info"); } }); this.add(infoLabel, BorderLayout.SOUTH); }
// // Build installer window // public static void showInstallerWindow() { _installerFrame = new JFrame(Config.getWindowTitle()); Container cont = _installerFrame.getContentPane(); cont.setLayout(new BorderLayout()); // North pane Box topPane = new Box(BoxLayout.X_AXIS); JLabel title = new JLabel(Config.getWindowHeading()); Font titleFont = new Font("SansSerif", Font.BOLD, 22); title.setFont(titleFont); title.setForeground(Color.black); // Create Sun logo URL urlLogo = Main.class.getResource(Config.getWindowLogo()); Image img = Toolkit.getDefaultToolkit().getImage(urlLogo); MediaTracker md = new MediaTracker(_installerFrame); md.addImage(img, 0); try { md.waitForAll(); } catch (Exception ioe) { Config.trace(ioe.toString()); } if (md.isErrorID(0)) Config.trace("Error loading image"); Icon sunLogo = new ImageIcon(img); JLabel logoLabel = new JLabel(sunLogo); logoLabel.setOpaque(true); topPane.add(topPane.createHorizontalStrut(5)); topPane.add(title); topPane.add(topPane.createHorizontalGlue()); topPane.add(logoLabel); topPane.add(topPane.createHorizontalStrut(5)); // West Pane Box westPane = new Box(BoxLayout.X_AXIS); westPane.add(westPane.createHorizontalStrut(10)); // South Pane Box bottomPane = new Box(BoxLayout.X_AXIS); bottomPane.add(bottomPane.createHorizontalGlue()); JButton abortButton = new JButton(Config.getWindowAbortButton()); abortButton.setMnemonic(Config.getWindowAbortMnemonic()); bottomPane.add(abortButton); bottomPane.add(bottomPane.createHorizontalGlue()); bottomPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0)); // Center Pane Box centerPane = new Box(BoxLayout.Y_AXIS); JLabel hidden = new JLabel(Config.getWindowHiddenLabel()); hidden.setVisible(false); centerPane.add(hidden); _stepLabels = new JLabel[5]; for (int i = 0; i < _stepLabels.length; i++) { _stepLabels[i] = new JLabel(Config.getWindowStep(i)); _stepLabels[i].setEnabled(false); centerPane.add(_stepLabels[i]); // install label's length will expand,so set a longer size. if (i == STEP_INSTALL) { Dimension dim = new JLabel(Config.getWindowStepWait(STEP_INSTALL)).getPreferredSize(); _stepLabels[i].setPreferredSize(dim); } } hidden = new JLabel(Config.getWindowHiddenLabel()); hidden.setVisible(false); centerPane.add(hidden); // Setup box layout cont.add(topPane, "North"); cont.add(westPane, "West"); cont.add(bottomPane, "South"); cont.add(centerPane, "Center"); _installerFrame.pack(); Dimension dim = _installerFrame.getSize(); // hard code to ensure title is completely visible on Sol/lin. if (dim.width < 400) { dim.width = 400; _installerFrame.setSize(dim); } Rectangle size = _installerFrame.getBounds(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); size.width = Math.min(screenSize.width, size.width); size.height = Math.min(screenSize.height, size.height); // Put window at 1/4, 1/4 of screen resoluion _installerFrame.setBounds( (screenSize.width - size.width) / 4, (screenSize.height - size.height) / 4, size.width, size.height); // Setup event listners _installerFrame.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent we) { installFailed("Window closed", null); } }); abortButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ae) { installFailed("Abort pressed", null); } }); // Show window _installerFrame.show(); }
public Design() throws Exception { super.setBackground(Color.BLACK); this.setTitle(""); con = getContentPane(); con.setLayout(null); dim = tk.getDefaultToolkit().getScreenSize(); this.setTitle("Customer Peer Login"); l1 = new JLabel(new ImageIcon("plain.jpg")); l1.setBounds(0, 0, 400, 400); con.add(l1); l1.setBorder(BorderFactory.createEtchedBorder(5, Color.black, Color.black)); title = new JLabel("CUSTOMER PEER LOGIN "); title.setFont(new Font("Bookman Old Style", Font.ROMAN_BASELINE, 20)); title.setForeground(Color.red); title.setBounds(80, 30, 300, 30); l1.add(title); l4 = new JLabel("CMACHINE NAME"); l4.setFont(new Font("Bookman Old Style", Font.BOLD, 16)); l4.setForeground(Color.BLUE); l4.setBounds(70, 100, 160, 20); // l4.setBorder(BorderFactory.createEtchedBorder(5,Color.green,Color.green)); l1.add(l4); jtf2 = new JTextField(); jtf2.setBounds(250, 100, 100, 20); jtf2.setBorder(BorderFactory.createEtchedBorder(5, Color.green, Color.green)); l1.add(jtf2); l2 = new JLabel("CUSER LOGIN"); l2.setFont(new Font("Bookman Old Style", Font.BOLD, 16)); l2.setForeground(Color.blue); l2.setBounds(70, 150, 120, 20); l1.add(l2); jtf1 = new JTextField(); jtf1.setBounds(250, 150, 100, 20); jtf1.setBorder(BorderFactory.createEtchedBorder(5, Color.green, Color.green)); l1.add(jtf1); l3 = new JLabel("CPASSWORD"); l3.setFont(new Font("Bookman Old Style", Font.BOLD, 16)); l3.setForeground(Color.blue); l3.setBounds(70, 200, 120, 20); l1.add(l3); jptf1 = new JPasswordField(); jptf1.setBounds(250, 200, 100, 20); jptf1.setBorder(BorderFactory.createEtchedBorder(5, Color.green, Color.green)); l1.add(jptf1); JLabel l4 = new JLabel("DAgent"); l4.setFont(new Font("Bookman Old Style", Font.BOLD, 16)); l4.setForeground(Color.blue); l4.setBounds(70, 250, 120, 20); l1.add(l4); box = new JComboBox(); box.setBounds(250, 250, 100, 20); box.setBorder(BorderFactory.createEtchedBorder(5, Color.green, Color.green)); l1.add(box); b2 = new JButton("Register"); b2.setBounds(50, 300, 100, 20); l1.add(b2); b2.setBorder(BorderFactory.createEtchedBorder(10, Color.BLUE, Color.BLUE)); b3 = new JButton("Login"); b3.setBounds(150, 300, 100, 20); b3.setBorder(BorderFactory.createEtchedBorder(10, Color.BLUE, Color.BLUE)); l1.add(b3); b1 = new JButton("Cancel"); b1.setBounds(250, 300, 100, 20); b1.setBorder(BorderFactory.createEtchedBorder(10, Color.BLUE, Color.BLUE)); l1.add(b1); b1.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent we) { dispose(); } }); try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); conn = DriverManager.getConnection("jdbc:odbc:agent"); } catch (Exception exp) { } try { Statement satem = conn.createStatement(); ResultSet rsatem = satem.executeQuery("select * from Dagent"); while (rsatem.next()) { String namem = rsatem.getString("uname"); box.addItem(namem); } } catch (Exception expo1) { } b2.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent we) { String username = jtf1.getText().trim(); String password = jptf1.getText().trim(); String mechine = jtf2.getText().trim(); String dname = box.getSelectedItem().toString(); int porte = 0; try { Statement sate = conn.createStatement(); ResultSet rsate = sate.executeQuery("select * from Dagent where uname='" + dname + "'"); if (rsate.next()) { servermachine = rsate.getString("umechine"); porte = rsate.getInt("ulistport"); System.out.println(servermachine); } System.out.println(servermachine); } catch (Exception exp) { exp.printStackTrace(); } try { packet p = new packet(); p.setaction("Creg"); p.setCuser(username); p.setCpass(password); p.setCmname(mechine); p.setCDpeer(dname); Socket soc = new Socket(servermachine, porte); ObjectOutputStream out = new ObjectOutputStream(soc.getOutputStream()); out.writeObject(p); ObjectInputStream in = new ObjectInputStream(soc.getInputStream()); packet rpac = (packet) in.readObject(); if (rpac.getaction().equals("ok")) { JOptionPane.showMessageDialog(null, "Sucessfully Registered"); jtf2.setText(""); jtf1.setText(""); jptf1.setText(""); } else { JOptionPane.showMessageDialog(null, "Already Registered"); jtf2.setText(""); jtf1.setText(""); jptf1.setText(""); } } catch (Exception exp) { } } }); b3.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent we) { String username = jtf1.getText().trim(); String password = jptf1.getText().trim(); String mechine = jtf2.getText().trim(); String Dname = box.getSelectedItem().toString(); int porte = 0; try { Statement sate = conn.createStatement(); ResultSet rsate = sate.executeQuery("select * from Dagent where uname='" + Dname + "'"); if (rsate.next()) { servermachine = rsate.getString("umechine"); porte = rsate.getInt("ulistport"); System.out.println(servermachine); } System.out.println(servermachine); } catch (Exception exp) { } try { packet p1 = new packet(); p1.setaction("clogin"); p1.setCuser(username); p1.setCpass(password); p1.setCmname(mechine); p1.setCDpeer(Dname); Socket soc1 = new Socket(servermachine, porte); ObjectOutputStream out1 = new ObjectOutputStream(soc1.getOutputStream()); out1.writeObject(p1); ObjectInputStream in1 = new ObjectInputStream(soc1.getInputStream()); packet rpac1 = (packet) in1.readObject(); if (rpac1.getaction().equals("ok")) { int port1 = 0; try { int portm = rpac1.getCport(); System.out.println("XXXXXXX" + portm); // JOptionPane.showMessageDialog(null,"Sucessfully Started"); new Listen(portm); new process(username, portm); dispose(); } catch (Exception exp) { } } else { JOptionPane.showMessageDialog( null, "Enter valid username and password", "Server reply", 2); jtf1.setText(""); jtf2.setText(""); jptf1.setText(""); } } catch (Exception exp) { } } }); setSize(400, 400); show(); setLocation(150, 100); setResizable(false); }
protected void enterLogin() { char[] password = m_passwordField.getPassword(); String strUser = (String) m_cmbUser.getSelectedItem(); setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); boolean blogin = WUserUtil.isOperatorNameok(strUser, false); if (blogin) { blogin = vnmrjPassword(strUser, password); if (!blogin) blogin = unixPassword(strUser, password); } if (blogin) { m_lblLogin.setForeground(Color.black); m_lblLogin.setText("Login Successful"); m_lblLogin.setVisible(true); // Get the Email column string for access to the operator data String emStr = vnmr.util.Util.getLabel("_admin_Email"); String stremail = WUserUtil.getOperatordata(strUser, emStr); // Get the Panel Level column string for access to the operator data String plStr = vnmr.util.Util.getLabel("_admin_Panel_Level"); String strPanel = WUserUtil.getOperatordata(strUser, plStr); if (stremail == null || stremail.equals("null")) stremail = ""; try { Integer.parseInt(strPanel); } catch (Exception e) { strPanel = WGlobal.PANELLEVEL; } m_trayTimer.stop(); Messages.postDebug(" Login: "******"appdir('reset','") .append(strUser) .append("','") .append(stremail) .append("',") .append(strPanel) .append(")") .toString()); exp.sendToVnmr("vnmrjcmd('util', 'bgReady')\n"); } setVisible(false); // Save the current position and size of this panel in case it // was changed Dimension size = getSize(); width = size.width; height = size.height; position = getLocation(); writePersistence(); // Call the macro to update this operator's // ExperimentSelector_operatorName.xml file // from the protocols themselves. This macro will // cause an update of the ES when it is finished // Util.getAppIF().sendToVnmr("updateExpSelector"); // I am not sure why we need to force updates since updateExpSelector // should have caused an update by writing to ES_op.xml file. // However, it works better if we do the force update. // ExpSelector.setForceUpdate(true); } else { m_lblLogin.setForeground(DisplayOptions.getColor("Error")); // m_lblLogin.setText("<HTML>Incorrect username/password <p> Please try again </HTML>"); m_lblLogin.setVisible(true); } setCursor(Cursor.getDefaultCursor()); }
protected void dolayout(String strDir, String strFreq, String strTraynum) { // TopBar String strTitle = gettitle(strFreq); Color color = DisplayOptions.getColor("Heading3"); // Center Panel JPanel panelCenter = new JPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints( 0, 0, 1, 1, 0.2, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0); ImageIcon icon = getImageIcon(); // panelCenter.add(new JLabel(icon)); addComp(panelCenter, new JLabel(icon), gbc, 0, 0); strTitle = getSampleName(strDir, strTraynum); m_lblSampleName = new JLabel(strTitle); if (strTitle == null || !strTitle.trim().equals("")) strTitle = "3"; Font font = m_lblSampleName.getFont(); font = DisplayOptions.getFont(font.getName(), Font.BOLD, 300); m_lblSampleName.setFont(font); m_lblSampleName.setForeground(color); // panelCenter.add(m_lblSampleName); m_pnlSampleName = new JPanel(new CardLayout()); m_pnlSampleName.add(m_lblSampleName, OTHER); addComp(panelCenter, m_pnlSampleName, gbc, 1, 0); m_pnlSampleName.setVisible(false); m_pnlTrays = new JPanel(new GridLayout(1, 0)); // Vast panels VBox pnlVast1 = new VBox(m_pnlTrays, "1"); m_pnlTrays.add(pnlVast1); m_pnlVast[0] = pnlVast1; VBox pnlVast2 = new VBox(m_pnlTrays, "2"); m_pnlTrays.add(pnlVast2); m_pnlVast[1] = pnlVast2; VBox pnlVast3 = new VBox(m_pnlTrays, "3"); m_pnlTrays.add(pnlVast3); m_pnlVast[2] = pnlVast3; VBox pnlVast4 = new VBox(m_pnlTrays, "4"); m_pnlTrays.add(pnlVast4); m_pnlVast[3] = pnlVast4; VBox pnlVast5 = new VBox(m_pnlTrays, "5"); m_pnlTrays.add(pnlVast5); m_pnlVast[4] = pnlVast5; m_pnlSampleName.add(m_pnlTrays, VAST); // Login Panel JPanel panelThird = new JPanel(new BorderLayout()); JPanel panelLogin = new JPanel(new GridBagLayout()); gbc = new GridBagConstraints(); panelThird.add(panelLogin); Object[] aStrUser = getOperators(); m_cmbUser = new JComboBox(aStrUser); BasicComboBoxRenderer renderer = new BasicComboBoxRenderer(); m_cmbUser.setRenderer(renderer); m_cmbUser.setEditable(true); m_passwordField = new JPasswordField(); // *Warning, working around a Java problem* // When we went to the T3500 running Redhat 5.3, the JPasswordField // fields sometimes does not allow ANY entry of characters. Setting // the enableInputMethods() to true fixed this problem. There are // comments that indicate that this could cause the typed characters // to be visible. I have not found that to be a problem. // This may not be required in the future, or could cause characters // to become visible in the future if Java changes it's code. // GRS 8/20/09 m_passwordField.enableInputMethods(true); m_lblLogin = new VLoginLabel(null, "Incorrect username/password \n Please try again ", 0, 0); m_lblLogin.setVisible(false); okButton.setActionCommand("enter"); okButton.addActionListener(this); cancelButton.setActionCommand("cancel"); cancelButton.addActionListener(this); helpButton.setActionCommand("help"); helpButton.addActionListener(this); m_passwordField.addKeyListener( new KeyAdapter() { public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) enterLogin(); } }); // These is some wierd problem such that sometimes, the vnmrj command // area gets the focus and these items in the login box do not get // the focus. Even clicking in these items does not bring focus to // them. Issuing requestFocus() does not bring focus to them. // I can however, determing if either the operator entry box or // the password box has focus and if neither does, I can unshow and // reshow the panel and that fixes the focus. So, I have added this // to the mouseClicked action. If neither has focus, it will // take focus with setVisible false then true. comboTextField = m_cmbUser.getEditor().getEditorComponent(); m_passwordField.addMouseListener(this); comboTextField.addMouseListener(this); m_lblUsername = new JLabel(Util.getLabel("_Operator")); addComp(panelLogin, m_lblUsername, gbc, 0, 0); addComp(panelLogin, m_cmbUser, gbc, 1, 0); m_lblPassword = new JLabel(Util.getLabel("_Password")); addComp(panelLogin, m_lblPassword, gbc, 0, 1); addComp(panelLogin, m_passwordField, gbc, 1, 1); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.gridheight = GridBagConstraints.REMAINDER; addComp(panelLogin, m_lblLogin, gbc, 2, 0); setPref(); Container container = getContentPane(); JPanel panelLoginBox = new JPanel(new BorderLayout()); panelLoginBox.add(panelCenter, BorderLayout.CENTER); panelLoginBox.add(panelThird, BorderLayout.SOUTH); container.add(panelLoginBox, BorderLayout.CENTER); }