public void actionPerformed(ActionEvent ev) { try { // stok String query = "DELETE FROM stok_produk WHERE id_produk=" + idProduk; int hasil1 = stm.executeUpdate(query); // pemasukkan query = "DELETE FROM pemasukan WHERE id_produk=" + idProduk; int hasil2 = stm.executeUpdate(query); // pengeluaran query = "DELETE FROM pengeluaran WHERE id_produk=" + idProduk; int hasil3 = stm.executeUpdate(query); // produk query = "DELETE FROM produk WHERE id_produk=" + idProduk; int hasil4 = stm.executeUpdate(query); if (hasil1 == 1 || hasil2 == 1 || hasil3 == 1 && hasil4 == 1) { setDataTabel(); JOptionPane.showMessageDialog(null, "berhasil hapus"); } else { JOptionPane.showMessageDialog(null, "gagal"); } } catch (SQLException SQLerr) { SQLerr.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } }
@Override public void actionPerformed(ActionEvent axnEve) { Object obj = axnEve.getSource(); if (obj == replyBut) { try { if (Home.composeDial != null && Home.composeDial.isShowing()) { } else { Home.composeDial = new ComposeMailDialog( msgID, workingSet.getString("mail_addresses"), workingSet.getString("subject")); } } catch (SQLException sqlExc) { sqlExc.printStackTrace(); } } else if (obj == forwardBut) { try { if (Home.composeDial != null && Home.composeDial.isShowing()) { } else { Home.composeDial = new ComposeMailDialog( msgID, workingSet.getString("subject") + "\n\n" + workingSet.getString("content")); } } catch (SQLException sqlExc) { sqlExc.printStackTrace(); } } }
public void excluir(Oriundo oriundo) throws SQLException { Connection con = DriverManager.getConnection( new conexao().url, new conexao().config.getString("usuario"), new conexao().config.getString("senha")); PreparedStatement ps = null; String sqlExcluir = "DELETE FROM oriundo WHERE codigo=?"; try { ps = con.prepareStatement(sqlExcluir); ps.setInt(1, oriundo.getCodigo()); ps.executeUpdate(); JOptionPane.showMessageDialog( null, "Ecluido Com Sucesso: ", "Mensagem do Sistema - Excluir", 1); } catch (NumberFormatException e) { JOptionPane.showMessageDialog( null, "NumberFormaterExeption Erro: " + e.getMessage(), "ClasseDAO Func.Excluir", 0); e.printStackTrace(); } catch (NullPointerException e) { JOptionPane.showMessageDialog( null, "NullPointerException Erro: " + e.getMessage(), "ClasseDAO Func. Excluir", 0); e.printStackTrace(); } catch (SQLException e) { JOptionPane.showMessageDialog( null, "SQLException Erro: " + e.getMessage(), "ClasseDAO Func. Excluir", 0); e.printStackTrace(); } catch (Exception e) { JOptionPane.showMessageDialog( null, "Exception Erro: " + e.getMessage(), "ClasseDAO Func. Excluir", 0); e.printStackTrace(); } finally { ps.close(); con.close(); } }
public void actionPerformed(java.awt.event.ActionEvent evt) { String sql1 = "select a.* FROM ANTENA a WHERE a.ID_antena='" + (newJPanel.jList1.getSelectedIndex() + 1) + "' "; String pom = ""; System.out.println(sql1); try { Class.forName("oracle.jdbc.driver.OracleDriver"); Connection conn; try { conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl", user, password); Statement stmt1 = conn.createStatement(); ResultSet rs1 = stmt1.executeQuery(sql1); while (rs1.next()) { NewJPanel.jTextField1.setText(rs1.getString("ID_antena")); NewJPanel.jTextField2.setText(rs1.getString("Producent")); NewJPanel.jTextField3.setText(rs1.getString("Numer_identyfikacyjny")); NewJPanel.jTextField4.setText(rs1.getString("Czestotliwosc")); NewJPanel.jTextField5.setText(rs1.getString("Polaryzacja")); NewJPanel.jTextField6.setText(rs1.getString("Moc")); NewJPanel.jTextField7.setText(rs1.getString("Rodzaj")); } } catch (SQLException e1) { System.out.println("tutaj 1"); e1.printStackTrace(); } } catch (ClassNotFoundException e1) { System.out.println("tutaj 2"); e1.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(); } }
/** * metoda pobierajaca wszystkie rekordy z BD1. * * @return */ public ArrayList<StudentFirst> getAllStudentFromDBfirst() { logger.info("getAllContactFromDB"); ResultSet result = null; ArrayList<StudentFirst> students = new ArrayList<>(); try { prepStmt = conn.prepareStatement("SELECT * FROM student1"); result = prepStmt.executeQuery(); int id, index; String name, surname, university, faculty, field; for (int i = 0; result.next(); i++) { id = result.getInt("stud1_id"); index = result.getInt("stud1_index"); name = result.getString("stud1_name"); surname = result.getString("stud1_lastname"); university = result.getString("stud1_university"); faculty = result.getString("stud1_faculty"); field = result.getString("stud1_field"); students.add(new StudentFirst(id, index, name, surname, university, faculty, field)); logger.info(students.get(i).toString()); } if (students.size() == 0) { logger.info("Pusta BD?"); } return students; } catch (SQLException e1) { JOptionPane.showMessageDialog(null, e1); e1.printStackTrace(); return null; } }
public ExptLocatorTree(Genome g) { super(); try { java.sql.Connection c = DatabaseFactory.getConnection(ExptLocator.dbRole); int species = g.getSpeciesDBID(); int genome = g.getDBID(); Statement s = c.createStatement(); ResultSet rs = null; rs = s.executeQuery( "select e.name, e.version from experiment e, exptToGenome eg where e.active=1 and " + "e.id=eg.experiment and eg.genome=" + genome); while (rs.next()) { String name = rs.getString(1); String version = rs.getString(2); ChipChipLocator loc = new ChipChipLocator(g, name, version); this.addElement(loc.getTreeAddr(), loc); } rs.close(); rs = s.executeQuery( "select ra.name, ra.version from rosettaanalysis ra, rosettaToGenome rg where " + "ra.id = rg.analysis and ra.active=1 and rg.genome=" + genome); while (rs.next()) { String name = rs.getString(1); String version = rs.getString(2); MSPLocator msp = new MSPLocator(g, name, version); this.addElement(msp.getTreeAddr(), msp); } rs.close(); rs = s.executeQuery( "select ra.name, ra.version from bayesanalysis ra, bayesToGenome rg where " + "ra.id = rg.analysis and ra.active=1 and rg.genome=" + genome); while (rs.next()) { String name2 = rs.getString(1); String version2 = rs.getString(2); ExptLocator loc2 = new BayesLocator(g, name2, version2); addElement(loc2.getTreeAddr(), loc2); } rs.close(); s.close(); DatabaseFactory.freeConnection(c); } catch (SQLException se) { se.printStackTrace(System.err); throw new RuntimeException(se); } catch (UnknownRoleException e) { e.printStackTrace(); } }
private void prosesEdit(String query) { try { int hasil = stm.executeUpdate(query); if (hasil == 1) { setDataTabel(); JOptionPane.showMessageDialog(null, "edit berhasil"); } else { JOptionPane.showMessageDialog(null, "gagal"); } } catch (SQLException SQLerr) { SQLerr.printStackTrace(); } }
/** * verifica si hay productos asociados * * @param table table */ private boolean verify() { String sql = "SELECT XX_VMR_ReferenceMatrix_ID " + "FROM XX_VMR_ReferenceMatrix " + "WHERE XX_VMR_PO_LINEREFPROV_ID=" + (Integer) LineRefProv.getXX_VMR_PO_LineRefProv_ID(); PreparedStatement pstmt = null; ResultSet rs = null; try { pstmt = DB.prepareStatement(sql, null); rs = pstmt.executeQuery(); while (rs.next()) { associatedReference_ID = rs.getInt("XX_VMR_ReferenceMatrix_ID"); rs.close(); pstmt.close(); return true; } } catch (SQLException e) { log.log(Level.SEVERE, sql, e); } finally { try { rs.close(); } catch (SQLException e1) { e1.printStackTrace(); } try { pstmt.close(); } catch (SQLException e) { e.printStackTrace(); } } return false; } // tableLoad
private boolean isInMatrix() { String SQL = "Select * " + "from XX_VMR_REFERENCEMATRIX " + "where XX_VMR_PO_LINEREFPROV_ID=" + LineRefProv.get_ID(); PreparedStatement pstmt = null; ResultSet rs = null; try { pstmt = DB.prepareStatement(SQL, null); rs = pstmt.executeQuery(); while (rs.next()) { return true; } } catch (Exception a) { log.log(Level.SEVERE, SQL, a); } finally { try { rs.close(); } catch (SQLException e1) { e1.printStackTrace(); } try { pstmt.close(); } catch (SQLException e) { e.printStackTrace(); } } return false; }
public List<Oriundo> listar() throws SQLException { List<Oriundo> resultado = new ArrayList<Oriundo>(); conexao propCon = new conexao(); Connection con = DriverManager.getConnection( new conexao().url, propCon.config.getString("usuario"), propCon.config.getString("senha")); PreparedStatement ps = null; ResultSet rs = null; String sqlListar = "SELECT * FROM oriundo Order by codigo DESC"; Oriundo oriundo; try { ps = con.prepareStatement(sqlListar); rs = ps.executeQuery(); // if(rs==null){ // return null; // } while (rs.next()) { oriundo = new Oriundo(); oriundo.setCodigo(rs.getInt("codigo")); oriundo.setDescricao(rs.getString("descricao")); oriundo.setData_cadastro(rs.getDate("data_cadastro")); oriundo.setDia_fechamento(rs.getInt("dia_fechamento")); oriundo.setDia_pag(rs.getInt("dia_pag")); resultado.add(oriundo); } } catch (NumberFormatException e) { JOptionPane.showMessageDialog( null, "NumberFormaterExeption Erro: " + e.getMessage(), "ClasseDAO Func.Localizar", 0); e.printStackTrace(); } catch (NullPointerException e) { JOptionPane.showMessageDialog( null, "NullPointerException Erro: " + e.getMessage(), "ClasseDAO Func. Localizar", 0); e.printStackTrace(); } catch (SQLException e) { JOptionPane.showMessageDialog( null, "SQLException Erro: " + e.getMessage(), "ClasseDAO Func. Localizar", 0); e.printStackTrace(); } catch (Exception e) { JOptionPane.showMessageDialog( null, "Exception Erro: " + e.getMessage(), "ClasseDAO Func. Localizar", 0); e.printStackTrace(); } finally { ps.close(); con.close(); } return resultado; }
public static void updateDoljnost() { try { DBClass db = new DBClass(); ArrayList<Doljnost> d = db.doljnostFromDB(); comboBox_doljnost.removeAllItems(); for (int i = 0; i < d.size(); i++) { comboBox_doljnost.addItem(d.get(i)); } } catch (ClassNotFoundException e) { e.printStackTrace(); JOptionPane.showMessageDialog(null, e.getMessage()); } catch (SQLException ee) { ee.printStackTrace(); JOptionPane.showMessageDialog(null, ee.getMessage()); } }
private void insertTestData() { try { DatabaseManagerCommon.createTestTables(sStatement); refreshTree(); txtCommand.setText(DatabaseManagerCommon.createTestData(sStatement)); refreshTree(); for (int i = 0; i < DatabaseManagerCommon.testDataSql.length; i++) { addToRecent(DatabaseManagerCommon.testDataSql[i]); } execute(); } catch (SQLException e) { e.printStackTrace(); } }
public static void updateKvalification() { try { DBClass db2 = new DBClass(); ArrayList<Kvalification> k = db2.kvalificationFromDB(); comboBox_kvalification.removeAllItems(); for (int i = 0; i < k.size(); i++) { comboBox_kvalification.addItem(k.get(i)); } } catch (ClassNotFoundException e) { e.printStackTrace(); JOptionPane.showMessageDialog(null, e.getMessage()); } catch (SQLException ee) { ee.printStackTrace(); JOptionPane.showMessageDialog(null, ee.getMessage()); } }
public void setJenis() { dataJenis = new ArrayList<Jenis>(); try { String qry = "SELECT * from jenis"; ResultSet rs = stm.executeQuery(qry); while (rs.next()) { Jenis j = new Jenis(); j.setIdJenis(rs.getInt("id_jenis")); j.setNamaJenis(rs.getString("nama_jenis")); dataJenis.add(j); } } catch (SQLException SQLerr) { SQLerr.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } }
public Oriundo localizar(Integer codigo) throws SQLException { Connection con = DriverManager.getConnection( new conexao().url, new conexao().config.getString("usuario"), new conexao().config.getString("senha")); PreparedStatement ps = null; ResultSet rs = null; String sqlLocalizar = "SELECT * FROM oriundo WHERE codigo=?"; Oriundo oriundo = new Oriundo(); try { ps = con.prepareStatement(sqlLocalizar); ps.setInt(1, codigo); rs = ps.executeQuery(); // if(!rs.next()){ // return null; // } oriundo.setCodigo(rs.getInt("codigo")); oriundo.setDescricao(rs.getString("descricao")); oriundo.setData_cadastro(rs.getDate("data_cadastro")); oriundo.setDia_fechamento(rs.getInt("dia_fechamento")); oriundo.setDia_pag(rs.getInt("dia_pag")); return oriundo; } catch (NumberFormatException e) { JOptionPane.showMessageDialog( null, "NumberFormaterExeption Erro: " + e.getMessage(), "ClasseDAO Func.Localizar", 0); e.printStackTrace(); } catch (NullPointerException e) { JOptionPane.showMessageDialog( null, "NullPointerException Erro: " + e.getMessage(), "ClasseDAO Func. Localizar", 0); e.printStackTrace(); } catch (SQLException e) { JOptionPane.showMessageDialog( null, "SQLException Erro: " + e.getMessage(), "ClasseDAO Func. Localizar", 0); e.printStackTrace(); } catch (Exception e) { JOptionPane.showMessageDialog( null, "Exception Erro: " + e.getMessage(), "ClasseDAO Func. Localizar", 0); e.printStackTrace(); } finally { ps.close(); con.close(); } return oriundo; }
// Вид формы при изменении сотрудника 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 method that checks for existance of children public boolean HasChildren(String tsn) { String temp = "SELECT tsn from Tree where parent_tsn='" + tsn + "'"; if (lrank.compareTo("0") != 0 && lrank.compareTo("7") != 0) temp = temp + " AND rank_id<=" + lrank; System.out.println(temp); int numberOfRows = 0; boolean flag = false; try { result = statement.executeQuery(temp); metadata = result.getMetaData(); if (result.last()) numberOfRows = result.getRow(); result.first(); if (numberOfRows > 0 && metadata.getColumnCount() > 0) flag = true; } catch (SQLException sql) { sql.printStackTrace(); System.exit(1); } return flag; } // end of method HasChildren
// Вид формы при добавлении нового сотрудника 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()); } }
/** * metoda sluzaca do ladowania cz1. Student do BD1. * * @param studentFirst */ public boolean putStudentToDBfirst(StudentFirst studentFirst) { logger.info("putVehicleToDB: " + studentFirst.toString()); try { prepStmt = conn.prepareStatement("insert into student1 values (null, ?, ?, ?, ?, ?, ?);"); // ----// int i = 0; prepStmt.setInt(++i, studentFirst.getIndex()); prepStmt.setString(++i, studentFirst.getName()); prepStmt.setString(++i, studentFirst.getLastname()); prepStmt.setString(++i, studentFirst.getUniversity()); prepStmt.setString(++i, studentFirst.getFaculty()); prepStmt.setString(++i, studentFirst.getField()); // ----// prepStmt.execute(); } catch (SQLException e) { JOptionPane.showMessageDialog(null, e); e.printStackTrace(); return false; } return true; }
public void atualizar(Oriundo oriundo) throws SQLException { Connection con = DriverManager.getConnection( new conexao().url, new conexao().config.getString("usuario"), new conexao().config.getString("senha")); PreparedStatement ps = null; String sqlAtualizar = "UPDATE oriundo SET descricao=?, data_cadastro=?, dia_fechamento=?, dia_pag=? WHERE codigo=?"; try { ps = con.prepareStatement(sqlAtualizar); ps.setString(1, oriundo.getDescricao()); ps.setDate(2, oriundo.getData_cadastro()); ps.setInt(3, oriundo.getDia_fechamento()); ps.setInt(4, oriundo.getDia_pag()); ps.setInt(5, oriundo.getCodigo()); ps.executeUpdate(); JOptionPane.showMessageDialog( null, "Atualizado Com Sucesso: ", "Mensagem do Sistema - Atualizar", 1); } catch (NumberFormatException e) { JOptionPane.showMessageDialog( null, "NumberFormaterExeption Erro: " + e.getMessage(), "ClasseDAO Func.Atualizar", 0); e.printStackTrace(); } catch (NullPointerException e) { JOptionPane.showMessageDialog( null, "NullPointerException Erro: " + e.getMessage(), "ClasseDAO Func. Atualizar", 0); e.printStackTrace(); } catch (SQLException e) { JOptionPane.showMessageDialog( null, "SQLException Erro: " + e.getMessage(), "ClasseDAO Func. Atualizar", 0); e.printStackTrace(); } catch (Exception e) { JOptionPane.showMessageDialog( null, "Exception Erro: " + e.getMessage(), "ClasseDAO Func. Atualizar", 0); e.printStackTrace(); } finally { ps.close(); con.close(); } }
public void salvar(Oriundo oriundo) throws SQLException { Connection con = DriverManager.getConnection( new conexao().url, new conexao().config.getString("usuario"), new conexao().config.getString("senha")); PreparedStatement ps = null; String sqlSalvar = "INSERT INTO oriundo (descricao, data_cadastro, dia_fechamento, dia_pag ) VALUES (?, ?, ?, ?)"; try { ps = con.prepareStatement(sqlSalvar); ps.setString(1, oriundo.getDescricao()); ps.setDate(2, oriundo.getData_cadastro()); ps.setInt(3, oriundo.getDia_fechamento()); ps.setInt(4, oriundo.getDia_pag()); ps.executeUpdate(); // JOptionPane.showMessageDialog(null, "Inserido Com Sucesso: ", "Mensagem do Sistema - // Salvar", 1); } catch (NumberFormatException e) { JOptionPane.showMessageDialog( null, "NumberFormaterExeption Erro: " + e.getMessage(), "ClasseDAO Func.Salvar", 0); e.printStackTrace(); } catch (NullPointerException e) { JOptionPane.showMessageDialog( null, "NullPointerException Erro: " + e.getMessage(), "ClasseDAO Func. Salvar", 0); e.printStackTrace(); } catch (SQLException e) { JOptionPane.showMessageDialog( null, "SQLException Erro: " + e.getMessage(), "ClasseDAO Func. Salvar", 0); e.printStackTrace(); } catch (Exception e) { JOptionPane.showMessageDialog( null, "Exception Erro: " + e.getMessage(), "ClasseDAO Func. Salvar", 0); e.printStackTrace(); } finally { ps.close(); con.close(); } }
private void connect(Connection c) { if (c == null) { return; } if (cConn != null) { try { cConn.close(); } catch (SQLException e) { } } cConn = c; try { dMeta = cConn.getMetaData(); sStatement = cConn.createStatement(); refreshTree(); } catch (SQLException e) { e.printStackTrace(); } }
public storiconoleggio() { storico = new JFrame("Storico cliente:"); storico.setDefaultCloseOperation(DISPOSE_ON_CLOSE); storico.setVisible(true); operazioni = new JPanel(); operazioni.setLayout(new BoxLayout(operazioni, BoxLayout.Y_AXIS)); sotto = new JPanel(); gruppo = Box.createVerticalBox(); indietro = new JButton("Indietro"); ascoltatore = new listenernolcli(); Object righe[][] = { {"# Noleggio", "ID Bagnino", "# Ombrellone", "Data Noleggio", "Num. Lettini", "ID Cliente"} }; Object colonne[] = {"", "", "", "", "", ""}; JTable tabella = new JTable(righe, colonne); try { String url = "jdbc:mysql://127.0.0.1:3306/lido"; String userid = "root"; String paswordd = "root"; con = DriverManager.getConnection(url, userid, paswordd); requete = con.createStatement(); rs = requete.executeQuery( "SELECT * FROM lido.bagnino_noleggia_ombrellone WHERE cliente_idcliente =" + login.getNomeUtente()); ResultSetMetaData md = rs.getMetaData(); int columnCount = md.getColumnCount(); Vector columns = new Vector(columnCount); for (int i = 1; i <= columnCount; i++) columns.add(md.getColumnName(i)); Vector data = new Vector(); Vector row; while (rs.next()) { row = new Vector(columnCount); for (int i = 1; i <= columnCount; i++) { row.add(rs.getString(i)); } data.add(row); } table = new JTable(data, columns); table.setPreferredScrollableViewportSize(new Dimension(500, 70)); table.setFillsViewportHeight(true); table.setVisible(true); table.validate(); } catch (SQLException sqle) { System.out.println(sqle); sqle.printStackTrace(); } indietro.addActionListener(ascoltatore); operazioni.add(tabella); operazioni.add(table); sotto.add(indietro); gruppo.add(operazioni); gruppo.add(sotto); storico.add(gruppo); storico.pack(); }
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); }
public void tableChanged(TableModelEvent tme) { int baris = tme.getFirstRow(); int kolom = tme.getColumn(); TableModel model = (TableModel) tme.getSource(); int id = (Integer) model.getValueAt(baris, 0); String query = ""; switch (kolom) { case 1: String nama = (String) model.getValueAt(baris, kolom); query = "UPDATE produk SET nama_produk='" + nama + "' WHERE id_produk=" + id; prosesEdit(query); break; case 2: String jenis = (String) model.getValueAt(baris, kolom); try { query = "select * from jenis where nama_jenis='" + jenis + "'"; ResultSet rs = stm.executeQuery(query); if (rs.next()) { int idJenis = rs.getInt("id_jenis"); query = "UPDATE produk SET id_jenis=" + idJenis + " WHERE id_produk=" + id; prosesEdit(query); } else { setDataTabel(); JOptionPane.showMessageDialog(null, "gagal,jenis tidak ada"); } } catch (SQLException SQLerr) { SQLerr.printStackTrace(); } break; case 3: int stok = (Integer) model.getValueAt(baris, kolom); query = "UPDATE `stok_produk` SET stok=" + stok + " WHERE id_produk=" + id; prosesEdit(query); break; case 4: int harga = (Integer) model.getValueAt(baris, kolom); query = "UPDATE produk SET harga=" + harga + " WHERE id_produk=" + id; prosesEdit(query); break; case 5: String suplier = (String) model.getValueAt(baris, kolom); try { query = "SELECT * FROM suplier WHERE nama_suplier='" + suplier + "'"; ResultSet rs = stm.executeQuery(query); if (rs.next()) { int idSuplier = rs.getInt("id_suplier"); query = "UPDATE produk SET id_suplier=" + idSuplier + " WHERE id_produk=" + id; prosesEdit(query); } else { setDataTabel(); JOptionPane.showMessageDialog(null, "gagal,suplier belum terdaftar"); } } catch (SQLException SQLerr) { SQLerr.printStackTrace(); } break; default: break; } }
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); }
public void actionPerformed(ActionEvent event) { // if clear button is pressed, clear all fields if (event.getSource() == clear_button) { // erase all fields taskname_field.setText(""); taskdesc_field.setText(""); priority_checkbox.setSelected(false); numberofdays_field.setText(""); // isallocatedcheckbox.setSelected(false); duedate_field.setText(""); } // if submit button is pressed, save all data onto database if (event.getSource() == submit_button) { try { { Calendar calendar = Calendar.getInstance(); calendar.setTime(new Date()); // set to current date calendar.add( Calendar.DAY_OF_MONTH, Integer.parseInt(this.numberofdays_field.getText()) - 1); // add days required... then: // ^ subtract one day, because if task is created today and allocated tomorrow for one // day, // then it should be done by end of day tomorrow Date date = calendar.getTime(); // (see next *1) use this date to be the earliest // because of expected task duration /*This is a constraint * the date and the length of days that user expected to take * if not feasible then the program will say so * */ // method compares the current date and the date that was entered by the user if (this.task_idfield.getText().length() != 7 // check chars || this.taskname_field.getText().length() > 50 // check chars || this.taskdesc_field.getText().length() > 50 || ((Date) this.duedate_field.getValue()).compareTo(date) < 0 // check that the date is possible (see last *1) || this.numberofdays_field.getText().length() > 2 || this.numberofdays_field.getText().length() == 0 // check number of digits || Integer.parseInt(this.numberofdays_field.getText()) < 1) // check number of days required for task { JOptionPane.showMessageDialog( this, "Task ID has to be 7 chars; " + "\n" + "Description <= 50 chars; " + "\n" + "Because the expected duration of the task is " + Integer.parseInt(this.numberofdays_field.getText()) + " days, the due date cannot be earlier than: " + new StringBuffer(new SimpleDateFormat("dd/MM/yyyy").format(date)).toString() + "; " + "\n" + "Task duration must be 2 digit number maximum and must be an integer greater than 0"); } else // check if taskid_field is equals to any of the fields on the database if (task_idfield.equals("")) { JOptionPane.showMessageDialog( this, "Please insert an identification number for a task"); } else // add constraint and tell customer to enter 7 values if (taskname_field.equals("")) { JOptionPane.showMessageDialog(this, "Please insert a name to identity the task"); } else { // get all inputs from user inputs and store in variables taskid_input = task_idfield.getText(); taskname_input = taskname_field.getText(); taskdesc_input = taskdesc_field.getText(); if (priority_checkbox.isSelected()) { priority_input = 1; } else { priority_input = 0; } // create and store date from user input date = (Date) duedate_field.getValue(); // store number of days input from user numberofdays_input = Integer.parseInt(numberofdays_field.getText()); // String[] column_names = { "Task ID", "Task Name", "Task Description", "Task // Priority", "Due Date", "Number of Days", "Is Allocated" , "Unallocateable" }; task = new Object[8]; task[0] = taskid_input; task[1] = taskname_input; task[2] = taskdesc_input; task[3] = priority_input; task[4] = date; task[5] = numberofdays_input; task[6] = 0; task[7] = 0; try { // SqlConnection.connect(); SqlConnection.ps = SqlConnection.connection.prepareStatement( "INSERT INTO TASK VALUES (?,?,?,?,?,?,?,?)"); SqlConnection.ps.setString(1, taskid_input); SqlConnection.ps.setString(2, taskname_input); SqlConnection.ps.setString(3, taskdesc_input); SqlConnection.ps.setInt(4, priority_input); SqlConnection.ps.setDate(5, new java.sql.Date(date.getTime())); SqlConnection.ps.setInt(6, numberofdays_input); SqlConnection.ps.setInt(7, 0); SqlConnection.ps.setInt(8, 0); SqlConnection.ps.executeUpdate(); // now enter skills into TASK SKILL database for (int i = 0; i < skill_list.size(); i++) { if (skill_list.get(i).isSelected()) { String skillid = skill_list.get(i).getText(); SqlConnection.statement.executeUpdate( "INSERT INTO TASKSKILL VALUES ('" + taskid_input + "', '" + skillid + "')"); } } SqlConnection.ps.close(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } // SqlConnection.ps.close(); SqlConnection.closeConnection(); this.setVisible(false); } } } catch (Exception exc) { JOptionPane.showMessageDialog( this, "Check your inputs:" + "\n" + "Priority has to be a 1-digit number;" + "\n" + "Date has to be in the format dd/MM/yyyy;" + "\n" + "Task length has to be 2-digit number"); System.out.println(exc); } } // display dialog box asking task manager if they want to quit, // if task manager does not want to quit, go back to adding more tasks // if customer quits, close the dialog box and the frame // now close the window after saving }
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(); } }
@Override public void start(Stage primaryStage) throws Exception { try { screenSize = Screen.getPrimary().getVisualBounds(); width = screenSize.getWidth(); // gd.getDisplayMode().getWidth(); height = screenSize.getHeight(); // gd.getDisplayMode().getHeight(); } catch (Exception excep) { System.out.println("<----- Exception in Get Screen Size ----->"); excep.printStackTrace(); System.out.println("<---------->\n"); } try { dbCon = DriverManager.getConnection( "jdbc:mysql://192.168.1.6:3306/ale", "Root", "oqu#$XQgHFzDj@1MGg1G8"); estCon = true; } catch (SQLException sqlExcep) { System.out.println("<----- SQL Exception in Establishing Database Connection ----->"); sqlExcep.printStackTrace(); System.out.println("<---------->\n"); } xmlParser.generateUserInfo(); superUser = xmlParser.getSuperUser(); // ----------------------------------------------------------------------------------------------------> Top Panel Start closeBtn = new Button(""); closeBtn.getStyleClass().add("systemBtn"); closeBtn.setOnAction( e -> { systemClose(); }); minimizeBtn = new Button(""); minimizeBtn.getStyleClass().add("systemBtn"); minimizeBtn.setOnAction( e -> { primaryStage.setIconified(true); }); miscContainer = new HBox(); calcBtn = new Button(); calcBtn.getStyleClass().addAll("calcBtn"); calcBtn.setOnAction( e -> { calculator calculator = new calculator(); scientificCalculator scientificCalculator = new scientificCalculator(); calculator.start(calculatorName); }); miscContainer.getChildren().add(calcBtn); topPanel = new HBox(1); topPanel.getStyleClass().add("topPanel"); topPanel.setPrefWidth(width); topPanel.setAlignment(Pos.CENTER_RIGHT); topPanel.setPadding(new Insets(0, 0, 0, 0)); topPanel.getChildren().addAll(miscContainer, minimizeBtn, closeBtn); // ------------------------------------------------------------------------------------------------------> Top Panel End // ----------------------------------------------------------------------------------------------> Navigation Panel Start Line initDivider = new Line(); initDivider.setStartX(0.0f); initDivider.setEndX(205.0f); initDivider.setStroke(Color.GRAY); // <----- Dashboard -----> dashboardToolTip = new Tooltip("Dashboard"); dashboardBtn = new Button(""); dashboardBtn.getStyleClass().add("dashboardBtn"); dashboardBtn.setTooltip(dashboardToolTip); dashboardBtn.setOnAction( e -> { resetBtns(); rootPane.setCenter(dashBoardBase); }); // <----- Profile -----> profileToolTip = new Tooltip("Profile"); profileBtn = new Button(); profileBtn.getStyleClass().add("profileBtn"); profileBtn.setTooltip(profileToolTip); profileBtn.setOnAction( e -> { resetBtns(); rootPane.setCenter(profilePanel); }); // <----- Courses -----> courseToolTip = new Tooltip("Courses"); coursesBtn = new Button(""); coursesBtn.getStyleClass().add("coursesBtn"); coursesBtn.setTooltip(courseToolTip); coursesBtn.setOnAction( e -> { resetBtns(); rootPane.setCenter(coursesPanel); // miscContainer.getChildren().addAll(watchVidBtn); coursesPanel.setContent(coursesGridPanel); }); Line mainDivider = new Line(); mainDivider.setStartX(0.0f); mainDivider.setEndX(205.0f); mainDivider.setStroke(Color.GRAY); // <----- Simulations -----> simsToolTip = new Tooltip("Simulations"); simsBtn = new Button(); simsBtn.getStyleClass().add("simsBtn"); simsBtn.setTooltip(simsToolTip); simsBtn.setOnAction( e -> { resetBtns(); rootPane.setCenter(simsPanel); simsPanel.setContent(simsGridPanel); }); // <----- Text Editor -----> textEditorToolTip = new Tooltip("Text Editor"); textEditorBtn = new Button(); textEditorBtn.getStyleClass().add("textEditorBtn"); textEditorBtn.setTooltip(textEditorToolTip); textEditorBtn.setOnAction( e -> { resetBtns(); rootPane.setCenter(textEditorPanel); miscContainer.getChildren().addAll(saveDocBtn); }); Line toolsDivider = new Line(); toolsDivider.setStartX(0.0f); toolsDivider.setEndX(205.0f); toolsDivider.setStroke(Color.GRAY); // <----- Wolfram Alpha -----> wolframToolTip = new Tooltip("Wolfram Alpha"); wolframBtn = new Button(); wolframBtn.getStyleClass().add("wolframBtn"); wolframBtn.setTooltip(wolframToolTip); wolframBtn.setOnAction( e -> { resetBtns(); rootPane.setCenter(wolframPanel); }); // <----- Wikipedia -----> wikipediaToolTip = new Tooltip(); wikipediaBtn = new Button(); wikipediaBtn.getStyleClass().add("wikipediaBtn"); wikipediaBtn.setTooltip(wikipediaToolTip); wikipediaBtn.setOnAction( e -> { resetBtns(); rootPane.setCenter(wikipediaPanel); }); Line sitesDivider = new Line(); sitesDivider.setStartX(0.0f); sitesDivider.setEndX(205.0f); sitesDivider.setStroke(Color.GRAY); // <----- Settings -----> settingsToolTip = new Tooltip("Settings"); settingsBtn = new Button(); settingsBtn.getStyleClass().add("settingsBtn"); settingsBtn.setTooltip(settingsToolTip); settingsBtn.setOnAction( e -> { resetBtns(); rootPane.setCenter(settingsPanel); }); leftPanel = new VBox(0); // leftPanel.setPrefWidth(1); leftPanel.getStyleClass().add("leftPane"); leftPanel .getChildren() .addAll( initDivider, dashboardBtn, profileBtn, coursesBtn, mainDivider, simsBtn, textEditorBtn, toolsDivider, wolframBtn, wikipediaBtn, sitesDivider, settingsBtn); topPanel = new HBox(1); topPanel.getStyleClass().add("topPanel"); topPanel.setPrefWidth(width); topPanel.setAlignment(Pos.CENTER_RIGHT); topPanel.setPadding(new Insets(0, 0, 0, 0)); topPanel.getChildren().addAll(miscContainer, minimizeBtn, closeBtn); // ------------------------------------------------------------------------------------------------> Navigation Panel End // -----------------------------------------------------------------------------------------------> Dashboard Pane Start final WebView webVid = new WebView(); final WebEngine webVidEngine = webVid.getEngine(); webVid.setPrefHeight(860); webVid.setPrefWidth(width - 118); webVidEngine.loadContent(""); final NumberAxis xAxis = new NumberAxis(); final NumberAxis yAxis = new NumberAxis(); xAxis.setLabel("Day"); yAxis.setLabel("Score"); final LineChart<Number, Number> lineChart = new LineChart<Number, Number>(xAxis, yAxis); lineChart.setTitle("Line Chart"); XYChart.Series<Number, Number> series = new XYChart.Series<Number, Number>(); series.setName("My Data"); // populating the series with data series.getData().add(new XYChart.Data<Number, Number>(0.25, 36)); series.getData().add(new XYChart.Data<Number, Number>(1, 23)); series.getData().add(new XYChart.Data<Number, Number>(2, 114)); series.getData().add(new XYChart.Data<Number, Number>(3, 15)); series.getData().add(new XYChart.Data<Number, Number>(4, 124)); lineChart.getData().add(series); lineChart.setPrefWidth(400); lineChart.setPrefHeight(300); lineChart.setLegendVisible(false); chatRoomField = new TextField(); chatRoomField.getStyleClass().add("textField"); chatRoomField.setPromptText("Enter Chat Room"); chatRoomField.setOnKeyPressed( new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent event) { if (event.getCode() == KeyCode.ENTER) { chatRoom = chatRoomField.getText(); client.connect(messageArea, messageInputArea, superUser, chatRoom); } } }); messageArea = new TextArea(); messageArea.getStyleClass().add("textArea"); messageArea.setWrapText(true); messageArea.setPrefHeight(740); messageArea.setEditable(false); messageInputArea = new TextArea(); messageInputArea.getStyleClass().add("textArea"); messageInputArea.setWrapText(true); messageInputArea.setPrefHeight(100); messageInputArea.setPromptText("Enter Message"); messageInputArea.setOnKeyPressed( new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent event) { if (event.getCode() == KeyCode.ENTER) { client.send(messageArea, messageInputArea, superUser, chatRoom); event.consume(); } } }); chatBox = new VBox(); chatBox.setPrefWidth(250); chatBox.setMaxWidth(250); chatBox.getStyleClass().add("chatBox"); chatBox.getChildren().addAll(chatRoomField, messageArea, messageInputArea); // client.test(messageArea, messageInputArea); dashboardGridPanel = new GridPane(); dashboardGridPanel.getStyleClass().add("gridPane"); dashboardGridPanel.setVgap(5); dashboardGridPanel.setHgap(5); dashboardGridPanel.setGridLinesVisible(false); dashboardGridPanel.setPrefWidth(width - 430); dashboardGridPanel.setPrefHeight(860); dashboardGridPanel.setColumnIndex(lineChart, 0); dashboardGridPanel.setRowIndex(lineChart, 0); dashboardGridPanel.getChildren().addAll(lineChart); dashboardPanel = new ScrollPane(); dashboardPanel.getStyleClass().add("scrollPane"); dashboardPanel.setPrefWidth(width - 400); dashboardPanel.setPrefHeight(860); dashboardPanel.setContent(dashboardGridPanel); dashBoardBase = new HBox(); dashBoardBase.setPrefWidth(width - (leftPanel.getWidth() + chatBox.getWidth())); dashBoardBase.setPrefHeight(860); dashBoardBase.getChildren().addAll(dashboardPanel, chatBox); // -------------------------------------------------------------------------------------------------> Dashboard Pane End // -------------------------------------------------------------------------------------------------> Profile Pane Start profilePictureBtn = new Button(); profilePictureBtn.getStyleClass().addAll("profilePictureBtn"); String profileUserName = xmlParser.getSuperUser(); String profileEmail = xmlParser.getEmail(); String profileAge = xmlParser.getAge(); String profileSchool = xmlParser.getSchool(); String profileCountry = ""; String profileCity = ""; userNameLbl = new Label(profileUserName); userNameLbl.getStyleClass().add("profileLbl"); userNameLbl.setAlignment(Pos.CENTER); emailLbl = new Label(profileEmail); emailLbl.getStyleClass().add("profileLbl"); ageLbl = new Label(profileAge); ageLbl.getStyleClass().add("profileLbl"); schoolLbl = new Label(profileSchool); schoolLbl.getStyleClass().add("profileLbl"); profileGridPanel = new GridPane(); profileGridPanel.getStyleClass().add("gridPane"); profileGridPanel.setVgap(5); profileGridPanel.setHgap(5); profileGridPanel.setGridLinesVisible(false); profileGridPanel.setPrefWidth(width - 208); profileGridPanel.setPrefHeight(860); profileGridPanel.setAlignment(Pos.TOP_CENTER); profileGridPanel.setRowIndex(profilePictureBtn, 0); profileGridPanel.setColumnIndex(profilePictureBtn, 0); profileGridPanel.setRowIndex(userNameLbl, 1); profileGridPanel.setColumnIndex(userNameLbl, 0); profileGridPanel.setRowIndex(emailLbl, 2); profileGridPanel.setColumnIndex(emailLbl, 0); profileGridPanel.setRowIndex(ageLbl, 3); profileGridPanel.setColumnIndex(ageLbl, 0); profileGridPanel.setRowIndex(schoolLbl, 4); profileGridPanel.setColumnIndex(schoolLbl, 0); profileGridPanel .getChildren() .addAll(profilePictureBtn, userNameLbl, emailLbl, ageLbl, schoolLbl); profilePanel = new ScrollPane(); profilePanel.getStyleClass().add("scrollPane"); profilePanel.setContent(profileGridPanel); // ---------------------------------------------------------------------------------------------------> Profile Pane End // -------------------------------------------------------------------------------------------------> Courses Pane Start String course = ""; // Media media = new Media("media.mp4"); // mediaPlayer = new MediaPlayer(media); // mediaPlayer.setAutoPlay(true); // mediaView = new MediaView(mediaPlayer); watchVidBtn = new Button("Watch Video"); watchVidBtn.getStyleClass().add("btn"); watchVidBtn.setOnAction( e -> { // coursesPanel.setContent(mediaView); }); chemistryBtn = new Button(); chemistryBtn.getStyleClass().add("chemistryBtn"); chemistryBtn.setOnAction( e -> { displayCourse("chemistry"); }); physicsBtn = new Button(); physicsBtn.getStyleClass().add("physicsBtn"); physicsBtn.setOnAction( e -> { displayCourse("physics"); }); mathsBtn = new Button(); mathsBtn.getStyleClass().add("mathsBtn"); bioBtn = new Button(); bioBtn.getStyleClass().add("bioBtn"); bioBtn.setOnAction( e -> { rootPane.setCenter(biologyCourse.biologyPane()); }); // Course Web View try { courseView = new WebView(); courseWebEngine = courseView.getEngine(); courseView.setPrefHeight(860); courseView.setPrefWidth(width - 208); } catch (Exception excep) { System.out.println("<----- Exception in Course Web ----->"); excep.printStackTrace(); System.out.println("<---------->\n"); } coursesGridPanel = new GridPane(); coursesGridPanel.getStyleClass().add("gridPane"); coursesGridPanel.setVgap(5); coursesGridPanel.setHgap(5); coursesGridPanel.setGridLinesVisible(false); coursesGridPanel.setPrefWidth(width - 208); coursesGridPanel.setPrefHeight(860); coursesGridPanel.setRowIndex(chemistryBtn, 1); coursesGridPanel.setColumnIndex(chemistryBtn, 1); coursesGridPanel.setRowIndex(physicsBtn, 1); coursesGridPanel.setColumnIndex(physicsBtn, 2); coursesGridPanel.setRowIndex(mathsBtn, 1); coursesGridPanel.setColumnIndex(mathsBtn, 3); coursesGridPanel.setRowIndex(bioBtn, 1); coursesGridPanel.setColumnIndex(bioBtn, 4); coursesGridPanel.getChildren().addAll(chemistryBtn, physicsBtn, mathsBtn, bioBtn); coursesPanel = new ScrollPane(); coursesPanel.getStyleClass().add("scrollPane"); coursesPanel.setPrefWidth(width - 118); coursesPanel.setPrefHeight(860); coursesPanel.setContent(coursesGridPanel); // ---------------------------------------------------------------------------------------------------> Courses Pane End // ---------------------------------------------------------------------------------------------> Simulations Pane Start final WebView browser = new WebView(); final WebEngine webEngine = browser.getEngine(); browser.setPrefHeight(860); browser.setPrefWidth(width - 208); /* File phetImageFile = new File("img/styleDark/poweredByPHET.png"); String phetImageURL = phetImageFile.toURI().toURL().toString(); Image phetImage = new Image(phetImageURL, false); */ final ImageView phetImageView = new ImageView(); final Image phetImage = new Image(Main.class.getResourceAsStream("img/styleDark/poweredByPHET.png")); phetImageView.setImage(phetImage); Label motionLbl = new Label("Motion"); motionLbl.getStyleClass().add("lbl"); forcesAndMotionBtn = new Button(); forcesAndMotionBtn.getStyleClass().add("forcesAndMotionBtn"); forcesAndMotionBtn.setOnAction( e -> { webEngine.load( "https://phet.colorado.edu/sims/html/balancing-act/latest/balancing-act_en.html"); simsPanel.setContent(browser); }); balancingActBtn = new Button(); balancingActBtn.getStyleClass().add("balancingActBtn"); balancingActBtn.setOnAction( e -> { webEngine.load( "https://phet.colorado.edu/sims/html/balancing-act/latest/balancing-act_en.html"); simsPanel.setContent(browser); }); energySkateParkBtn = new Button(); energySkateParkBtn.getStyleClass().add("energySkateParkBtn"); energySkateParkBtn.setOnAction( e -> { webEngine.load( "https://phet.colorado.edu/sims/html/energy-skate-park-basics/latest/" + "energy-skate-park-basics_en.html"); simsPanel.setContent(browser); }); balloonsAndStaticElectricityBtn = new Button(); balloonsAndStaticElectricityBtn.getStyleClass().add("balloonsAndStaticElectricityBtn"); balloonsAndStaticElectricityBtn.setOnAction( e -> { webEngine.load( "https://phet.colorado.edu/sims/html/balloons-and-static-electricity/latest/" + "balloons-and-static-electricity_en.html"); simsPanel.setContent(browser); }); buildAnAtomBtn = new Button(); buildAnAtomBtn.getStyleClass().add("buildAnAtomBtn"); buildAnAtomBtn.setOnAction( e -> { webEngine.load( "https://phet.colorado.edu/sims/html/build-an-atom/latest/build-an-atom_en.html"); simsPanel.setContent(browser); }); colorVisionBtn = new Button(); colorVisionBtn.getStyleClass().add("colorVisionBtn"); colorVisionBtn.setOnAction( e -> { webEngine.load( "https://phet.colorado.edu/sims/html/color-vision/latest/color-vision_en.html"); simsPanel.setContent(browser); }); Label soundAndWavesLbl = new Label("Sound and Waves"); soundAndWavesLbl.getStyleClass().add("lbl"); wavesOnAStringBtn = new Button(); wavesOnAStringBtn.getStyleClass().add("wavesOnAStringBtn"); wavesOnAStringBtn.setOnAction( e -> { webEngine.load( "https://phet.colorado.edu/sims/html/wave-on-a-string/latest/wave-on-a-string_en.html"); simsPanel.setContent(browser); }); /* motionSimsFlowPane = new FlowPane(); motionSimsFlowPane.getStyleClass().add("flowPane"); motionSimsFlowPane.setVgap(5); motionSimsFlowPane.setHgap(5); motionSimsFlowPane.setAlignment(Pos.TOP_LEFT); motionSimsFlowPane.getChildren().addAll(forcesAndMotionBtn, balancingActBtn, energySkateParkBtn, buildAnAtomBtn, colorVisionBtn, wavesOnAStringBtn); soundAndWavesFlowPane = new FlowPane(); soundAndWavesFlowPane.getStyleClass().add("flowPane"); soundAndWavesFlowPane.setVgap(5); soundAndWavesFlowPane.setHgap(5); soundAndWavesFlowPane.setAlignment(Pos.TOP_LEFT); soundAndWavesFlowPane.getChildren().addAll(wavesOnAStringBtn); simsBox = new VBox(); simsBox.getStyleClass().add("vbox"); simsBox.setPrefHeight(height); simsBox.setPrefWidth(width); simsBox.getChildren().addAll(motionLbl, motionSimsFlowPane, soundAndWavesLbl, soundAndWavesFlowPane); */ simsGridPanel = new GridPane(); simsGridPanel.getStyleClass().add("gridPane"); simsGridPanel.setVgap(5); simsGridPanel.setHgap(5); simsGridPanel.setGridLinesVisible(false); simsGridPanel.setPrefWidth(width - 208); simsGridPanel.setPrefHeight(860); simsGridPanel.setRowIndex(phetImageView, 0); simsGridPanel.setColumnIndex(phetImageView, 4); simsGridPanel.setRowIndex(motionLbl, 0); simsGridPanel.setColumnIndex(motionLbl, 0); simsGridPanel.setRowIndex(forcesAndMotionBtn, 1); simsGridPanel.setColumnIndex(forcesAndMotionBtn, 0); simsGridPanel.setRowIndex(balancingActBtn, 1); simsGridPanel.setColumnIndex(balancingActBtn, 1); simsGridPanel.setRowIndex(energySkateParkBtn, 1); simsGridPanel.setColumnIndex(energySkateParkBtn, 2); simsGridPanel.setRowIndex(buildAnAtomBtn, 1); simsGridPanel.setColumnIndex(buildAnAtomBtn, 3); simsGridPanel.setRowIndex(colorVisionBtn, 1); simsGridPanel.setColumnIndex(colorVisionBtn, 4); simsGridPanel.setRowIndex(soundAndWavesLbl, 2); simsGridPanel.setColumnIndex(soundAndWavesLbl, 0); simsGridPanel.setColumnSpan(soundAndWavesLbl, 4); simsGridPanel.setRowIndex(wavesOnAStringBtn, 3); simsGridPanel.setColumnIndex(wavesOnAStringBtn, 0); simsGridPanel .getChildren() .addAll( phetImageView, motionLbl, forcesAndMotionBtn, balancingActBtn, energySkateParkBtn, buildAnAtomBtn, colorVisionBtn, soundAndWavesLbl, wavesOnAStringBtn); simsPanel = new ScrollPane(); simsPanel.getStyleClass().add("scrollPane"); simsPanel.setContent(simsGridPanel); // -----------------------------------------------------------------------------------------------> Simulations Pane End // ---------------------------------------------------------------------------------------------> Text Editor Pane Start htmlEditor = new HTMLEditor(); htmlEditor.setPrefHeight(860); htmlEditor.setPrefWidth(width - 208); // Prevents Scroll on Space Pressed htmlEditor.addEventFilter( KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent event) { if (event.getEventType() == KeyEvent.KEY_PRESSED) { if (event.getCode() == KeyCode.SPACE) { event.consume(); } } } }); XWPFDocument document = new XWPFDocument(); XWPFParagraph tmpParagraph = document.createParagraph(); XWPFRun tmpRun = tmpParagraph.createRun(); saveDocBtn = new Button(); saveDocBtn.getStyleClass().add("btn"); saveDocBtn.setText("Save"); saveDocBtn.setOnAction( e -> { tmpRun.setText(tools.stripHTMLTags(htmlEditor.getHtmlText())); tmpRun.setFontSize(12); saveDocument(document, primaryStage); }); textEditorPanel = new ScrollPane(); textEditorPanel.getStyleClass().add("scrollPane"); textEditorPanel.setContent(htmlEditor); // -----------------------------------------------------------------------------------------------> Text Editor Pane End // -------------------------------------------------------------------------------------------------> Wolfram Pane Start Boolean wolframActive = false; try { final WebView wolframWeb = new WebView(); wolframWeb.getStyleClass().add("webView"); final WebEngine wolframWebEngine = wolframWeb.getEngine(); wolframWeb.setPrefHeight(860); wolframWeb.setPrefWidth(width - 208); if (wolframActive == false) { wolframWebEngine.load("http://www.wolframalpha.com/"); wolframActive = true; } wolframPanel = new ScrollPane(); wolframPanel.setContent(wolframWeb); } catch (Exception excep) { System.out.println("<----- Exception in Wolfram Alpha Web ----->"); excep.printStackTrace(); System.out.println("<---------->\n"); } // ---------------------------------------------------------------------------------------------------> Wolfram Pane End // ------------------------------------------------------------------------------------------------> Wikipedia Pane Start Boolean wikipediaActive = false; try { final WebView wikipediaWeb = new WebView(); wikipediaWeb.getStyleClass().add("scrollPane"); wikipediaWebEngine = wikipediaWeb.getEngine(); wikipediaWeb.setPrefHeight(860); wikipediaWeb.setPrefWidth(width - 208); if (wikipediaActive == false) { wikipediaWebEngine.load("https://en.wikipedia.org/wiki/Main_Page"); wikipediaActive = true; } wikipediaPanel = new ScrollPane(); wikipediaPanel.setContent(wikipediaWeb); } catch (Exception e) { e.printStackTrace(); } // --------------------------------------------------------------------------------------------------> Wikipedia Pane End // -------------------------------------------------------------------------------------------------> Settings Pane Start settingsGridPanel = new GridPane(); settingsGridPanel.getStyleClass().add("gridPane"); settingsGridPanel.setPrefWidth(width - 208); settingsGridPanel.setPrefHeight(height); settingsGridPanel.setVgap(5); settingsGridPanel.setHgap(5); settingsPanel = new ScrollPane(); settingsPanel.getStyleClass().add("scrollPane"); settingsPanel.setContent(settingsGridPanel); // ---------------------------------------------------------------------------------------------------> Settings Pane End rootPane = new BorderPane(); rootPane.setLeft(leftPanel); rootPane.setTop(topPanel); rootPane.setCenter(dashBoardBase); rootPane.getStyleClass().add("rootPane"); rootPane.getStylesheets().add(Main.class.getResource("css/styleDark.css").toExternalForm()); programWidth = primaryStage.getWidth(); programHeight = primaryStage.getHeight(); primaryStage.setTitle("ALE"); primaryStage.initStyle(StageStyle.UNDECORATED); primaryStage .getIcons() .add(new javafx.scene.image.Image(Main.class.getResourceAsStream("img/aleIcon.png"))); primaryStage.setScene(new Scene(rootPane, width, height)); primaryStage.show(); }