public username() { setLayout(new BorderLayout()); setVisible(true); setResizable(false); int width = Toolkit.getDefaultToolkit().getScreenSize().width; int hight = Toolkit.getDefaultToolkit().getScreenSize().height; setBounds(300, 0, width - 600, hight); add(BorderLayout.CENTER, new p3()); }
public hostelStatus() { setTitle("Hostel"); connect(); updateRecord(); JFrame fr = new JFrame(); Toolkit tkt = fr.getToolkit(); Dimension frsize = tkt.getScreenSize(); setBounds(frsize.width / 4, frsize.height / 12, frsize.width / 2, frsize.height / 8); setLayout(null); cn = getContentPane(); cn.setBackground(new Color(190, 180, 170)); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); tl = new JLabel("Current Hostels Status"); tl.setFont(new Font("Engravers MT", 1, 25)); tl.setForeground(new Color(247, 251, 249)); p1 = new JPanel(); p1.setBounds(0, 0, 600, 50); p1.add(tl); p1.setBackground(new Color(31, 88, 166)); cn.add(p1); b1 = new JButton("LOAD"); b1.setMnemonic('L'); b1.addActionListener(new dispListener()); b1.setBounds(230, 320, 120, 30); b2 = new JButton("EXIT"); b2.setMnemonic('X'); b2.addActionListener(new exitListener()); b2.setBounds(350, 320, 100, 30); cn.add(b1); cn.add(b2); table = new JTable(data, col); table.setFont(new Font("Serif", Font.BOLD, 16)); table.setBackground(new Color(250, 250, 250)); table.setEnabled(false); JScrollPane jsp = new JScrollPane(table); jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); jsp.setBounds(5, 100, 590, 200); cn.add(jsp); screensize = Toolkit.getDefaultToolkit().getScreenSize(); setSize(600, 400); setVisible(true); setVisible(true); setResizable(true); connect(); }
private void addMenuItems(JMenu f, String m[]) { Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); for (int i = 0; i < m.length; i++) { if (m[i].equals("--")) { f.addSeparator(); } else if (m[i].equals("---")) { // (ulrivo): full size on screen with less than 640 width if (d.width >= 640) { f.addSeparator(); } else { return; } } else { JMenuItem item = new JMenuItem(m[i].substring(1)); char c = m[i].charAt(0); if (c != '-') { item.setMnemonic(c); } item.addActionListener(this); f.add(item); } } }
private void backButtonActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_backButtonActionPerformed // TODO add your handling code here: this.dispose(); // JFrame frame1= new JFrame(); Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); AccessControl accessControlForm = new AccessControl(); accessControlForm.setLocation((screen.width - 400) / 2, ((screen.height - 350) / 2)); accessControlForm.setVisible(true); } // GEN-LAST:event_backButtonActionPerformed
/** Method declaration */ private void initGUI() { Panel pQuery = new Panel(); Panel pCommand = new Panel(); pResult = new Panel(); pQuery.setLayout(new BorderLayout()); pCommand.setLayout(new BorderLayout()); pResult.setLayout(new BorderLayout()); Font fFont = new Font("Dialog", Font.PLAIN, 12); txtCommand = new TextArea(5, 40); txtCommand.addKeyListener(this); txtResult = new TextArea(20, 40); txtCommand.setFont(fFont); txtResult.setFont(new Font("Courier", Font.PLAIN, 12)); butExecute = new Button("Execute"); butClear = new Button("Clear"); butExecute.addActionListener(this); butClear.addActionListener(this); pCommand.add("East", butExecute); pCommand.add("West", butClear); pCommand.add("Center", txtCommand); gResult = new Grid(); setLayout(new BorderLayout()); pResult.add("Center", gResult); pQuery.add("North", pCommand); pQuery.add("Center", pResult); fMain.add("Center", pQuery); tTree = new Tree(); // (ulrivo): screen with less than 640 width Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); if (d.width >= 640) { tTree.setMinimumSize(new Dimension(200, 100)); } else { tTree.setMinimumSize(new Dimension(80, 100)); } gResult.setMinimumSize(new Dimension(200, 300)); fMain.add("West", tTree); doLayout(); fMain.pack(); }
public static void main(String[] args) { TableModelDemo applet = new TableModelDemo(); JFrame frame = new JFrame(); // EXIT_ON_CLOSE == 3 frame.setDefaultCloseOperation(3); frame.setTitle("TableModelDemo"); frame.getContentPane().add(applet, BorderLayout.CENTER); applet.init(); applet.start(); frame.setSize(500, 220); Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); frame.setLocation( (d.width - frame.getSize().width) / 2, (d.height - frame.getSize().height) / 2); frame.setVisible(true); }
public Deta_Ventas_r() { setBackground(Color.gray); setLayout(null); setSize(400, 400); l1 = new Label(" clave "); t1 = new TextField(36); l2 = new Label("Vendedor"); t2 = new TextField(20); l3 = new Label("Cliente"); t3 = new TextField(20); l4 = new Label("Fechas"); t4 = new TextField(5); l5 = new Label("monto_final"); t5 = new TextField(5); t4.setEditable(false); t5.setEditable(false); b = new Button("Registrar"); add(l1); add(t1); add(l2); add(t2); add(l3); add(t3); add(l4); add(t4); add(l5); add(t5); add(b); l1.setBounds(24, 75, 71, 23); l2.setBounds(24, 103, 90, 23); l3.setBounds(24, 131, 90, 23); l4.setBounds(24, 159, 90, 23); l5.setBounds(24, 185, 90, 23); t1.setBounds(114, 75, 270, 23); t2.setBounds(114, 103, 270, 23); t3.setBounds(114, 131, 270, 23); t4.setBounds(114, 159, 270, 23); t5.setBounds(114, 185, 270, 23); b.setBounds(167, 215, 65, 23); b.addActionListener(this); setUndecorated(true); setLocation((Toolkit.getDefaultToolkit().getScreenSize().width / 2) - 200, 50); start(); }
public reminder(int m, int y, int m3, int y3) { m1 = m; y1 = y; m2 = m3; y2 = y3; try { f.setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("skrm.jpg"))); String cn = UIManager.getSystemLookAndFeelClassName(); UIManager.setLookAndFeel(cn); // Use the native L&F } catch (Exception cnf) { System.out.println(cnf); } f = new JFrame("Print Reminders"); f.setVisible(true); f.setLayout(null); f.setSize(300, 100); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); b = new JButton("Print Reminders"); b.addActionListener(this); back = new JButton("Back"); back.addActionListener(this); f.add(b); b.setBounds(10, 10, 100, 20); b.setMnemonic('P'); f.add(back); back.setMnemonic('B'); back.setBounds(150, 10, 100, 20); // f.pack(); }
public class Payment extends JInternalFrame { private JLabel label1, label2, label3, label4, label5, label6, label7; public JTextField text1, text4, text5, text6, text7; public JComboBox combo1, combo2, combo3, combo4, combo5, combo6, combo7, combo8; private JButton button1, button2, button3, button4, button5, button6; private JPanel panel1, pane, panel3; Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); public DateButton p_date; String payNo, pasNo, pasName, mode, dt, amount, rev; public Payment() { super("Payment Process", false, true, false, true); setDefaultCloseOperation(DISPOSE_ON_CLOSE); label1 = new JLabel("Paymnent Number"); label2 = new JLabel("Passenger Number"); label3 = new JLabel("Passenger Name"); label6 = new JLabel("Mode of Payment"); label4 = new JLabel("Date of Payment"); label5 = new JLabel("Amount Paid"); label7 = new JLabel("Received By"); text1 = new JTextField(10); text5 = new JTextField(10); p_date = new DateButton(); p_date.setForeground(Color.red); combo1 = new JComboBox(); combo2 = new JComboBox(); combo3 = new JComboBox(); combo4 = new JComboBox(); combo4.addItem("Cash"); combo4.addItem("Bank"); combo8 = new JComboBox(); button1 = new JButton("Pay", new ImageIcon(ClassLoader.getSystemResource("Images/payments.png"))); button2 = new JButton( "Print Receipt", new ImageIcon(ClassLoader.getSystemResource("Images/print.png"))); button3 = new JButton("Cancel", new ImageIcon(ClassLoader.getSystemResource("Images/exit.png"))); button4 = new JButton("Search", new ImageIcon(ClassLoader.getSystemResource("Images/search.png"))); button5 = new JButton("Delete", new ImageIcon(ClassLoader.getSystemResource("Images/delete.png"))); // combo3.addItem(new) panel1 = new JPanel(new GridLayout(7, 2)); panel1.setPreferredSize(new Dimension(350, 250)); panel1.add(label1); panel1.add(text1); panel1.add(label2); panel1.add(combo1); panel1.add(label3); panel1.add(combo2); panel1.add(label6); panel1.add(combo4); panel1.add(label4); panel1.add(p_date); panel1.add(label5); panel1.add(combo8); panel1.add(label7); panel1.add(combo3); // combo8.removeAllItems(); pane = new JPanel(); pane.add(button1); pane.add(button2); pane.add(button3); pane.add(button4); panel3 = new JPanel(); panel3.add(panel1); panel3.add(pane); button2.setEnabled(false); add(panel3); setSize(500, 350); setCombo(); setcbr(); generator(); setamount(); setLocation((screen.width - 300) / 2, ((screen.height - 300) / 2)); setResizable(false); combo1.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { combo2.setSelectedIndex(combo1.getSelectedIndex()); combo8.removeItem(combo8.getSelectedItem()); setamount(); } }); button3.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { setVisible(true); dispose(); } }); button2.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { Receipt frm = new Receipt(); MDIWindow.desktop.add(frm); frm.setVisible(true); button2.setEnabled(false); } }); button1.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { if (combo1.getSelectedItem() == null) { JOptionPane.showMessageDialog( null, "All Passenger have paid", "Error", JOptionPane.DEFAULT_OPTION); return; } if (combo2.getSelectedItem() == null) { JOptionPane.showMessageDialog( null, "All Passenger have paid", "Error", JOptionPane.DEFAULT_OPTION); return; } generator(); if (combo8.getSelectedItem() == null) { JOptionPane.showMessageDialog( null, "The Passenger has not been booked", "ERROR", JOptionPane.DEFAULT_OPTION); return; } try { Statement statement = DBConnection.getDBConnection().createStatement(); { String temp = "INSERT INTO Payment (Payment_No, Pass_No, Pass_Name, Payment_Mode, Date_Payment,Amount_Paid,Received_By) VALUES ('" + text1.getText() + "', '" + combo1.getSelectedItem() + "', '" + combo2.getSelectedItem() + "', '" + combo4.getSelectedItem() + "', '" + p_date.getText() + "', '" + combo8.getSelectedItem() + "', '" + combo3.getSelectedItem() + "')"; combo1.removeItem(combo1.getSelectedItem()); combo2.removeItem(combo2.getSelectedItem()); int result = statement.executeUpdate(temp); JOptionPane.showMessageDialog( null, "Passenger Account updated", "Updated", JOptionPane.DEFAULT_OPTION); } } catch (SQLException sqlex) { sqlex.printStackTrace(); } try { Statement statement = DBConnection.getDBConnection().createStatement(); { String temp = "UPDATE Passenger SET Pay_Status='Paid'" + "WHERE Pass_NO LIKE '" + combo1.getSelectedItem() + "'"; int result = statement.executeUpdate(temp); } } catch (SQLException sqlex) { sqlex.printStackTrace(); } button1.setEnabled(false); button2.setEnabled(true); } }); button4.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { try { if (!text1.equals("")) { Statement statement = DBConnection.getDBConnection().createStatement(); String query = ("SELECT * FROM Payment where Payment_No ='" + text1.getText() + "'"); ResultSet rs = statement.executeQuery(query); display(rs); statement.close(); } } catch (SQLException sqlex) { sqlex.printStackTrace(); } setVisible(true); } }); } private void generator() { try { ResultSet rst = DBConnection.getDBConnection() .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE) .executeQuery("SELECT Payment_No FROM Payment"); text1.setText("1000"); while (rst.next()) { String s; int number = rst.getInt(1); number = number + 1; s = "" + number; text1.setText(s); int x; } } catch (Exception n) { n.printStackTrace(); } } private void setCombo() { try { ResultSet rst = DBConnection.getDBConnection() .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE) .executeQuery( "SELECT Emp.empNo, Emp.Sname, Emp.Fname, Emp.Lname, Emp.Designation FROM Emp WHERE Emp.Designation='Booking Clerk'"); while (rst.next()) { combo3.addItem(rst.getString(3)); } } catch (Exception n) { n.printStackTrace(); } } private void setcbr() { try { ResultSet rst = DBConnection.getDBConnection() .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE) .executeQuery( "SELECT * FROM Passenger where Booked_status='Booked' and Pay_Status='Not_Paid'"); System.out.println("Hello"); while (rst.next()) { combo1.addItem(rst.getString(1)); combo2.addItem(rst.getString(2)); } } catch (Exception n) { n.printStackTrace(); } } private void setamount() { try { ResultSet rst = DBConnection.getDBConnection() .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE) .executeQuery( "SELECT Amount FROM BOOKING where Pass_No='" + combo1.getSelectedItem() + "'"); while (rst.next()) { combo8.addItem(rst.getString(1)); } } catch (Exception n) { n.printStackTrace(); } } public void display(ResultSet rs) { try { boolean recordNumber = rs.next(); if (recordNumber) { payNo = rs.getString(1); pasNo = rs.getString(2); pasName = rs.getString(3); mode = rs.getString(4); dt = rs.getString(5); amount = rs.getString(6); rev = rs.getString(7); text1.setText(payNo); combo1.setSelectedItem(pasNo); combo2.setSelectedItem(pasName); combo4.setSelectedItem(mode); p_date.setText(dt); combo8.setSelectedItem(amount); combo3.setSelectedItem(rev); } else { JOptionPane.showMessageDialog( null, "Record Not found", "ERROR", JOptionPane.DEFAULT_OPTION); } } catch (SQLException sqlex) { sqlex.printStackTrace(); } } }
public class NewUser extends JFrame { private JLabel username, password, confirm, label1, label2; private JPasswordField pass1, pass2; private JTextField txtusername, name; private JButton button1, button2; private JPanel panel1, panel2; private JComboBox combo1; Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); public NewUser() { super("Adding New User"); label1 = new JLabel("Name"); label2 = new JLabel("Category"); username = new JLabel("Username"); password = new JLabel("Password"); confirm = new JLabel("Re-enter Password"); pass1 = new JPasswordField(); pass2 = new JPasswordField(); txtusername = new JTextField(); name = new JTextField(); combo1 = new JComboBox(); button1 = new JButton("Ok", new ImageIcon("Icon/i16x16/ok.png")); button2 = new JButton("Cancel", new ImageIcon("Icon/i16x16/exit.png")); panel1 = new JPanel(new GridLayout(6, 2)); panel1.add(label1); panel1.add(name); panel1.add(label2); panel1.add(combo1); panel1.add(username); panel1.add(txtusername); panel1.add(password); panel1.add(pass1); panel1.add(confirm); panel1.add(pass2); panel1.add(button1); panel1.add(button2); combo1.addItem("Manager"); combo1.addItem("Booking Clerk"); combo1.addItem("Supervisor"); panel2 = new JPanel(); panel2.add(panel1); getContentPane().add(panel2); setSize(350, 195); setVisible(true); setLocation((screen.width - 500) / 2, ((screen.height - 350) / 2)); setResizable(false); name.addKeyListener( new KeyAdapter() { public void keyTyped(KeyEvent e) { char c = e.getKeyChar(); if (!(Character.isLetter(c) || (c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_SPACE) || (c == KeyEvent.VK_DELETE))) { getToolkit().beep(); JOptionPane.showMessageDialog( null, "Invalid Character", "ERROR", JOptionPane.DEFAULT_OPTION); e.consume(); } } }); txtusername.addKeyListener( new KeyAdapter() { public void keyTyped(KeyEvent e) { char c = e.getKeyChar(); if (!(Character.isLetter(c) || (c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_SPACE) || (c == KeyEvent.VK_DELETE))) { getToolkit().beep(); JOptionPane.showMessageDialog( null, "Invalid Character", "ERROR", JOptionPane.DEFAULT_OPTION); e.consume(); } } }); button1.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { if (name.getText() == null || name.getText().equals("")) { JOptionPane.showMessageDialog( null, "Enter name", "ERROR", JOptionPane.DEFAULT_OPTION); name.requestFocus(); return; } if (txtusername.getText() == null || txtusername.getText().equals("")) { JOptionPane.showMessageDialog( null, "Enter username", "ERROR", JOptionPane.DEFAULT_OPTION); txtusername.requestFocus(); return; } if (pass1.getText() == null || pass1.getText().equals("")) { JOptionPane.showMessageDialog( null, "Enter password", "ERROR", JOptionPane.DEFAULT_OPTION); pass1.requestFocus(); return; } if (pass2.getText() == null || pass2.getText().equals("")) { JOptionPane.showMessageDialog( null, "Confirm your password", "ERROR", JOptionPane.DEFAULT_OPTION); pass2.requestFocus(); return; } if (!pass1.getText().equals(pass2.getText())) { JOptionPane.showMessageDialog( null, "passwords do not match.", "ERROR", JOptionPane.DEFAULT_OPTION); pass2.requestFocus(); return; } try { Statement statement = Connect.getConnection().createStatement(); { String temp = "INSERT INTO users (Name,Category,username, password) VALUES ('" + name.getText() + "', '" + combo1.getSelectedItem() + "', '" + txtusername.getText() + "', '" + pass1.getText() + "')"; int result = statement.executeUpdate(temp); JOptionPane.showMessageDialog( null, "User is succesfully added", "SUCCESS", JOptionPane.DEFAULT_OPTION); dispose(); } } catch (Exception in) { in.printStackTrace(); } } }); button2.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { dispose(); } }); } public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); new MainMenu().setVisible(true); } }
public Summary(int patient_id) { this.patient_id = patient_id; setTitle("Summary"); setSize( (int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth()), (int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight()) - 40); setResizable(false); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); head = new JLabel("MEDI_SCAN DIAGNOSTIC LAB SERVICES", SwingConstants.CENTER); head.setForeground(Color.WHITE); Font f2 = new Font("Papyrus", Font.BOLD, 36); head.setFont(f2); res = new JLabel("RESULT SUMMARY", SwingConstants.CENTER); res.setForeground(Color.WHITE); Font f3 = new Font("Papyrus", Font.BOLD, 28); res.setFont(f3); Font f1 = new Font("Goudy Old Style", Font.BOLD, 16); hello = new JLabel("Hello Mr./Miss "); hello.setForeground(new Color(54, 34, 174)); hello.setFont(f1); fin = new JLabel("Your Medical Test Is Finished"); fin.setFont(f1); fin.setForeground(new Color(54, 34, 174)); pname = new JLabel("Patient Name"); pname.setForeground(new Color(54, 34, 174)); pname.setFont(f1); ldate = new JLabel("Test Date"); ldate.setForeground(new Color(54, 34, 174)); ldate.setFont(f1); age = new JLabel("Age"); age.setForeground(new Color(54, 34, 174)); age.setFont(f1); sex = new JLabel("Sex"); sex.setForeground(new Color(54, 34, 174)); sex.setFont(f1); tname = new JLabel("Test Name"); tname.setForeground(new Color(54, 34, 174)); tname.setFont(f1); nvalue = new JLabel("Normal Value"); nvalue.setForeground(new Color(54, 34, 174)); nvalue.setFont(f1); trate = new JLabel("Test Rate"); trate.setForeground(new Color(54, 34, 174)); trate.setFont(f1); tresult = new JLabel("Test Result"); tresult.setForeground(new Color(54, 34, 174)); tresult.setFont(f1); tamt = new JLabel("Total Amout"); tamt.setForeground(new Color(54, 34, 174)); tamt.setFont(f1); exit = new JButton("EXIT"); exit.setFont(f1); pHead = new JPanel(new GridLayout(2, 1)); pHead.setBackground(new Color(134, 134, 234)); pCenter = new JPanel(new GridBagLayout()); pCenter.setBackground(new Color(211, 248, 253)); pCom = new JPanel(new BorderLayout()); pCom.setBackground(new Color(211, 248, 253)); pSouth = new JPanel(new FlowLayout(FlowLayout.RIGHT)); pSouth.setBackground(new Color(211, 248, 253)); // Adding Icon on top-left. ImageIcon img = new ImageIcon("pics/logo.jpg"); this.setIconImage(img.getImage()); try { Connection con = JDBCConnection.getConnection(); PreparedStatement pstmt = con.prepareStatement( "Select first_name,last_name,age,sex,test_id,tdate from patientreg where patient_id=?"); pstmt.setInt(1, this.patient_id); ResultSet rs = pstmt.executeQuery(); if (rs.next()) { first_name = rs.getString("first_name"); lname = rs.getString("last_name"); name = new JLabel(first_name + " " + lname); name1 = new JLabel(first_name + " " + lname); p_age = rs.getInt("age"); pAge = new JLabel(p_age + ""); p_sex = rs.getString("sex"); psex = new JLabel(p_sex); t_id = rs.getInt("test_id"); t_date = rs.getString("tdate"); date1 = new JLabel(t_date); } } catch (SQLException s) { s.printStackTrace(); } try { Connection con = JDBCConnection.getConnection(); PreparedStatement pstmt = con.prepareStatement("Select test_result from reportbydoctor where patient_id=?"); pstmt.setInt(1, this.patient_id); ResultSet rs = pstmt.executeQuery(); if (rs.next()) { te_res = rs.getString("test_result"); result = new JLabel(te_res); } } catch (SQLException s) { s.printStackTrace(); } try { Connection con = JDBCConnection.getConnection(); PreparedStatement pstmt = con.prepareStatement("select normal_val,rate,test_name from addtest where test_id=?"); pstmt.setInt(1, t_id); ResultSet rs = pstmt.executeQuery(); if (rs.next()) { n_value = rs.getInt("normal_val"); normal_value1 = new JLabel(n_value + ""); te_rate = rs.getInt("rate"); rate1 = new JLabel(te_rate + ""); rate2 = new JLabel(te_rate + ""); te_name = rs.getString("test_name"); testname = new JLabel(te_name); } } catch (SQLException a) { a.printStackTrace(); } content = getContentPane(); // for label hello GridBagConstraints gc = new GridBagConstraints(); gc.fill = GridBagConstraints.NONE; gc.gridx = 1; gc.gridwidth = 1; gc.gridy = 1; gc.ipadx = 0; gc.ipady = 10; gc.weightx = 0; gc.weighty = 0; gc.anchor = GridBagConstraints.WEST; gc.insets = new Insets(0, 50, 20, 0); pCenter.add(hello, gc); // for label name1 gc = new GridBagConstraints(); gc.fill = GridBagConstraints.NONE; gc.gridx = 2; gc.gridwidth = 1; gc.gridy = 1; gc.ipadx = 0; gc.ipady = 10; gc.weightx = 0; gc.weighty = 0; gc.anchor = GridBagConstraints.WEST; gc.insets = new Insets(0, 0, 20, 0); pCenter.add(name1, gc); // for label fin gc = new GridBagConstraints(); gc.fill = GridBagConstraints.NONE; gc.gridx = 3; gc.gridwidth = 2; gc.gridy = 1; gc.ipadx = 0; gc.ipady = 10; gc.weightx = 0; gc.weighty = 0; gc.anchor = GridBagConstraints.WEST; gc.insets = new Insets(0, 0, 20, 20); pCenter.add(fin, gc); // for label pname gc = new GridBagConstraints(); gc.fill = GridBagConstraints.NONE; gc.gridx = 1; gc.gridwidth = 1; gc.gridy = 2; gc.ipadx = 0; gc.ipady = 10; gc.weightx = 0; gc.weighty = 0; gc.anchor = GridBagConstraints.WEST; gc.insets = new Insets(0, 0, 20, 20); pCenter.add(pname, gc); // for label name gc = new GridBagConstraints(); gc.fill = GridBagConstraints.NONE; gc.gridx = 2; gc.gridwidth = 1; gc.gridy = 2; gc.ipadx = 0; gc.ipady = 10; gc.weightx = 0; gc.weighty = 0; gc.anchor = GridBagConstraints.WEST; gc.insets = new Insets(0, 0, 20, 20); pCenter.add(name, gc); // for label ldate gc = new GridBagConstraints(); gc.fill = GridBagConstraints.NONE; gc.gridx = 1; gc.gridwidth = 1; gc.gridy = 3; gc.ipadx = 0; gc.ipady = 10; gc.weightx = 0; gc.weighty = 0; gc.anchor = GridBagConstraints.WEST; gc.insets = new Insets(0, 0, 20, 20); pCenter.add(ldate, gc); // for label date1 gc = new GridBagConstraints(); gc.fill = GridBagConstraints.NONE; gc.gridx = 2; gc.gridwidth = 1; gc.gridy = 3; gc.ipadx = 0; gc.ipady = 10; gc.weightx = 0; gc.weighty = 0; gc.anchor = GridBagConstraints.WEST; gc.insets = new Insets(0, 0, 20, 20); pCenter.add(date1, gc); // for label age gc = new GridBagConstraints(); gc.fill = GridBagConstraints.NONE; gc.gridx = 1; gc.gridwidth = 1; gc.gridy = 4; gc.ipadx = 0; gc.ipady = 10; gc.weightx = 0; gc.weighty = 0; gc.anchor = GridBagConstraints.WEST; gc.insets = new Insets(0, 0, 20, 20); pCenter.add(age, gc); // for label pAge gc = new GridBagConstraints(); gc.fill = GridBagConstraints.NONE; gc.gridx = 2; gc.gridwidth = 1; gc.gridy = 4; gc.ipadx = 0; gc.ipady = 10; gc.weightx = 0; gc.weighty = 0; gc.anchor = GridBagConstraints.WEST; gc.insets = new Insets(0, 0, 20, 20); pCenter.add(pAge, gc); // for label sex gc = new GridBagConstraints(); gc.fill = GridBagConstraints.NONE; gc.gridx = 1; gc.gridwidth = 1; gc.gridy = 5; gc.ipadx = 125; gc.ipady = 10; gc.weightx = 0; gc.weighty = 0; gc.anchor = GridBagConstraints.WEST; gc.insets = new Insets(0, 0, 20, 20); pCenter.add(sex, gc); // for label psex gc = new GridBagConstraints(); gc.fill = GridBagConstraints.NONE; gc.gridx = 2; gc.gridwidth = 1; gc.gridy = 5; gc.ipadx = 0; gc.ipady = 10; gc.weightx = 0; gc.weighty = 0; gc.anchor = GridBagConstraints.WEST; gc.insets = new Insets(0, 0, 20, 20); pCenter.add(psex, gc); // for label tname gc = new GridBagConstraints(); gc.fill = GridBagConstraints.NONE; gc.gridx = 1; gc.gridwidth = 1; gc.gridy = 6; gc.ipadx = 0; gc.ipady = 10; gc.weightx = 0; gc.weighty = 0; gc.anchor = GridBagConstraints.WEST; gc.insets = new Insets(0, 0, 20, 20); pCenter.add(tname, gc); // for label nvalue gc = new GridBagConstraints(); gc.fill = GridBagConstraints.NONE; gc.gridx = 2; gc.gridwidth = 1; gc.gridy = 6; gc.ipadx = 0; gc.ipady = 10; gc.weightx = 0; gc.weighty = 0; gc.anchor = GridBagConstraints.WEST; gc.insets = new Insets(0, 0, 20, 20); pCenter.add(nvalue, gc); // for label trate gc = new GridBagConstraints(); gc.fill = GridBagConstraints.NONE; gc.gridx = 3; gc.gridwidth = 1; gc.gridy = 6; gc.ipadx = 0; gc.ipady = 10; gc.weightx = 0; gc.weighty = 0; gc.anchor = GridBagConstraints.WEST; gc.insets = new Insets(0, 0, 20, 20); pCenter.add(trate, gc); // for label tresult gc = new GridBagConstraints(); gc.fill = GridBagConstraints.NONE; gc.gridx = 4; gc.gridwidth = 1; gc.gridy = 6; gc.ipadx = 0; gc.ipady = 10; gc.weightx = 0; gc.weighty = 0; gc.anchor = GridBagConstraints.WEST; gc.insets = new Insets(0, 0, 20, 20); pCenter.add(tresult, gc); // for label testname gc = new GridBagConstraints(); gc.fill = GridBagConstraints.NONE; gc.gridx = 1; gc.gridwidth = 1; gc.gridy = 7; gc.ipadx = 0; gc.ipady = 10; gc.weightx = 0; gc.weighty = 0; gc.anchor = GridBagConstraints.WEST; gc.insets = new Insets(0, 0, 20, 20); pCenter.add(testname, gc); // for label normal_value1 gc = new GridBagConstraints(); gc.fill = GridBagConstraints.NONE; gc.gridx = 2; gc.gridwidth = 1; gc.gridy = 7; gc.ipadx = 0; gc.ipady = 10; gc.weightx = 0; gc.weighty = 0; gc.anchor = GridBagConstraints.WEST; gc.insets = new Insets(0, 0, 20, 20); pCenter.add(normal_value1, gc); // for label rate1 gc = new GridBagConstraints(); gc.fill = GridBagConstraints.NONE; gc.gridx = 3; gc.gridwidth = 1; gc.gridy = 7; gc.ipadx = 0; gc.ipady = 10; gc.weightx = 0; gc.weighty = 0; gc.anchor = GridBagConstraints.WEST; gc.insets = new Insets(0, 0, 20, 20); pCenter.add(rate1, gc); // for label result gc = new GridBagConstraints(); gc.fill = GridBagConstraints.NONE; gc.gridx = 4; gc.gridwidth = 1; gc.gridy = 7; gc.ipadx = 0; gc.ipady = 10; gc.weightx = 0; gc.weighty = 0; gc.anchor = GridBagConstraints.WEST; gc.insets = new Insets(0, 0, 20, 20); pCenter.add(result, gc); // for label tamt gc = new GridBagConstraints(); gc.fill = GridBagConstraints.NONE; gc.gridx = 3; gc.gridwidth = 1; gc.gridy = 8; gc.ipadx = 0; gc.ipady = 10; gc.weightx = 0; gc.weighty = 0; gc.anchor = GridBagConstraints.WEST; gc.insets = new Insets(0, 0, 20, 20); pCenter.add(tamt, gc); // for label rate2 gc = new GridBagConstraints(); gc.fill = GridBagConstraints.NONE; gc.gridx = 4; gc.gridwidth = 1; gc.gridy = 8; gc.ipadx = 0; gc.ipady = 10; gc.weightx = 0; gc.weighty = 0; gc.anchor = GridBagConstraints.WEST; gc.insets = new Insets(0, 0, 20, 20); pCenter.add(rate2, gc); exit.addActionListener(this); pSouth.add(exit); content.add(pSouth, BorderLayout.SOUTH); pHead.add(head); pHead.add(res); content.add(pHead, BorderLayout.NORTH); content.add(pCenter, BorderLayout.CENTER); setVisible(true); }
void main() { CommonSwing.setDefaultColor(); fMain = new JFrame("HSQL Database Manager"); // (ulrivo): An actual icon. fMain.getContentPane().add(createToolBar(), "North"); fMain.setIconImage(CommonSwing.getIcon()); fMain.addWindowListener(this); JMenuBar bar = new JMenuBar(); // used shortcuts: CERGTSIUDOLM String fitems[] = { "-Connect...", "--", "-Open Script...", "-Save Script...", "-Save Result...", "--", "-Exit" }; addMenu(bar, "File", fitems); String vitems[] = {"RRefresh Tree", "--", "GResults in Grid", "TResults in Text"}; addMenu(bar, "View", vitems); String sitems[] = { "SSELECT", "IINSERT", "UUPDATE", "DDELETE", "---", "-CREATE TABLE", "-DROP TABLE", "-CREATE INDEX", "-DROP INDEX", "--", "-CHECKPOINT", "-SCRIPT", "-SET", "-SHUTDOWN", "--", "-Test Script" }; addMenu(bar, "Command", sitems); mRecent = new JMenu("Recent"); bar.add(mRecent); String soptions[] = { "-AutoCommit on", "-AutoCommit off", "OCommit", "LRollback", "--", "-Disable MaxRows", "-Set MaxRows to 100", "--", "-Logging on", "-Logging off", "--", "-Insert test data" }; addMenu(bar, "Options", soptions); String stools[] = {"-Dump", "-Restore", "-Transfer"}; addMenu(bar, "Tools", stools); fMain.setJMenuBar(bar); initGUI(); sRecent = new String[iMaxRecent]; Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); Dimension size = fMain.getSize(); // (ulrivo): full size on screen with less than 640 width if (d.width >= 640) { fMain.setLocation((d.width - size.width) / 2, (d.height - size.height) / 2); } else { fMain.setLocation(0, 0); fMain.setSize(d); } fMain.show(); // (ulrivo): load query from command line if (defScript != null) { if (defDirectory != null) { defScript = defDirectory + File.separator + defScript; } // if insert stmet is thousands of records...skip showing it // as text. Too huge. StringBuffer buf = new StringBuffer(); ifHuge = DatabaseManagerCommon.readFile(defScript); if (4096 <= ifHuge.length()) { buf.append("This huge file cannot be edited. Please execute\n"); txtCommand.setText(buf.toString()); } else { txtCommand.setText(ifHuge); } } txtCommand.requestFocus(); }
Usermaster() { Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); x = dim.width; y = dim.height; setSize(x, y); setUndecorated(true); Container c = getContentPane(); center = new JPanel() { public void paintComponent(Graphics g) { Toolkit kit = Toolkit.getDefaultToolkit(); Image img = kit.getImage("Image/user.jpg"); MediaTracker t = new MediaTracker(this); t.addImage(img, 0); while (true) { try { t.waitForAll(); break; } catch (Exception ee) { } } g.drawImage(img, 0, 0, x, y, null); } }; c.add(center); center.setLayout(null); titleLb = new JLabel( "<html><body ><font size='5'><b><i> User Name </b></i></font></body></html>"); titleLb.setForeground(new Color(10, 110, 255)); titleLb.setBounds(x / 2 + 50, x / 4, 150, 50); center.add(titleLb); output = new JLabel( "<html><body ><font size='5'><b><i> OUTPUT </b></i></font></body></html>"); output.setForeground(Color.white); output.setBounds(x / 2 - 250, x / 6, 150, 50); center.add(output); login = new JButton(new ImageIcon("Image/logBut.gif")); login.setBorder(BorderFactory.createRaisedBevelBorder()); login.setBounds(x / 2 + 100, x / 2 - 70, 100, 100); login.setBackground(Color.white); pass = new JPasswordField(); pass.setToolTipText("Enter The Password To Payroll System"); login.requestFocus(); pass.setBorder(BorderFactory.createRaisedBevelBorder()); pass.setForeground(new Color(10, 110, 255)); pass.setFont(new Font("Arial", Font.BOLD, 22)); pass.setCaretColor(Color.red); pass.setBounds(x / 2 + 50, x / 3, 200, 35); center.add(pass); center.add(login); pass.addKeyListener( new KeyAdapter() { public void keyPressed(KeyEvent e) { output.setText( "<html><body ><font size='5'><b><i> OUTPUT </b></i></font></body></html>"); output.setForeground(Color.white); } }); try { clsConnection connect = new clsConnection(); conn = connect.setConnection(conn, "", ""); } catch (Exception e) { } login.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { try { st = conn.createStatement(); rs = st.executeQuery("select * from img"); while (rs.next()) { if (pass.getText().equals(rs.getString(3))) { setVisible(false); URL url = closeSystem.class.getResource("spacemusic.au"); click = Applet.newAudioClip(url); click.play(); paro.setVisible(true); } else { pass.setText(""); pass.requestFocus(); output.setText("Fell"); output.setFont(new Font("Arial", Font.BOLD, 36)); output.setForeground(Color.red); } } } catch (Exception er) { System.out.println("Sorry\n" + er); } } }); }
Head() { setTitle("Head Office"); setLocation(440, 80); f1.setLayout(null); Toolkit kit = Toolkit.getDefaultToolkit(); Dimension screenSize = kit.getScreenSize(); int screenHeight = screenSize.height - 30; // int screenWidth = screenSize.width; setSize(800, 738); // System.out.println(screenHeight); setResizable(false); // setSize(800,800); lno = new JLabel("Head office Number :"); lname = new JLabel(" Name :"); contact = new JLabel(" Contact :"); address = new JLabel(" Address :"); state = new JLabel(" State :"); startdate = new JLabel(" Start Date :"); howmany = new JLabel(" Total Employee :"); t1 = new JTextField(10); t2 = new JTextField(10); t3 = new JTextField(10); t4 = new JTextField(10); t5 = new JTextField(10); t6 = new JTextField(10); t7 = new JTextField(10); add = new JButton(" Add"); ok = new JButton("OK"); ok.addActionListener(this); add.addActionListener(this); taddress = new JTextArea(15, 20); scrpn = new JScrollPane(taddress); f1.add(lno); f1.add(t1); f1.add(lname); f1.add(t2); f1.add(contact); f1.add(t3); f1.add(t4); f1.add(add); f1.add(t5); f1.add(address); f1.add(scrpn); f1.add(state); f1.add(t6); f1.add(t7); f1.add(howmany); f1.add(startdate); b6 = new JButton( "Exit"); // , new ImageIcon(ClassLoader.getSystemResource("Images/update.png"))); b7 = new JButton("View"); b6.setBounds(180, 370, 100, 30); b7.setBounds(50, 370, 100, 30); add(b6); add(b7); b6.addActionListener(this); b7.addActionListener(this); lno.setBounds(10, 25, 150, 25); t1.setBounds(150, 23, 125, 25); lname.setBounds(10, 67, 150, 25); t2.setBounds(150, 67, 150, 25); contact.setBounds(10, 110, 150, 25); t3.setBounds(150, 110, 125, 25); state.setBounds(10, 153, 150, 25); t4.setBounds(150, 153, 125, 25); startdate.setBounds(10, 196, 150, 25); t5.setBounds(150, 196, 125, 25); address.setBounds(10, 239, 150, 25); t7.setBounds(150, 239, 250, 25); // scrpn.setBounds(150,239,200,50); howmany.setBounds(10, 310, 150, 25); t6.setBounds(150, 310, 125, 25); ok.setBounds(190, 420, 90, 25); setSize(445, 500); add(f1, BorderLayout.CENTER); setVisible(true); try { Class.forName("com.mysql.jdbc.Driver"); System.out.println("Driver loaded Succesfull"); cn = DriverManager.getConnection("jdbc:mysql://127.0.0.1/payroll", "root", "root"); System.out.println("Connection Succesfull"); st = cn.createStatement(); } catch (Exception e) { JOptionPane.showMessageDialog(this, "Error is" + e); } }
/** * This method is called from within the constructor to initialize the form. WARNING: Do NOT * modify this code. The content of this method is always regenerated by the Form Editor. */ public void close() { WindowEvent winClosingEvent = new WindowEvent(this, WindowEvent.WINDOW_CLOSING); Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(winClosingEvent); }
public EchoAWT() throws UnknownHostException { super("채팅 프로그램"); // 각종 정의 h = new JPanel(new GridLayout(2, 3)); m = new JPanel(new BorderLayout()); f = new JPanel(new BorderLayout()); s = new JPanel(new BorderLayout()); login = new JPanel(new BorderLayout()); // name = new JLabel(" 사용자 이름 "); name = new JLabel(" 메세지 입력 "); jta = new JTextArea(); // clientList = new JTextArea(0, 10); clientList = new JList(); jsp = new JScrollPane(jta); list = new JScrollPane(clientList); jtf = new JTextField("입력하세요."); hi = new JTextField("HOST IP 입력"); pi = new JTextField("PORT 입력"); localport = new JTextField("원하는 PORT 입력"); lid = new JTextField("ID를 입력하세요."); lpw = new JTextField("PW를 입력하세요."); serveropen = new JButton("서버 오픈"); textin = new JButton("입력"); clientin = new JButton("서버 접속"); conf = new JButton("로그인"); join = new JButton("회원가입"); addr = InetAddress.getLocalHost(); // 사용자 해상도 및 창 크기 설정 및 가져오기. Toolkit tk = Toolkit.getDefaultToolkit(); Dimension screenSize = tk.getScreenSize(); setSize(500, 500); Dimension d = getSize(); // 각종 버튼 및 텍스트 필드 리스너 jtf.addActionListener(this); hi.addActionListener(this); pi.addActionListener(this); localport.addActionListener(this); lid.addActionListener(this); lpw.addActionListener(this); conf.addActionListener(this); join.addActionListener(this); serveropen.addActionListener(this); clientin.addActionListener(this); textin.addActionListener(this); jtf.addFocusListener(this); hi.addFocusListener(this); pi.addFocusListener(this); localport.addFocusListener(this); lid.addFocusListener(this); lpw.addFocusListener(this); // 서버 접속 h.add(hi); h.add(pi); h.add(clientin); // 서버 생성 h.add(new JLabel("IP : " + addr.getHostAddress(), (int) CENTER_ALIGNMENT)); h.add(localport); h.add(serveropen); // 채팅글창 글 작성 막기 jta.setEditable(false); // 접속자 리스트 width 제한 clientList.setFixedCellWidth(d.width / 3); // 입력 창 f.add(name, "West"); f.add(jtf, "Center"); f.add(textin, "East"); // 접속자 확인창 s.add(new JLabel("접속자", (int) CENTER_ALIGNMENT), "North"); s.add(list, "Center"); // clientList.setEditable(false); // 메인 창 m.add(jsp, "Center"); m.add(s, "East"); // 프레임 설정 add(h, "North"); add(m, "Center"); add(f, "South"); // 로그인 다이얼로그 jd = new JDialog(); jd.setTitle("채팅 로그인"); jd.add(login); jd.setSize(200, 200); Dimension dd = jd.getSize(); jd.setLocation(screenSize.width / 2 - (dd.width / 2), screenSize.height / 2 - (dd.height / 2)); jd.setVisible(true); // 로그인창 JPanel lm = new JPanel(new GridLayout(4, 1)); lm.add(lid); lm.add(new Label()); lm.add(lpw); lm.add(new Label()); JPanel bt = new JPanel(); bt.add(conf); bt.add(join); login.add(new Label(), "North"); login.add(new Label(), "West"); login.add(new Label(), "East"); login.add(lm, "Center"); login.add(bt, "South"); // 창의 위치, 보임, EXIT 단추 활성화. setLocation(screenSize.width / 2 - (d.width / 2), screenSize.height / 2 - (d.height / 2)); setVisible(false); setDefaultCloseOperation(EXIT_ON_CLOSE); }
/** Method declaration */ void main() { fMain = new Frame("HSQL Database Manager"); imgEmpty = createImage(new MemoryImageSource(2, 2, new int[4 * 4], 2, 2)); fMain.setIconImage(imgEmpty); fMain.addWindowListener(this); MenuBar bar = new MenuBar(); // used shortcuts: CERGTSIUDOLM String fitems[] = { "-Connect...", "--", "-Open Script...", "-Save Script...", "-Save Result...", "--", "-Exit" }; addMenu(bar, "File", fitems); String vitems[] = { "RRefresh Tree", "--", "GResults in Grid", "TResults in Text", "--", "1Shrink Tree", "2Enlarge Tree", "3Shrink Command", "4Enlarge Command" }; addMenu(bar, "View", vitems); String sitems[] = { "SSELECT", "IINSERT", "UUPDATE", "DDELETE", "--", "-CREATE TABLE", "-DROP TABLE", "-CREATE INDEX", "-DROP INDEX", "--", "-CHECKPOINT", "-SCRIPT", "-SET", "-SHUTDOWN", "--", "-Test Script" }; addMenu(bar, "Command", sitems); Menu recent = new Menu("Recent"); mRecent = new Menu("Recent"); bar.add(mRecent); String soptions[] = { "-AutoCommit on", "-AutoCommit off", "OCommit", "LRollback", "--", "-Disable MaxRows", "-Set MaxRows to 100", "--", "-Logging on", "-Logging off", "--", "-Insert test data" }; addMenu(bar, "Options", soptions); /* NB - 26052002 Restore is not implemented yet in the transfer tool */ String stools[] = {"-Dump", /*"-Restore",*/ "-Transfer"}; addMenu(bar, "Tools", stools); fMain.setMenuBar(bar); fMain.setSize(640, 480); fMain.add("Center", this); initGUI(); sRecent = new String[iMaxRecent]; Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); Dimension size = fMain.getSize(); // (ulrivo): full size on screen with less than 640 width if (d.width >= 640) { fMain.setLocation((d.width - size.width) / 2, (d.height - size.height) / 2); } else { fMain.setLocation(0, 0); fMain.setSize(d); } fMain.show(); // (ulrivo): load query from command line if (defScript != null) { if (defDirectory != null) { defScript = defDirectory + File.separator + defScript; } txtCommand.setText(DatabaseManagerCommon.readFile(defScript)); } txtCommand.requestFocus(); }
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); }