public DemoControls(ImageOps demo) { super(demo.name); this.demo = demo; setBackground(Color.gray); add(imgCombo = new JComboBox()); imgCombo.setFont(font); for (int i = 0; i < ImageOps.imgName.length; i++) { imgCombo.addItem(ImageOps.imgName[i]); } imgCombo.addActionListener(this); add(opsCombo = new JComboBox()); opsCombo.setFont(font); for (int i = 0; i < ImageOps.opsName.length; i++) { opsCombo.addItem(ImageOps.opsName[i]); } opsCombo.addActionListener(this); }
{ for (myjava.gui.syntax.Painter painter : myjava.gui.syntax.Painter.getPainters()) { painterComboBox.addItem(painter); EntryListPanel panel = new EntryListPanel(painter); listPanelSet.add(panel); centerPanel.add(panel, painter.getName()); } componentSet.addAll(Arrays.asList(matchBracket, painterComboBox, centerPanel)); }
/** * creates a new channel, if the channel exists it is removed (this method doubles as a * removeChannel) * * @param name the name of the channel */ public void newChannel(String name, boolean pass) { if (channels.containsKey(name)) { channels.remove(name); cboChannels.removeItem(name); } else { channels.put(name, new Boolean(pass)); cboChannels.addItem(name); } }
private void updateParams(EDPCellData data) { paramComboBox.removeAllItems(); paramKeys = data.getPlugin().getPrintfDescrs(!m_isCrawlRuleEditor); if (!m_isCrawlRuleEditor) { paramComboBox.addItem(STRING_LITERAL); } for (Iterator it = paramKeys.values().iterator(); it.hasNext(); ) { ConfigParamDescr descr = (ConfigParamDescr) it.next(); int type = descr.getType(); if (!m_isCrawlRuleEditor && (type == ConfigParamDescr.TYPE_SET || type == ConfigParamDescr.TYPE_RANGE)) continue; paramComboBox.addItem(descr); } paramComboBox.setEnabled(true); paramComboBox.setSelectedIndex(0); paramComboBox.setToolTipText("Select a parameter to insert into the format string"); insertButton.setEnabled(true); }
private void addPainter(myjava.gui.syntax.Painter painter) { EntryListPanel newPanel = new EntryListPanel(painter); listPanelSet.add(newPanel); centerPanel.add(newPanel, painter.getName()); painterComboBox.removeItemListener(painterChangeListener); painterComboBox.removeAllItems(); for (EntryListPanel p : listPanelSet) { painterComboBox.addItem(p.getPainter()); } removedPainters.remove(painter); painterComboBox.addItemListener(painterChangeListener); }
protected void updateCategoryChooser() { if (categoryChooser != null) { ArrayList<String> categories; categoryChooser.removeAllItems(); categories = new ArrayList<String>(contribListing.getCategories(filter)); // for (int i = 0; i < categories.size(); i++) { // System.out.println(i + " category: " + categories.get(i)); // } Collections.sort(categories); // categories.add(0, ContributionManagerDialog.ANY_CATEGORY); boolean categoriesFound = false; categoryChooser.addItem(ContributionManagerDialog.ANY_CATEGORY); for (String s : categories) { categoryChooser.addItem(s); if (!s.equals(Contribution.UNKNOWN_CATEGORY)) { categoriesFound = true; } } categoryChooser.setVisible(categoriesFound); } }
private void initMatches() { matchesKeys.put(STRING_LITERAL, ""); matchesKeys.put("Any number", "[0-9]+"); matchesKeys.put("Anything", ".*"); matchesKeys.put("Start", "^"); matchesKeys.put("End", "$"); matchesKeys.put("Single path component", "[^/]+"); for (Iterator it = matchesKeys.keySet().iterator(); it.hasNext(); ) { matchComboBox.addItem(it.next()); } }
/* * The following method creates the combo box with font size choices * postcondition: returns the panel containing the size combo box. */ public JPanel createSizeComboBox() { sizeCombo = new JComboBox(); sizeCombo.addItem(SMALLEST); sizeCombo.addItem(SMALL); sizeCombo.addItem(SMALL_MEDIUM); sizeCombo.addItem(MEDIUM); sizeCombo.addItem(MEDIUM_LARGE); sizeCombo.addItem(LARGE); sizeCombo.addItem(LARGEST); sizeCombo.addItem(HUGE); sizeCombo.addItem(WOW); sizeCombo.setEditable(true); // facenameCombo.addActionListener(this); sizeCombo.setSelectedIndex(2); JPanel panel = new JPanel(); panel.add(sizeCombo); panel.setBorder(new TitledBorder(new EtchedBorder(), "Font Name")); return panel; } // end createComboBox method
ApplicationFrame() { super("Ecuatii Neliniare"); setSize(frameWidth, frameHeight); setDefaultCloseOperation(this.EXIT_ON_CLOSE); panel.setOpaque(true); getContentPane().add(panel); addComponentListener(this); for (int i = 0; i < Methods.length; i++) ChooseMethod.addItem(Methods[i]); buttonPanel.add(ChooseMethod); buttonPanel.setOpaque(true); JButton buttonAdd = new JButton("Aplica..."); buttonAdd.setPreferredSize(new Dimension(125, 25)); buttonAdd.addActionListener(this); buttonPanel.add(buttonAdd); unitXSlider.setMinorTickSpacing(5); unitXSlider.setPaintTicks(true); unitXSlider.addChangeListener(this); unitYSlider.setMinorTickSpacing(5); unitYSlider.setPaintTicks(true); unitYSlider.addChangeListener(this); buttonPanel.add(unitXSlider); buttonPanel.add(unitYSlider); Border padding = BorderFactory.createEmptyBorder(0, 20, 20, 20); panel.setBorder(padding); panel.add(buttonPanel, BorderLayout.NORTH); panel.add(graph, BorderLayout.CENTER); pack(); setVisible(true); }
public ChoiceField(ChoiceOption option) { super(option); this.choices = option.getChoices().toArray(new Choice[0]); comboBox = new JComboBox(); for (int i = 0; i < choices.length; i++) { comboBox.addItem(makeEntry(choices[i].getDisplayName())); if (i == 0 || choices[i].isDefault()) { comboBox.setSelectedIndex(i); } } comboBox.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { fireChangeEvent(); } }); configureEnableToggle( option.isInitiallyEnabled(), option.getDisabledValue(), Arrays.asList((JComponent) comboBox)); }
public Design() throws Exception { super.setBackground(Color.BLACK); this.setTitle(""); con = getContentPane(); con.setLayout(null); dim = tk.getDefaultToolkit().getScreenSize(); this.setTitle("Customer Peer Login"); l1 = new JLabel(new ImageIcon("plain.jpg")); l1.setBounds(0, 0, 400, 400); con.add(l1); l1.setBorder(BorderFactory.createEtchedBorder(5, Color.black, Color.black)); title = new JLabel("CUSTOMER PEER LOGIN "); title.setFont(new Font("Bookman Old Style", Font.ROMAN_BASELINE, 20)); title.setForeground(Color.red); title.setBounds(80, 30, 300, 30); l1.add(title); l4 = new JLabel("CMACHINE NAME"); l4.setFont(new Font("Bookman Old Style", Font.BOLD, 16)); l4.setForeground(Color.BLUE); l4.setBounds(70, 100, 160, 20); // l4.setBorder(BorderFactory.createEtchedBorder(5,Color.green,Color.green)); l1.add(l4); jtf2 = new JTextField(); jtf2.setBounds(250, 100, 100, 20); jtf2.setBorder(BorderFactory.createEtchedBorder(5, Color.green, Color.green)); l1.add(jtf2); l2 = new JLabel("CUSER LOGIN"); l2.setFont(new Font("Bookman Old Style", Font.BOLD, 16)); l2.setForeground(Color.blue); l2.setBounds(70, 150, 120, 20); l1.add(l2); jtf1 = new JTextField(); jtf1.setBounds(250, 150, 100, 20); jtf1.setBorder(BorderFactory.createEtchedBorder(5, Color.green, Color.green)); l1.add(jtf1); l3 = new JLabel("CPASSWORD"); l3.setFont(new Font("Bookman Old Style", Font.BOLD, 16)); l3.setForeground(Color.blue); l3.setBounds(70, 200, 120, 20); l1.add(l3); jptf1 = new JPasswordField(); jptf1.setBounds(250, 200, 100, 20); jptf1.setBorder(BorderFactory.createEtchedBorder(5, Color.green, Color.green)); l1.add(jptf1); JLabel l4 = new JLabel("DAgent"); l4.setFont(new Font("Bookman Old Style", Font.BOLD, 16)); l4.setForeground(Color.blue); l4.setBounds(70, 250, 120, 20); l1.add(l4); box = new JComboBox(); box.setBounds(250, 250, 100, 20); box.setBorder(BorderFactory.createEtchedBorder(5, Color.green, Color.green)); l1.add(box); b2 = new JButton("Register"); b2.setBounds(50, 300, 100, 20); l1.add(b2); b2.setBorder(BorderFactory.createEtchedBorder(10, Color.BLUE, Color.BLUE)); b3 = new JButton("Login"); b3.setBounds(150, 300, 100, 20); b3.setBorder(BorderFactory.createEtchedBorder(10, Color.BLUE, Color.BLUE)); l1.add(b3); b1 = new JButton("Cancel"); b1.setBounds(250, 300, 100, 20); b1.setBorder(BorderFactory.createEtchedBorder(10, Color.BLUE, Color.BLUE)); l1.add(b1); b1.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent we) { dispose(); } }); try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); conn = DriverManager.getConnection("jdbc:odbc:agent"); } catch (Exception exp) { } try { Statement satem = conn.createStatement(); ResultSet rsatem = satem.executeQuery("select * from Dagent"); while (rsatem.next()) { String namem = rsatem.getString("uname"); box.addItem(namem); } } catch (Exception expo1) { } b2.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent we) { String username = jtf1.getText().trim(); String password = jptf1.getText().trim(); String mechine = jtf2.getText().trim(); String dname = box.getSelectedItem().toString(); int porte = 0; try { Statement sate = conn.createStatement(); ResultSet rsate = sate.executeQuery("select * from Dagent where uname='" + dname + "'"); if (rsate.next()) { servermachine = rsate.getString("umechine"); porte = rsate.getInt("ulistport"); System.out.println(servermachine); } System.out.println(servermachine); } catch (Exception exp) { exp.printStackTrace(); } try { packet p = new packet(); p.setaction("Creg"); p.setCuser(username); p.setCpass(password); p.setCmname(mechine); p.setCDpeer(dname); Socket soc = new Socket(servermachine, porte); ObjectOutputStream out = new ObjectOutputStream(soc.getOutputStream()); out.writeObject(p); ObjectInputStream in = new ObjectInputStream(soc.getInputStream()); packet rpac = (packet) in.readObject(); if (rpac.getaction().equals("ok")) { JOptionPane.showMessageDialog(null, "Sucessfully Registered"); jtf2.setText(""); jtf1.setText(""); jptf1.setText(""); } else { JOptionPane.showMessageDialog(null, "Already Registered"); jtf2.setText(""); jtf1.setText(""); jptf1.setText(""); } } catch (Exception exp) { } } }); b3.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent we) { String username = jtf1.getText().trim(); String password = jptf1.getText().trim(); String mechine = jtf2.getText().trim(); String Dname = box.getSelectedItem().toString(); int porte = 0; try { Statement sate = conn.createStatement(); ResultSet rsate = sate.executeQuery("select * from Dagent where uname='" + Dname + "'"); if (rsate.next()) { servermachine = rsate.getString("umechine"); porte = rsate.getInt("ulistport"); System.out.println(servermachine); } System.out.println(servermachine); } catch (Exception exp) { } try { packet p1 = new packet(); p1.setaction("clogin"); p1.setCuser(username); p1.setCpass(password); p1.setCmname(mechine); p1.setCDpeer(Dname); Socket soc1 = new Socket(servermachine, porte); ObjectOutputStream out1 = new ObjectOutputStream(soc1.getOutputStream()); out1.writeObject(p1); ObjectInputStream in1 = new ObjectInputStream(soc1.getInputStream()); packet rpac1 = (packet) in1.readObject(); if (rpac1.getaction().equals("ok")) { int port1 = 0; try { int portm = rpac1.getCport(); System.out.println("XXXXXXX" + portm); // JOptionPane.showMessageDialog(null,"Sucessfully Started"); new Listen(portm); new process(username, portm); dispose(); } catch (Exception exp) { } } else { JOptionPane.showMessageDialog( null, "Enter valid username and password", "Server reply", 2); jtf1.setText(""); jtf2.setText(""); jptf1.setText(""); } } catch (Exception exp) { } } }); setSize(400, 400); show(); setLocation(150, 100); setResizable(false); }
/** * Returns the message to display from the JOptionPane the receiver is providing the look and feel * for. */ protected Object getMessage() { inputComponent = null; if (optionPane != null) { if (optionPane.getWantsInput()) { /* Create a user component to capture the input. If the selectionValues are non null the component and there are < 20 values it'll be a combobox, if non null and >= 20, it'll be a list, otherwise it'll be a textfield. */ Object message = optionPane.getMessage(); Object[] sValues = optionPane.getSelectionValues(); Object inputValue = optionPane.getInitialSelectionValue(); JComponent toAdd; if (sValues != null) { if (sValues.length < 20) { JComboBox cBox = new JComboBox(); cBox.setName("OptionPane.comboBox"); for (int counter = 0, maxCounter = sValues.length; counter < maxCounter; counter++) { cBox.addItem(sValues[counter]); } if (inputValue != null) { cBox.setSelectedItem(inputValue); } inputComponent = cBox; toAdd = cBox; } else { JList list = new JList(sValues); JScrollPane sp = new JScrollPane(list); sp.setName("OptionPane.scrollPane"); list.setName("OptionPane.list"); list.setVisibleRowCount(10); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); if (inputValue != null) list.setSelectedValue(inputValue, true); list.addMouseListener(getHandler()); toAdd = sp; inputComponent = list; } } else { MultiplexingTextField tf = new MultiplexingTextField(20); tf.setName("OptionPane.textField"); tf.setKeyStrokes(new KeyStroke[] {KeyStroke.getKeyStroke("ENTER")}); if (inputValue != null) { String inputString = inputValue.toString(); tf.setText(inputString); tf.setSelectionStart(0); tf.setSelectionEnd(inputString.length()); } tf.addActionListener(getHandler()); toAdd = inputComponent = tf; } Object[] newMessage; if (message == null) { newMessage = new Object[1]; newMessage[0] = toAdd; } else { newMessage = new Object[2]; newMessage[0] = message; newMessage[1] = toAdd; } return newMessage; } return optionPane.getMessage(); } return null; }
/* * The following method creates the combo box with font style choices * postcondition: returns the panel containing the combo box. */ public JPanel createFacenameComboBox() { // YOU MUST ALTER THESE BASED ON YOUR SYSTEM. facenameCombo = new JComboBox(); facenameCombo.addItem(new String("Times")); facenameCombo.addItem(new String("Agent Orange")); facenameCombo.addItem(new String("Aldo's Nova")); facenameCombo.addItem(new String("American Typewriter")); facenameCombo.addItem(new String("American Typewriter Condensed")); facenameCombo.addItem(new String("American Typewriter Light")); facenameCombo.addItem(new String("Andale Mono")); facenameCombo.addItem(new String("AntsyPants")); facenameCombo.addItem(new String("Apple Chancery")); facenameCombo.addItem(new String("Arial")); facenameCombo.addItem(new String("Arial Black")); facenameCombo.addItem(new String("Arial Narrow")); facenameCombo.addItem(new String("Aristocrat LET")); facenameCombo.addItem(new String("AstigamaTizm")); facenameCombo.addItem(new String("BASEHEAD")); facenameCombo.addItem(new String("Baskerville")); facenameCombo.addItem(new String("BellBottom")); facenameCombo.addItem(new String("Bertram LET")); facenameCombo.addItem(new String("BiauKai")); facenameCombo.addItem(new String("Bickley Script LET")); facenameCombo.addItem(new String("Bite me")); facenameCombo.addItem(new String("Bizarro")); facenameCombo.addItem(new String("Bodoni Ornaments ITC TT")); facenameCombo.addItem(new String("Calaveras")); facenameCombo.addItem(new String("Capitals")); facenameCombo.addItem(new String("Century Gothic")); facenameCombo.addItem(new String("Chalkboard")); facenameCombo.addItem(new String("Charcoal")); facenameCombo.addItem(new String("Chicago")); facenameCombo.addItem(new String("Cochin")); facenameCombo.addItem(new String("Comic Sans MS")); facenameCombo.addItem(new String("Copperplate")); facenameCombo.addItem(new String("Courier")); facenameCombo.addItem(new String("Courier New")); facenameCombo.addItem(new String("Curlz MT")); facenameCombo.addItem(new String("Didot")); facenameCombo.addItem(new String("Edwardian Script ITC")); facenameCombo.addItem(new String("Fang Song")); facenameCombo.addItem(new String("Fortuna Dot")); facenameCombo.addItem(new String("Futura")); facenameCombo.addItem(new String("Gadget")); facenameCombo.addItem(new String("Geeza Pro")); facenameCombo.addItem(new String("Geneva")); facenameCombo.addItem(new String("Georgia")); facenameCombo.addItem(new String("Gill Sans")); facenameCombo.addItem(new String("Gringo Nights")); facenameCombo.addItem(new String("Hei")); facenameCombo.addItem(new String("Helvetica")); facenameCombo.addItem(new String("Herculanum")); facenameCombo.addItem(new String("Hypmotizin")); facenameCombo.addItem(new String("Impact")); facenameCombo.addItem(new String("Jokerman LET")); facenameCombo.addItem(new String("MadisonSquare")); facenameCombo.addItem(new String("MammaGamma")); facenameCombo.addItem(new String("Mathmos Original")); facenameCombo.addItem(new String("MammaGamma")); facenameCombo.addItem(new String("Marker Felt")); facenameCombo.addItem(new String("MassiveHeadache3")); facenameCombo.addItem(new String("Parry Hotter")); facenameCombo.setEditable(true); // facenameCombo.addActionListener(this); JPanel panel = new JPanel(); panel.add(facenameCombo); panel.setBorder(new TitledBorder(new EtchedBorder(), "Font Name")); return panel; } // end createComboBox method
public Viewer() { leveldbStore.setMultiSelectionEnabled(false); leveldbStore.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); putButton.setEnabled(false); key.setEnabled(false); value.setEnabled(false); findField.setEnabled(false); deleteButton.setEnabled(false); saveButton.setEnabled(false); putType.setEnabled(false); putType.setEditable(false); signedBox.setEnabled(false); openButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (openButton.isEnabled()) { openButton.setEnabled(false); new Thread() { public void run() { if (leveldbStore.showOpenDialog(pane) == JFileChooser.APPROVE_OPTION) { File select = leveldbStore.getSelectedFile(); if (select.isDirectory()) { new OpenLevelDBDialog(Viewer.this, select); openDatabase(select); dbPathField.setText(select.getAbsolutePath()); } else { JOptionPane.showMessageDialog( pane, "The selecting item must be a directory", "Unable to load database", JOptionPane.WARNING_MESSAGE); } } else { openButton.setEnabled(true); } } }.start(); } } }); deleteButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (dataList.getSelectedValue() != null) { delete(dataList.getSelectedValue().key); } openDatabase(leveldbStore.getSelectedFile()); } }); putButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { put( ((PutType) putType.getSelectedItem()).getBytes(key.getText()), ((PutType) putType.getSelectedItem()).getBytes(value.getText())); openDatabase(leveldbStore.getSelectedFile()); } }); findField.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openDatabase(leveldbStore.getSelectedFile()); } }); findField .getDocument() .addDocumentListener( new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { openDatabase(leveldbStore.getSelectedFile()); } @Override public void removeUpdate(DocumentEvent e) { openDatabase(leveldbStore.getSelectedFile()); } @Override public void changedUpdate(DocumentEvent e) { openDatabase(leveldbStore.getSelectedFile()); } }); findField .getDocument() .addUndoableEditListener( new UndoableEditListener() { @Override public void undoableEditHappened(UndoableEditEvent e) { openDatabase(leveldbStore.getSelectedFile()); } }); hexKey .getDocument() .addDocumentListener( new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { update(hexKey); } @Override public void removeUpdate(DocumentEvent e) { update(hexKey); } @Override public void changedUpdate(DocumentEvent e) { update(hexKey); } }); hexKey .getDocument() .addUndoableEditListener( new UndoableEditListener() { @Override public void undoableEditHappened(UndoableEditEvent e) { update(hexKey); } }); stringKey .getDocument() .addDocumentListener( new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { update(stringKey); } @Override public void removeUpdate(DocumentEvent e) { update(stringKey); } @Override public void changedUpdate(DocumentEvent e) { update(stringKey); } }); stringKey .getDocument() .addUndoableEditListener( new UndoableEditListener() { @Override public void undoableEditHappened(UndoableEditEvent e) { update(stringKey); } }); hexValue .getDocument() .addDocumentListener( new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { update(hexValue); } @Override public void removeUpdate(DocumentEvent e) { update(hexValue); } @Override public void changedUpdate(DocumentEvent e) { update(hexValue); } }); hexValue .getDocument() .addUndoableEditListener( new UndoableEditListener() { @Override public void undoableEditHappened(UndoableEditEvent e) { update(hexValue); } }); stringValue .getDocument() .addDocumentListener( new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { update(stringValue); } @Override public void removeUpdate(DocumentEvent e) { update(stringValue); } @Override public void changedUpdate(DocumentEvent e) { update(stringValue); } }); stringValue .getDocument() .addUndoableEditListener( new UndoableEditListener() { @Override public void undoableEditHappened(UndoableEditEvent e) { update(stringValue); } }); saveButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { save(); openDatabase(leveldbStore.getSelectedFile()); } }); dataList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); dataList.addListSelectionListener( new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { DBItem item = dataList.getSelectedValue(); if (item != null) { hexValue.setText(cutToLine(LevelDBViewer.toHexString(item.value), 64)); stringValue.setText(cutToLine(new String(item.value), 64)); hexKey.setText(cutToLine(LevelDBViewer.toHexString(item.key), 64)); stringKey.setText(cutToLine(new String(item.key), 64)); lengthLabel.setText(String.valueOf(item.value.length + item.key.length)); keyLength.setText(String.valueOf(item.key.length)); valueLength.setText(String.valueOf(item.value.length)); } } }); signedBox.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { LevelDBViewer.DEFAULT_SINGED = signedBox.isSelected(); int i = dataList.getSelectedIndex(); dataList.clearSelection(); dataList.updateUI(); dataList.setSelectedIndex(i); update(hexKey); update(hexValue); } }); for (PutType t : PutType.values()) { putType.addItem(t); } putType.setSelectedItem(PutType.STRING); putType.addItemListener( new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { openDatabase(leveldbStore.getSelectedFile()); } }); putType.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openDatabase(leveldbStore.getSelectedFile()); } }); dialog.setLocationByPlatform(true); dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); dialog.setContentPane(pane); dialog.setTitle("LevelDB Viewer By Marcus (https://github.com/SuperMarcus)"); dialog.getRootPane().setDefaultButton(openButton); dialog.pack(); dialog.setVisible(true); }
editprof(String str, String user) { cp = getContentPane(); cp.setLayout(null); user1 = user; try { UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); } catch (Exception e) { } JTextField ft = new JTextField(); name1 = new JLabel("First Name"); try { r = new FileReader(user + "/First name.txt"); ft.read(r, null); r.close(); } catch (Exception de) { } name = new JTextField(); name.setText(ft.getText()); last1 = new JLabel("Enter Last Name"); try { r = new FileReader(user + "/last name.txt"); ft.read(r, null); r.close(); } catch (Exception de) { } last = new JTextField(); last.setText(ft.getText()); pass = new JLabel("Password"); try { r = new FileReader(user + "/password.txt"); ft.read(r, null); r.close(); } catch (Exception de) { } pwd = new JPasswordField(); pwd.setText(ft.getText()); pwd.setEditable(false); email1 = new JLabel("Enter email address"); try { r = new FileReader(user + "/email.txt"); ft.read(r, null); r.close(); } catch (Exception de) { } email = new JTextField(); email.setText(ft.getText()); addimage = new JButton("Add Image"); icon = new JLabel(); date1 = new JLabel("Date Of Birth"); date = new JComboBox(); for (int i = 1; i <= 31; i++) { date.addItem(i); } month = new JComboBox(); month.addItem("Jan"); month.addItem("Feb"); month.addItem("Mar"); month.addItem("Apr"); month.addItem("May"); month.addItem("Jun"); month.addItem("Jul"); month.addItem("Aug"); month.addItem("Sep"); month.addItem("Oct"); month.addItem("Nov"); month.addItem("Dec"); year = new JComboBox(); for (int j = 1900; j <= 2010; j++) { year.addItem(j); } sx = new JLabel("Gender"); gen = new JComboBox(); gen.addItem("Male"); gen.addItem("Female"); con1 = new JLabel("Country Name"); con = new JComboBox(); con.addItem(" Austrelia"); con.addItem(" America"); con.addItem(" Antartica"); con.addItem(" Africa"); con.addItem(" Canda"); con.addItem(" Corea"); con.addItem(" Chaina"); con.addItem(" Denmark"); con.addItem(" England"); con.addItem(" Franc"); con.addItem(" Hangery"); con.addItem(" Holand"); con.addItem(" Itali"); con.addItem(" India"); con.addItem(" Indonesia"); con.addItem(" Jermany"); con.addItem(" Japan"); con.addItem(" Korea"); con.addItem(" Kembridge"); con.addItem(" Merusalem"); con.addItem(" Noth America"); con.addItem(" Norvey"); con.addItem(" West Indies"); con.addItem(" Peru"); con.addItem(" Zimbawe"); about = new JLabel("About me"); try { r = new FileReader(user + "/about.txt"); ft.read(r, null); r.close(); } catch (Exception de) { } int h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS; int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS; main = new JTextArea(); main.setText(ft.getText()); JScrollPane jsp = new JScrollPane(main, v, h); allow = new JLabel("Allow To:"); JCheckBox c1 = new JCheckBox(" orkut Friends"); JCheckBox c2 = new JCheckBox("Collage Friends"); JCheckBox c3 = new JCheckBox("Business Partner"); JCheckBox c4 = new JCheckBox("Relatives"); col = new JLabel("Collage Name:"); try { r = new FileReader(user + "/Collage.txt"); ft.read(r, null); r.close(); } catch (Exception de) { } col1 = new JTextField(); col1.setText(ft.getText()); try { r = new FileReader(user + "/UniverSity.txt"); ft.read(r, null); r.close(); } catch (Exception de) { } uni = new JLabel("Univercity"); uni1 = new JTextField(); uni1.setText(ft.getText()); state1 = new JLabel("State Name"); try { r = new FileReader(user + "/state.txt"); ft.read(r, null); r.close(); } catch (Exception de) { } state = new JTextField(); state.setText(ft.getText()); city = new JLabel("City"); try { r = new FileReader(user + "/City.txt"); ft.read(r, null); r.close(); } catch (Exception de) { } city1 = new JTextField(); city1.setText(ft.getText()); try { r = new FileReader(user + "/imagepath.txt"); ft.read(r, null); r.close(); } catch (Exception de) { } ImageIcon io = new ImageIcon(ft.getText()); icon.setIcon(io); next = new JButton("Update"); next.setBackground(Color.white); // adding to container name1.setBounds(10, 10, 130, 25); name.setBounds(150, 10, 130, 25); last1.setBounds(10, 40, 130, 25); last.setBounds(150, 40, 130, 25); email1.setBounds(10, 70, 130, 25); email.setBounds(150, 70, 130, 25); pass.setBounds(290, 70, 130, 25); pwd.setBounds(390, 70, 130, 25); addimage.setBounds(350, 440, 100, 25); icon.setBounds(490, 410, 100, 100); date1.setBounds(10, 100, 130, 25); date.setBounds(120, 100, 40, 25); month.setBounds(180, 100, 130, 25); year.setBounds(320, 100, 130, 25); sx.setBounds(10, 140, 130, 25); gen.setBounds(150, 140, 130, 25); about.setBounds(10, 180, 130, 25); jsp.setBounds(150, 180, 250, 80); allow.setBounds(10, 260, 130, 25); c1.setBounds(150, 260, 130, 25); c2.setBounds(290, 260, 130, 25); c3.setBounds(150, 290, 130, 25); c4.setBounds(290, 290, 130, 25); uni.setBounds(10, 330, 130, 25); uni1.setBounds(150, 330, 130, 25); col.setBounds(10, 360, 130, 25); col1.setBounds(150, 360, 130, 25); con1.setBounds(10, 390, 130, 25); con.setBounds(150, 390, 130, 25); state1.setBounds(10, 430, 130, 25); state.setBounds(150, 430, 130, 25); city.setBounds(10, 460, 130, 25); city1.setBounds(150, 460, 130, 25); next.setBounds(50, 490, 130, 25); cp.add(name); cp.add(name1); cp.add(last); cp.add(last1); cp.add(email); cp.add(email1); cp.add(addimage); cp.add(icon); cp.add(date1); cp.add(date); cp.add(month); cp.add(year); cp.add(about); cp.add(jsp); cp.add(sx); cp.add(gen); cp.add(allow); cp.add(c1); cp.add(c2); cp.add(c3); cp.add(c4); cp.add(next); cp.add(uni); cp.add(uni1); cp.add(col); cp.add(col1); cp.add(con); cp.add(con1); cp.add(state1); cp.add(state); cp.add(city); cp.add(city1); cp.add(next); cp.add(pwd); cp.add(pass); addimage.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { filepath = name.getText(); JFileChooser chooser = new JFileChooser(); while (true) { int val = chooser.showOpenDialog(editprof.this); File f = chooser.getSelectedFile(); String path = f.getPath(); String name = f.getName(); try { if (val == JFileChooser.CANCEL_OPTION || val == -1) { break; } else { image = new ImageIcon(path); icon.setIcon(image); w = new FileWriter(filepath + "/" + "imagePath.txt"); w.write(path + ""); w.close(); break; } } catch (Exception se) { } } } }); date.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { int str = (Integer) e.getItem(); File f = new File(name.getText()); f.mkdir(); try { w = new FileWriter(name.getText() + "/" + "date.txt"); w.write(str + ""); w.close(); } catch (IOException de) { } } }); month.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e1) { String str = (String) e1.getItem(); File f = new File(name.getText()); f.mkdir(); try { w = new FileWriter(name.getText() + "/" + "month.txt"); w.write(str + ""); w.close(); } catch (IOException de) { } } }); con.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e2) { String str = (String) e2.getItem(); File f = new File(name.getText()); f.mkdir(); try { w = new FileWriter(name.getText() + "/" + "contry.txt"); w.write(str + ""); w.close(); } catch (IOException de) { } } }); year.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e2) { int str = (Integer) e2.getItem(); File f = new File(name.getText()); f.mkdir(); try { w = new FileWriter(name.getText() + "/" + "year.txt"); w.write(str + ""); w.close(); } catch (IOException de) { } } }); gen.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e3) { String str = (String) e3.getItem(); File f = new File(name.getText()); f.mkdir(); try { w = new FileWriter(name.getText() + "/" + "gender.txt"); w.write(str + ""); w.close(); } catch (IOException de) { } } }); next.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent se) { try { w = new FileWriter(name.getText() + "/" + "First name.txt"); w.write(name.getText()); w.close(); w = new FileWriter(name.getText() + "/" + "last name.txt"); w.write(last.getText()); w.close(); w = new FileWriter(name.getText() + "/" + "email.txt"); w.write(email.getText()); w.close(); w = new FileWriter(name.getText() + "/" + "Collage.txt"); w.write(col1.getText()); w.close(); w = new FileWriter(name.getText() + "/" + "UniverSity.txt"); w.write(uni1.getText()); w.close(); w = new FileWriter(name.getText() + "/" + "state.txt"); w.write(state.getText()); w.close(); w = new FileWriter(name.getText() + "/" + "City.txt"); w.write(city1.getText()); w.close(); w = new FileWriter(name.getText() + "/" + "about.txt"); w.write(main.getText()); w.close(); w = new FileWriter(name.getText() + "/" + "password.txt"); w.write(pwd.getText()); w.close(); profile e1 = new profile("My Profile", user1); e1.setVisible(true); e1.setLocation(00, 00); e1.setSize(800, 800); setVisible(false); } catch (Exception be) { } } }); }
/** Create the UI for this editor */ void makeUI() { JPanel mainPanel = new JPanel(new BorderLayout()); mainPanel.setBorder(new LineBorder(Color.blue)); getContentPane().add(mainPanel, BorderLayout.CENTER); // the map and associated toolbar npEditControl = new NPController(); mapEditPanel = npEditControl.getNavigatedPanel(); // here's where the map will be drawn mapEditPanel.setPreferredSize(new Dimension(250, 250)); mapEditPanel.setSelectRegionMode(true); JToolBar navToolbar = mapEditPanel.getNavToolBar(); navToolbar.setFloatable(false); JToolBar moveToolbar = mapEditPanel.getMoveToolBar(); moveToolbar.setFloatable(false); // toolbar.remove("setReference"); JPanel toolbar = new JPanel(); List localMaps = maps; if (localMaps == null) { localMaps = getDefaultMaps(); } JMenu mapMenu = new JMenu("Maps"); JMenuBar menuHolder = new JMenuBar(); menuHolder.setBorder(null); menuHolder.add(mapMenu); toolbar.add(menuHolder); for (int mapIdx = 0; mapIdx < localMaps.size(); mapIdx++) { final MapData mapData = (MapData) localMaps.get(mapIdx); final JCheckBoxMenuItem cbx = new JCheckBoxMenuItem(mapData.getDescription(), mapData.getVisible()); if (mapData.getVisible()) { toggleMap(mapData, true); } mapMenu.add(cbx); cbx.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent event) { toggleMap(mapData, cbx.isSelected()); } }); } GuiUtils.limitMenuSize(mapMenu, "Maps ", 20); toolbar.add(navToolbar); toolbar.add(moveToolbar); JPanel mapSide = new JPanel(); mapSide.setLayout(new BorderLayout()); TitledBorder mapBorder = new TitledBorder( standardBorder, "Edit Projection", TitledBorder.ABOVE_TOP, TitledBorder.CENTER); mapSide.setBorder(mapBorder); mapSide.add(toolbar, BorderLayout.NORTH); mapSide.add(mapEditPanel, BorderLayout.CENTER); mainPanel.add(mapSide, BorderLayout.WEST); // the projection parameters // the Projection name JLabel nameLabel = GuiUtils.rLabel("Name: "); nameTF = new JTextField(20); // the list of Projection classes is kept in a comboBox typeLabel = GuiUtils.rLabel("Type: "); projClassCB = new JComboBox(); // standard list of projection classes List classNames = getDefaultProjections(); for (int i = 0; i < classNames.size(); i++) { String className = (String) classNames.get(i); try { projClassCB.addItem(new ProjectionClass(className)); } catch (ClassNotFoundException ee) { System.err.println("ProjectionManager failed on " + className + " " + ee); } catch (IntrospectionException ee) { System.err.println("ProjectionManager failed on " + className + " " + ee); } } GuiUtils.tmpInsets = new Insets(4, 4, 4, 4); JPanel topPanel = GuiUtils.doLayout( new Component[] {nameLabel, nameTF, typeLabel, projClassCB}, 2, GuiUtils.WT_N, GuiUtils.WT_N); // the Projection parameter area paramPanel = new JPanel(); paramPanel.setLayout(new BorderLayout()); paramPanel.setBorder( new TitledBorder( standardBorder, "Projection Parameters", TitledBorder.ABOVE_TOP, TitledBorder.CENTER)); // the bottom button panel JPanel buttPanel = new JPanel(); JButton acceptButton = new JButton("Save"); JButton previewButton = new JButton("Preview"); JButton cancelButton = new JButton("Cancel"); buttPanel.add(acceptButton, null); buttPanel.add(previewButton, null); buttPanel.add(cancelButton, null); JPanel mainBox = GuiUtils.topCenterBottom(topPanel, paramPanel, buttPanel); mainPanel.add(mainBox, BorderLayout.CENTER); pack(); // enable event listeners when we're done constructing the UI projClassCB.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { ProjectionClass selectClass = (ProjectionClass) projClassCB.getSelectedItem(); setProjection(selectClass.makeDefaultProjection()); } }); acceptButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { accept(); } }); previewButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { ProjectionClass projClass = findProjectionClass(editProjection); if (null != projClass) { setProjFromDialog(projClass, editProjection); setProjection(editProjection); } } }); cancelButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { NewProjectionDialog.this.setVisible(false); } }); }
private void createFileMenu() { fileMenu = new JMenu("File"); menuBar.add(fileMenu); newItem = new JMenuItem("New..."); fileMenu.add(newItem); // construct components of option pane to input name and type of new AM final Object[] newMsg = new Object[3]; newMsg[0] = "Name for new AM:"; final JTextField newName = new JTextField("new-am"); newMsg[1] = newName; final JComboBox cb = new JComboBox(); for (int i = 0; i < Libgist.extInfo.length; i++) { cb.addItem(Libgist.extInfo[i].name); } newMsg[2] = cb; newItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { // first close the currently opened index int response = JOptionPane.showOptionDialog( MainWindow.this, newMsg, "New", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, null, null); if (response != JOptionPane.OK_OPTION) { return; } // create new AM cmd.reset(); cmd.cmdType = LibgistCommand.CREATE; cmd.indexName.append(newName.getText()); cmd.extension.append(Libgist.extInfo[cb.getSelectedIndex()]); opThread.dispatchCmd(cmd); } }); openItem = new JMenuItem("Open..."); final JFileChooser openChooser = new JFileChooser("."); openChooser.setDialogTitle("Open Index"); openChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); fileMenu.add(openItem); openItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { // first close currently opened index // let user choose index file int retval = openChooser.showOpenDialog(MainWindow.this); if (retval != 0) { return; } String fileName = openChooser.getSelectedFile().getPath(); // open AM cmd.reset(); cmd.cmdType = LibgistCommand.OPEN; cmd.indexName.append(fileName); opThread.dispatchCmd(cmd); enableIndexOpened(); } }); closeItem = new JMenuItem("Close"); fileMenu.add(closeItem); closeItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { // close AM cmd.reset(); cmd.cmdType = LibgistCommand.CLOSE; opThread.dispatchCmd(cmd); // MainWindow.this.setTitle("amdb"); } }); flushItem = new JMenuItem("Flush"); fileMenu.add(flushItem); flushItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { // open AM cmd.reset(); cmd.cmdType = LibgistCommand.FLUSH; opThread.dispatchCmd(cmd); } }); fileMenu.addSeparator(); optionsItem = new JMenuItem("Properties..."); fileMenu.add(optionsItem); optionsItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { Properties.edit(); } }); settingsItem = new JMenuItem("Save Settings"); fileMenu.add(settingsItem); settingsItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { saveConfig(); } }); fileMenu.addSeparator(); exitItem = new JMenuItem("Exit"); fileMenu.add(exitItem); exitItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { // close AM opThread.stopNow(); Libgist.cleanup(); System.exit(0); } }); }
@SuppressWarnings({"unchecked", "rawtypes"}) private void initializeComponent() { // Initialize panels panel_1 = new JPanel(); panel_2 = new JPanel(); panel_3 = new JPanel(); panel_4 = new JPanel(); panel_5 = new JPanel(); panel_6 = new JPanel(); panel_7 = new JPanel(); // Initialize spinner spinnermodel = new SpinnerNumberModel(0, 0, 10, 1); spinner = new JSpinner(spinnermodel); // Initialize combo box searchcombobox = new JComboBox(); searchcombobox.addItem("All"); searchcombobox.addItem("By Name"); searchcombobox.addItem("By Guardian Name"); searchcombobox.addItem("By Course"); searchcombobox.addItem("Due Fees"); searchcombobox.setSelectedIndex(0); coursecombobox = new JComboBox(); coursecombobox.addItem("Select Course"); Database db = new Database(); String courses[] = db.getCourses(); if (courses != null) { for (String x : courses) { coursecombobox.addItem(x); } } // Initialize text field searchtextfield = new JTextField(10); addfeestextfield = new JTextField(8); // Initialize button searchbutton = new JButton("Search"); addfeesbutton = new JButton("Add fees"); addcoursebutton = new JButton("Add Course"); // Initialize check box allfieldcheckbox = new JCheckBox("Show all fields"); allfieldcheckbox.setSelected(true); // Initialize label totalstudentlabel = new JLabel("Total Student"); feespayedlabel = new JLabel("Fees Payed"); feesduelabel = new JLabel("Fees due"); totalfeeslabel = new JLabel("Total fees"); // Add Item listener to check box allfieldcheckbox.addItemListener(this); // Add Action Listener to button searchbutton.addActionListener(this); addfeesbutton.addActionListener(this); addcoursebutton.addActionListener(this); // Add Key Listener to button searchbutton.addKeyListener(this); addfeesbutton.addKeyListener(this); addcoursebutton.addKeyListener(this); }
/** Generates Configuration tab. */ private void fillConfigurationPanel() { JPanel desc = new JPanel(new GridLayout(2, 0)); desc.setBorder(BorderFactory.createTitledBorder("Description")); desc.add( new JLabel("<html><font color=\"blue\">" + myMonitor.getDescription() + "</font></html>")); desc.add(cbEnabled); cbEnabled.setSelected(enabled); cbEnabled.addChangeListener(this); confPanel.add(desc); JPanel mlpanel = new JPanel(new GridLayout(1, 0)); mlpanel.setBorder(BorderFactory.createTitledBorder("Monitored Network Elements")); montable = new JTable(montablemodel); montable.setPreferredScrollableViewportSize(new Dimension(200, 100)); montable.getColumnModel().getColumn(0).setPreferredWidth(140); montable.getColumnModel().getColumn(1).setPreferredWidth(60); montable.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { int row = montable.rowAtPoint(new Point(e.getX(), e.getY())); AbstractNetworkElement ne = null; if ((row >= 0) && (row < myMonitor.getPredecessors().size())) ne = myMonitor.getPredecessors().get(row); else return; treePane.actionSelected(ne, true); } return; } }); mlpanel.add(new JScrollPane(montable)); confPanel.add(mlpanel); JPanel cpanel = new JPanel(new GridLayout(1, 0)); cpanel.setBorder(BorderFactory.createTitledBorder("Controlleded Network Elements")); ctrltable = new JTable(ctrltablemodel); ctrltable.setPreferredScrollableViewportSize(new Dimension(200, 100)); ctrltable.getColumnModel().getColumn(0).setPreferredWidth(140); ctrltable.getColumnModel().getColumn(1).setPreferredWidth(60); ctrltable.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { int row = ctrltable.rowAtPoint(new Point(e.getX(), e.getY())); AbstractNetworkElement ne = null; if ((row >= 0) && (row < myMonitor.getSuccessors().size())) ne = myMonitor.getSuccessors().get(row); else return; treePane.actionSelected(ne, true); } return; } }); cpanel.add(new JScrollPane(ctrltable)); confPanel.add(cpanel); JPanel pcl = new JPanel(new FlowLayout()); // controller list buttonProp.setEnabled(false); buttonProp.setActionCommand(cmdCtrlProp); buttonProp.addActionListener(this); pcl.setBorder(BorderFactory.createTitledBorder("Complex Controller")); buttonProp.setEnabled(false); listCControllers = new JComboBox(); listCControllers.addItem("None"); String[] ctrlClasses = myMonitor.getComplexControllerClasses(); for (int i = 0; i < ctrlClasses.length; i++) { if ((myController != null) && (myController.getClass().getName().compareTo(ctrlClasses[i]) == 0)) { listCControllers.addItem(myController); listCControllers.setSelectedIndex(i + 1); buttonProp.setEnabled(true); } else { try { Class cl = Class.forName(ctrlClasses[i]); AbstractControllerComplex cc = (AbstractControllerComplex) cl.newInstance(); cc.setMyMonitor(myMonitor); cc.initialize(); listCControllers.addItem(cc); } catch (Exception e) { } } } listCControllers.setActionCommand(cmdCtrlList); listCControllers.addActionListener(this); pcl.add(listCControllers); pcl.add(buttonProp); confPanel.add(pcl); return; }
public static void main(String args[]) { // style that is necessary try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException e) { } catch (InstantiationException e) { } catch (IllegalAccessException e) { } catch (UnsupportedLookAndFeelException e) { } // Standard preparation for a frame fmain = new JFrame("Schedule Appointments"); // Create and name frame fmain.setSize(330, 375); // Set size to 400x400 pixels pane = fmain.getContentPane(); pane.setLayout(null); // Apply null layout fmain.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Close when X is clicked // controls and portions of Calendar lmonth = new JLabel("January"); lyear = new JLabel("Change year:"); cyear = new JComboBox(); prev = new JButton("<<"); next = new JButton(">>"); canc = new JButton("Cancel"); mcal = new DefaultTableModel() { public boolean isCellEditable(int rowIndex, int mColIndex) { return false; } }; Cal = new JTable(mcal); scal = new JScrollPane(Cal); pcal = new JPanel(null); canc.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { System.exit(0); } }); // action listeners for buttons and the like prev.addActionListener(new btnPrev_Action()); next.addActionListener(new btnNext_Action()); cyear.addActionListener(new cmbYear_Action()); Cal.addMouseListener(new mouseCont()); // Adding the elements to the pane pane.add(pcal); pcal.add(lmonth); pcal.add(cyear); pcal.add(prev); pcal.add(next); pcal.add(canc); pcal.add(scal); // Setting where the elements are on the pane pcal.setBounds(0, 0, 320, 335); lmonth.setBounds(160 - lmonth.getPreferredSize().width / 2, 25, 100, 25); canc.setBounds(10, 305, 80, 20); cyear.setBounds(215, 305, 100, 20); prev.setBounds(10, 25, 50, 25); next.setBounds(260, 25, 50, 25); scal.setBounds(10, 50, 300, 250); // Make frame visible fmain.setResizable(false); fmain.setVisible(true); // Inner workings for the day mechanism GregorianCalendar cal = new GregorianCalendar(); // Create calendar rday = cal.get(GregorianCalendar.DAY_OF_MONTH); // Get day rmonth = cal.get(GregorianCalendar.MONTH); // Get month ryear = cal.get(GregorianCalendar.YEAR); // Get year currentMonth = rmonth; // Match month and year currentYear = ryear; // Add days String[] days = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; // All of the days for (int i = 0; i < 7; i++) { mcal.addColumn(days[i]); } Cal.getParent().setBackground(Cal.getBackground()); // Set background // No resize/reorder Cal.getTableHeader().setResizingAllowed(false); Cal.getTableHeader().setReorderingAllowed(false); // Single cell selection Cal.setColumnSelectionAllowed(true); Cal.setRowSelectionAllowed(true); Cal.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // Set row/column count Cal.setRowHeight(38); mcal.setColumnCount(7); mcal.setRowCount(6); // Placing the dates in the cells for (int i = ryear - 100; i <= ryear + 100; i++) { cyear.addItem(String.valueOf(i)); } // Refresh calendar refreshCalendar(rmonth, ryear); // Refresh calendar }
public Assi() { c = getContentPane(); c.setLayout(new BorderLayout()); c.add(pnn, BorderLayout.NORTH); c.add(pns, BorderLayout.SOUTH); c.add(pnc, BorderLayout.CENTER); c.add(pne, BorderLayout.EAST); pne.setLayout(new GridLayout(2, 1)); pne.add(pne1); pne.add(pne2); pne1.setLayout(new FlowLayout()); pne1.add(go); go.addItem("Student"); go.addItem("Teacher"); go.addItem("Course"); go.addItem("Result"); pne1.add(b6); pne2.setLayout(cl2); pns.add(b1); pns.add(b2); pns.add(b3); pns.add(b4); pns.add(b5); setJMenuBar(m); m.add(student); m.add(teacher); m.add(course); m.add(result); stu.setLayout(new GridLayout(8, 2)); stu.add(l1); stu.add(t1); stu.add(l2); stu.add(t2); stu.add(l3); stu.add(t3); stu.add(l4); stu.add(t4); stu.add(l5); stu.add(t5); stu.add(l6); stu.add(t6); cou.setLayout(new GridLayout(4, 2)); cou.add(l7); cou.add(t7); cou.add(l8); cou.add(t8); cou.add(l9); cou.add(t9); cou.add(l0); cou.add(t0); tea.setLayout(new GridLayout(4, 2)); tea.add(l11); tea.add(t11); tea.add(l12); tea.add(t12); tea.add(l13); tea.add(t13); tea.add(l14); tea.add(t14); res.setLayout(new GridLayout(15, 3)); res.add(l15); res.add(t15); res.add(l16); res.add(t16); res.add(l17); res.add(t17); res.add(lg); res.add(l); res.add(l18); res.add(t18); res.add(l19); res.add(t19); res.add(l20); res.add(t20); res.add(l21); res.add(t21); res.add(l22); res.add(t22); res.add(l23); res.add(t23); res.add(l24); res.add(t24); res.add(l25); res.add(t25); res.add(l26); res.add(t26); res.add(l27); res.add(t27); res.add(l28); res.add(t28); pnc.setLayout(cl); pnc.add(blk, "cblk"); pnc.add(stu, "cstu"); pnc.add(tea, "ctea"); pnc.add(cou, "ccou"); pnc.add(res, "cres"); b1.addActionListener(this); b2.addActionListener(this); b3.addActionListener(this); b4.addActionListener(this); b5.addActionListener(this); b6.addActionListener(this); student.addActionListener(this); teacher.addActionListener(this); course.addActionListener(this); result.addActionListener(this); go.addItemListener(this); }