AdminMain() { l = new JLabel(); l.setBounds(10, 20, 1340, 1000); l.setBackground(Color.black); Font ft = new Font("Arial", Font.BOLD, 30); Font ft1 = new Font("Arial", Font.BOLD, 14); Font ft2 = new Font("Arial", Font.BOLD, 20); f1 = new Frame("Soft Test Management (Beta)"); f1.setLayout(null); l1 = new Label("Test Instructions", l1.CENTER); l1.setBounds(10, 20, 1300, 60); l1.setForeground(Color.blue); l1.setBackground(Color.white); l1.setFont(ft); l2 = new JLabel("Deletion of Faculty/Students"); l2.setBounds(20, 30, 1000, 500); l2.setBackground(Color.blue); l2.setFont(ft2); l3 = new JLabel("Test Pattern"); l3.setBounds(20, 90, 1300, 500); l3.setBackground(Color.green); l3.setFont(ft2); b1 = new JButton("Go !"); b1.setBounds(300, 220, 120, 30); b1.setBackground(Color.white); b1.setForeground(Color.blue); b1.setFont(ft2); b2 = new JButton("Go"); b2.setBounds(300, 240, 120, 30); b2.setBackground(Color.white); b2.setForeground(Color.blue); b2.setFont(ft2); f1.add(l); l.add(l1); l2.add(b1); l.add(l2); l3.add(b2); l.add(l3); b1.addActionListener(this); b2.addActionListener(this); f1.setVisible(true); f1.setSize(1800, 800); }
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(); }
/** Initialize the contents of the frame. */ private void initialize() { frame = new JFrame(); frame.setBounds(100, 100, 450, 300); frame.setVisible(true); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().setLayout(null); JButton btnCustomer = new JButton("Customer"); btnCustomer.setFont(new Font("Tahoma", Font.BOLD, 16)); btnCustomer.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { JOptionPane.showMessageDialog(null, "Welcome to Coffee Kiosk "); // Coffee1 nw = new Coffee1(); // nw.NewScreen(); cust = cust + 1; Customer cs = new Customer(); cs.CustomerScreen(); } }); btnCustomer.setBounds(83, 94, 117, 86); frame.getContentPane().add(btnCustomer); JButton btnAdmin = new JButton("Admin"); btnAdmin.setFont(new Font("Tahoma", Font.BOLD, 16)); btnAdmin.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(null, "Welcome Admin "); Login ls = new Login(); ls.LoginScreen(); } }); btnAdmin.setBounds(229, 94, 117, 86); frame.getContentPane().add(btnAdmin); JButton btnExit = new JButton("EXIT"); btnExit.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { JOptionPane.showMessageDialog(null, "Thank You for using Coffee Kiosk"); System.exit(0); } }); btnExit.setBounds(168, 207, 89, 23); frame.getContentPane().add(btnExit); JLabel lblLeedsCoffeeKiosk = new JLabel("LEEDS COFFEE KIOSK"); lblLeedsCoffeeKiosk.setHorizontalAlignment(SwingConstants.CENTER); lblLeedsCoffeeKiosk.setFont(new Font("Times New Roman", Font.BOLD | Font.ITALIC, 30)); lblLeedsCoffeeKiosk.setForeground(new Color(148, 0, 211)); lblLeedsCoffeeKiosk.setBounds(36, 11, 366, 72); frame.getContentPane().add(lblLeedsCoffeeKiosk); }
public CFFreeSwitchSwingAuditActionAttrJPanel( ICFFreeSwitchSwingSchema argSchema, ICFSecurityAuditActionObj argFocus) { super(); JLabel label; JComponent compo; CFJReferenceEditor reference; final String S_ProcName = "construct-schema-focus"; if (argSchema == null) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 1, "argSchema"); } // argFocus is optional; focus may be set later during execution as // conditions of the runtime change. swingSchema = argSchema; setSwingFocusAsAuditAction(argFocus); final int spacing = 5; int y = spacing; final int height = 25; final int textheight = 80; final int vspacing = height + spacing; final int textvspacing = textheight + spacing; final int labelx = spacing; final int labelwidth = 200; final int fieldx = labelx + labelwidth + spacing; final int fieldwidth = 785; final int panelwidth = fieldx + fieldwidth + spacing; // temporary -- I think you have to have a panel bigger than the coordinates initially setSize(panelwidth, 100000); label = getSwingLabelAuditActionId(); add(label); label.setBounds(labelx, y, labelwidth, height); compo = getSwingEditorAuditActionId(); add(compo); compo.setBounds(fieldx, y, fieldwidth, height); y = y + vspacing; label = getSwingLabelDescription(); add(label); label.setBounds(labelx, y, labelwidth, height); compo = getSwingEditorDescription(); add(compo); compo.setBounds(fieldx, y, fieldwidth, height); y = y + vspacing; // Now we can set the proper size based on the fields and references populated setSize(panelwidth, y); Dimension pfsz = new Dimension(panelwidth, y); setPreferredSize(pfsz); Dimension min = new Dimension(400, y); setMinimumSize(min); populateFields(); adjustComponentEnableStates(); swingIsInitializing = false; }
public void doLayout() { JLabel label; JComponent compo; CFJReferenceEditor reference; Dimension dim; final int spacing = 5; int y = spacing; final int height = 25; final int textheight = 80; final int vspacing = height + spacing; final int textvspacing = textheight + spacing; final int labelx = spacing; final int labelwidth = 200; final int fieldx = labelx + labelwidth + spacing; final int fieldwidth = 1024; Dimension jpsz = getSize(); int usefieldwidth = jpsz.width - 215; label = getSwingLabelId(); label.setBounds(labelx, y, labelwidth, height); compo = getSwingEditorId(); dim = compo.getMaximumSize(); if (dim.width < usefieldwidth) { compo.setBounds(fieldx, y, dim.width, height); } else { compo.setBounds(fieldx, y, fieldwidth, height); } y = y + vspacing; label = getSwingLabelFullDomainName(); label.setBounds(labelx, y, labelwidth, height); compo = getSwingEditorFullDomainName(); dim = compo.getMaximumSize(); if (dim.width < usefieldwidth) { compo.setBounds(fieldx, y, dim.width, height); } else { compo.setBounds(fieldx, y, fieldwidth, height); } y = y + vspacing; label = getSwingLabelDescription(); label.setBounds(labelx, y, labelwidth, height); compo = getSwingEditorDescription(); dim = compo.getMaximumSize(); if (dim.width < usefieldwidth) { compo.setBounds(fieldx, y, dim.width, height); } else { compo.setBounds(fieldx, y, fieldwidth, height); } y = y + vspacing; }
public void tampilan_GUI() { this.getContentPane().setBackground(Color.yellow); this.getContentPane().setLayout(null); jLabel1.setFont(new java.awt.Font("Dialog", 1, 16)); jLabel1.setText("Please Waiting..."); jLabel1.setBounds(new Rectangle(14, 5, 187, 30)); prosesBar.setBounds(new Rectangle(14, 40, 311, 16)); prosesBar.setStringPainted(true); statusProses.setText(""); statusProses.setBounds(new Rectangle(14, 60, 311, 16)); this.getContentPane().add(jLabel1); this.getContentPane().add(prosesBar); this.getContentPane().add(statusProses); }
LoginForm() { setDefaultLookAndFeelDecorated(true); f = new JFrame("LoginForm"); f.setSize(750, 330); f.setLocation(200, 200); f.setResizable(false); JPanel p = new JPanel(); f.getContentPane().add(p); p.setBackground(Color.white); icon = new ImageIcon("img.jpg"); image = new JLabel(icon); image.setSize(100, 100); l2 = new JLabel("�"); t1 = new JTextField(16); l3 = new JLabel("Password"); jp1 = new JPasswordField(16); // img = getImage(getDocumentBase(), getParameter("img")); b1 = new JButton("Login"); b2 = new JButton("Reset"); b3 = new JButton("Cancel"); l1 = new JLabel(" SANJEEVANI HOSPITAL"); Font fk = new Font("Algerian", Font.BOLD, 40); l1.setFont(fk); l1.setForeground(Color.RED); l2 = new JLabel("UserName"); l4 = new JLabel("� "); p.add(l1); p.add(l4); p.add(l2); p.add(t1); p.add(l3); p.add(jp1); p.add(b1); p.add(b2); p.add(b3); p.add(image, BorderLayout.SOUTH); b1.addActionListener(this); b2.addActionListener(this); b3.addActionListener(this); f.setVisible(true); }
public void doLayout() { JLabel label; JComponent compo; CFJReferenceEditor reference; Dimension dim; final int spacing = 5; int y = spacing; final int height = 25; final int textheight = 80; final int vspacing = height + spacing; final int textvspacing = textheight + spacing; final int labelx = spacing; final int labelwidth = 200; final int fieldx = labelx + labelwidth + spacing; final int fieldwidth = 1024; Dimension jpsz = getSize(); int usefieldwidth = jpsz.width - 215; label = getSwingLabelContainerTenant(); label.setBounds(labelx, y, labelwidth, height); reference = getSwingReferenceContainerTenant(); reference.setBounds(fieldx, y, usefieldwidth, height); y = y + vspacing; label = getSwingLabelTSecGroupId(); label.setBounds(labelx, y, labelwidth, height); compo = getSwingEditorTSecGroupId(); dim = compo.getMaximumSize(); if (dim.width < usefieldwidth) { compo.setBounds(fieldx, y, dim.width, height); } else { compo.setBounds(fieldx, y, fieldwidth, height); } y = y + vspacing; label = getSwingLabelName(); label.setBounds(labelx, y, labelwidth, height); compo = getSwingEditorName(); dim = compo.getMaximumSize(); if (dim.width < usefieldwidth) { compo.setBounds(fieldx, y, dim.width, height); } else { compo.setBounds(fieldx, y, fieldwidth, height); } y = y + vspacing; }
// event handling public void actionPerformed(ActionEvent e) { if (e.getSource() == btnok) { PreparedStatement pstm; ResultSet rs; String sql; // if no entries has been made and hit ok button throw an error // you can do this step using try clause as well if ((tf1.getText().equals("") && (tf2.getText().equals("")))) { lblmsg.setText("Enter your details "); lblmsg.setForeground(Color.magenta); } else { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection connect = DriverManager.getConnection("jdbc:odbc:student_base"); System.out.println("Connected to the database"); pstm = connect.prepareStatement("insert into student_base values(?,?)"); pstm.setString(1, tf1.getText()); pstm.setString(2, tf2.getText()); // execute method to execute the query pstm.executeUpdate(); lblmsg.setText("Details have been added to database"); // closing the prepared statement and connection object pstm.close(); connect.close(); } catch (SQLException sqe) { System.out.println("SQl error"); } catch (ClassNotFoundException cnf) { System.out.println("Class not found error"); } } } // upon clickin button addnew , your textfield will be empty to enternext record if (e.getSource() == btnaddnew) { tf1.setText(""); tf2.setText(""); } if (e.getSource() == btnexit) { System.exit(1); } }
public void status_Proses(boolean sukses, String status, int nilaiProsesBar) { statusProses.setText(status); prosesBar.setValue(prosesBar.getValue() + nilaiProsesBar); if (proses == false) { JOptionPane.showMessageDialog(null, "Gagal Login\nKarena" + statusGagal); removeAll(); dispose(); new LoginDialog_Database().show(); } proses = sukses; statusGagal = status; }
public Welcome() { c.setLayout(null); c.add(welcome); welcome.setBounds(250, 100, 600, 50); welcome.setFont(font1); welcome.setForeground(Color.black); c.add(hotel); hotel.setBounds(350, 170, 700, 50); hotel.setFont(font2); hotel.setForeground(Color.black); c.add(check); check.setBounds(450, 350, 250, 50); check.addActionListener(this); c.add(order); order.setBounds(150, 350, 250, 50); order.addActionListener(this); c.add(bill); bill.setBounds(750, 350, 250, 50); bill.addActionListener(this); c.add(exit); exit.setBounds(40, 600, 130, 20); exit.addActionListener(this); c.add(back).setBounds(0, 0, 1800, 1000); }
public void adicionaOPTelaInicial(Connection conn, JobProtheus jobProtheus, JobLote job) throws SQLException { if (jobProtheus != null) { // antes de adicionar o job na tela de consultas jobs, verifica // se ja existe, se ja existir remove e adiciona novamente int total = modeloConsultaJobs.getRowCount() - 1; for (int j = total; j >= 0; j--) { JobProtheus jobAtual = modeloConsultaJobs.getJob(j); if (jobAtual.getJob().trim().equals(job.getJob().trim()) && jobAtual.getOperacao() == job.getOperNum()) { modeloConsultaJobs.removeJob(j); } } boolean temLinhaTempo = verificaSeSetorTemLinhaTempo(conn, jobProtheus.getCentroTrabalho().trim()); if (temLinhaTempo) { if (jobProtheus.getQuantidadeCompleta() == 0) { desativaIniciado( conn, jobProtheus.getJob().trim().replace(".", ""), jobProtheus.getOperacao()); } else { boolean iniciadoJaExiste = verificarSeJobEstaTabelaIniciado( conn, jobProtheus.getJob().trim().replace(".", ""), jobProtheus.getOperacao()); JobIniciado jobIniciado = retornaUltimoLote( conn, jobProtheus.getJob().trim().replace(".", ""), jobProtheus.getOperacao()); if (!iniciadoJaExiste) { incluiIniciado(conn, jobIniciado); } else { // fazer update jobsiniciados alterando os valores pelo lote mais atual alteraIniciado(conn, jobIniciado); } } } jLTotalAtrasados.setText(Principal.retornaTotalJobsAtrasados(modeloConsultaJobs)); } else { JOptionPane.showMessageDialog(null, "Job não encontrado na SC2010: " + job); } }
// Вид формы при изменении сотрудника public void sotrDiaUpdate(Sotrudnik s) { label_id_hidden.setText(Integer.toString(s.getId_sotrudnika())); textField_familiya.setText(s.getFamiliya()); textField_imya.setText(s.getImya()); textField_otchestvo.setText(s.getOtchestvo()); textField_phone.setText(s.getPhone()); textField_date.setText(s.getData_priema().toString()); comboBox_doljnost.removeAllItems(); comboBox_kvalification.removeAllItems(); try { DBClass db = new DBClass(); ArrayList<Doljnost> d = db.doljnostFromDB(); DBClass db2 = new DBClass(); Doljnost dd = db2.doljnostFromDB(s); for (int i = 0; i < d.size(); i++) { comboBox_doljnost.addItem(d.get(i)); Doljnost ddd = (Doljnost) comboBox_doljnost.getItemAt(i); if (dd.getNazvanie_doljnosti().equals(ddd.getNazvanie_doljnosti())) dd = ddd; } comboBox_doljnost.setSelectedItem(dd); DBClass db3 = new DBClass(); ArrayList<Kvalification> k = db3.kvalificationFromDB(); DBClass db4 = new DBClass(); Kvalification kk = db4.kvalificationFromDB(s); for (int i = 0; i < k.size(); i++) { comboBox_kvalification.addItem(k.get(i)); Kvalification kkk = (Kvalification) comboBox_kvalification.getItemAt(i); if (kk.getNazvanie_kvalification().equals(kkk.getNazvanie_kvalification())) kk = kkk; } comboBox_kvalification.setSelectedItem(kk); } catch (ClassNotFoundException e) { e.printStackTrace(); JOptionPane.showMessageDialog(panelException, e.getMessage()); } catch (SQLException ee) { ee.printStackTrace(); JOptionPane.showMessageDialog(panelException, ee.getMessage()); } }
// Вид формы при добавлении нового сотрудника public void sotrDiaInsert() { label_id_hidden.setText("Новый сотрудник"); textField_familiya.setText(""); textField_imya.setText(""); textField_otchestvo.setText(""); textField_phone.setText(""); comboBox_doljnost.removeAllItems(); comboBox_kvalification.removeAllItems(); Calendar calend = Calendar.getInstance(); if (calend.get(Calendar.MONTH) <= 9) { textField_date.setText( String.valueOf( (calend.get(Calendar.YEAR) + "-" + ("0" + (1 + calend.get(Calendar.MONTH))) + "-") + (calend.get(Calendar.DATE)))); } else textField_date.setText( String.valueOf( ((calend.get(Calendar.YEAR)) + "-" + (1 + calend.get(Calendar.MONTH)) + "-") + (calend.get(Calendar.DATE)))); textField_date.setEnabled(false); try { DBClass db = new DBClass(); ArrayList<Doljnost> d = db.doljnostFromDB(); for (int i = 0; i < d.size(); i++) { comboBox_doljnost.addItem(d.get(i)); } DBClass db2 = new DBClass(); ArrayList<Kvalification> k = db2.kvalificationFromDB(); for (int i = 0; i < k.size(); i++) { comboBox_kvalification.addItem(k.get(i)); } } catch (ClassNotFoundException e) { e.printStackTrace(); JOptionPane.showMessageDialog(panelException, e.getMessage()); } catch (SQLException ee) { ee.printStackTrace(); JOptionPane.showMessageDialog(panelException, ee.getMessage()); } }
public void actionPerformed(ActionEvent e) { JButton b = (JButton) e.getSource(); if (b == bu) { j14 = new JLabel("NEW IMAGE"); j14.setBounds(840, 200, 300, 300); q.add(j14); JFileChooser filechooser = new JFileChooser(); int result = filechooser.showOpenDialog(this); f = filechooser.getSelectedFile(); try { String dir1 = f.getAbsolutePath(); // setText(dir); str = dir1; // ResizeImage.resize(dir); f = new File(dir1); } catch (Exception e1) { } repaint(); // b=(JButton)e.getSource(); } if (b == ba) { try { read(); patient.add(tadd.getText(), tsym.getText(), f, str); JOptionPane.showMessageDialog(null, "Patient ID: " + patient.pid + " Record Added"); } catch (Exception e4) { System.out.println("" + e4); } } if (b == bm) { try { setVisible(false); } catch (Exception e4) { System.out.println("" + e4); } } }
/** Initialize the contents of the frame. */ private void initialize() { JPanel mainPanel = new JPanel(); JButton book = new JButton("Book"); mainPanel.add(book); book.setPreferredSize(new Dimension(200, 80)); JTextField enterFlightNum = new JTextField("Enter Flight Number"); enterFlightNum.setColumns(10); enterFlightNum.setBounds(227, 251, 286, 42); mainPanel.add(enterFlightNum); JButton mainMenu = new JButton("Main Menu"); mainPanel.add(mainMenu); mainMenu.setPreferredSize(new Dimension(200, 80)); mainMenu.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { fFrame.setVisible(false); new MainUI(c1); } }); book.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { try { c1.bookFlight(Integer.parseInt(enterFlightNum.getText())); ; } catch (Exception ex) { ex.printStackTrace(); } } }); JPanel mainPanel2 = new JPanel(); JLabel listFlights = new JLabel(); mainPanel2.add(listFlights); Connection connection; String labelText = "<html>"; try { Class.forName("com.mysql.jdbc.Driver"); System.out.println("Driver loaded"); connection = DriverManager.getConnection("jdbc:mysql://localhost/mydb", "CIS3270", "Cis3270"); System.out.println("Connection complete"); Statement statement; statement = connection.createStatement(); String queryString = "select * from flight"; ResultSet rs = statement.executeQuery(queryString); while (rs.next()) { labelText = labelText + rs.getString(1) + " " + rs.getString(3) + " " + rs.getString(4) + " " + rs.getString(5) + " " + rs.getString(6) + "<br>"; } } catch (Exception e) { } listFlights.setText(labelText); System.out.println(labelText); JPanel mainCombine = new JPanel(); mainCombine.add(mainPanel, BorderLayout.NORTH); mainCombine.add(mainPanel2, BorderLayout.SOUTH); fFrame = new JFrame(); fFrame.setSize(1000, 800); fFrame.add(mainCombine); fFrame.setVisible(true); fFrame.setResizable(false); fFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); fFrame.getContentPane().setLayout(null); }
/** Initialize the contents of the frame. */ private void initialize() { frame = new JFrame(); frame.getContentPane().setBackground(new Color(153, 50, 204)); frame.setBounds(100, 100, 725, 547); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().setLayout(null); JLabel lblNewLabel = new JLabel("Username"); lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 18)); lblNewLabel.setBounds(119, 113, 146, 36); frame.getContentPane().add(lblNewLabel); textField = new JTextField(); textField.setBounds(355, 122, 153, 22); frame.getContentPane().add(textField); textField.setColumns(10); JLabel lblNewLabel_1 = new JLabel("Password"); lblNewLabel_1.setFont(new Font("Tahoma", Font.PLAIN, 18)); lblNewLabel_1.setBounds(119, 213, 87, 22); frame.getContentPane().add(lblNewLabel_1); JButton btnNewButton = new JButton("Back"); btnNewButton.setFont(new Font("Tahoma", Font.PLAIN, 22)); btnNewButton.setBounds(124, 313, 121, 36); frame.getContentPane().add(btnNewButton); JButton btnNewButton_1 = new JButton("Login"); btnNewButton_1.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { try { String query = "select * from logindetails where UserName=? and Password=?"; PreparedStatement pst = connect.prepareStatement(query); pst.setString(1, textField.getText()); pst.setString(2, passwordField.getText()); ResultSet rs = pst.executeQuery(); if (rs.next()) { // JOptionPane.showMessageDialog(null, "connection successfull"); ah.setVisible(true); frame.dispose(); } else { JOptionPane.showMessageDialog( null, "user credentials are wrong.Try again with correct credentials"); } } catch (Exception e) { JOptionPane.showMessageDialog(null, e); } } }); btnNewButton_1.setFont(new Font("Tahoma", Font.PLAIN, 22)); btnNewButton_1.setBounds(424, 314, 97, 35); frame.getContentPane().add(btnNewButton_1); passwordField = new JPasswordField(); passwordField.setBounds(355, 215, 166, 22); frame.getContentPane().add(passwordField); JLabel lblNewLabel_2 = new JLabel("Administrator Login"); lblNewLabel_2.setForeground(new Color(128, 128, 128)); lblNewLabel_2.setFont(new Font("Tahoma", Font.BOLD, 28)); lblNewLabel_2.setBounds(199, 48, 309, 34); frame.getContentPane().add(lblNewLabel_2); }
DoctorInfomodify() { super("Doctor Information"); setSize(1200, 750); setLocationRelativeTo(null); setLayout(null); lmain = new JLabel("Doctor Information"); lmain.setBounds(440, 35, 107, 15); add(lmain); ldi = new JLabel("Doctor Information"); ldi.setBounds(40, 70, 120, 15); add(ldi); lname = new JLabel("Name :"); lname.setBounds(104, 97, 70, 25); add(lname); tfname = new JTextField(30); tfname.setBounds(270, 97, 250, 20); add(tfname); ladd = new JLabel("Address :"); ladd.setBounds(104, 138, 70, 15); add(ladd); taadd = new TextArea(); taadd.setBounds(270, 138, 250, 100); add(taadd); ltel = new JLabel("Contact :"); ltel.setBounds(575, 138, 50, 25); add(ltel); ldid = new JLabel("Doctor ID:"); ldid.setBounds(570, 97, 70, 25); add(ldid); tfdid = new JTextField(30); tfdid.setBounds(643, 97, 50, 20); add(tfdid); tftel = new JTextField(30); tftel.setBounds(640, 138, 200, 20); add(tftel); settings.Numvalidator(tftel); ldspec = new JLabel("Specialization :"); ldspec.setBounds(104, 310, 100, 25); add(ldspec); taspecial = new TextArea(); taspecial.setBounds(270, 310, 250, 100); add(taspecial); lwork = new JLabel("Working hours :"); lwork.setBounds(570, 310, 100, 15); add(lwork); lworkfrom = new JLabel("From :"); lworkfrom.setBounds(670, 305, 37, 25); add(lworkfrom); tfworkf = new JTextField(30); tfworkf.setBounds(710, 310, 30, 20); add(tfworkf); settings.Numvalidator(tfworkf); lworkto = new JLabel("to :"); lworkto.setBounds(747, 305, 20, 25); add(lworkto); tfworkt = new JTextField(30); tfworkt.setBounds(775, 310, 30, 20); add(tfworkt); settings.Numvalidator(tfworkt); bsub = new JButton("SEARCH", new ImageIcon("images/search.png")); bsub.setBounds(250, 643, 110, 30); add(bsub); bclr = new JButton("CLEAR", new ImageIcon("images/LOGGOFF.PNG")); bclr.setBounds(390, 643, 100, 30); add(bclr); bmod = new JButton("MODIFY", new ImageIcon("images/modify.png")); bmod.setBounds(530, 643, 100, 30); add(bmod); bback = new JButton("BACK", new ImageIcon("images/restore.png")); bback.setBounds(700, 643, 100, 30); add(bback); try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); cn = DriverManager.getConnection("Jdbc:Odbc:doc"); } catch (Exception e) { System.out.println(e); } bclr.addActionListener(new clear()); bsub.addActionListener(new submit()); bmod.addActionListener(new modify()); bback.addActionListener(new back()); setVisible(true); }
public MakeReservation() { new BorderLayout(); standardRoom.setMnemonic(KeyEvent.VK_K); standardRoom.setActionCommand("Standard Room"); standardRoom.setSelected(true); familyRoom.setMnemonic(KeyEvent.VK_F); familyRoom.setActionCommand("Family Room"); suiteRoom.setMnemonic(KeyEvent.VK_S); suiteRoom.setActionCommand("Suite"); // Add Booking Button ImageIcon bookRoomIcon = createImageIcon("images/book.png"); bookRoom = new JButton("Book Room", bookRoomIcon); bookRoom.setVerticalTextPosition(AbstractButton.BOTTOM); bookRoom.setHorizontalTextPosition(AbstractButton.CENTER); bookRoom.setMnemonic(KeyEvent.VK_M); bookRoom.addActionListener(this); bookRoom.setActionCommand("book"); // Group the radio buttons. group.add(standardRoom); group.add(familyRoom); group.add(suiteRoom); // Create the labels. nameLabel = new JLabel("Name: "); amountroomsLabel = new JLabel("How many rooms? "); checkoutdateLabel = new JLabel("Check-Out Date: "); checkindateLabel = new JLabel("Check-In Date: "); // Create the text fields and set them up. nameField = new JFormattedTextField(); nameField.setColumns(10); amountroomsField = new JFormattedTextField(new Integer(1)); amountroomsField.setValue(new Integer(1)); amountroomsField.setColumns(10); // java.util.Date dt_checkin = new java.util.Date(); LocalDate today = LocalDate.now(); // java.text.SimpleDateFormat sdf_checkin = new java.text.SimpleDateFormat("MM/dd/yyyy"); currentDate_checkin = today.toString(); checkindateField = new JFormattedTextField(currentDate_checkin); checkindateField.setColumns(10); // java.util.Date dt_checkout = new java.util.Date(); LocalDate tomorrow = today.plus(1, ChronoUnit.DAYS); // java.text.SimpleDateFormat sdf_checkout = new java.text.SimpleDateFormat("MM/dd/yyyy"); currentDate_checkout = tomorrow.toString(); checkoutdateField = new JFormattedTextField(currentDate_checkout); checkoutdateField.setColumns(10); // Tell accessibility tools about label/textfield pairs. nameLabel.setLabelFor(nameField); amountroomsLabel.setLabelFor(amountroomsField); checkoutdateLabel.setLabelFor(checkoutdateField); checkindateLabel.setLabelFor(checkindateField); // Lay out the labels in a panel. JPanel labelPane1 = new JPanel(new GridLayout(0, 1)); labelPane1.add(amountroomsLabel); JPanel labelPane3 = new JPanel(new GridLayout(0, 1)); labelPane3.add(checkindateLabel); JPanel labelPane2 = new JPanel(new GridLayout(0, 1)); labelPane2.add(checkoutdateLabel); JPanel labelPane4 = new JPanel(new GridLayout(0, 1)); labelPane4.add(nameLabel); // Layout the text fields in a panel. JPanel fieldPane1 = new JPanel(new GridLayout(0, 1)); fieldPane1.add(amountroomsField); JPanel fieldPane3 = new JPanel(new GridLayout(0, 1)); fieldPane3.add(checkindateField); JPanel fieldPane2 = new JPanel(new GridLayout(0, 1)); fieldPane2.add(checkoutdateField); JPanel fieldPane4 = new JPanel(new GridLayout(0, 1)); fieldPane4.add(nameField); // Put the radio buttons in a column in a panel. JPanel radioPanel = new JPanel(new GridLayout(0, 1)); radioPanel.add(standardRoom); radioPanel.add(familyRoom); radioPanel.add(suiteRoom); // Put the panels in this panel, labels on left, // text fields on right. setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); add(labelPane1, BorderLayout.LINE_START); add(fieldPane1, BorderLayout.LINE_END); add(labelPane3, BorderLayout.LINE_START); add(fieldPane3, BorderLayout.LINE_END); add(labelPane2, BorderLayout.LINE_START); add(fieldPane2, BorderLayout.LINE_END); add(labelPane4, BorderLayout.LINE_START); add(fieldPane4, BorderLayout.LINE_END); add(radioPanel, BorderLayout.LINE_END); add(bookRoom); }
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); }
private void insertRows(Connection connection) { // Build the SQL INSERT statement String sqlInsert = "insert into " + jtfTableName.getText() + " values ("; // Use a Scanner to read text from the file Scanner input = null; // Get file name from the text field String filename = jtfFilename.getText().trim(); try { // Create a scanner input = new Scanner(new File(filename)); // Create a statement Statement statement = connection.createStatement(); System.out.println( "Driver major version? " + connection.getMetaData().getDriverMajorVersion()); // Determine if batchUpdatesSupported is supported boolean batchUpdatesSupported = false; try { if (connection.getMetaData().supportsBatchUpdates()) { batchUpdatesSupported = true; System.out.println("batch updates supported"); } else { System.out.println( "The driver is of JDBC 2 type, but " + "does not support batch updates"); } } catch (UnsupportedOperationException ex) { System.out.println("The driver does not support JDBC 2"); } // Determine if the driver is capable of batch updates if (batchUpdatesSupported) { // Read a line and add the insert table command to the batch while (input.hasNext()) { statement.addBatch(sqlInsert + input.nextLine() + ")"); } statement.executeBatch(); jlblStatus.setText("Batch updates completed"); } else { // Read a line and execute insert table command while (input.hasNext()) { statement.executeUpdate(sqlInsert + input.nextLine() + ")"); } jlblStatus.setText("Single row update completed"); } } catch (SQLException ex) { System.out.println(ex); } catch (FileNotFoundException ex) { System.out.println("File not found: " + filename); } catch (IOException ex) { ex.printStackTrace(); } finally { if (input != null) input.close(); } }
public void setContent(String cat) { cat = cat.trim(); selectAllCB.setVisible(false); selectAllCB.setSelected(false); deleteBut.setVisible(false); restoreBut.setVisible(false); refreshBut.setVisible(true); Object columns[] = null; int count = 0; switch (cat) { case "Inbox": columns = new Object[] {"", "From", "Date", "Subject", "Content"}; count = Database.getCount("Inbox"); workingSet = db.getData("SELECT * FROM messages WHERE tag='inbox' ORDER BY msg_id desc"); ; break; case "SentMail": columns = new Object[] {"", "To", "Date", "Subject", "Content"}; count = Database.getCount("Sentmail"); workingSet = db.getData("SELECT * FROM messages WHERE tag='sentmail' ORDER BY msg_id desc"); break; case "Draft": columns = new Object[] {"", "To", "Date", "Subject", "Content"}; count = Database.getCount("Draft"); workingSet = db.getData("SELECT * FROM messages WHERE tag='draft' ORDER BY msg_id desc"); break; case "Outbox": columns = new Object[] {"", "To", "Date", "Subject", "Content"}; count = Database.getCount("Outbox"); workingSet = db.getData("SELECT * FROM messages WHERE tag='outbox' ORDER BY msg_id desc"); break; case "Trash": // restoreBut.setVisible(true); columns = new Object[] {"", "To/From", "Date", "Subject", "Content"}; count = Database.getCount("Trash"); workingSet = db.getData( "SELECT * FROM messages,trash WHERE messages.tag='trash' and messages.msg_id=trash.msg_id ORDER BY deleted_at desc"); break; default: System.out.println("in default case"); } if (count > 0) { selectAllCB.setVisible(true); rows = new Object[count][]; msgID = new int[count]; try { workingSet.beforeFirst(); for (int i = 0; i < count && workingSet.next(); i++) { msgID[i] = workingSet.getInt(1); rows[i] = new Object[] { false, workingSet.getString(2), workingSet.getDate(3), workingSet.getString(4), workingSet.getString(5) }; } } catch (SQLException sqlExc) { JOptionPane.showMessageDialog(null, sqlExc, "EXCEPTION", JOptionPane.ERROR_MESSAGE); sqlExc.printStackTrace(); } tableModel = new MyDefaultTableModel(rows, columns); table = new JTable(tableModel); table.getSelectionModel().addListSelectionListener(this); table.addMouseListener(this); table.getTableHeader().setOpaque(true); table.getTableHeader().setReorderingAllowed(false); // table.getTableHeader().setBackground(Color.blue); table.getTableHeader().setForeground(Color.blue); // table.setRowSelectionAllowed(false); // table.setColumnSelectionAllowed(false); table.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 14)); table.setRowHeight(20); table.setFillsViewportHeight(true); TableColumn column = null; for (int i = 0; i < 5; i++) { column = table.getColumnModel().getColumn(i); if (i == 0) { column.setPreferredWidth(6); } else if (i == 3) { column.setPreferredWidth(250); } else if (i == 4) { column.setPreferredWidth(450); } else { column.setPreferredWidth(40); } } table.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS); remove(contentPan); contentPan = new JScrollPane(table); contentPan.setBackground(Color.orange); contentPan.setOpaque(true); contentPan.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); add(contentPan, "Center"); Home.home.homeFrame.setVisible(true); } else { JPanel centPan = new JPanel(new GridBagLayout()); centPan.setBackground(new Color(52, 86, 70)); JLabel label = new JLabel("No Messages In This Category"); label.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 22)); label.setForeground(Color.orange); centPan.add(label); remove(contentPan); contentPan = new JScrollPane(centPan); contentPan.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); add(contentPan, "Center"); contentPan.repaint(); } }
public void createGUI() { setLayout(new BorderLayout()); toolBar = new JToolBar("options", JToolBar.HORIZONTAL); toolBar.setFloatable(false); toolBar.setOpaque(true); toolBar.setBackground(new Color(154, 12, 12)); toolBar.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 15)); selectAllCB = new JCheckBox("Select All"); selectAllCB.setVisible(false); selectAllCB.setForeground(Color.white); selectAllCB.addActionListener(this); refreshBut = new JButton(new ImageIcon(this.getClass().getResource("/images/reloadIcon.png"))); refreshBut.setVisible(false); refreshBut.setToolTipText("Refresh"); refreshBut.setForeground(new Color(20, 88, 49)); refreshBut.addActionListener(this); backBut = new JButton(new ImageIcon(this.getClass().getResource("/images/backIcon.png"))); backBut.setVisible(false); backBut.setToolTipText("Back"); backBut.setForeground(new Color(20, 88, 49)); backBut.addActionListener(this); deleteBut = new JButton(new ImageIcon(this.getClass().getResource("/images/trashIcon.png"))); deleteBut.setToolTipText("Delete"); deleteBut.setForeground(Color.red); deleteBut.setVisible(false); deleteBut.addActionListener(this); deleteBut.setBackground(Color.red); restoreBut = new JButton(new ImageIcon(this.getClass().getResource("/images/restoreIcon.png"))); restoreBut.setToolTipText("Restore"); restoreBut.setForeground(Color.blue); restoreBut.setVisible(false); restoreBut.addActionListener(this); toolBar.addSeparator(new Dimension(10, 5)); toolBar.add(selectAllCB); toolBar.add(backBut); toolBar.add(refreshBut); toolBar.add(deleteBut); toolBar.add(restoreBut); add(toolBar, "North"); JPanel centPan = new JPanel(new GridBagLayout()); centPan.setBackground(new Color(52, 86, 70)); JLabel label = new JLabel("Select A Category From Left Pane"); label.setFont(new Font("arial", Font.BOLD, 35)); label.setForeground(Color.yellow); centPan.add(label); contentPan = new JScrollPane(centPan); contentPan.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); add(contentPan, "Center"); contentPan.repaint(); db = new Database(); // inboxSet = db.getData("SELECT * FROM messages WHERE tag='inbox' ORDER BY msg_id // desc"); // sentmailSet = db.getData("SELECT * FROM messages WHERE tag='sentmail' ORDER BY msg_id // desc"); // draftSet = db.getData("SELECT * FROM messages WHERE tag='draft' ORDER BY msg_id // desc"); // outboxSet = db.getData("SELECT * FROM messages WHERE tag='outbox' ORDER BY msg_id // desc"); // trashSet = db.getData("SELECT * FROM messages,trash WHERE messages.tag='trash' and // messages.msg_id=trash.msg_id ORDER BY deleted_at desc"); }
public AuthDialog(final JFrame parent, String title, boolean modal) { super(parent, title, modal); // Set up close behaviour setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { if (!okButtonClicked) System.exit(0); } }); // Set up OK button behaviour JButton okButton = new JButton("OK"); okButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (getUserName().length() == 0) { showMessageDialog( AuthDialog.this, "Please enter a username", "Format Error", ERROR_MESSAGE); return; } if (getDatabasePassword().length() == 0) { showMessageDialog( AuthDialog.this, "Please enter a password", "Format Error", ERROR_MESSAGE); return; } okButtonClicked = true; setVisible(false); } }); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } }); // Set up dialog contents labelPanel.setBorder(BorderFactory.createEmptyBorder(20, 20, 5, 5)); inputPanel.setBorder(BorderFactory.createEmptyBorder(20, 5, 5, 20)); labelPanel.setLayout(new GridLayout(2, 1)); labelPanel.add(new JLabel("User Name: ")); labelPanel.add(new JLabel("Password:"******"ESCAPE"), "exitAction"); actionMap.put( "exitAction", new AbstractAction() { public void actionPerformed(ActionEvent e) { System.exit(0); } }); // Pack it all pack(); // Center on the screen setLocationRelativeTo(null); }
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); } } }); }
public patientAdd(String s) { super(s); image = new JLabel() { public void paint(Graphics g) { ImageIcon ic = new ImageIcon(str); Image img = ic.getImage(); g.drawImage(img, 0, 0, 150, 150, this); } }; image.setBounds(670, 270, 300, 300); bu = new JButton("UPLOAD"); bu.setBounds(700, 230, 100, 20); bu.addActionListener(this); // q.add(bu); ldt = new JLabel("Date"); lpid = new JLabel("Patient ID"); lpnm = new JLabel("Patient Name"); lgen = new JLabel("Gender"); lbg = new JLabel("Blood Group"); lage = new JLabel("Age"); lwt = new JLabel("Weight Kg"); ladd = new JLabel("Address"); lcno = new JLabel("Cont. no."); ldnm = new JLabel("Doctor Name Dr."); lsym = new JLabel("Symptoms"); ldig = new JLabel("Diagnosis"); lfee = new JLabel("Fee Rs."); cbg = new CheckboxGroup(); cm = new Checkbox("Male", cbg, false); cm.addItemListener(this); cf = new Checkbox("Female", cbg, false); cf.setState(true); cf.addItemListener(this); tdt = new JTextField(15); tpid = new JTextField(6); tpid.addFocusListener(this); tpfnm = new JTextField("first"); tpmnm = new JTextField("middle"); tplnm = new JTextField("last"); tage = new JTextField(4); tage.addFocusListener(this); tbg = new JTextField(6); twt = new JTextField(5); tadd = new TextArea(patient.addr); tcno = new JTextField(20); tdnm = new JTextField(20); tsym = new TextArea(); tdig = new JTextField(20); tfee = new JTextField(6); tfee.addFocusListener(this); ba = new JButton("ADD"); ba.addActionListener(this); bm = new JButton("CANCEL"); bm.addActionListener(this); bd = new JButton("DELETE"); bd.addActionListener(this); bl = new JButton("DISPLAY"); bl.addActionListener(this); bs = new JButton("SEARCH"); bs.addActionListener(this); JPanel p = new JPanel(); p.add(ba); p.add(bm); // p.add(bd); // p.add(bl); // p.add(bs); add(p, BorderLayout.SOUTH); q = new JPanel(); q.setLayout(null); ldt.setBounds(1015, 20, 60, 20); q.add(ldt); tdt.setBounds(1060, 20, 170, 20); q.add(tdt); lpid.setBounds(70, 60, 80, 20); q.add(lpid); tpid.setBounds(200, 60, 60, 20); q.add(tpid); lpnm.setBounds(70, 100, 80, 20); q.add(lpnm); tpfnm.setBounds(200, 100, 100, 20); q.add(tpfnm); tpmnm.setBounds(320, 100, 100, 20); q.add(tpmnm); tplnm.setBounds(440, 100, 100, 20); q.add(tplnm); lgen.setBounds(70, 140, 60, 20); q.add(lgen); lbg.setBounds(370, 140, 80, 20); q.add(lbg); tbg.setBounds(470, 140, 60, 20); q.add(tbg); cm.setBounds(200, 140, 60, 20); cf.setBounds(280, 140, 60, 20); lage.setBounds(70, 180, 40, 20); q.add(lage); tage.setBounds(200, 180, 50, 20); q.add(tage); lwt.setBounds(370, 180, 200, 20); q.add(lwt); twt.setBounds(470, 180, 60, 20); q.add(twt); ladd.setBounds(70, 220, 60, 20); q.add(ladd); tadd.setBounds(200, 220, 350, 50); q.add(tadd); lcno.setBounds(70, 310, 60, 20); q.add(lcno); tcno.setBounds(200, 310, 120, 20); q.add(tcno); ldnm.setBounds(70, 350, 200, 20); q.add(ldnm); tdnm.setBounds(200, 350, 150, 20); q.add(tdnm); lsym.setBounds(70, 390, 100, 20); q.add(lsym); tsym.setBounds(200, 390, 300, 70); q.add(tsym); ldig.setBounds(70, 480, 60, 20); q.add(ldig); tdig.setBounds(200, 480, 100, 20); q.add(tdig); lfee.setBounds(70, 520, 200, 20); q.add(lfee); tfee.setBounds(200, 520, 40, 20); q.add(tfee); q.add(cm); q.add(cf); q.add(image); q.add(bu); add(q, BorderLayout.CENTER); addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { try { patient.con.close(); System.exit(0); } catch (Exception e8) { } } }); System.out.println(tadd.getText()); setSize(1330, 740); setVisible(true); }
public General_Info() { pic.setIcon(userPic); String url = "jdbc:odbc:lib"; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); connection = DriverManager.getConnection(url); } catch (ClassNotFoundException cnfex) { System.err.println("Failed to load driver"); cnfex.printStackTrace(); System.exit(1); } catch (SQLException sqlex) { System.err.println("unable to connect"); sqlex.printStackTrace(); } // validation for telephone tel_text.addKeyListener( new KeyAdapter() { public void keyTyped(KeyEvent e) { char c = e.getKeyChar(); if (!((Character.isDigit(c) || (c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)))) { getToolkit().beep(); e.consume(); } } }); // validation for fax fax_text.addKeyListener( new KeyAdapter() { public void keyTyped(KeyEvent e) { char c = e.getKeyChar(); if (!((Character.isDigit(c) || (c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)))) { getToolkit().beep(); e.consume(); } } }); patron_text.setText("P-"); patron_text.addFocusListener( new MyActionListener() { public void focusLost(FocusEvent e) { try { Statement statement = connection.createStatement(); String query2 = "SELECT * FROM patronmaster " + "WHERE id = '" + patron_text.getText() + "'"; ResultSet rs2 = statement.executeQuery(query2); int cnt = 0; while (rs2.next()) { cnt++; } if (cnt != 0) { try { userPic = new ImageIcon(patron_text.getText() + ".gif"); pic.setIcon(userPic); } catch (Exception ex) { ex.printStackTrace(); pic.setIcon(userPic); } String query1 = "SELECT * FROM patronmaster " + "WHERE id = '" + patron_text.getText() + "'"; ResultSet rs1 = statement.executeQuery(query1); try { rs1.next(); int confirm = JOptionPane.showConfirmDialog( null, "This record Exists, would you like to update it?", "CONFIRM", JOptionPane.YES_NO_OPTION); if (confirm == JOptionPane.NO_OPTION) { patron_text.setEditable(false); name_text.setEditable(false); passport_text.setEditable(false); expiry_date_text.setEditable(false); reg_by_text.setEditable(false); reg_date_text.setEditable(false); textArea.setEditable(false); tel_text.setEditable(false); fax_text.setEditable(false); email_text.setEditable(false); } else { } name_text.setText(rs1.getString(2)); passport_text.setText(rs1.getString(3)); expiry_date_text.setText(rs1.getString(6)); reg_by_text.setText(rs1.getString(7)); reg_date_text.setText(rs1.getString(8)); textArea.setText(rs1.getString(9)); tel_text.setText(rs1.getString(10)); fax_text.setText(rs1.getString(11)); email_text.setText(rs1.getString(12)); status_combo.setSelectedItem(rs1.getString(4)); salute_combo.setSelectedItem(rs1.getString(5)); group_combo.setSelectedItem(rs1.getString(13)); statement.close(); } catch (SQLException sqlex) { pic.setIcon(userPic); } } } catch (SQLException sqlex) { pic.setIcon(userPic); } } }); scroll.add(address); scroll.add(scrollPane); text.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridy = 0; gbc.gridx = 0; text.add(tel, gbc); gbc.gridy = 1; text.add(fax, gbc); gbc.gridy = 2; text.add(email, gbc); gbc.gridy = 0; gbc.gridx = 2; text.add(tel_text, gbc); gbc.gridy = 1; text.add(fax_text, gbc); gbc.gridy = 2; text.add(email_text, gbc); pic.setSize(50, 50); pane1.add(scroll, BorderLayout.CENTER); pane1.add(pic, BorderLayout.EAST); pane1.add(text, BorderLayout.WEST); add(pane1); }
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); } }
public void focusLost(FocusEvent e) { int id = 0; boolean res = false; JTextField t = (JTextField) e.getSource(); if (t == tpid) { try { id = Integer.parseInt(tpid.getText()); res = patient.psearch(id); } catch (Exception e1) { } if (res) { int no, ag = 0, fee = 0; String pfn = "", bg = "", pmn = "", dt1 = "", pln = "", add = "", sym = "", dn = "", dig = "", cn = "", gender = "", wgt = ""; try { dt1 = patient.rs.getString(1); no = patient.rs.getInt(2); pfn = patient.rs.getString(3); pmn = patient.rs.getString(4); pln = patient.rs.getString(5); gender = patient.rs.getString(6); ag = patient.rs.getInt(7); wgt = patient.rs.getString(8); add = patient.rs.getString(9); cn = patient.rs.getString(10); dn = patient.rs.getString(11); sym = patient.rs.getString(12); dig = patient.rs.getString(13); fee = patient.rs.getInt(14); bg = patient.rs.getString(15); dir = patient.rs.getString(17); s = dir; repaint(); j13 = new JLabel("OLD IMAGE"); j13.setBounds(840, 5, 300, 300); JLabel j12 = new JLabel("OLD PHOTO") { public void paint(Graphics g) { ImageIcon ic = new ImageIcon(s); Image img = ic.getImage(); g.drawImage(img, 0, 0, 150, 150, this); } }; // q.flushAll() /*ImageIcon ic=new ImageIcon(dir); JLabel j12=new JLabel("",ic,JLabel.CENTER);*/ j12.setBounds(670, 70, 300, 300); // image.setBounds(700,300,100,100); q.add(j12); q.add(j13); repaint(); System.out.println("8743t32874" + dir); } catch (Exception e2) { } if (gender.equals("Male")) cm.setState(true); else cf.setState(true); tdt.setText(dt1); tpfnm.setText(pfn); tpmnm.setText(pmn); tplnm.setText(pln); tage.setText("" + ag); tfee.setText("" + fee); tadd.setText(add); tdig.setText(dig); tdnm.setText(dn); tsym.setText(sym); tcno.setText(cn); twt.setText(wgt); tbg.setText(bg); // cm.setState(set1State()); // cf.setSelectedCheckbox(gender); ba.setEnabled(false); bm.setEnabled(true); bd.setEnabled(true); } else { if (id == 0) { bl.setEnabled(true); ba.setEnabled(false); } else ba.setEnabled(true); bm.setEnabled(false); bd.setEnabled(false); } } }
Jf() { j.setBounds(500, 40, 500, 500); j.setVisible(true); j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); j.setLayout(null); ImageIcon image = new ImageIcon("im1.jpg"); JLabel l = new JLabel(image); int m = image.getIconWidth(); int m1 = image.getIconHeight(); j.setResizable(false); // frame resize nahi hoga l.setBounds(0, 0, m, m1); j.add(l); l.add(linfo); l.add(lid); l.add(fid); l.add(lpass); l.add(fpass); fpass.setEchoChar('*'); l.add(blogin); l.add(bnewaccount); l.add(bforget); ImageIcon image1 = new ImageIcon("logo1.png"); JLabel limage = new JLabel(image1); l.add(limage); limage.setBounds(10, 50, 190, 130); Font f = new Font("ALGERIAN", Font.BOLD, 20); linfo.setFont(f); linfo.setBounds(40, 10, 420, 30); lid.setBounds(210, 50, 70, 30); fid.setBounds(290, 50, 150, 30); lpass.setBounds(210, 90, 70, 30); fpass.setBounds(290, 90, 150, 30); blogin.setBounds(210, 130, 100, 50); bnewaccount.setBounds(320, 130, 160, 20); bforget.setBounds(320, 160, 160, 20); blogin.setBackground(Color.green); bnewaccount.setBackground(Color.cyan); bforget.setBackground(Color.pink); blogin.addActionListener(new Login()); bnewaccount.addActionListener(new Account()); bforget.addActionListener(new Forget()); }