public static void main(String[] args) { /* Use an appropriate Look and Feel */ try { UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); // UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); } catch (UnsupportedLookAndFeelException ex) { ex.printStackTrace(); } catch (IllegalAccessException ex) { ex.printStackTrace(); } catch (InstantiationException ex) { ex.printStackTrace(); } catch (ClassNotFoundException ex) { ex.printStackTrace(); } /* Turn off metal's use of bold fonts */ UIManager.put("swing.boldMetal", Boolean.FALSE); // Schedule a job for the event-dispatching thread: // adding TrayIcon. SwingUtilities.invokeLater( new Runnable() { public void run() { weather = new Wetter(); createAndShowGUI(); } }); }
public void run() { String texto = ""; while (repetir) { try { Empleados e = (Empleados) inObjeto.readObject(); textarea1.setText(""); textarea1.setForeground(Color.blue); if (e == null) { textarea1.setForeground(Color.red); PintaMensaje("<<EL EMPLEADO NO EXISTE>>"); } else { texto = "Empleado: " + e.getEmpNo() + "\n " + "Oficio: " + e.getOficio() + "\tApellido: " + e.getApellido() + "\n " + "Comisión: " + e.getComision() + "\tDirección: " + e.getDir() + "\n " + "Alta: " + e.getFechaAlt() + "\tSalario: " + e.getSalario() + "\n " + "Departamento: " + e.getDepartamentos().getDnombre(); textarea1.append(texto); } } catch (SocketException s) { repetir = false; } catch (IOException e) { e.printStackTrace(); repetir = false; } catch (ClassNotFoundException e) { e.printStackTrace(); repetir = false; } } try { socket.close(); System.exit(0); } catch (IOException e) { e.printStackTrace(); } }
public static void main(String[] args) { MyCustomizableGUI custGUI = new MyCustomizableGUI(); UserPreferences savedPrefs; try (FileInputStream fileIn = new FileInputStream("preferences.ser"); ObjectInputStream objectIn = new ObjectInputStream(fileIn); ) { savedPrefs = (UserPreferences) objectIn.readObject(); if (savedPrefs.getColor().contains("Red")) { custGUI.textField.setForeground(Color.red); custGUI.color.setSelectedItem("Red"); } else if (savedPrefs.getColor().contains("Green")) { custGUI.textField.setForeground(Color.green); custGUI.color.setSelectedItem("Green"); } else if (savedPrefs.getColor().contains("Blue")) { custGUI.textField.setForeground(Color.blue); custGUI.color.setSelectedItem("Blue"); } else if (savedPrefs.getColor().contains("Cyan")) { custGUI.textField.setForeground(Color.cyan); custGUI.color.setSelectedItem("Cyan"); } else if (savedPrefs.getColor().contains("Magenta")) { custGUI.textField.setForeground(Color.magenta); custGUI.color.setSelectedItem("Magenta"); } else if (savedPrefs.getColor().contains("Yellow")) { custGUI.textField.setForeground(Color.yellow); custGUI.color.setSelectedItem("Yellow"); } else if (savedPrefs.getColor().contains("Black")) { custGUI.textField.setForeground(Color.black); custGUI.color.setSelectedItem("Black"); } custGUI.setFont(savedPrefs.getFont(), savedPrefs.getFontSize()); custGUI.font.setSelectedItem(savedPrefs.getFont()); custGUI.fontSize.setSelectedItem("" + savedPrefs.getFontSize()); } catch (FileNotFoundException noFile) { // load default font and color custGUI.setFont("Arial", 25); custGUI.textField.setForeground(Color.black); } catch (ClassNotFoundException noPrefs) { noPrefs.printStackTrace(); } catch (IOException e) { System.out.println("I/O Error: " + e.getMessage()); } }
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 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()); } }
// Вид формы при изменении сотрудника 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()); } }
/** * the constructor of the class * * @param editor the editor */ public ColorChooser(Editor editor) { this.editor = editor; // adds the w3c standard colors chooser panel SVGW3CColorChooserPanel w3cColorChooserPanel = new SVGW3CColorChooserPanel(editor); addChooserPanel(w3cColorChooserPanel); // creating the color flavors try { colorFlavor = new DataFlavor(DataFlavor.javaJVMLocalObjectMimeType + ";class=java.awt.Color"); w3cSVGColorFlavor = new DataFlavor( DataFlavor.javaJVMLocalObjectMimeType + ";class=fr.itris.glips.library.color.SVGW3CColor"); } catch (ClassNotFoundException ex) { ex.printStackTrace(); colorFlavor = DataFlavor.stringFlavor; w3cSVGColorFlavor = DataFlavor.stringFlavor; } }
public static void main(String[] arguments) { // Schedule a job for the event dispatch thread: // creating and showing this application's GUI. try { UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); } catch (UnsupportedLookAndFeelException ex) { ex.printStackTrace(); } catch (IllegalAccessException ex) { ex.printStackTrace(); } catch (InstantiationException ex) { ex.printStackTrace(); } catch (ClassNotFoundException ex) { ex.printStackTrace(); } javax.swing.SwingUtilities.invokeLater( new Runnable() { public void run() { createAndShowGUI(); } }); }
public ReverseFlashCard() { // basic init setTitle("WayMemo -Reverse Flash Card Mode"); this.setSize(800, 600); paneCenter = new JPanel(new GridLayout(7, 1)); add(ln, "North"); add(paneCenter, "Center"); add(b2, "West"); add(bReset, "South"); add(b1, "East"); paneCenter.add(l1); paneCenter.add(l2); paneCenter.add(l3); paneCenter.add(l4); paneCenter.add(l5); paneCenter.add(b3); paneCenter.add(pMark); pMark.add(bMark); pMark.add(bUnMark); pMark.add(lt); // text area init Utility.initTextAreaView(l1); Utility.initTextAreaView(l2); Utility.initTextAreaView(l3); Utility.initTextAreaView(l4); Utility.initTextAreaView(l5); // action // Action actionNext = new AbstractAction() { public void actionPerformed(ActionEvent e) { num++; wordDisplay(); } }; b1.getInputMap().put(KeyStroke.getKeyStroke("C"), "pressed"); b1.getActionMap().put("released", actionNext); // Action actionBack = new AbstractAction() { public void actionPerformed(ActionEvent e) { num--; wordDisplay(); } }; b2.getInputMap().put(KeyStroke.getKeyStroke("Z"), "pressed"); b2.getActionMap().put("released", actionBack); // Action actionShow = new AbstractAction() { public void actionPerformed(ActionEvent e) { l1.setText(dtr[num]); l3.setText(d2[num]); l4.setText(d3[num]); l5.setText(d4[num]); } }; b3.getInputMap().put(KeyStroke.getKeyStroke("X"), "pressed"); b3.getActionMap().put("released", actionShow); // // Action actionMark = new AbstractAction() { public void actionPerformed(ActionEvent e) { d1[num] = "[MARKED*]" + d1[num]; l2.setText(d1[num]); } }; bMark.getInputMap().put(KeyStroke.getKeyStroke("S"), "pressed"); bMark.getActionMap().put("released", actionMark); // // // Action actionUnmark = new AbstractAction() { public void actionPerformed(ActionEvent e) { d1[num] = od1[num]; l2.setText(d1[num]); } }; bUnMark.getInputMap().put(KeyStroke.getKeyStroke("F2"), "pressed"); bUnMark.getActionMap().put("released", actionUnmark); // // Action actionReset = new AbstractAction() { public void actionPerformed(ActionEvent e) { num = 0; wordDisplay(); } }; bReset.getInputMap().put(KeyStroke.getKeyStroke("r"), "pressed"); bReset.getActionMap().put("released", actionReset); // // b1.setMnemonic(KeyEvent.VK_C); b2.setMnemonic(KeyEvent.VK_Z); b3.setMnemonic(KeyEvent.VK_X); bMark.setMnemonic(KeyEvent.VK_S); bUnMark.setMnemonic(KeyEvent.VK_D); bReset.setMnemonic(KeyEvent.VK_R); b1.addActionListener(actionNext); b2.addActionListener(actionBack); b3.addActionListener(actionShow); bReset.addActionListener(actionReset); bMark.addActionListener(actionMark); bUnMark.addActionListener(actionUnmark); // // try { this.fileScan(new OpenFileDTR().getPathDTR()); } catch (IOException e) { } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InstantiationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (UnsupportedLookAndFeelException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
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); }