public void go() { picture(); ActionListener listener = new BtListener(); go.addActionListener(listener); btn_update_manual.addActionListener(listener); go.setForeground(Color.black); // rights.setFont((new Font("Arial", Font.PLAIN, 12))); title.setFont((new Font("Arial", Font.BOLD, 36))); title.setForeground(new Color(238, 253, 253)); today.setFont((new Font("Arial", Font.BOLD, 16))); today.setForeground(new Color(163, 184, 204)); frame.setLayout(new BorderLayout()); from.setBackground(Color.white); to.setBackground(Color.white); converted.setFont(new Font("Arial", Font.BOLD, 24)); converted.setForeground(new Color(238, 253, 253)); Lfrom.setForeground(new Color(238, 253, 253)); Lto.setForeground(new Color(238, 253, 253)); quantity.setForeground(new Color(238, 253, 253)); Lfrom.setFont(new Font("Arial", Font.BOLD, 24)); Lto.setFont(new Font("Arial", Font.BOLD, 24)); quantity.setFont(new Font("Arial", Font.BOLD, 24)); north.setLayout(new FlowLayout()); north.add(title); north.setBackground(new Color(59, 62, 71)); frame.add(BorderLayout.NORTH, north); inner.setLayout(new BorderLayout()); inner.add(BorderLayout.NORTH, today); inner.add(BorderLayout.WEST, picPanel); center.setLayout(new GridLayout(2, 4, 5, 5)); center.add(Lfrom); center.add(from); center.add(Lto); center.add(to); center.add(quantity); center.add(amount); center.add(go); inner.setBackground(new Color(59, 62, 71)); inner.add(BorderLayout.SOUTH, center); center.setBackground(new Color(59, 62, 71)); frame.add(BorderLayout.CENTER, inner); south.setBackground(new Color(59, 62, 71)); south.setLayout(new FlowLayout()); south.add(converted); south.add(answer); south.add(btn_update_manual); // south.add(rights); frame.add(BorderLayout.SOUTH, south); frame.setSize(850, 700); frame.setVisible(true); frame.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent event) { frame.setVisible(false); frame.dispose(); System.exit(0); } }); }
// implement an abstract member to set colors void setColor(Color c) { if (c != null) { _value.setBackground(c); } else { _value.setBackground(_defaultColor); } _value.setOpaque(true); }
MsMsBottomPanel(MsMsVisualizerWindow masterFrame, RawDataFile dataFile, ParameterSet parameters) { this.dataFile = dataFile; this.masterFrame = masterFrame; setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); setBackground(Color.white); setBorder(new EmptyBorder(5, 5, 5, 0)); add(Box.createHorizontalGlue()); GUIUtils.addLabel(this, "Show: ", SwingConstants.RIGHT); thresholdCombo = new JComboBox<Object>(PeakThresholdMode.values()); thresholdCombo.setSelectedItem(PeakThresholdMode.NONE); thresholdCombo.setBackground(Color.white); thresholdCombo.setFont(smallFont); thresholdCombo.addActionListener(this); add(thresholdCombo); JPanel peakThresholdPanel = new JPanel(); peakThresholdPanel.setBackground(Color.white); peakThresholdPanel.setLayout(new BoxLayout(peakThresholdPanel, BoxLayout.X_AXIS)); GUIUtils.addLabel(peakThresholdPanel, "Value: ", SwingConstants.RIGHT); peakTextField = new JTextField(); peakTextField.setPreferredSize(new Dimension(50, 15)); peakTextField.setFont(smallFont); peakTextField.addActionListener(this); peakThresholdPanel.add(peakTextField); add(peakThresholdPanel); GUIUtils.addLabel(this, " from peak list: ", SwingConstants.RIGHT); peakListSelector = new JComboBox<PeakList>(); peakListSelector.setBackground(Color.white); peakListSelector.setFont(smallFont); peakListSelector.addActionListener(masterFrame); peakListSelector.setActionCommand("PEAKLIST_CHANGE"); add(peakListSelector); thresholdSettings = parameters.getParameter(MsMsParameters.peakThresholdSettings); thresholdCombo.setSelectedItem(thresholdSettings.getMode()); add(Box.createHorizontalStrut(10)); add(Box.createHorizontalGlue()); }
public void p(Object obj) throws Exception { JComboBox combo = (JComboBox) obj; combo.setFont(combo.getFont().deriveFont(Font.PLAIN)); combo.setBackground(Color.WHITE); if (color == null) color = DEFAULT_COLOR; if (font == null) font = DEFAULT_FONT; combo.setRenderer(new ListRenderer1(icon, color, font)); }
public static JComboBox getComboBox() { JComboBox component = new JComboBox(); component.setBackground(BACKGROUND_COLOR_TXTA); component.setForeground(TEXT_COLOR); component.setCursor(CURSOR); component.setFont(FONT_TYPE_TXTA); return component; }
/** * This method initializes jComboBoxPagoResto * * <p>return javax.swing.JComboBox */ private JComboBox getJComboBoxPagoResto() { if (jComboBoxPagoResto == null) { jComboBoxPagoResto = new JComboBox(); jComboBoxPagoResto.setBackground(new java.awt.Color(224, 224, 222)); jComboBoxPagoResto.setPreferredSize(new java.awt.Dimension(50, 20)); jComboBoxPagoResto.addItem(new LabelValueBean("SI", "0")); jComboBoxPagoResto.addItem(new LabelValueBean("NO", "99")); jComboBoxPagoResto.addKeyListener(this); } return jComboBoxPagoResto; }
/** * Constructor for the LiveSearchBox. First create a pointer to the controller. Then create a * JComboBox, set the preferred size, set the setEditable to true, and set the background. The * component is retrieved from adress and sets a size. Finally a listener is added to component. */ public LiveSearchBox() { controller = Controller.getInstance(); adress = new JComboBox(); Dimension d = adress.getPreferredSize(); adress.setPreferredSize(new Dimension(170, (int) d.getHeight())); adress.setEditable(true); adress.setBackground(Color.lightGray); component = (JTextField) adress.getEditor().getEditorComponent(); component.setSize(50, 10); doc = component.getDocument(); listener = createListener(); doc.addDocumentListener(listener); }
public Component getTableCellRendererComponent( JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { if (isSelected) { setForeground(table.getSelectionForeground()); super.setBackground(table.getSelectionBackground()); } else { setForeground(table.getForeground()); setBackground(table.getBackground()); } // Select the current value setSelectedItem(value); return this; }
private void setupLayout() { setBackground(new Color(70, 130, 180)); anotherBox.setBackground(new Color(176, 196, 222)); pictureBox.setBackground(new Color(176, 196, 222)); anotherBox.setFont(new Font("Baskerville", Font.PLAIN, 13)); saveButton.setFont(new Font("Baskerville", Font.PLAIN, 13)); pictureBox.setFont(new Font("Baskerville", Font.PLAIN, 13)); loadButton.setFont(new Font("Baskerville", Font.PLAIN, 13)); layout.putConstraint(SpringLayout.SOUTH, pictureBox, 0, SpringLayout.SOUTH, anotherBox); layout.putConstraint(SpringLayout.NORTH, pictureBox, 0, SpringLayout.NORTH, anotherBox); layout.putConstraint(SpringLayout.EAST, pictureBox, 159, SpringLayout.EAST, anotherBox); layout.putConstraint(SpringLayout.NORTH, saveButton, 15, SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.NORTH, payne, 25, SpringLayout.SOUTH, saveButton); layout.putConstraint(SpringLayout.WEST, saveButton, 25, SpringLayout.WEST, this); layout.putConstraint(SpringLayout.WEST, payne, 25, SpringLayout.WEST, this); layout.putConstraint(SpringLayout.NORTH, btnNewButton, 15, SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.WEST, btnNewButton, 25, SpringLayout.EAST, pictureBox); layout.putConstraint(SpringLayout.WEST, pictureBox, 25, SpringLayout.EAST, anotherBox); layout.putConstraint(SpringLayout.NORTH, loadButton, 15, SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.WEST, loadButton, 25, SpringLayout.EAST, saveButton); layout.putConstraint(SpringLayout.NORTH, anotherBox, 15, SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.WEST, anotherBox, 25, SpringLayout.EAST, loadButton); }
@Override public Component getTableCellEditorComponent( JTable table, Object value, boolean isSelected, int row, int column) { // Only the selected component will be edited, so always set the colors to the table's selection // colors. comboBox.setForeground(table.getSelectionForeground()); comboBox.setBackground(table.getSelectionBackground()); for (int i = 0; i < comboBox.getComponentCount(); i++) { if (comboBox.getComponent(i) instanceof AbstractButton) { comboBox.getComponent(i).setBackground(comboBox.getBackground()); } } comboBox.setSelectedItem(value); return comboBox; }
public Component getTableCellRendererComponent( JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { if (isSelected) { setForeground(table.getSelectionForeground()); super.setBackground(table.getSelectionBackground()); } else { setForeground(table.getForeground()); setBackground(table.getBackground()); } // Select the current value // set the correct selected value... Misc.setComboBoxTag(true, value, this); return this; }
public MirthComboBoxTableCellEditor( JTable table, Object[] items, int clickCount, boolean focusable, final ActionListener actionListener) { this.clickCount = clickCount; comboBox = new JComboBox(items); comboBox.setFocusable(focusable); comboBox.setMaximumRowCount(20); comboBox.setForeground(table.getForeground()); comboBox.setBackground(table.getBackground()); comboBox.setRenderer(new DataTypeListCellRenderer()); // Allow an action listener to be passed in. However, we need to fireEditingStopped after the // action has finished so we wrap it in another listener comboBox.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (actionListener != null) { actionListener.actionPerformed(e); } fireEditingStopped(); } }); // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4515838 // Workaround to remove the border around the comboBox for (int i = 0; i < comboBox.getComponentCount(); i++) { if (comboBox.getComponent(i) instanceof AbstractButton) { ((AbstractButton) comboBox.getComponent(i)).setBorderPainted(false); } } }
public emp() { setTitle("AMRITA HUMAN RESOURCE MANAGEMENT SYSTEM (EMPLOYEE DETAIL)"); getContentPane().add(p, BorderLayout.CENTER); getContentPane().add(q, BorderLayout.SOUTH); setTitle("Placement Office"); lname = new JLabel("Name: "); lextra = new JLabel("Vacancy(s): "); lfield = new JLabel("Field: "); lsal = new JLabel("Minimum Expected Salary: "); lusr = new JLabel("Login name: "); lpwd = new JLabel("Password: "******"5,000"); cbsal.addItem("10,000"); cbsal.addItem("15,000"); cbsal.addItem("20,000"); cbsal.setBackground(Color.ORANGE); it = new JRadioButton("Software Engg."); civil = new JRadioButton("Civil Engg."); mech = new JRadioButton("Mechanical Engg."); ButtonGroup bg2 = new ButtonGroup(); bg2.add(it); bg2.add(civil); bg2.add(mech); civil.setBackground(Color.ORANGE); bSub = new JButton("Submit"); bRes = new JButton("Reset"); p.setLayout(new GridLayout(11, 2)); Blank = new JLabel(""); Blank1 = new JLabel(""); Blank2 = new JLabel(""); Blank3 = new JLabel(""); Blank4 = new JLabel(""); p.add(lusr); p.add(tusr); p.add(lpwd); p.add(tpwd); p.add(lname); p.add(tname); p.add(lextra); p.add(textra); p.add(lfield); p.add(it); p.add(Blank4); p.add(civil); p.add(Blank1); p.add(mech); p.add(lsal); p.add(cbsal); q.add(bSub); q.add(bRes); bSub.addActionListener(this); bRes.addActionListener(this); setVisible(true); setBounds(200, 200, 300, 300); setDefaultCloseOperation(EXIT_ON_CLOSE); }
/** Initialize the contents of the frame. */ private void initialize() { frame = new JFrame(); frame.getContentPane().setBackground(Color.WHITE); frame.getContentPane().setForeground(Color.RED); frame.setBackground(Color.WHITE); frame.setBounds(100, 100, 613, 459); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().setLayout(null); JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP); tabbedPane.setForeground(Color.BLACK); tabbedPane.setBackground(Color.WHITE); tabbedPane.setBounds(1, 2, 596, 408); frame.getContentPane().add(tabbedPane); JPanel panel_1 = new JPanel(); panel_1.setBackground(Color.WHITE); panel_1.setForeground(Color.GREEN); tabbedPane.addTab("Recieved Mail", null, panel_1, null); panel_1.setLayout(null); JTextPane textPane_1 = new JTextPane(); textPane_1.setBackground(Color.WHITE); textPane_1.setForeground(Color.BLACK); textPane_1.setEditable(false); JScrollPane scrollPane1 = new JScrollPane(textPane_1); scrollPane1.setBounds(150, 100, 420, 250); panel_1.add(scrollPane1); // panel_1.add(textPane_1); DefaultListModel listModel = new DefaultListModel(); File[] files1 = new File("src/inbox").listFiles(); for (File file : files1) { if (file.isFile()) listModel.addElement((file.getName()).substring(0, (file.getName()).length() - 4)); } JList list = new JList(listModel); list.setForeground(Color.BLACK); list.setBackground(Color.WHITE); // list.setBounds(10, 11, 112, 280); // panel_1.add(list); JScrollPane scrollPane = new JScrollPane(list); // scrollPane.setViewportView(list); scrollPane.setBounds(20, 11, 112, 340); panel_1.add(scrollPane); JLabel lblMessage = new JLabel("Message"); lblMessage.setForeground(Color.BLACK); lblMessage.setBounds(175, 77, 79, 14); panel_1.add(lblMessage); JPanel panel = new JPanel(); panel.setBackground(Color.WHITE); tabbedPane.addTab("Send Email", null, panel, null); panel.setLayout(null); JComboBox contactCombo = new JComboBox(); contactCombo.setForeground(Color.BLACK); contactCombo.setBackground(Color.WHITE); contactCombo.setBounds(172, 21, 409, 20); panel.add(contactCombo); JLabel label = new JLabel("Message:"); label.setForeground(Color.BLACK); label.setBounds(13, 117, 91, 14); panel.add(label); JTextPane messagePane = new JTextPane(); messagePane.setBackground(Color.WHITE); messagePane.setForeground(Color.BLACK); messagePane.setBounds(10, 124, 539, 194); // panel.add(messagePane); JButton button_1 = new JButton("Send"); button_1.setForeground(Color.BLACK); button_1.setBackground(Color.WHITE); button_1.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { String to = contactCombo.getSelectedItem().toString(); String subject = txtSubject.getText(); Random rn = new Random(); String ShareID = Integer.toString((new Random()).nextInt((999999999 - 100) + 1) + 100); System.out.println(ShareID); String from = "src/proxies/proxies.txt"; String message = messagePane.getText(); try { // if(selectedFileIn == true) System.out.println("sendmail1"); SendMail.Distributor(to, ShareID, from, message, "", subject); System.out.println("sendmail2"); // selectedFileIn = false; } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } messagePane.setText(""); contactCombo.repaint(); attField.setText(""); attField.removeAll(); } }); JScrollPane sP = new JScrollPane( messagePane, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); sP.setBounds(13, 142, 568, 194); panel.add(sP); button_1.setBounds(482, 346, 99, 23); panel.add(button_1); JLabel lblTo = new JLabel("To"); lblTo.setForeground(Color.BLACK); lblTo.setBackground(Color.BLACK); lblTo.setBounds(116, 24, 46, 14); panel.add(lblTo); attField = new JTextField(); attField.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) {} }); attField.setBounds(172, 52, 409, 20); panel.add(attField); attField.setColumns(10); JButton btnSearchButton = new JButton("Search"); btnSearchButton.setBackground(Color.WHITE); btnSearchButton.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { JFileChooser fileChooser = new JFileChooser(); fileChooser.showOpenDialog(frame); // fileChooser.setCurrentDirectory(new File(System.getProperty("src/"))); selectedFile = fileChooser.getSelectedFile(); attField.setText(selectedFile.getName()); selectedFileIn = true; // selectedFile = fileChooser.getSelectedFile(); } }); btnSearchButton.setBounds(73, 51, 89, 23); panel.add(btnSearchButton); txtSubject = new JTextField(); txtSubject.setBounds(172, 83, 409, 20); panel.add(txtSubject); txtSubject.setColumns(10); JLabel lblSubject = new JLabel("Subject"); lblSubject.setForeground(Color.BLACK); lblSubject.setBackground(Color.BLACK); lblSubject.setBounds(116, 85, 46, 14); panel.add(lblSubject); JPanel panel_2 = new JPanel(); panel_2.setBackground(Color.WHITE); tabbedPane.addTab("Add Contact", null, panel_2, null); panel_2.setLayout(null); JLabel lblEmailAddress = new JLabel("Email Address"); lblEmailAddress.setForeground(Color.BLACK); lblEmailAddress.setBounds(75, 159, 72, 14); panel_2.add(lblEmailAddress); JTextPane proxyPane = new JTextPane(); proxyPane.setForeground(Color.BLACK); proxyPane.setBackground(Color.LIGHT_GRAY); proxyPane.setBounds(157, 159, 298, 102); panel_2.add(proxyPane); JLabel lblContactName = new JLabel("Contact Name"); lblContactName.setForeground(Color.BLACK); lblContactName.setBounds(69, 124, 72, 14); panel_2.add(lblContactName); contactField = new JTextField(); contactField.setBackground(Color.LIGHT_GRAY); contactField.setColumns(10); contactField.setBounds(157, 121, 298, 20); panel_2.add(contactField); JButton btnAddContact = new JButton("Add Contact"); btnAddContact.setBackground(Color.WHITE); btnAddContact.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { BufferedWriter output = null; // Add new contact String conName = contactField.getText(); String allprox = proxyPane.getText(); File conFile = new File("src/contacts/" + conName + ".txt"); try { output = new BufferedWriter(new FileWriter(conFile)); output.write(allprox); output.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); btnAddContact.setBounds(157, 301, 118, 23); panel_2.add(btnAddContact); // List<String> contacts = new ArrayList<String>(); // comboBox.addItem("hg"); File[] files = new File("src/contacts").listFiles(); for (File file : files) { if (file.isFile()) contactCombo.addItem((file.getName()).substring(0, (file.getName()).length() - 4)); } list.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { String strbldr = ""; String loc = "src/inbox/" + list.getSelectedValue().toString() + ".txt"; try { BufferedReader buffread = new BufferedReader(new FileReader(loc)); String line = buffread.readLine(); while (line != null) { strbldr += line; strbldr += "\n"; line = buffread.readLine(); } buffread.close(); } catch (Exception e) { } ; textPane_1.setText(strbldr); textPane_1.setCaretPosition(0); } }); class Inner extends Thread { public void run() { do { System.out.println("Hello from a thread!"); try { ReceiveMail.run(); scrollPane.repaint(); this.sleep(10000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } while (true); } public void main(String args[]) { (new Inner()).start(); } } Inner reloads = new Inner(); reloads.start(); }
public Viajes() { super.setBounds(181, 61, 700, 538); // (ancho,alto) super.setLayout(null); super.setOpaque(false); super.setVisible(false); try { UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); } catch (Exception ex) { ex.printStackTrace(); } tbDatos = new JTable(dataModel); tbDatos.setEnabled(false); tbDatos.setAutoResizeMode(5); tbDatos.setCellSelectionEnabled(true); tbDatos.setForeground(Color.BLACK); pnDatos = new JScrollPane(tbDatos); pnDatos.setBounds(30, 30, 640, 478); pnDatos.setVisible(false); this.add(pnDatos); llenarDatos(); jlbCodigo = new JLabel("*Código"); jlbCodigo.setBounds(90, 100, 220, 25); jlbCodigo.setForeground(Color.BLACK); jlbCodigo.setFont(new Font("Segoe UI", Font.PLAIN, 18)); this.add(jlbCodigo); jtxtCodigo = new JTextField(""); jtxtCodigo.setBounds(90, 125, 520, 30); jtxtCodigo.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1)); jtxtCodigo.addKeyListener(this); this.add(jtxtCodigo); jlbOrigen = new JLabel("*Origen"); jlbOrigen.setBounds(90, 180, 150, 25); jlbOrigen.setForeground(Color.BLACK); jlbOrigen.setFont(new Font("Segoe UI", Font.PLAIN, 18)); this.add(jlbOrigen); jcbOrigen = new JComboBox(); jcbOrigen.setBorder(null); jcbOrigen.setBackground(Color.WHITE); jcbOrigen.addItem("Medellín"); jcbOrigen.addItem("Bogotá"); jcbOrigen.addItem("Barranquilla"); jcbOrigen.setBounds(90, 205, 250, 30); this.add(jcbOrigen); jlbDestino = new JLabel("*Destino"); jlbDestino.setBounds(360, 180, 150, 25); jlbDestino.setForeground(Color.BLACK); jlbDestino.setFont(new Font("Segoe UI", Font.PLAIN, 18)); this.add(jlbDestino); jcbDestino = new JComboBox(); jcbDestino.setBorder(null); jcbDestino.setBackground(Color.WHITE); jcbDestino.addItem("Bogotá"); jcbDestino.addItem("Medellín"); jcbDestino.addItem("Barranquilla"); jcbDestino.setBounds(360, 205, 250, 30); this.add(jcbDestino); jlbPrecio = new JLabel("*Precio"); jlbPrecio.setBounds(90, 260, 120, 25); jlbPrecio.setForeground(Color.BLACK); jlbPrecio.setFont(new Font("Segoe UI", Font.PLAIN, 18)); this.add(jlbPrecio); jtxtPrecio = new JTextField(""); jtxtPrecio.setBounds(90, 285, 520, 30); jtxtPrecio.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1)); jtxtPrecio.addKeyListener(this); this.add(jtxtPrecio); jlbEstado = new JLabel("*Estado"); jlbEstado.setBounds(90, 340, 150, 25); jlbEstado.setForeground(Color.BLACK); jlbEstado.setFont(new Font("Segoe UI", Font.PLAIN, 18)); this.add(jlbEstado); jcbEstado = new JComboBox(); jcbEstado.setBorder(null); jcbEstado.setBackground(Color.WHITE); jcbEstado.addItem("Activo"); jcbEstado.addItem("Inactivo"); jcbEstado.setBounds(90, 365, 520, 30); this.add(jcbEstado); jbtnListar = new JButton(" Lista"); jbtnListar.setBounds(0, 0, 233, 60); jbtnListar.setIcon(new ImageIcon(getClass().getResource("/Imagenes/icons/List-26.png"))); jbtnListar.setBorder(null); jbtnListar.setBackground(new Color(0, 154, 225)); jbtnListar.setForeground(Color.WHITE); jbtnListar.setFont(new Font("Segoe UI", Font.PLAIN, 20)); jbtnListar.setCursor(new Cursor(java.awt.Cursor.HAND_CURSOR)); jbtnListar.addMouseListener(this); jbtnListar.addActionListener(this); jbtnListar.setFocusPainted(false); this.add(jbtnListar); jbtnBuscar = new JButton(" Buscar"); jbtnBuscar.setBounds(233, 0, 234, 60); jbtnBuscar.setIcon(new ImageIcon(getClass().getResource("/Imagenes/icons/Search-26.png"))); jbtnBuscar.setBorder(null); jbtnBuscar.setBackground(new Color(0, 154, 225)); jbtnBuscar.setForeground(Color.WHITE); jbtnBuscar.setFont(new Font("Segoe UI", Font.PLAIN, 20)); jbtnBuscar.setCursor(new Cursor(java.awt.Cursor.HAND_CURSOR)); jbtnBuscar.addMouseListener(this); jbtnBuscar.addActionListener(this); jbtnBuscar.setFocusPainted(false); this.add(jbtnBuscar); jbtnActualizar = new JButton(" Actualizar"); jbtnActualizar.setBounds(233, 0, 234, 60); jbtnActualizar.setIcon(new ImageIcon(getClass().getResource("/Imagenes/icons/Edit-26.png"))); jbtnActualizar.setBorder(null); jbtnActualizar.setBackground(new Color(0, 154, 225)); jbtnActualizar.setForeground(Color.WHITE); jbtnActualizar.setFont(new Font("Segoe UI", Font.PLAIN, 20)); jbtnActualizar.setCursor(new Cursor(java.awt.Cursor.HAND_CURSOR)); jbtnActualizar.addMouseListener(this); jbtnActualizar.setVisible(false); jbtnActualizar.addActionListener(this); jbtnActualizar.setFocusPainted(false); this.add(jbtnActualizar); jbtnLimpiar = new JButton(" Limpiar"); jbtnLimpiar.setBounds(467, 0, 233, 60); jbtnLimpiar.setIcon(new ImageIcon(getClass().getResource("/Imagenes/icons/Clean-26.png"))); jbtnLimpiar.setBorder(null); jbtnLimpiar.setBackground(new Color(0, 154, 225)); jbtnLimpiar.setForeground(Color.WHITE); jbtnLimpiar.setFont(new Font("Segoe UI", Font.PLAIN, 20)); jbtnLimpiar.setCursor(new Cursor(java.awt.Cursor.HAND_CURSOR)); jbtnLimpiar.addMouseListener(this); jbtnLimpiar.addActionListener(this); jbtnLimpiar.setFocusPainted(false); this.add(jbtnLimpiar); jpBotones = new JPanel(); jpBotones.setBackground(new Color(0, 123, 183)); jpBotones.add(jbtnListar); jpBotones.add(jbtnBuscar); jpBotones.add(jbtnActualizar); jpBotones.add(jbtnLimpiar); jpBotones.setLayout(null); jpBotones.setBounds(0, 478, 700, 60); this.add(jpBotones); jlbValidar = new JLabel("Los campos con (*) son obligatorios"); jlbValidar.setForeground(Color.WHITE); jlbValidar.setBounds(80, 8, 300, 27); jlbValidar.setFont(new Font("Segoe UI", Font.PLAIN, 17)); this.add(jlbValidar); jpError = new JPanel(); jpError.add(jlbValidar); jpError.setLayout(null); jpError.setBackground(new Color(0, 123, 183)); jpError.setBounds(0, 0, 700, 45); this.add(jpError); this.repaint(); }
private void jbInit() throws Exception { // Leemos la conexion // // con = getDBConnection(); GeopistaGeneradorListadosConexionBD geopistaListados = new GeopistaGeneradorListadosConexionBD(); this.setLayout(null); this.setSize(new Dimension(854, 500)); jPanel1.setLayout(null); jPanel1.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED)); lblDatosGenerales.setText(aplicacion.getI18nString("generador.app.reports.datos.generales")); lblModulo.setText(aplicacion.getI18nString("generador.app.reports.modulo")); lblCapa.setText(aplicacion.getI18nString("generador.app.reports.capa")); // Cargamos la lista de capas ArrayList capas = geopistaListados.capasGeopista(); Iterator i = capas.iterator(); lblDatosGenerales.setBounds(new Rectangle(135, 5, 185, 20)); lblModulo.setBounds(new Rectangle(135, 23, 60, 25)); lblCapa.setBounds(new Rectangle(135, 50, 45, 30)); jPanel1.setBounds(new Rectangle(10, 15, 750, 500)); jSeparator1.setBounds(new Rectangle(0, 135, 735, 5)); while (i.hasNext()) { modeloList.addElement(i.next()); } // Creamos la lista con el modelo anteriormente definido // -- jPanel1.setSize(new Dimension(750, 600)); cmbModulos.setBackground(new Color(254, 255, 255)); cmbModulos.setBounds(new Rectangle(215, 25, 520, 20)); lstCapas.setSelectionModel(listSelectionModel1); lblTitulo.setText(aplicacion.getI18nString("informe.datos.seleccion.titulo.fichero")); lblTitulo.setBounds(new Rectangle(140, 215, 95, 15)); txtTituloInforme.setBounds(new Rectangle(140, 230, 595, 20)); lstCapas.addKeyListener( new java.awt.event.KeyAdapter() { public void keyReleased(java.awt.event.KeyEvent e) { String cadena = (String) lstCapas.getSelectedValue(); lstCapas.ensureIndexIsVisible(lstCapas.getSelectedIndex()); lstCapas.setSelectedValue((String) cadena, true); } }); lstCapas.addMouseListener( new MouseListener() { public void mouseClicked(MouseEvent e) { wizardContext.inputChanged(); } public void mousePressed(MouseEvent e) {} public void mouseReleased(MouseEvent e) {} public void mouseEntered(MouseEvent e) {} { } public void mouseExited(MouseEvent e) {} }); lblDescripcion.setText(aplicacion.getI18nString("generador.app.reports.descripcion.informe")); lblDescripcion.setBounds(new Rectangle(140, 255, 95, 20)); txtDescripcion.setBounds(new Rectangle(140, 280, 595, 95)); lblOrientacion.setText(aplicacion.getI18nString("generador.app.reports.orientacion.informe")); lblOrientacion.setBounds(new Rectangle(135, 178, 85, 25)); lblNombreFichero.setText(aplicacion.getI18nString("generador.app.reports.nombre.fichero")); lblNombreFichero.setBounds(new Rectangle(135, 145, 120, 30)); txtNombreFichero.setBounds(new Rectangle(215, 150, 520, 20)); // hb.enableHelpKey(this,"encabezado",hs); // Ponemos a mano los Módulos , prueba cmbModulos.addItem( (String) aplicacion.getI18nString("generador.app.reports.modulo.planeamiento")); cmbModulos.addItem(aplicacion.getI18nString("generador.app.reports.modulo.catastro")); cmbModulos.addItem(aplicacion.getI18nString("generador.app.reports.modulo.informacion")); cmbModulos.addItem(aplicacion.getI18nString("generador.app.reports.modulo.patrimonio")); cmbModulos.addItem(aplicacion.getI18nString("generador.app.reports.modulo.infraestructuras")); // Ponemos las explicaciones de las secciones /* lblExplicacionDatosInformes.setText(aplicacion.getI18nString("informe.datos.generales.explicacion.comentarios")); txtTituloInforme.setToolTipText(aplicacion.getI18nString("informe.datos.generales.explicacion.titulo.fichero")); txtDescripcion.setToolTipText(aplicacion.getI18nString("informe.datos.generales.explicacion.detalle")); txtNombreFichero.setToolTipText(aplicacion.getI18nString("informe.datos.generales.explicacion.nombre.fichero")); lblUbicacion.setText(aplicacion.getI18nString("informe.datos.generales.explicacion.ubicacion"));*/ // Ponemos a mano la horientacion optVertical.setText(aplicacion.getI18nString("generador.app.reports.orientacion.vertical")); optHorizontal.setText(aplicacion.getI18nString("generador.app.reports.orientacion.horizontal")); // Nuevo Listener para ver cuando cambia la caja de texto txtTituloInforme.addKeyListener( new KeyListener() { public void keyTyped(KeyEvent e) {} public void keyPressed(KeyEvent e) { wizardContext.inputChanged(); } public void keyReleased(KeyEvent e) {} }); optVertical.setText(aplicacion.getI18nString("generador.app.reports.orientacion.vertical")); optVertical.setSelected(true); optVertical.setBounds(new Rectangle(215, 180, 125, 20)); optVertical.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { optVertical_actionPerformed(e); } }); optHorizontal.setText(aplicacion.getI18nString("generador.app.reports.orientacion.horizontal")); optHorizontal.setBounds(new Rectangle(360, 180, 135, 20)); optHorizontal.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { optHorizontal_actionPerformed(e); } }); jScrollPane1.setBounds(new Rectangle(215, 60, 520, 70)); jSeparator2.setBounds(new Rectangle(5, 205, 730, 5)); lblImagen.setBounds(new Rectangle(15, 20, 110, 490)); lblImagen.setIcon(IconLoader.icon((String) blackboardInformes.get("tipoBanner"))); lblImagen.setBounds(new Rectangle(15, 20, 110, 490)); lblImagen.setBorder(BorderFactory.createLineBorder(Color.black, 1)); lblImagen.setBorder(BorderFactory.createLineBorder(Color.black, 1)); txtNombreFichero.addKeyListener( new KeyListener() { public void keyTyped(KeyEvent e) {} public void keyPressed(KeyEvent e) { wizardContext.inputChanged(); } public void keyReleased(KeyEvent e) {} }); jScrollPane1.getViewport().add(lstCapas, null); jPanel1.add(jSeparator2, null); jPanel1.add(jScrollPane1, null); jPanel1.add(optHorizontal, null); jPanel1.add(optVertical, null); jPanel1.add(txtTituloInforme, null); jPanel1.add(lblTitulo, null); jPanel1.add(txtDescripcion, null); jPanel1.add(lblDescripcion, null); jPanel1.add(lblOrientacion, null); jPanel1.add(txtNombreFichero, null); jPanel1.add(lblNombreFichero, null); jPanel1.add(jSeparator1, null); jPanel1.add(lblCapa, null); jPanel1.add(cmbModulos, null); jPanel1.add(lblModulo, null); jPanel1.add(lblDatosGenerales, null); this.add(lblImagen, null); this.add(jPanel1, null); // Cargamos las capas en la lista }
/** Create the frame. */ @SuppressWarnings({"unchecked", "rawtypes"}) public MembersManagement() { connection = DBConnector.dbConnector(); setIconImage( Toolkit.getDefaultToolkit() .getImage( MembersManagement.class.getResource( "/Resources/Custo.Man.Christmas.Folder.Library.ico.png"))); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 1366, 768); contentPane = new JPanel(); contentPane.setBackground(Color.DARK_GRAY); contentPane.setBorder(new LineBorder(Color.BLUE, 1, true)); setContentPane(contentPane); StartPosition.centerOnScreen(this); String[] MemberType = new String[] {"Students", "Teachers"}; JButton button = new JButton("_"); button.setBounds(1234, 1, 44, 23); button.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { MinFrame(); } }); contentPane.setLayout(null); button.setForeground(Color.WHITE); button.setFocusable(false); button.setBackground(Color.DARK_GRAY); contentPane.add(button); JButton button_1 = new JButton(""); button_1.setBounds(1277, 1, 44, 23); button_1.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { MaxFrame(); } }); button_1.setIcon(new ImageIcon(MembersManagement.class.getResource("/Resources/Maximize.png"))); button_1.setForeground(Color.WHITE); button_1.setFocusable(false); button_1.setBackground(Color.DARK_GRAY); contentPane.add(button_1); JButton button_2 = new JButton("X"); button_2.setBounds(1321, 1, 44, 23); button_2.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { CloseFrame(); } }); button_2.setForeground(Color.WHITE); button_2.setFont(new Font("Ubuntu", Font.BOLD, 8)); button_2.setFocusable(false); button_2.setBackground(Color.RED); contentPane.add(button_2); Border emptyBorder = BorderFactory.createEmptyBorder(); JLabel lblStudentsManagement = new JLabel("Members Management"); lblStudentsManagement.setBounds(403, 34, 543, 78); lblStudentsManagement.setHorizontalAlignment(SwingConstants.CENTER); lblStudentsManagement.setForeground(new Color(255, 255, 255)); lblStudentsManagement.setFont(new Font("Ubuntu", Font.BOLD, 36)); contentPane.add(lblStudentsManagement); String[] searchCriteria = new String[] {"Name", "Registration Number"}; JPanel panel3 = new JPanel(); panel3.setBackground(Color.DARK_GRAY); panel3.setBorder(new LineBorder(Color.BLUE)); panel3.setBounds(14, 187, 1340, 568); contentPane.add(panel3); panel3.setLayout(null); panel3.setVisible(false); JLabel lblSelectSearchCriteria = new JLabel("Select Search Criteria"); lblSelectSearchCriteria.setForeground(Color.WHITE); lblSelectSearchCriteria.setFont(new Font("Ubuntu", Font.PLAIN, 13)); lblSelectSearchCriteria.setBounds(487, 39, 149, 21); panel3.add(lblSelectSearchCriteria); JScrollPane scrollPane_1 = new JScrollPane(); scrollPane_1.setBounds(10, 99, 1320, 402); panel3.add(scrollPane_1); table_1 = new JTable(); table_1.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); table_1.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); scrollPane_1.setViewportView(table_1); JLabel lblCriteria = new JLabel("Name"); lblCriteria.setForeground(Color.WHITE); lblCriteria.setFont(new Font("Ubuntu", Font.PLAIN, 13)); lblCriteria.setBounds(952, 39, 149, 21); panel3.add(lblCriteria); JComboBox cmbSearchCriteria = new JComboBox(searchCriteria); cmbSearchCriteria.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (cmbSearchCriteria.getSelectedItem().toString() == "Name") { lblCriteria.setText("Name"); txtSearch.setBounds(1001, 37, 160, 25); } else if (cmbSearchCriteria.getSelectedItem().toString() == "Registration Number") { lblCriteria.setText("Registration Number"); txtSearch.setBounds(1100, 37, 160, 25); } } }); cmbSearchCriteria.setForeground(Color.WHITE); cmbSearchCriteria.setFont(new Font("Ubuntu", Font.PLAIN, 13)); cmbSearchCriteria.setBorder(emptyBorder); cmbSearchCriteria.setBackground(Color.DARK_GRAY); cmbSearchCriteria.setBounds(646, 39, 160, 20); panel3.add(cmbSearchCriteria); JComboBox cmbType = new JComboBox(MemberType); cmbType.setForeground(Color.WHITE); cmbType.setFont(new Font("Ubuntu", Font.PLAIN, 13)); cmbType.setBackground(Color.DARK_GRAY); cmbType.setBounds(246, 39, 160, 20); panel3.add(cmbType); JLabel lblSearchBy = new JLabel("Search By"); lblSearchBy.setForeground(Color.WHITE); lblSearchBy.setFont(new Font("Ubuntu", Font.PLAIN, 13)); lblSearchBy.setBounds(885, 39, 75, 21); panel3.add(lblSearchBy); txtSearch = new JTextField(); txtSearch.addKeyListener( new KeyAdapter() { @Override public void keyTyped(KeyEvent e) { String type = cmbType.getSelectedItem().toString(); String sCriteria = cmbSearchCriteria.getSelectedItem().toString(); if (type == "Students") { if (sCriteria == "Name") { try { LibMemberDM bDM = new LibMemberDM(); table_1.setModel( DbUtils.resultSetToTableModel(bDM.searchByNameS(txtSearch.getText()))); } catch (Exception ex) { JOptionPane.showMessageDialog(null, ex.getMessage()); } } else if (sCriteria == "Registration Number") { try { LibMemberDM bDM = new LibMemberDM(); table_1.setModel( DbUtils.resultSetToTableModel(bDM.searchByRegNoS(txtSearch.getText()))); } catch (Exception ex) { JOptionPane.showMessageDialog(null, ex.getMessage()); } } } else if (type == "Teachers") { if (sCriteria == "Name") { try { LibMemberDM bDM = new LibMemberDM(); table_1.setModel( DbUtils.resultSetToTableModel(bDM.searchByNameT(txtSearch.getText()))); } catch (Exception ex) { JOptionPane.showMessageDialog(null, ex.getMessage()); } } else if (sCriteria == "Registration Number") { try { LibMemberDM bDM = new LibMemberDM(); table_1.setModel( DbUtils.resultSetToTableModel(bDM.searchByRegNoT(txtSearch.getText()))); } catch (Exception ex) { JOptionPane.showMessageDialog(null, ex.getMessage()); } } } } }); txtSearch.setForeground(Color.WHITE); txtSearch.setFont(new Font("Ubuntu", Font.PLAIN, 13)); txtSearch.setBorder(emptyBorder); txtSearch.setBackground(Color.GRAY); txtSearch.setBounds(1001, 37, 200, 25); panel3.add(txtSearch); txtSearch.setColumns(10); JButton btnUpdate = new JButton("Update"); btnUpdate.setFont(new Font("Ubuntu", Font.PLAIN, 12)); btnUpdate.setBackground(Color.DARK_GRAY); btnUpdate.setForeground(Color.WHITE); btnUpdate.setBounds(518, 523, 89, 23); panel3.add(btnUpdate); JButton btnRemove = new JButton("Remove"); btnRemove.setFont(new Font("Ubuntu", Font.PLAIN, 12)); btnRemove.setBackground(Color.DARK_GRAY); btnRemove.setForeground(Color.WHITE); btnRemove.setBounds(676, 523, 89, 23); panel3.add(btnRemove); JLabel lblSelectMemberType = new JLabel("Select Member Type"); lblSelectMemberType.setForeground(Color.WHITE); lblSelectMemberType.setFont(new Font("Ubuntu", Font.PLAIN, 13)); lblSelectMemberType.setBounds(97, 39, 149, 21); panel3.add(lblSelectMemberType); JPanel panel1 = new JPanel(); panel1.setBorder(new LineBorder(Color.BLUE)); panel1.setBackground(Color.DARK_GRAY); panel1.setBounds(14, 187, 1340, 568); contentPane.add(panel1); panel1.setVisible(true); panel1.setLayout(null); JComboBox cmbMemType = new JComboBox(MemberType); cmbMemType.setForeground(Color.WHITE); cmbMemType.setFont(new Font("Ubuntu", Font.PLAIN, 13)); cmbMemType.setBorder(emptyBorder); cmbMemType.setBackground(Color.DARK_GRAY); cmbMemType.setBounds(449, 39, 146, 25); panel1.add(cmbMemType); JButton btnView = new JButton("View Members"); btnView.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { String Type = cmbMemType.getSelectedItem().toString(); try { if (Type == "Students") { String Query = "select t2.MemID, t1.FullName, t1.Address, t1.DOB, t1.NIC, t1.Sex, t1.ContactNo, t1.CurrentGrade, t1.CurrentClass from StudentsMF t1, LibMem t2 where t1.RegNo = t2.RegNoS"; PreparedStatement pst = connection.prepareStatement(Query); ResultSet rs = pst.executeQuery(); table.setModel(DbUtils.resultSetToTableModel(rs)); rs.close(); pst.close(); } else if (Type == "Teachers") { String Query = "select t2.MemID, t1.Name, t1.Adress, t1.DOB, t1.NIC, t1.Sex, t1.ContactNo, t1.TGrade, t1.Type from TeachersMF t1, LibMem t2 where t1.RegNo = t2.RegNoT"; PreparedStatement pst = connection.prepareStatement(Query); ResultSet rs = pst.executeQuery(); table.setModel(DbUtils.resultSetToTableModel(rs)); rs.close(); pst.close(); } } catch (Exception e) { e.printStackTrace(); } } }); btnView.setForeground(Color.WHITE); btnView.setBackground(Color.DARK_GRAY); btnView.setFont(new Font("Ubuntu", Font.PLAIN, 13)); btnView.setBounds(736, 36, 131, 30); panel1.add(btnView); JScrollPane scrollPane = new JScrollPane(); scrollPane.setBounds(10, 99, 1320, 458); panel1.add(scrollPane); table = new JTable(); table.setGridColor(Color.GRAY); table.setFont(new Font("Ubuntu", Font.PLAIN, 11)); table.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); table.setBackground(Color.WHITE); table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); scrollPane.setViewportView(table); JPanel panel2 = new JPanel(); panel2.setBorder(new LineBorder(Color.BLUE)); panel2.setBackground(Color.DARK_GRAY); panel2.setBounds(14, 187, 1340, 568); contentPane.add(panel2); panel2.setLayout(null); JLabel lblISBN = new JLabel("Registration Number"); lblISBN.setForeground(Color.WHITE); lblISBN.setFont(new Font("Ubuntu", Font.PLAIN, 13)); lblISBN.setBounds(232, 183, 142, 22); panel2.add(lblISBN); txtRegNo = new JTextField(); txtRegNo.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); txtRegNo.setBackground(Color.GRAY); txtRegNo.setForeground(Color.WHITE); txtRegNo.setFont(new Font("Ubuntu", Font.PLAIN, 13)); txtRegNo.setBounds(413, 182, 208, 24); txtRegNo.setBorder(emptyBorder); panel2.add(txtRegNo); txtRegNo.setColumns(10); txtPassword = new JTextField(); txtPassword.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); txtPassword.setForeground(Color.WHITE); txtPassword.setFont(new Font("Ubuntu", Font.PLAIN, 13)); txtPassword.setBorder(emptyBorder); txtPassword.setColumns(10); txtPassword.setBackground(Color.GRAY); txtPassword.setBounds(413, 214, 208, 24); panel2.add(txtPassword); JLabel lblName = new JLabel("Password"); lblName.setForeground(Color.WHITE); lblName.setFont(new Font("Ubuntu", Font.PLAIN, 13)); lblName.setBounds(232, 215, 142, 22); panel2.add(lblName); JLabel lblNicNumber = new JLabel("Re-Enter Password"); lblNicNumber.setForeground(Color.WHITE); lblNicNumber.setFont(new Font("Ubuntu", Font.PLAIN, 13)); lblNicNumber.setBounds(232, 248, 142, 22); panel2.add(lblNicNumber); txtRPassword = new JTextField(); txtRPassword.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); txtRPassword.setForeground(Color.WHITE); txtRPassword.setFont(new Font("Ubuntu", Font.PLAIN, 13)); txtRPassword.setBorder(emptyBorder); txtRPassword.setColumns(10); txtRPassword.setBackground(Color.GRAY); txtRPassword.setBounds(413, 247, 208, 24); panel2.add(txtRPassword); JButton btnClear = new JButton("Clear"); btnClear.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { clearFeilds(); } }); btnClear.setForeground(Color.WHITE); btnClear.setFont(new Font("Ubuntu", Font.PLAIN, 13)); btnClear.setBackground(Color.DARK_GRAY); btnClear.setBounds(474, 344, 110, 32); panel2.add(btnClear); JButton btnAddMember = new JButton("Add Member"); btnAddMember.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (!txtRPassword.getText().equals("") || !txtPassword.getText().equals("") || !txtRegNo.getText().equals("")) { if (txtPassword.getText().equals(txtRPassword.getText())) { try { LibMemberDM mDM = new LibMemberDM(); LibMember member = new LibMember(); member.setMemID(txtRegNo.getText()); member.setPassword(txtPassword.getText()); // checking whether RegNo exist in the database { String query1 = "select RegNo from TeachersMF where RegNo=?"; String query2 = "select RegNo from StudentsMF where RegNo=?"; PreparedStatement pst1 = connection.prepareStatement(query1); pst1.setString(1, member.getMemID()); PreparedStatement pst2 = connection.prepareStatement(query2); pst2.setString(1, member.getMemID()); ResultSet rs1 = pst1.executeQuery(); ResultSet rs2 = pst2.executeQuery(); int count1 = 0, count2 = 0; while (rs1.next()) count1++; while (rs2.next()) count2++; if (count1 == 0 && count2 == 0) JOptionPane.showMessageDialog( null, "Registration Number does not exist!", "Error", JOptionPane.WARNING_MESSAGE); else if (count1 == 1 && count2 == 0) { String query3 = "select MemID from LibMem where MemID='" + member.getMemID() + "'"; PreparedStatement pst3 = connection.prepareStatement(query3); ResultSet rs3 = pst3.executeQuery(); int count3 = 0; while (rs3.next()) count3++; if (count3 != 0) JOptionPane.showMessageDialog(null, "User Already Exist!"); else if (count3 == 0) { if (mDM.insertMemberT(member)) { JOptionPane.showMessageDialog(null, "Successful"); clearFeilds(); } else JOptionPane.showMessageDialog(null, "Failed"); rs3.close(); pst3.close(); } } else if (count1 == 0 && count2 == 1) { String query6 = "select * from LibMem where MemID='" + member.getMemID() + "'"; PreparedStatement pst5 = connection.prepareStatement(query6); ResultSet rs4 = pst5.executeQuery(); int count3 = 0; while (rs4.next()) count3++; if (count3 != 0) JOptionPane.showMessageDialog(null, "User Already Exist!"); else if (count3 == 0) { if (mDM.insertMemberS(member)) { JOptionPane.showMessageDialog(null, "Successful"); clearFeilds(); } else JOptionPane.showMessageDialog(null, "Failed"); rs4.close(); pst5.close(); } } rs1.close(); rs2.close(); pst1.close(); pst2.close(); } catch (Exception x) { JOptionPane.showMessageDialog(null, x); System.out.println(x); } } else JOptionPane.showMessageDialog(null, "Passwords do not Match"); } else JOptionPane.showMessageDialog(null, "Fill in All the Details"); } }); btnAddMember.setFont(new Font("Ubuntu", Font.PLAIN, 13)); btnAddMember.setBackground(Color.DARK_GRAY); btnAddMember.setForeground(Color.WHITE); btnAddMember.setBounds(265, 344, 125, 32); panel2.add(btnAddMember); JLabel label = new JLabel(""); label.setIcon( new ImageIcon(MembersManagement.class.getResource("/Resources/sign-up-icon.png"))); label.setBounds(856, 140, 256, 226); panel2.add(label); panel2.setVisible(false); // Creating Tab Buttons of Tabs Pane JButton btnEditStudentDetails = new JButton("Edit Member Details"); JButton btnAddStudents = new JButton("Add Members"); JButton btnViewStudents = new JButton("View Members"); btnViewStudents.setFont(new Font("Ubuntu", Font.PLAIN, 13)); btnViewStudents.setForeground(Color.WHITE); btnViewStudents.setBackground(Color.BLUE); btnViewStudents.setBounds(14, 164, 124, 23); contentPane.add(btnViewStudents); btnAddStudents.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (btnAddStudents.hasFocus()) { btnAddStudents.setBackground(Color.BLUE); btnAddStudents.setForeground(Color.WHITE); btnViewStudents.setBackground(Color.DARK_GRAY); btnViewStudents.setForeground(Color.WHITE); btnEditStudentDetails.setBackground(Color.DARK_GRAY); btnEditStudentDetails.setForeground(Color.WHITE); } if (panel2.isVisible() == false) { panel2.setVisible(true); panel1.setVisible(false); panel3.setVisible(false); } } }); btnAddStudents.setForeground(Color.WHITE); btnAddStudents.setBorder(BorderFactory.createLineBorder(Color.BLUE)); btnAddStudents.setFont(new Font("Ubuntu", Font.PLAIN, 13)); btnAddStudents.setBackground(Color.DARK_GRAY); btnAddStudents.setBounds(137, 164, 144, 23); contentPane.add(btnAddStudents); btnEditStudentDetails.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (btnEditStudentDetails.hasFocus()) { btnEditStudentDetails.setBackground(Color.BLUE); btnEditStudentDetails.setForeground(Color.WHITE); btnAddStudents.setBackground(Color.DARK_GRAY); btnAddStudents.setForeground(Color.WHITE); btnViewStudents.setBackground(Color.DARK_GRAY); btnViewStudents.setForeground(Color.WHITE); } if (panel3.isVisible() == false) { panel3.setVisible(true); panel1.setVisible(false); panel2.setVisible(false); } } }); btnEditStudentDetails.setForeground(Color.WHITE); btnEditStudentDetails.setBorder(BorderFactory.createLineBorder(Color.BLUE)); btnEditStudentDetails.setFont(new Font("Ubuntu", Font.PLAIN, 13)); btnEditStudentDetails.setBackground(Color.DARK_GRAY); btnEditStudentDetails.setBounds(280, 164, 169, 23); contentPane.add(btnEditStudentDetails); btnViewStudents.setBorder(BorderFactory.createLineBorder(Color.BLUE)); btnViewStudents.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (btnViewStudents.hasFocus()) { btnViewStudents.setBackground(Color.BLUE); btnViewStudents.setForeground(Color.WHITE); btnAddStudents.setBackground(Color.DARK_GRAY); btnAddStudents.setForeground(Color.WHITE); btnEditStudentDetails.setBackground(Color.DARK_GRAY); btnEditStudentDetails.setForeground(Color.WHITE); } if (panel1.isVisible() == false) { panel1.setVisible(true); panel2.setVisible(false); panel3.setVisible(false); } } }); }
public FoodEditor(JFrame parent, RItem data) { super(parent, "Scroll Editor: " + data.id); this.data = data; JPanel itemProps = new JPanel(); GroupLayout layout = new GroupLayout(itemProps); itemProps.setLayout(layout); layout.setAutoCreateGaps(true); JLabel nameLabel = new JLabel("Name: "); JLabel costLabel = new JLabel("Cost: "); JLabel colorLabel = new JLabel("Color: "); JLabel charLabel = new JLabel("Character: "); JLabel weightLabel = new JLabel("Weight: "); JLabel spellLabel = new JLabel("Spell: "); nameField = new JTextField(15); costField = new JFormattedTextField(NeonFormat.getIntegerInstance()); colorBox = new JComboBox<String>(ColorFactory.getColorNames()); colorBox.setBackground(Color.black); colorBox.setRenderer(new ColorCellRenderer()); colorBox.addActionListener(new ColorListener(colorBox)); charField = new JFormattedTextField(getMaskFormatter("*", 'X')); weightField = new JFormattedTextField(NeonFormat.getFloatInstance()); spellBox = new JComboBox<String>(loadSpells()); JLabel nameHelpLabel = HelpLabels.getNameHelpLabel(); JLabel costHelpLabel = HelpLabels.getCostHelpLabel(); JLabel colorHelpLabel = HelpLabels.getColorHelpLabel(); JLabel charHelpLabel = HelpLabels.getCharHelpLabel(); JLabel weightHelpLabel = HelpLabels.getWeightHelpLabel(); JLabel foodHelpLabel = HelpLabels.getFoodEffectHelpLabel(); layout.setVerticalGroup( layout .createSequentialGroup() .addGroup( layout .createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(nameLabel) .addComponent(nameField) .addComponent(nameHelpLabel)) .addGroup( layout .createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(costLabel) .addComponent(costField) .addComponent(costHelpLabel)) .addGroup( layout .createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(colorLabel) .addComponent(colorBox) .addComponent(colorHelpLabel)) .addGroup( layout .createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(charLabel) .addComponent(charField) .addComponent(charHelpLabel)) .addGroup( layout .createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(weightLabel) .addComponent(weightField) .addComponent(weightHelpLabel)) .addGroup( layout .createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(spellLabel) .addComponent(spellBox) .addComponent(foodHelpLabel))); layout.setHorizontalGroup( layout .createSequentialGroup() .addGroup( layout .createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(nameLabel) .addComponent(costLabel) .addComponent(colorLabel) .addComponent(charLabel) .addComponent(weightLabel) .addComponent(spellLabel)) .addGroup( layout .createParallelGroup(GroupLayout.Alignment.LEADING, false) .addComponent( nameField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(costField) .addComponent(colorBox) .addComponent(charField) .addComponent(weightField) .addComponent(spellBox)) .addGap(10) .addGroup( layout .createParallelGroup(GroupLayout.Alignment.LEADING, false) .addComponent(nameHelpLabel) .addComponent(costHelpLabel) .addComponent(colorHelpLabel) .addComponent(charHelpLabel) .addComponent(weightHelpLabel) .addComponent(foodHelpLabel))); JScrollPane propScroller = new JScrollPane(itemProps); propScroller.setBorder(new TitledBorder("Properties")); frame.add(propScroller, BorderLayout.CENTER); }
private void jbInit() throws Exception { this.getContentPane().setLayout(null); this.setSize(new Dimension(1024, 768)); welcomeNote.setBounds(new Rectangle(10, 10, 1000, 180)); welcomeNote.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED)); welcomeNote.setLayout(null); welcomeNote.setBackground(new Color(255, 198, 132)); jLabel1.setBounds(new Rectangle(5, 10, 995, 150)); jLabel1.setHorizontalAlignment(SwingConstants.CENTER); jLabel1.setFont(new Font("Tahoma", 1, 75)); jLabel1.setHorizontalTextPosition(SwingConstants.CENTER); PaymentPanel.setLayout(null); PaymentPanel.setSize(new Dimension(553, 404)); header.setText("Payment Details"); header.setBounds(new Rectangle(140, 10, 260, 45)); header.setFont(new Font("Tahoma", 0, 30)); header.setHorizontalAlignment(SwingConstants.CENTER); cardNo.setText("Card no :"); cardNo.setBounds(new Rectangle(20, 90, 135, 25)); cardNo.setFont(new Font("Tahoma", 0, 18)); cardNo.setHorizontalAlignment(SwingConstants.CENTER); holderName.setText("Holder name :"); holderName.setBounds(new Rectangle(20, 125, 135, 25)); holderName.setFont(new Font("Tahoma", 0, 18)); holderName.setHorizontalAlignment(SwingConstants.CENTER); bankName.setText("Bank name :"); bankName.setBounds(new Rectangle(20, 165, 135, 25)); bankName.setFont(new Font("Tahoma", 0, 18)); bankName.setHorizontalAlignment(SwingConstants.CENTER); validUpto.setText("Valid upto:"); validUpto.setBounds(new Rectangle(20, 240, 135, 25)); validUpto.setFont(new Font("Tahoma", 0, 18)); validUpto.setHorizontalAlignment(SwingConstants.CENTER); cardNoText.setBounds(new Rectangle(170, 90, 235, 25)); // jTextField2.setBounds(new Rectangle(170, 160, 235, 25)); bankNameText.setBounds(new Rectangle(170, 160, 235, 25)); // jTextField4.setBounds(new Rectangle(170, 125, 235, 25)); holderNameText.setBounds(new Rectangle(170, 125, 235, 25)); cardType.setText("Card Type :"); cardType.setBounds(new Rectangle(25, 200, 135, 25)); cardType.setFont(new Font("Tahoma", 0, 18)); cardType.setHorizontalAlignment(SwingConstants.CENTER); cardTypeBox.setBounds(new Rectangle(170, 200, 235, 25)); cardTypeBox.setSelectedIndex(-1); cardTypeBox.setBackground(Color.white); reset.setText("RESET"); reset.setBounds(new Rectangle(305, 305, 110, 25)); reset.setFont(new Font("Tahoma", 1, 11)); reset.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { reset_actionPerformed(e); } }); submit.setText("SUBMIT"); submit.setBounds(new Rectangle(150, 305, 110, 25)); submit.setFont(new Font("Tahoma", 1, 11)); submit.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { submit_actionPerformed(e); } }); month.setBounds(new Rectangle(205, 240, 90, 20)); month.setSelectedIndex(-1); month.setBackground(Color.white); year.setBounds(new Rectangle(360, 240, 70, 20)); yyyy.setText("YYYY"); yyyy.setBounds(new Rectangle(320, 240, 30, 20)); yyyy.setFont(new Font("Tahoma", 1, 11)); mm.setText("MM"); mm.setBounds(new Rectangle(175, 240, 25, 20)); mm.setFont(new Font("Tahoma", 1, 11)); // PaymentPanel.getContentPane().add(jTextField4, null); // PaymentPanel.getContentPane().add(jTextField2, null); PaymentPanel./*getContentPane().*/ add(mm, null); PaymentPanel.add(yyyy, null); PaymentPanel.add(year, null); PaymentPanel.add(month, null); PaymentPanel.add(submit, null); PaymentPanel.add(reset, null); PaymentPanel.add(cardTypeBox, null); PaymentPanel.add(cardType, null); PaymentPanel.add(holderNameText, null); PaymentPanel.add(bankNameText, null); PaymentPanel.add(cardNoText, null); PaymentPanel.add(validUpto, null); PaymentPanel.add(bankName, null); PaymentPanel.add(holderName, null); PaymentPanel.add(cardNo, null); PaymentPanel.add(header, null); PaymentPanel.setVisible(true); // homeContent.setLineWrap(true); // homeContent.setLineWrap(true); // homeContent.setLineWrap(true); // homeContent.a PaymentPanel.setBounds(new Rectangle(275, 260, 553, 404)); PaymentPanel.setBackground(new Color(245, 184, 141)); PaymentPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); jPanel1.setBounds(new Rectangle(15, 160, 995, 30)); jPanel1.setLayout(gridLayout1); homeButton.setText("HOME"); homeButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { homeButton_actionPerformed(e); } }); menuButton.setText("MENU"); menuButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { menuButton_actionPerformed(e); } }); contactButton.setText("CONTACT"); contactButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { contactButton_actionPerformed(e); } }); locationButton.setText("LOCATIONS"); locationButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { locationButton_actionPerformed(e); } }); orderButton.setText("ORDER"); orderButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { orderButton_actionPerformed(e); } }); feedbackButton.setText("FEEDBACK"); feedbackButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { feedbackButton_actionPerformed(e); } }); aboutusButton.setText("ABOUT US"); aboutusButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { aboutusButton_actionPerformed(e); } }); logoutButton.setText("LOGOUT"); logoutButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { logoutButton_actionPerformed(e); } }); welcomeNote.add(jLabel1, null); jPanel1.add(homeButton, null); jPanel1.add(menuButton, null); jPanel1.add(locationButton, null); jPanel1.add(aboutusButton, null); jPanel1.add(contactButton, null); jPanel1.add(orderButton, null); jPanel1.add(logoutButton, null); jPanel1.add(feedbackButton, null); this.getContentPane().add(jPanel1, null); this.getContentPane().add(welcomeNote, null); // this.setVisible(true); this.getContentPane().add(PaymentPanel, null); this.setSize(new Dimension(1024, 768)); this.setTitle("Payment"); this.setBackground(Color.white); }
private void generateLeftPanelElements() { labelSeason = new JLabel("Season:"); labelSeason.setFont(new Font("Consolas", Font.BOLD, 14)); currentSeason = new JLabel("2012"); currentSeason.setFont(new Font("Consolas", Font.ITALIC, 17)); localTeam = new JComboBox(); localTeam.setFont(new Font("Consolas", Font.PLAIN, 12)); localTeam.setModel(new DefaultComboBoxModel(Teams.getTeamsByYear(CommonGui.DEFAULT_SEASON))); localTeam.setBackground(new Color(204, 204, 204)); awayTeam = new JComboBox(); awayTeam.setFont(new Font("Consolas", Font.PLAIN, 12)); awayTeam.setModel(new DefaultComboBoxModel(Teams.getTeamsByYear(CommonGui.DEFAULT_SEASON))); awayTeam.setBackground(new Color(204, 204, 204)); week = new JSpinner(); week.setModel(new SpinnerNumberModel(1, 1, 50, 1)); week.setFont(new Font("Consolas", Font.PLAIN, 13)); GroupLayout gl_leftPanel = new GroupLayout(leftPanel); gl_leftPanel.setHorizontalGroup( gl_leftPanel .createParallelGroup(Alignment.LEADING) .addGroup( gl_leftPanel .createSequentialGroup() .addContainerGap() .addGroup( gl_leftPanel .createParallelGroup(Alignment.LEADING) .addGroup( gl_leftPanel .createSequentialGroup() .addComponent( labelSeason, GroupLayout.PREFERRED_SIZE, 74, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(currentSeason)) .addGroup( gl_leftPanel .createSequentialGroup() .addComponent( localTeam, GroupLayout.PREFERRED_SIZE, 112, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.UNRELATED) .addComponent( awayTeam, GroupLayout.PREFERRED_SIZE, 112, GroupLayout.PREFERRED_SIZE) .addGap(14) .addComponent( week, GroupLayout.PREFERRED_SIZE, 37, GroupLayout.PREFERRED_SIZE))) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); gl_leftPanel.setVerticalGroup( gl_leftPanel .createParallelGroup(Alignment.LEADING) .addGroup( gl_leftPanel .createSequentialGroup() .addGap(34) .addGroup( gl_leftPanel .createParallelGroup(Alignment.BASELINE) .addComponent( currentSeason, GroupLayout.PREFERRED_SIZE, 28, GroupLayout.PREFERRED_SIZE) .addComponent( labelSeason, GroupLayout.PREFERRED_SIZE, 28, GroupLayout.PREFERRED_SIZE)) .addGap(51) .addGroup( gl_leftPanel .createParallelGroup(Alignment.BASELINE) .addComponent( localTeam, GroupLayout.PREFERRED_SIZE, 26, GroupLayout.PREFERRED_SIZE) .addComponent( awayTeam, GroupLayout.PREFERRED_SIZE, 26, GroupLayout.PREFERRED_SIZE) .addComponent( week, GroupLayout.PREFERRED_SIZE, 26, GroupLayout.PREFERRED_SIZE)) .addGap(11))); leftPanel.setLayout(gl_leftPanel); }
/** Create the frame. */ public GIncidencia() { setIconImage( Toolkit.getDefaultToolkit() .getImage( GIncidencia.class.getResource("/javax/swing/plaf/basic/icons/JavaCup16.png"))); setResizable(false); setTitle(" Ingresar Nueva GIncidencia"); setBounds(100, 100, 887, 575); getContentPane().setLayout(null); lblMensListado2 = new JLabel(""); lblMensListado2.setFont(new Font("Tahoma", Font.PLAIN, 13)); lblMensListado2.setVisible(false); lblMensListado2.setBounds(349, 64, 346, 19); getContentPane().add(lblMensListado2); lblMensListado1 = new JLabel(""); lblMensListado1.setVisible(false); lblMensListado1.setFont(new Font("Tahoma", Font.PLAIN, 13)); lblMensListado1.setBounds(10, 64, 319, 19); getContentPane().add(lblMensListado1); panel = new JPanel(); panel.setVisible(false); panel.setBounds(10, 11, 319, 515); panel.setBackground(new Color(51, 102, 153)); panel.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); getContentPane().add(panel); panel.setLayout(null); btnListado = new JButton("LISTAR"); btnListado.setVisible(false); btnListado.setBackground(SystemColor.controlShadow); btnListado.addActionListener(this); btnListado.setIcon( new ImageIcon( GIncidencia.class.getResource("/com/sun/java/swing/plaf/motif/icons/Warn.gif"))); Incidencia = new JScrollPane(); Incidencia.setVisible(false); Incidencia.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, null, null, null, null)); Incidencia.setBounds(339, 103, 522, 388); getContentPane().add(Incidencia); txtIncidencia = new JTextArea(); txtIncidencia.setFont(new Font("Arial", Font.PLAIN, 17)); txtIncidencia.setToolTipText(""); Incidencia.setViewportView(txtIncidencia); btnLimpiar = new JButton("LIMPIAR"); btnLimpiar.setVisible(false); btnBuscar = new JButton("BUSCAR"); btnBuscar.setVisible(false); btnNuevo = new JButton("NUEVO"); btnNuevo.setVisible(false); btnNuevo.setIcon( new ImageIcon( GIncidencia.class.getResource("/com/sun/java/swing/plaf/windows/icons/File.gif"))); btnNuevo.setBackground(SystemColor.controlShadow); btnNuevo.setBounds(339, 11, 228, 33); getContentPane().add(btnNuevo); btnNuevo.addActionListener(this); btnBuscar.setBackground(SystemColor.controlShadow); btnBuscar.setIcon( new ImageIcon( GIncidencia.class.getResource("/com/sun/java/swing/plaf/windows/icons/Directory.gif"))); btnBuscar.setBounds(339, 11, 228, 33); getContentPane().add(btnBuscar); btnBuscar.addActionListener(this); btnLimpiar.setIcon( new ImageIcon(GIncidencia.class.getResource("/javax/swing/plaf/metal/icons/sortDown.png"))); btnLimpiar.setBackground(SystemColor.controlShadow); btnLimpiar.setBounds(633, 11, 228, 33); getContentPane().add(btnLimpiar); btnLimpiar.addActionListener(this); btnRegistrar = new JButton("REGISTRAR"); btnRegistrar.setVisible(false); btnRegistrar.setIcon( new ImageIcon( GIncidencia.class.getResource( "/com/sun/javafx/webkit/prism/resources/mediaPlayDisabled.png"))); btnRegistrar.setBackground(SystemColor.controlShadow); btnRegistrar.setBounds(339, 55, 522, 37); getContentPane().add(btnRegistrar); btnRegistrar.addActionListener(this); btnModificar = new JButton("MODIFICAR"); btnModificar.setVisible(false); btnModificar.setIcon( new ImageIcon( GIncidencia.class.getResource( "/com/sun/javafx/scene/control/skin/caspian/dialog-more-details.png"))); btnModificar.setBackground(SystemColor.controlShadow); btnModificar.setBounds(339, 55, 522, 37); getContentPane().add(btnModificar); btnModificar.addActionListener(this); btnListado.setBounds(10, 11, 260, 37); getContentPane().add(btnListado); JSeparator separator = new JSeparator(); separator.setBounds(10, 111, 299, 7); panel.add(separator); JSeparator separator_1 = new JSeparator(); separator_1.setBounds(10, 294, 299, 14); panel.add(separator_1); JLabel lblNewLabel = new JLabel("CODIGO DE USUARIO:"); lblNewLabel.setForeground(Color.WHITE); lblNewLabel.setBounds(10, 36, 172, 14); panel.add(lblNewLabel); JLabel lblCodigo = new JLabel("CODIGO DE INCIDENCIA: "); lblCodigo.setForeground(Color.WHITE); lblCodigo.setBounds(10, 11, 172, 14); panel.add(lblCodigo); txtCodigo = new JTextField(); txtCodigo.setFont(new Font("Tahoma", Font.PLAIN, 13)); txtCodigo.setHorizontalAlignment(SwingConstants.RIGHT); txtCodigo.setBackground(SystemColor.controlShadow); txtCodigo.setEditable(false); txtCodigo.setBounds(203, 9, 106, 17); panel.add(txtCodigo); txtCodigo.setColumns(10); txtCodUsu = new JTextField(); txtCodUsu.setFont(new Font("Tahoma", Font.PLAIN, 13)); txtCodUsu.setHorizontalAlignment(SwingConstants.RIGHT); txtCodUsu.setBackground(SystemColor.controlShadow); txtCodUsu.setEditable(false); txtCodUsu.setColumns(10); txtCodUsu.setBounds(203, 34, 106, 17); panel.add(txtCodUsu); JLabel lblCodigoDeEspecialista = new JLabel("CODIGO DE ESPECIALISTA:"); lblCodigoDeEspecialista.setForeground(Color.WHITE); lblCodigoDeEspecialista.setBounds(10, 61, 172, 14); panel.add(lblCodigoDeEspecialista); JLabel lblCodigoDeTipo = new JLabel("CODIGO DE TIPO DE INCIDENCIA:"); lblCodigoDeTipo.setForeground(Color.WHITE); lblCodigoDeTipo.setBounds(10, 86, 188, 14); panel.add(lblCodigoDeTipo); JLabel lblDescripcion = new JLabel("DESCRIPCION:"); lblDescripcion.setForeground(Color.WHITE); lblDescripcion.setBounds(10, 115, 110, 14); panel.add(lblDescripcion); JLabel lblComentariosObservaciones = new JLabel("COMENTARIOS / OBSERVACIONES:"); lblComentariosObservaciones.setForeground(Color.WHITE); lblComentariosObservaciones.setBounds(10, 198, 188, 28); panel.add(lblComentariosObservaciones); JLabel lblTiempoEstimadoDe = new JLabel("TIEMPO ESTIMADO DE SOLUCION:"); lblTiempoEstimadoDe.setForeground(Color.WHITE); lblTiempoEstimadoDe.setBounds(10, 309, 203, 14); panel.add(lblTiempoEstimadoDe); txtTiempoEstimado = new JTextField(); txtTiempoEstimado.addKeyListener(this); txtTiempoEstimado.setFont(new Font("Tahoma", Font.PLAIN, 13)); txtTiempoEstimado.setHorizontalAlignment(SwingConstants.RIGHT); txtTiempoEstimado.setColumns(10); txtTiempoEstimado.setBounds(215, 306, 94, 17); panel.add(txtTiempoEstimado); JLabel lblTiempoRealDe = new JLabel("TIEMPO REAL DE SOLUCION:"); lblTiempoRealDe.setForeground(Color.WHITE); lblTiempoRealDe.setBounds(10, 337, 172, 14); panel.add(lblTiempoRealDe); txtTiempoReal = new JTextField(); txtTiempoReal.addKeyListener(this); txtTiempoReal.setFont(new Font("Tahoma", Font.PLAIN, 13)); txtTiempoReal.setHorizontalAlignment(SwingConstants.RIGHT); txtTiempoReal.setColumns(10); txtTiempoReal.setBounds(215, 334, 94, 17); panel.add(txtTiempoReal); JLabel lblFechaDeRegistro = new JLabel("FECHA DE REGISTRO:"); lblFechaDeRegistro.setForeground(Color.WHITE); lblFechaDeRegistro.setBounds(10, 365, 172, 14); panel.add(lblFechaDeRegistro); txtFecRegistro = new JTextField(); txtFecRegistro.setFont(new Font("Tahoma", Font.PLAIN, 13)); txtFecRegistro.setHorizontalAlignment(SwingConstants.RIGHT); txtFecRegistro.setBackground(SystemColor.controlShadow); txtFecRegistro.setEditable(false); txtFecRegistro.setColumns(10); txtFecRegistro.setBounds(181, 362, 128, 17); panel.add(txtFecRegistro); JLabel lblFechaDeInicio = new JLabel("FECHA DE INICIO DE ATENCION:"); lblFechaDeInicio.setForeground(Color.WHITE); lblFechaDeInicio.setBounds(10, 393, 188, 14); panel.add(lblFechaDeInicio); try { MaskFormatter mascara = new MaskFormatter("##-##-####"); mascara.setPlaceholderCharacter(' '); txtFecInicio = new JFormattedTextField(mascara); txtFecInicio.setHorizontalAlignment(SwingConstants.RIGHT); txtFecInicio.setFont(new Font("Tahoma", Font.PLAIN, 13)); txtFecInicio.setBounds(215, 390, 100, 17); panel.add(txtFecInicio); } catch (Exception e) { e.printStackTrace(); } JLabel lblFechaDeFin = new JLabel("FECHA FINAL DE ATENCION:"); lblFechaDeFin.setForeground(Color.WHITE); lblFechaDeFin.setBounds(10, 421, 172, 14); panel.add(lblFechaDeFin); try { MaskFormatter mascara = new MaskFormatter("##-##-####"); mascara.setPlaceholderCharacter(' '); txtFecFinal = new JFormattedTextField(mascara); txtFecFinal.setHorizontalAlignment(SwingConstants.RIGHT); txtFecFinal.setFont(new Font("Tahoma", Font.PLAIN, 13)); txtFecFinal.setBounds(215, 418, 100, 17); panel.add(txtFecFinal); } catch (Exception e) { e.printStackTrace(); } JLabel lblEstado = new JLabel("ESTADO:"); lblEstado.setForeground(Color.WHITE); lblEstado.setBounds(10, 449, 86, 14); panel.add(lblEstado); cboEstado = new JComboBox(); cboEstado.setFont(new Font("Tahoma", Font.PLAIN, 13)); cboEstado.setBackground(UIManager.getColor("Button.background")); cboEstado.setModel( new DefaultComboBoxModel(new String[] {"Registrada", "Iniciada", "Cancelada", "Cerrada"})); cboEstado.setBounds(137, 446, 172, 20); panel.add(cboEstado); JScrollPane scrollPane_1 = new JScrollPane(); scrollPane_1.setBounds(10, 129, 299, 69); panel.add(scrollPane_1); txtDescripcion = new JTextArea(); txtDescripcion.addKeyListener(this); txtDescripcion.setFont(new Font("Arial", Font.PLAIN, 19)); scrollPane_1.setViewportView(txtDescripcion); JScrollPane scrollPane_2 = new JScrollPane(); scrollPane_2.setBounds(10, 220, 299, 69); panel.add(scrollPane_2); txtObservacion = new JTextArea(); txtObservacion.addKeyListener(this); txtObservacion.setFont(new Font("Arial", Font.PLAIN, 19)); scrollPane_2.setViewportView(txtObservacion); cboEspecialista = new JComboBox(); cboEspecialista.setFont(new Font("Tahoma", Font.PLAIN, 13)); cboEspecialista.setBounds(203, 58, 106, 20); cboEspecialista.addItem(""); panel.add(cboEspecialista); cboTipoInc = new JComboBox(); cboTipoInc.setFont(new Font("Tahoma", Font.PLAIN, 13)); cboTipoInc.setBounds(203, 83, 106, 20); cboTipoInc.addItem(""); panel.add(cboTipoInc); btnImprimir = new JButton("IMPRIMIR"); btnImprimir.addActionListener(this); btnImprimir.setIcon( new ImageIcon(GIncidencia.class.getResource("/sun/print/resources/orientLandscape.png"))); btnImprimir.setBounds(633, 493, 228, 33); getContentPane().add(btnImprimir); Listado = new JScrollPane(TablaIncidencias); Listado.setVisible(false); Listado.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, null, null, null, null)); JViewport viewport = new JViewport(); Listado.setRowHeaderView(viewport); Listado.setBounds(10, 99, 861, 347); getContentPane().add(Listado); TablaIncidencias = new JTable(); TablaIncidencias.setFont(new Font("Tahoma", Font.PLAIN, 13)); TablaIncidencias.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); Listado.setViewportView(TablaIncidencias); columnas(); tamañoColumnas(); llenaCampos(); }
public SyntaxTab() { super(new BorderLayout(), "Syntax highlighting"); /* * upper checkboxes */ JPanel upper = new JPanel(new GridLayout(2, 1, 0, 0)); upper.setOpaque(false); upper.add(MyPanel.wrap(highlightSyntax)); upper.add(MyPanel.wrap(matchBracket)); highlightSyntax.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent ev) { SyntaxTab.this.updateComponentStatus(); } }); this.add(upper, BorderLayout.PAGE_START); /* * upper panel (painters) */ painterComboBox.setSelectedItem(myjava.gui.syntax.Painter.getCurrentInstance()); painterComboBox.setFont(f13); if (isMetal) painterComboBox.setBackground(Color.WHITE); painterComboBox.addItemListener(this.painterChangeListener); JButton addPainter = new MyButton("+") { { if (isMetal) { this.setPreferredSize(new Dimension(28, 28)); } } @Override public void actionPerformed(ActionEvent ev) { String name; do { name = JOptionPane.showInputDialog( SyntaxTab.this, "Enter a name:", "Name", JOptionPane.QUESTION_MESSAGE); } while (!myjava.gui.syntax.Painter.isValidPrompt(name, SyntaxTab.this)); if ((name != null) && (!name.isEmpty())) { // name is valid, neither cancelled nor pressed enter directly myjava.gui.syntax.Painter newPainter = ((myjava.gui.syntax.Painter) (painterComboBox.getSelectedItem())) .newInstance(name); addPainter(newPainter); System.out.println("now set, should call listener"); painterComboBox.setSelectedItem(newPainter); // auto-call ItemListener(s) } } }; JButton removePainter = new MyButton("-") { { if (isMetal) { this.setPreferredSize(new Dimension(28, 28)); } } @Override public void actionPerformed(ActionEvent ev) { myjava.gui.syntax.Painter painter = (myjava.gui.syntax.Painter) (painterComboBox.getSelectedItem()); if (painter.equals(myjava.gui.syntax.Painter.getDefaultInstance())) { JOptionPane.showMessageDialog( SyntaxTab.this, "The default painter cannot be removed.", "Error", JOptionPane.ERROR_MESSAGE); } else { int option = JOptionPane.showConfirmDialog( SyntaxTab.this, "Remove painter \"" + painter.getName() + "\"?", "Confirm", JOptionPane.YES_NO_OPTION); if (option == JOptionPane.YES_OPTION) { // remove "painter" removedPainters.add(painter); painterComboBox.removeItemListener(painterChangeListener); painterComboBox.setSelectedItem(myjava.gui.syntax.Painter.getDefaultInstance()); painterComboBox.removeItem(painter); for (Iterator<EntryListPanel> it = listPanelSet.iterator(); it.hasNext(); ) { EntryListPanel panel = it.next(); if (panel.getPainter().getName().equals(painter.getName())) { System.out.println("removing, then break"); it.remove(); centerPanel.remove(panel); break; } } painterComboBox.addItemListener(painterChangeListener); cardLayout.show( centerPanel, myjava.gui.syntax.Painter.getDefaultInstance().getName()); } } } }; // lower part JPanel center = new JPanel(new BorderLayout()); JLabel selectLabel = new MyLabel("Selected painter:"); center.add( MyPanel.wrap(MyPanel.CENTER, selectLabel, painterComboBox, addPainter, removePainter), BorderLayout.PAGE_START); componentSet.addAll(Arrays.asList(selectLabel, addPainter, removePainter)); center.add(centerPanel, BorderLayout.CENTER); this.add(center, BorderLayout.CENTER); cardLayout.show(centerPanel, myjava.gui.syntax.Painter.getCurrentInstance().getName()); }
private JPanel createShopPanel() { JPanel pan = new JPanel(); pan.setLayout(new GridBagLayout()); Font labelFont = new Font(Font.SERIF, Font.BOLD, 20); JLabel lCustomer = new JLabel("Customer"); lCustomer.setFont(labelFont); JComboBox<String> tClient = new JComboBox<>(); tClient.addItem("New Client"); for (Client client : shop.getClients()) { tClient.addItem(client.getFullName()); } // tClient.setColumns(15); tClient.setBackground(Color.WHITE); pan.add( lCustomer, new GridBagConstraints( 0, 0, 1, 1, 0, 0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(0, 0, 15, 15), 0, 0)); pan.add( tClient, new GridBagConstraints( 1, 0, 1, 1, 0, 0, GridBagConstraints.LINE_START, 0, new Insets(0, 0, 15, 0), 0, 0)); JLabel model = new JLabel("Model"); JLabel engineType = new JLabel("Engine Type"); model.setFont(new Font(Font.SERIF, Font.BOLD, 15)); engineType.setFont(new Font(Font.SERIF, Font.BOLD, 15)); pan.add( model, new GridBagConstraints( 1, 1, 1, 1, 0, 0, GridBagConstraints.LINE_START, 0, new Insets(0, 0, 0, 0), 0, 0)); pan.add( engineType, new GridBagConstraints( 2, 1, 1, 1, 0, 0, GridBagConstraints.LINE_START, 0, new Insets(0, 25, 0, 0), 0, 0)); // ButtonGroup bg = new ButtonGroup(); // JPanel radioPanel = new JPanel(); JLabel lProduct = new JLabel("Car"); lProduct.setFont(labelFont); JComboBox<String> cars = new JComboBox<>(); fillFieldCars(cars); // radioPanel.setLayout(new GridLayout(3, 0)); // ActionListener rbListener = new RBListener(); // for (int i=0; i<shop.getCars().size(); i++) { // Car car = shop.getCars().get(i); // // JRadioButton rb = new JRadioButton(car.getManufacturer().toString() + " // "+car.getModel().toString()); // rb.setActionCommand(String.valueOf(i)); // rb.addActionListener(rbListener); // // if (i==0) { // rb.setSelected(true); // } // // bg.add(rb); // radioPanel.add(rb); // // } // cars.addActionListener(new ActionListener() { // @Override // public void actionPerformed(ActionEvent e) { // // } // }); JComboBox<EngineKind> engine = new JComboBox<>(); engine.addItem(shop.getCars().get(indexProduct).getEngineKind()); pan.add( lProduct, new GridBagConstraints( 0, 2, 1, 1, 0, 0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); pan.add( cars, new GridBagConstraints( 1, 2, 1, 1, 0, 0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); pan.add( engine, new GridBagConstraints( 2, 2, 1, 1, 0, 0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(0, 25, 0, 0), 0, 0)); JButton buy = new JButton("Buy"); buy.setFont(labelFont); pan.add( buy, new GridBagConstraints( 3, 5, 1, 1, 0, 0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(30, 0, 0, 0), 0, 0)); JButton returns = new JButton("Back"); returns.setFont(labelFont); pan.add( returns, new GridBagConstraints( 0, 5, 1, 1, 0, 0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(30, 0, 0, 0), 0, 0)); JLabel lPrice = new JLabel("Price"); lPrice.setFont(labelFont); pan.add( lPrice, new GridBagConstraints( 0, 4, 1, 1, 0, 0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(20, 0, 0, 0), 0, 0)); double price = shop.getCars().get(indexProduct).getPrice(); JTextField lPriceValue = new JTextField(); lPriceValue.setFont(new Font(Font.MONOSPACED, Font.BOLD, 20)); lPriceValue.setText(Double.toString(price) + " $"); lPriceValue.setEditable(false); pan.add( lPriceValue, new GridBagConstraints( 1, 4, 1, 1, 0, 0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(20, 0, 0, 0), 0, 0)); cars.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String carName = cars.getItemAt(cars.getSelectedIndex()); engine.removeAllItems(); for (Car car : shop.getCars()) { if ((car.getManufacturer() + " " + car.getModel()).equals(carName)) { EngineKind en = car.getEngineKind(); engine.addItem(en); } } } }); engine.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String carName = cars.getItemAt(cars.getSelectedIndex()); for (Car car : shop.getCars()) { if ((car.getManufacturer() + " " + car.getModel()).equals(carName) && car.getEngineKind().equals(engine.getItemAt(engine.getSelectedIndex()))) { double price = car.getPrice(); lPriceValue.setText(Double.toString(price) + " $"); return; } } } }); buy.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String name = tClient.getSelectedItem().toString(); System.out.println(name); Client client = shop.findClient(name); // if (client == null) { new NewClientUI(shop); frame.dispose(); } else { Car car = getCarFromStorage(cars, engine); if (car.getCount() == 0) { new CarIsNotAvailableUI(); return; } shop.sellAuto(car, client); new TableTransaction(shop); frame.dispose(); } } }); returns.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { new TableTransaction(shop); frame.dispose(); } }); return pan; }
public JPanel Panel() throws IOException { new ImageGet(); Image bgp = ImageGet.getImageByState("arrival"); background = new ImageIcon(bgp); p1.setBounds(0, 0, 942, 821); int b2size = 16; final MTextfield t1 = new MTextfield(); t1.setText(emPO.getPosID()); t1.setOpaque(false); t1.setBorder(BorderFactory.createEmptyBorder()); t1.setEditable(false); final MTextfield t2 = new MTextfield(); t2.setOpaque(false); t2.setBorder(BorderFactory.createEmptyBorder()); Color text = new Color(175, 172, 172); String[] site = {"南京", "上海", "北京", "广州"}; final JComboBox sitebox = new JComboBox(site); sitebox.setBackground(text); sitebox.setForeground(Color.white); String[] state = {"损坏", "完整", "丢失"}; final JComboBox statebox = new JComboBox(state); statebox.setBackground(text); statebox.setForeground(Color.white); String[] columnnames = {"", "", "", "", ""}; Object[][] data = {}; DefaultTableModel model = new DefaultTableModel(data, columnnames); final JTable table = new JTable(model) { public Component prepareRenderer(TableCellRenderer renderer, int row, int column) { Component c = super.prepareRenderer(renderer, row, column); if (c instanceof JComponent) { ((JComponent) c).setOpaque(false); } return c; } }; table.setForeground(Color.white); table.setOpaque(false); table.setRowHeight(31); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); TableColumn yytidColumn = table.getColumnModel().getColumn(0); TableColumn dateColumn = table.getColumnModel().getColumn(1); TableColumn siteColumn = table.getColumnModel().getColumn(2); TableColumn stateColumn = table.getColumnModel().getColumn(3); TableColumn zzzxidColumn = table.getColumnModel().getColumn(4); yytidColumn.setPreferredWidth(87); dateColumn.setPreferredWidth(87); siteColumn.setPreferredWidth(78); stateColumn.setPreferredWidth(80); zzzxidColumn.setPreferredWidth(118); table.getTableHeader().setOpaque(false); JScrollPane jp = new JScrollPane(table); jp.setOpaque(false); jp.getViewport().setOpaque(false); final JTextField time = new JTextField(); Calendar c = Calendar.getInstance(); Date d = c.getTime(); final DatePicker datepick = new DatePicker(time, d); datepick.setOpaque(false); // datepick.setLocale(Locale.CHINA);//设置显示语言 datepick.setPattern("yyyy-MM-dd"); // 设置日期格式化字符串 datepick.setEditorable(false); // 设置是否可编辑 datepick.setPreferredSize(new Dimension(150, 38)); // 设置大小 JButton b4 = new JButton(); b4.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { String date = datepick.getText(); String place = (String) sitebox.getSelectedItem(); String state = (String) statebox.getSelectedItem(); HallArrivalDocu bussari = new HallArrivalDocu(oos, ois); BussinessArrivalDocuPO badpo = new BussinessArrivalDocuPO(date, t2.getText(), place, state, t1.getText()); // System.out.println(date+" "+t2.getText()+" "+place+" "+state+" // "+t1.getText()); // System.out.println(badpo.getArrivaltime()+badpo.getBussinessID()); boolean isok = bussari.BuildHallArrivalDocu(badpo); System.out.println(isok); Object[] add = {date, t2.getText(), place, state, t1.getText()}; DefaultTableModel model = (DefaultTableModel) table.getModel(); model.insertRow(model.getRowCount(), add); // System.out.println(model.getRowCount()); } }); JButton b5 = new JButton(); b5.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub // ��ȡҪɾ�����,û��ѡ����-1 DefaultTableModel model = (DefaultTableModel) table.getModel(); int row = table.getSelectedRow(); // System.out.println(row); if (row == -1) { Mdialog.showMessageDialog("请选中要删除的行!"); } else { model.removeRow(row); } } }); JButton b6 = new JButton(); b6.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { Mdialog.showMessageDialog("成功建立到达单!"); } }); p1.setOpaque(false); p1.setLayout(null); // p1.add(l1); // p1.add(l2); // // p1.add(l3); // p1.add(l4); // p1.add(l5); // p1.add(l6); // p1.add(l7); // p1.add(l8); p1.add(t1); p1.add(t2); p1.add(datepick); p1.add(sitebox); p1.add(statebox); p1.add(b4); p1.add(b5); p1.add(b6); p1.add(jp); b4.setContentAreaFilled(false); b4.setBorder(BorderFactory.createEmptyBorder()); b5.setContentAreaFilled(false); b5.setBorder(BorderFactory.createEmptyBorder()); b6.setContentAreaFilled(false); b6.setBorder(BorderFactory.createEmptyBorder()); int xloc = 184, yloc = 128, length = 150, width = 38, interval = 58; t1.settextFont(); t2.settextFont(); t1.setBounds(xloc, yloc, length, width); datepick.setBounds(xloc, yloc + interval, length, width); sitebox.setBounds(xloc, yloc + interval * 2, length, width); statebox.setBounds(xloc, yloc + interval * 3, length, width); t2.setBounds(xloc, yloc + interval * 4, length, width); jp.setBounds(470, 196, 454, 250); b4.setBounds(96, 455, 280, 82); b5.setBounds(723, 471, 187, 66); b6.setBounds(348, 634, 268, 91); return p1; }
public void createDataEditPanelCourse(String CourseNo, String CourseName, String CourseCredit) { this.CourseNo = CourseNo; this.CourseName = CourseName; this.CourseCredit = CourseCredit; Credit = Float.parseFloat(CourseCredit); if (Credit == 0.75) CreditIndex = 0; else if (Credit == 1.50) CreditIndex = 1; else if (Credit == 3.00) CreditIndex = 2; else CreditIndex = 3; DEPC = new JDialog(); DEPC.setTitle("Course Edit Dialog"); Panel = new JPanel() { protected void paintComponent(Graphics g) { super.paintComponent(g); g.drawImage( new ImageIcon(getClass().getResource("/Icons/8.jpg")).getImage(), 0, 0, 600, 230, null); ButtonBorder.paintBorder(this, g, 172, 136, 130, 25); } }; Panel.setForeground(Color.WHITE); Panel.setLayout(null); CourseNoLabel1 = new JLabel("Course No. : "); CourseNoLabel1.setForeground(Color.WHITE); CourseNoLabel1.setFont(new Font("Rockwell Extra Bold", Font.PLAIN, 12)); CourseNoLabel1.setBounds(77, 29, 139, 27); Panel.add(CourseNoLabel1); CourseNoLabel2 = new JLabel(this.CourseNo); CourseNoLabel2.setForeground(Color.WHITE); CourseNoLabel2.setFont(new Font("Rockwell Extra Bold", Font.BOLD, 12)); CourseNoLabel2.setBounds(213, 29, 200, 27); Panel.add(CourseNoLabel2); CourseNameLabel = new JLabel("Course Title :"); CourseNameLabel.setForeground(Color.WHITE); CourseNameLabel.setFont(new Font("Rockwell Extra Bold", Font.PLAIN, 12)); CourseNameLabel.setBounds(77, 56, 139, 26); Panel.add(CourseNameLabel); CourseNameField = new JTextField(this.CourseName); CourseNameField.setForeground(Color.WHITE); CourseNameField.setFont(new Font("Rockwell Extra Bold", Font.PLAIN, 10)); CourseNameField.setBounds(213, 60, 200, 20); CourseNameField.setOpaque(false); CourseNameField.setHorizontalAlignment(SwingConstants.CENTER); Panel.add(CourseNameField); CourseCreditLabel = new JLabel("Course Credit :"); CourseCreditLabel.setForeground(Color.WHITE); CourseCreditLabel.setBounds(77, 87, 139, 26); CourseCreditLabel.setFont(new Font("Rockwell Extra Bold", Font.PLAIN, 12)); Panel.add(CourseCreditLabel); CourseCreditBox = new JComboBox<String>(); CourseCreditBox.setBackground(Color.GRAY); CourseCreditBox.setForeground(new Color(28, 0, 0)); CourseCreditBox.setBounds(213, 91, 103, 20); CourseCreditBox.setBorder(ButtonBorder); CourseCreditBox.addItem("0.75"); CourseCreditBox.addItem("1.50"); CourseCreditBox.addItem("3.00"); CourseCreditBox.addItem("4.00"); CourseCreditBox.setMaximumRowCount(3); CourseCreditBox.setSelectedIndex(CreditIndex); Panel.add(CourseCreditBox); UpdateButton = new JButton("Update"); UpdateButton.setForeground(Color.WHITE); UpdateButton.setFont(new Font("Rockwell Extra Bold", Font.BOLD, 10)); UpdateButton.setBounds(173, 137, 128, 23); UpdateButton.setContentAreaFilled(false); UpdateButton.addActionListener(this); Panel.add(UpdateButton); DEPC.getContentPane().add(Panel); DEPC.setSize(500, 230); DEPC.setLocation(500, 200); DEPC.setResizable(false); DEPC.setVisible(true); DEPC.setModal(true); }
public MyFrame(String title, Color col) { setTitle(title); // title is set in main method setSize(500, 500); // this may need changed but looks ok setLocationRelativeTo(null); // sets the location as the centre of the screen setResizable(false); Container c = getContentPane(); // container to hold the different panels c.setBackground(Color.white); // col from main c.setLayout(null); // no layout selected so we can place anywhere // add to container ImageIcon gameLogo = new ImageIcon( new ImageIcon(getClass().getResource("GameLogobBlank.png")) .getImage() .getScaledInstance(360, 80, java.awt.Image.SCALE_SMOOTH)); JPanel logoPanel = new JPanel(); JLabel logoLabel = new JLabel("", gameLogo, JLabel.CENTER); logoPanel.setBounds(50, 45, gameLogo.getIconWidth() + 20, gameLogo.getIconHeight() + 20); logoPanel.setBackground(Color.white); logoPanel.add(logoLabel); c.add(logoPanel); ImageIcon qubLogo = new ImageIcon(new ImageIcon(getClass().getResource("QUBLogo.png")).getImage()); JPanel qubLogoPanel = new JPanel(); JLabel qubLogoLabel = new JLabel("", qubLogo, JLabel.CENTER); qubLogoPanel.setBounds(15, 380, qubLogo.getIconWidth() + 10, qubLogo.getIconHeight() + 10); qubLogoPanel.setBackground(Color.white); qubLogoPanel.add(qubLogoLabel); c.add(qubLogoPanel); ImageIcon seseLogo = new ImageIcon( new ImageIcon(getClass().getResource("seseLogo.png")) .getImage() .getScaledInstance(120, 45, java.awt.Image.SCALE_SMOOTH)); JPanel seseLogoPanel = new JPanel(); JLabel seseLogoLabel = new JLabel("", seseLogo, JLabel.CENTER); seseLogoPanel.setBounds(350, 390, seseLogo.getIconWidth() + 10, seseLogo.getIconHeight() + 10); seseLogoPanel.setBackground(Color.white); seseLogoPanel.add(seseLogoLabel); c.add(seseLogoPanel); JPanel playerPanel = new JPanel(); // new panel for players playerPanel.setBounds(92, 200, 316, 27); // location playerPanel.setLayout(new GridLayout(1, 2)); // layout as grid playerPanel.setOpaque(false); c.add(playerPanel); // add to container combo.setBackground(Color.white); playerPanel.add(numOfP); // label to tell to select num of players playerPanel.add(combo); // drop down menu players.setEditable(false); players.setHorizontalAlignment(JLabel.CENTER); combo.addItemListener( new ItemListener() { // this is to set the number of players to be displayed public void itemStateChanged(ItemEvent ie) { if (ie.getStateChange() == ItemEvent.SELECTED) { String str = (String) combo .getSelectedItem(); // if the number changes then change the number of // player message if (str == "2") { players.setText("2 players selected"); } if (str == "3") { players.setText("3 players selected"); } if (str == "4") { players.setText("4 players selected"); } if (str == "5") { players.setText("5 players selected"); } if (str == "6") { players.setText("6 players selected"); } } // closes if statements } // closes method } // closes action listener ); // closes action listener JPanel startPanel = new JPanel(); // start panel for start button startPanel.setBounds(123, 239, 254, 70); // location startPanel.setLayout(new GridLayout(2, 1)); // using a grid layout startPanel.add(players); // text box says number of payers startPanel.setBackground(Color.white); startButton = new JButton(); startButton.setText( "Start Game!"); // button has the label start // actual start button startPanel.add(startButton); // button added startButton.addActionListener(startButtonActionListener); // added actionlistener c.add(startPanel); // added to container setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // close when closed setVisible(true); // takes off invisability cloak } // MyFrame constructor
public EducAssignmentPanel() { super("‘ормирование учебных поручений"); List<Image> icons = new Vector<Image>(); icons.add(new ImageIcon("images/уп.png").getImage()); setIconImages(icons); setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); this.setPreferredSize(new Dimension(DEFAULT_WIDTH, DEFAULT_HEIGHT)); this.setResizable(false); Dimension dim_screen = Toolkit.getDefaultToolkit().getScreenSize(); this.setLocation( (int) dim_screen.getWidth() / 2 - DEFAULT_WIDTH / 2, (int) dim_screen.getHeight() / 2 - DEFAULT_HEIGHT / 2); setDefaultCloseOperation(EXIT_ON_CLOSE); JPanel content_top = BoxLayoutUtils.createHorizontalPanel(); // ---------------------------------------------------------- JPanel semester = BoxLayoutUtils.createHorizontalPanel(); semester.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); JLabel lab_semester = new JLabel("¬ид семестра:"); semester_combo = new JComboBox<String>(); semester_combo.setBackground(Color.white); semester_combo.addItem("летний"); semester_combo.addItem("зимний"); lab_semester.setPreferredSize(new Dimension(100, 27)); lab_semester.setMaximumSize(lab_semester.getPreferredSize()); lab_semester.setMinimumSize(lab_semester.getPreferredSize()); semester_combo.setPreferredSize(new Dimension(100, 27)); semester_combo.setMaximumSize(semester_combo.getPreferredSize()); semester_combo.setMinimumSize(semester_combo.getPreferredSize()); semester.add(lab_semester); semester.add(semester_combo); JPanel bevel_semester = BoxLayoutUtils.createHorizontalPanel(); bevel_semester.setBorder(BorderFactory.createLoweredBevelBorder()); JPanel out_semester = BoxLayoutUtils.createHorizontalPanel(); out_semester.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); bevel_semester.add(semester); out_semester.add(bevel_semester); // ---------------------------------------------------------- JPanel cath = BoxLayoutUtils.createVerticalPanel(); cath.setBackground(Color.white); semester.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); CurriculumTransaction tr = new CurriculumTransaction(); ArrayList<String> cath_names = tr.getCathedras(); checks = new ArrayList<JCheckBox>(); this.checks.add(new JCheckBox("выбрать все...")); for (String name : cath_names) checks.add(new JCheckBox(name)); for (JCheckBox cur_check : checks) { cath.add(Box.createHorizontalStrut(5)); cath.add(cur_check); cur_check.setBackground(Color.white); } checks .get(0) .addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { JCheckBox check = (JCheckBox) e.getSource(); if (check.isSelected()) { for (JCheckBox cur : checks) cur.setSelected(true); } else for (JCheckBox cur : checks) cur.setSelected(false); } }); cath.add(Box.createGlue()); JPanel bevel_cath = BoxLayoutUtils.createHorizontalPanel(); bevel_cath.setBorder(BorderFactory.createLoweredBevelBorder()); JPanel out_cath = BoxLayoutUtils.createHorizontalPanel(); out_cath.setBorder(BorderFactory.createEmptyBorder(0, 5, 5, 5)); bevel_cath.add(new JScrollPane(cath)); out_cath.add(bevel_cath); // ---------------------------------------------------------- JPanel right = BoxLayoutUtils.createVerticalPanel(); right.add(out_semester); right.add(out_cath); content_top.add(right); chooser = new JFileChooser(); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); content_top.add(chooser); // ---------------------------------------------------------- JPanel content_create = BoxLayoutUtils.createHorizontalPanel(); content_create.add(Box.createHorizontalGlue()); create = new JButton("—формировать поручени¤"); create.setPreferredSize(new Dimension(200, 27)); create.setMinimumSize(create.getPreferredSize()); create.setMaximumSize(create.getPreferredSize()); cancel = new JButton("ќтмена"); cancel.setPreferredSize(new Dimension(100, 27)); cancel.setMinimumSize(cancel.getPreferredSize()); cancel.setMaximumSize(cancel.getPreferredSize()); content_create.add(create); content_create.add(Box.createHorizontalStrut(5)); content_create.add(cancel); content_create.add(Box.createHorizontalStrut(4)); JPanel create_empty = BoxLayoutUtils.createHorizontalPanel(); create_empty.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); JPanel content_bottom = BoxLayoutUtils.createHorizontalPanel(); content_bottom.setBorder(BorderFactory.createEtchedBorder()); create_empty.add(content_create); content_bottom.add(create_empty); JPanel content = BoxLayoutUtils.createVerticalPanel(); content.add(content_top); content.add(content_bottom); create.addActionListener(this); cancel.addActionListener(this); setContentPane(content); setVisible(true); }
Source() { jf = new JFrame("SOURCE::Jamming Simulation"); c = jf.getContentPane(); c.setLayout(null); jf.setSize(1000, 700); // c.setBackground(Color.DARK_GRAY); c.setBackground(new Color(10, 100, 120)); T0.setBounds(450, 30, 350, 45); T0.setFont(f); T0.setForeground(Color.GREEN); T2.setBounds(205, 150, 250, 45); T2.setFont(f2); T2.setForeground(Color.BLUE); T3.setBounds(205, 210, 250, 45); T3.setFont(f2); T3.setForeground(Color.BLUE); T4.setBounds(400, 210, 950, 45); T4.setFont(f2); T4.setForeground(new Color(120, 0, 0)); T5.setBounds(660, 145, 300, 45); T5.setFont(f2); T5.setForeground(Color.CYAN); T6.setBounds(760, 70, 400, 35); T6.setFont(f2); T6.setForeground(Color.RED); T7.setBounds(760, 110, 400, 35); T7.setFont(f2); T7.setForeground(Color.MAGENTA); btn1.setBounds(590, 153, 150, 33); btn1.setFont(f2); // btn1.setBackground(Color.WHITE); btn1.setForeground(new Color(120, 0, 0)); jp.setBounds(105, 126, 719, 450); jp.setBackground(new Color(0, 146, 187)); // jp1.setBackground(new Color(120,0,0)); jp1.setBounds(103, 124, 723, 453); T1.setBounds(300, 550, 250, 45); TAreu.setBounds(650, 550, 200, 35); btn.setBounds(440, 520, 150, 33); T1.setFont(f3); T1.setForeground(new Color(0, 120, 0)); btn.setFont(f2); // btn.setBackground(Color.WHITE); btn.setForeground(new Color(120, 0, 0)); TAreu.addItem("Mesh Route"); TAreu.addItem(" Node "); TAreu.setFont(f3); TAreu.setBackground(Color.WHITE); TAreu.setForeground(Color.BLUE); TAreu.setFont(f); pane.setBounds(385, 280, 400, 200); tf.setColumns(20); tf.setForeground(Color.MAGENTA); tf.setFont(f2); tf.setRows(10); tf.setName("tf"); pane.setName("pane"); pane.setViewportView(tf); ImageIcon ii = new ImageIcon(this.getClass().getResource("Source.jpg")); imageLabel.setIcon(ii); imageLabel.setBounds(0, 2, 1200, 100); btn1.addActionListener(this); btn.addActionListener(this); btn1.setMnemonic(KeyEvent.VK_B); btn.setMnemonic(KeyEvent.VK_S); jf.show(); c.add(btn); c.add(T2); c.add(T3); c.add(T4); c.add(pane, BorderLayout.CENTER); c.add(btn1); // c.add(T0); c.add(imageLabel1); c.add(jp); c.add(jp1); c.add(imageLabel); jf.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent win) { System.exit(0); } }); }
public Main_GUI() { super(); controller = Controller.getInstance(); getContentPane().setLayout(new BorderLayout(0, 0)); this.setTitle("ADVDISC MP2"); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); this.setSize((int) (screenSize.width / 1.2), 450); listBlock = new ArrayList<ArrayList<Matrix_Block>>(); fc = new JFileChooser(); try { for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (Exception e) { // If Nimbus is not available, you can set the GUI to another look and feel. } splitPane = new JSplitPane(); getContentPane().add(splitPane); panel_image = new JPanel(); System.out.println("Screen size: " + (int) (this.getSize().width / 4)); panel_image.setPreferredSize(new Dimension((int) (this.getSize().width / 1.5), 10)); splitPane.setLeftComponent(panel_image); panel_image.setLayout(new BorderLayout(0, 0)); panel_image_content = new JPanel(); panel_image.add(panel_image_content, BorderLayout.CENTER); panel_image_content.setLayout(new BorderLayout(0, 0)); panel_image_original = new JPanel(); panel_image_original.setBorder( new TitledBorder(null, "Original", TitledBorder.LEADING, TitledBorder.TOP, null, null)); panel_image_original.setBackground(new Color(255, 255, 255)); panel_image_original.setPreferredSize( new Dimension(panel_image.getPreferredSize().width / 2, 10)); panel_image_content.add(panel_image_original, BorderLayout.WEST); panel_image_original.setLayout(new BorderLayout(0, 0)); image_original = new JLabel("No Image"); image_original.setHorizontalAlignment(SwingConstants.CENTER); panel_image_original.add(image_original); panel_image_filtered = new JPanel(); panel_image_filtered.setBorder( new TitledBorder(null, "Filtered", TitledBorder.LEADING, TitledBorder.TOP, null, null)); panel_image_filtered.setBackground(new Color(255, 255, 255)); panel_image_content.add(panel_image_filtered, BorderLayout.CENTER); panel_image_filtered.setLayout(new BorderLayout(0, 0)); image_filtered = new JLabel("No Image"); image_filtered.setHorizontalAlignment(SwingConstants.CENTER); panel_image_filtered.add(image_filtered, BorderLayout.CENTER); panel_filter = new JPanel(); splitPane.setRightComponent(panel_filter); panel_filter.setLayout(new BorderLayout(0, 0)); panel_filter_header = new JPanel(); panel_filter_header.setBorder( new TitledBorder( null, "Filter Options", TitledBorder.LEADING, TitledBorder.TOP, null, null)); panel_filter_header.setPreferredSize(new Dimension(10, 90)); panel_filter.add(panel_filter_header, BorderLayout.NORTH); panel_filter_header.setLayout(new BorderLayout(0, 0)); panel_buttons = new JPanel(); panel_filter_header.add(panel_buttons, BorderLayout.SOUTH); panel_buttons.setLayout(new BorderLayout(0, 0)); panel_filter_options = new JPanel(); panel_filter_header.add(panel_filter_options, BorderLayout.NORTH); panel_filter_options.setLayout(new BorderLayout(0, 0)); lbl_image_filters = new JLabel("Image Filter : "); panel_filter_options.add(lbl_image_filters, BorderLayout.WEST); cmb_image_filters = new JComboBox<String>(); cmb_image_filters.setBackground(SystemColor.window); panel_filter_options.add(cmb_image_filters); cmb_image_filters.setModel( new DefaultComboBoxModel( new String[] { "Custom", "Blur", "Brighten", "Edge Detect", "Edge Enhance", "Emboss", "Darken", "Identity", "Sharpen", "Threshold" })); btn_reset_filter = new JButton("Reset Filter"); btn_reset_filter.addActionListener(this); panel_filter_options.add(btn_reset_filter, BorderLayout.SOUTH); panel_filter_content = new JPanel(); panel_filter_content.setBorder( new TitledBorder( UIManager.getBorder("TitledBorder.border"), "3x3 Matrix", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0))); panel_filter.add(panel_filter_content, BorderLayout.CENTER); panel_filter_content.setLayout(new BorderLayout(0, 0)); panel_matrix = new JPanel(); panel_filter_content.add(panel_matrix); GridBagLayout gbl_panel_matrix = new GridBagLayout(); gbl_panel_matrix.columnWidths = new int[] {0}; gbl_panel_matrix.rowHeights = new int[] {0}; gbl_panel_matrix.columnWeights = new double[] {Double.MIN_VALUE}; gbl_panel_matrix.rowWeights = new double[] {Double.MIN_VALUE}; panel_matrix.setLayout(gbl_panel_matrix); panel_factor = new JPanel(); panel_factor.setBackground(SystemColor.controlLtHighlight); panel_filter_content.add(panel_factor, BorderLayout.NORTH); panel_factor.setLayout(new BorderLayout(0, 0)); lbl_weight = new JLabel("Weight : "); panel_factor.add(lbl_weight, BorderLayout.WEST); textField = new JTextField(); panel_factor.add(textField, BorderLayout.CENTER); textField.setColumns(10); textField.setText("9.0"); btn_apply_filter = new JButton("Apply Filter"); btn_apply_filter.addActionListener(this); panel_filter.add(btn_apply_filter, BorderLayout.SOUTH); btn_apply_filter.setEnabled(false); menuBar = new JMenuBar(); getContentPane().add(menuBar, BorderLayout.NORTH); menu_file = new JMenu("File"); menuBar.add(menu_file); menuItem_newImage = new JMenuItem("New Image"); menuItem_newImage.addActionListener(this); menu_file.add(menuItem_newImage); menuItem_saveImage = new JMenuItem("Save Image"); menuItem_saveImage.addActionListener(this); menu_file.add(menuItem_saveImage); menu_matrix_size = new JMenu("Matrix Size"); menuBar.add(menu_matrix_size); menuItem_3x3 = new JMenuItem("3X3"); menuItem_3x3.addActionListener(this); menu_matrix_size.add(menuItem_3x3); menuItem_5x5 = new JMenuItem("5X5"); menuItem_5x5.addActionListener(this); menu_matrix_size.add(menuItem_5x5); setMatrix(3); setImageWidth((int) (panel_image.getPreferredSize().width / 2.2)); setImageHeight((int) (this.getSize().width / 3.2)); System.out.println("image size: " + image_height + "-" + image_width); this.setVisible(true); this.setResizable(false); this.setDefaultCloseOperation(EXIT_ON_CLOSE); }