/** * Create a default filename given the current date selection. If custom dates are selected, use * those dates; otherwise, use year and week numbers. * * @return The default filename. */ private String getDefaultFilename() { if (yearCB.getSelectedIndex() == 0 || weekCB.getSelectedIndex() == 0) return "timesheet-" + dateFormat.format(fromDate.getDate()).replaceAll("/", "") + "-" + dateFormat.format(toDate.getDate()).replaceAll("/", "") + ".txt"; return "timesheet-" + yearCB.getSelectedItem() + "wk" + weekCB.getSelectedItem() + ".txt"; }
@Override public void valueChanged(TreeSelectionEvent e) { if (e.getSource() == colors && !locked) { TreeSelectionModel tsm = colors.getSelectionModel(); TreePath tp[] = tsm.getSelectionPaths(); if (tp == null) return; Vector<ClassedItem> tmp = new Vector<ClassedItem>(); for (TreePath element : tp) { try { Object[] path = element.getPath(); ClassedItem ci = new ClassedItem(path[1].toString(), path[2].toString()); tmp.add(ci); } catch (Exception exp) { // User did not select a leafnode } } if (sceneElement instanceof NenyaImageSceneElement) { ((NenyaImageSceneElement) sceneElement).setColorList(tmp.toArray(new ClassedItem[0])); } if (sceneElement instanceof NenyaTileSceneElement) { ((NenyaTileSceneElement) sceneElement).setColorList(tmp.toArray(new ClassedItem[0])); } if (sceneElement instanceof NenyaComponentSceneElement) { ((NenyaComponentSceneElement) sceneElement) .getComponents()[itemList.getSelectedIndex()].setColorList( tmp.toArray(new ClassedItem[0])); } submitElement(sceneElement, null); } else { super.valueChanged(e); } }
private void onBatch() { final boolean b = useBatchInputCheckbox.isSelected(); orientationComboBox.setEnabled(b); lengthField.setEnabled(b); dpiXField.setEnabled(b); dpiYField.setEnabled(b); startDepthField.setEnabled(b); depthIncField.setEnabled(b); applyToAllButton.setEnabled(b); applyToSelectedButton.setEnabled(b); if (!b) { orientationLabel.setEnabled(b); lengthLabel.setEnabled(b); dpiXLabel.setEnabled(b); dpiYLabel.setEnabled(b); startDepthLabel.setEnabled(b); depthIncLabel.setEnabled(b); } else { orientationLabel.setEnabled(orientationComboBox.getSelectedIndex() != 2); // [Blank] lengthLabel.setEnabled(!lengthField.getText().equals("")); dpiXLabel.setEnabled(!dpiXField.getText().equals("")); dpiYLabel.setEnabled(!dpiYField.getText().equals("")); startDepthLabel.setEnabled(!startDepthField.getText().equals("")); depthIncLabel.setEnabled(!depthIncField.getText().equals("")); } }
// implemented for ActionListener event handling public void actionPerformed(ActionEvent e) { String actionCmd = e.getActionCommand(); Stack locStack = parentBrowserFrame.locationStack; Stack fwdStack = parentBrowserFrame.forwardStack; if (actionCmd.equals(homeCmd)) // event from home button { fwdStack.removeAllElements(); parentBrowserFrame.setBrowserLocation(mainBrowserURL); } else if (actionCmd.equals(backCmd)) // event from back button { if (!locStack.isEmpty()) { String myLocale = (String) (locStack.pop()); // push current location on forward stack fwdStack.push(location); getForwardButton().setEnabled(true); // do *not* cache the last location in the stack parentBrowserFrame.setBrowserLocation(myLocale, false); } } else if (actionCmd.equals(forwardCmd)) // event from forward button { if (!fwdStack.isEmpty()) { // remove location from forward stack String newLoc = (String) (fwdStack.pop()); // DO add the current location to the back stack parentBrowserFrame.setBrowserLocation(newLoc); } } else if (actionCmd.equals(comboCmd)) // event from URL combo box! { if (e.getSource() instanceof JComboBox) // just to be sure { JComboBox thisBox = (JComboBox) e.getSource(); String newLoc = thisBox.getSelectedItem().toString(); if (newLoc != null && !newLoc.equals("")) // ignore empty selections { if (thisBox.getSelectedIndex() == -1) { thisBox.insertItemAt(newLoc, 0); } fwdStack.removeAllElements(); parentBrowserFrame.setBrowserLocation(newLoc); } } } // disable the back button if we find the location stack is empty if (locStack.isEmpty()) { getBackButton().setEnabled(false); } // disable forward button if forward stack is empty if (fwdStack.isEmpty()) { getForwardButton().setEnabled(false); } }
private void savePreferences() { // grab the preferences so that they can be filled in from the // user's selections ThumbMakerPreferences myPreferences = ThumbMakerPreferences.getInstance(); // x resolution text box myPreferences.setStringPref(ThumbMakerPreferences.RES_WIDTH_PREF_NAME, xres.getText()); // y resolution text box myPreferences.setStringPref(ThumbMakerPreferences.RES_HEIGHT_PREF_NAME, yres.getText()); // aspect ratio checkbox String aspectText; if (aspect.isSelected()) { aspectText = ThumbMakerPreferences.BOOLEAN_TRUE_STRING; } else aspectText = ThumbMakerPreferences.BOOLEAN_FALSE_STRING; myPreferences.setStringPref(ThumbMakerPreferences.DO_MAINTAIN_ASPECT_PREF_NAME, aspectText); // red slider myPreferences.setIntegerPref(ThumbMakerPreferences.RED_VALUE_PREF_NAME, red.getValue()); // green slider myPreferences.setIntegerPref(ThumbMakerPreferences.GREEN_VALUE_PREF_NAME, green.getValue()); // blue slider myPreferences.setIntegerPref(ThumbMakerPreferences.BLUE_VALUE_PREF_NAME, blue.getValue()); // algorithm combo box myPreferences.setIntegerPref( ThumbMakerPreferences.RESIZE_ALG_PREF_NAME, algorithm.getSelectedIndex()); // format combo box myPreferences.setIntegerPref( ThumbMakerPreferences.THUMB_FORMAT_PREF_NAME, format.getSelectedIndex()); // prepend field myPreferences.setStringPref( ThumbMakerPreferences.STRING_TO_PREPEND_PREF_NAME, prepend.getText()); // append field myPreferences.setStringPref(ThumbMakerPreferences.STRING_TO_APPEND_PREF_NAME, append.getText()); // output folder field myPreferences.setStringPref(ThumbMakerPreferences.FILE_PATH_STRING_PREF_NAME, output.getText()); }
private void resetPanel() { cal = new GregorianCalendar( Integer.parseInt(yearSpi.getValue().toString()), monthBox.getSelectedIndex(), Integer.parseInt(lastLabel.getText())); startPoint_x = 20; startPoint_y = 10; panel.removeAll(); panel.repaint(); initCalPanel(); }
public void actionPerformed(ActionEvent e) { if (e.getSource().equals(opsCombo)) { demo.opsIndex = opsCombo.getSelectedIndex(); if (demo.opsIndex == 0) { demo.slider1.setValue(demo.low); demo.slider2.setValue(demo.high); demo.slider1.setEnabled(true); demo.slider2.setEnabled(true); } else if (demo.opsIndex == 1) { demo.slider1.setValue(demo.rescaleFactor); demo.slider2.setValue((int) demo.rescaleOffset); demo.slider1.setEnabled(true); demo.slider2.setEnabled(true); } else { demo.slider1.setEnabled(false); demo.slider2.setEnabled(false); } } else if (e.getSource().equals(imgCombo)) { demo.imgIndex = imgCombo.getSelectedIndex(); } demo.repaint(10); }
private void applyGroupPropToTable(final boolean applyToAllRows) { int[] applyRowIndices = null; if (applyToAllRows) { applyRowIndices = new int[imageTable.getRowCount()]; for (int i = 0; i < applyRowIndices.length; i++) { applyRowIndices[i] = i; } } else { applyRowIndices = imageTable.getSelectedRows(); if (applyRowIndices.length == 0) return; } final int orientation = orientationComboBox.getSelectedIndex(); if (orientation < 2) imageTable.applyOrientation(orientation, applyRowIndices); boolean dpiValueChanged = false; if (!dpiXField.getText().equals("")) { final int dpiX = Integer.valueOf(dpiXField.getText()); imageTable.applyDPIX(dpiX, applyRowIndices); dpiValueChanged = true; } if (!dpiYField.getText().equals("")) { final int dpiY = Integer.valueOf(dpiYField.getText()); imageTable.applyDPIY(dpiY, applyRowIndices); dpiValueChanged = true; } if (!lengthField.getText().equals("")) { final float length = Float.valueOf(lengthField.getText()); imageTable.applyLength(length, applyRowIndices); } // depth increment and start depth: both must be populated to apply if (!depthIncField.getText().equals("") && !startDepthField.getText().equals("")) { final float depthInc = Float.valueOf(depthIncField.getText()); final float depthStart = Float.valueOf(startDepthField.getText()); imageTable.applyDepths(depthStart, depthInc, applyRowIndices); } else if (!depthIncField.getText().equals("") || !startDepthField.getText().equals("")) { JOptionPane.showMessageDialog( this, "Both Start Depth and Depth Increment must be populated to apply values in Depth column"); } if (dpiValueChanged) imageTable.model.fireTableDataChanged(); }
// Add course method public void addCourse() { try { Database db = new Database(); String coursename = (String) coursecombobox.getSelectedItem(); if (coursecombobox.getSelectedIndex() == 0) { throw new Exception("No course selected"); } float fees = db.getCoursefees(coursename); float totalfees = fees + (ims.main.Settings.getInstallment() * (int) spinner.getValue()); long id = (long) table.getValueAt((int) table.getSelectionModel().getMinSelectionIndex(), 0); db.addCourseToCurrentStudent(id, totalfees, (int) spinner.getValue(), coursename); updateFeesData(id); courseReset(); } catch (Exception e) { JOptionPane.showMessageDialog(this, e.getMessage(), null, JOptionPane.ERROR_MESSAGE); } }
/** Reaction to buttons and combo boxes. */ public void actionPerformed(ActionEvent e) { String cmd = e.getActionCommand(); if (cmdCtrlProp.equals(cmd)) { try { Class c = Class.forName("aurora.hwc.control.Panel" + myController.getClass().getSimpleName()); AbstractPanelController cp = (AbstractPanelController) c.newInstance(); cp.initialize(myController, null); } catch (Exception ex) { } } if (cmdCtrlList.equals(cmd)) { JComboBox cb = (JComboBox) e.getSource(); if (cb.getSelectedIndex() > 0) { myController = (AbstractControllerComplex) listCControllers.getSelectedItem(); buttonProp.setEnabled(true); } else { buttonProp.setEnabled(false); myController = null; } myMonitor.setMyController(myController); } return; }
public DialogStammdaten(JFrame fenster, String[][] datensatz1, String s, Methoden datenbank1) { super(fenster, true); datenbank = datenbank1; datensatz = datensatz1; p = new JPanel(); platzhalter = new JLabel(); text1 = new JLabel("Name"); text2 = new JLabel("Personalnummer"); text3 = new JLabel("Titel"); text4 = new JLabel("Institut"); feld = new JComboBox(); textName = new JTextField(); textPersonalnr = new JTextField(); textInstitut = new JTextField(); textTitel = new JTextField(); menue = new JMenuBar(); datei = new JMenu("Datei"); aendern = new JMenuItem("Aendern"); hinzufuegen = new JMenuItem("Hinzufuegen"); loeschen = new JMenuItem("Loeschen"); beenden = new JMenuItem("Beenden"); final JDialog dialog = this; this.setTitle(s); feld = new JComboBox(ersteElemente(datensatz)); textName.setText(datensatz[0][0]); textPersonalnr.setText(datensatz[0][1]); setzen(datensatz, feld.getSelectedIndex()); feld.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getID() == ItemEvent.ITEM_STATE_CHANGED && e.getStateChange() == ItemEvent.SELECTED) { textName.setText((String) e.getItem()); textPersonalnr.setText(datensatz[feld.getSelectedIndex()][1]); setzen(datensatz, feld.getSelectedIndex()); } } }); datei.addMenuListener( new MenuListener() { public void menuSelected(MenuEvent e) { hinzufuegen.setEnabled(false); aendern.setEnabled(false); loeschen.setEnabled(false); if (!geaendert(datensatz, feld.getSelectedIndex())) { loeschen.setEnabled(true); } else if (!(textName.getText().equals("") || textPersonalnr.getText().equals(""))) { hinzufuegen.setEnabled(true); aendern.setEnabled(true); } } public void menuDeselected(MenuEvent e) {} public void menuCanceled(MenuEvent e) {} }); hinzufuegen.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { String[] daten = erstellen(); if (hinzufuegen(daten)) { dispose(); } else { JOptionPane.showMessageDialog( dialog, "Hinzufuegen geht nicht.", "Fehler", JOptionPane.ERROR_MESSAGE); } } }); aendern.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { String[] daten = erstellen(); if (aendern(datensatz[feld.getSelectedIndex()][1], daten)) { dispose(); } else { JOptionPane.showMessageDialog( dialog, "Aendern geht nicht.", "Fehler", JOptionPane.ERROR_MESSAGE); } } }); loeschen.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { String[] daten = erstellen(); if (loeschen(datensatz[feld.getSelectedIndex()][1])) { dispose(); } else { JOptionPane.showMessageDialog( dialog, "Loeschen geht nicht.", "Fehler", JOptionPane.ERROR_MESSAGE); } } }); beenden.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { dispose(); } }); datei.add(hinzufuegen); datei.add(aendern); datei.add(loeschen); datei.add(beenden); menue.add(datei); this.setJMenuBar(menue); p.setLayout(new GridLayout(2, 5)); p.add(platzhalter); p.add(text1); p.add(text2); p.add(text3); p.add(text4); p.add(feld); p.add(textName); p.add(textPersonalnr); p.add(textTitel); p.add(textInstitut); this.setContentPane(p); this.pack(); this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); }
/** * Checks whether the interval has been set using the date chooser. * * @return True if custom. */ boolean isIntervalCustom() { return yearCB.getSelectedIndex() == 0 || weekCB.getSelectedIndex() == 0; }
// Method to update Table and related components private void update() { Database db = new Database(); String column[] = { "ID", "NAME", "GENDER", "GUARDIAN_ROLE", "GUARDIAN_NAME", "PRESENT_ADDRESS", "PRESENT_CITY", "PRESENT_PHONE" }; try { // Update table if (searchcombobox.getSelectedIndex() == 0 && allfieldcheckbox.isSelected()) { mytablemodel = new MyTableModel(db.getAllStudent(), db.getColumnNameFromStudent()); } else if (searchcombobox.getSelectedIndex() == 0 && !allfieldcheckbox.isSelected()) { mytablemodel = new MyTableModel(db.getSomeFieldsFromStudent(), column); } else if (searchcombobox.getSelectedIndex() == 1 && allfieldcheckbox.isSelected()) { String query = "SELECT * FROM Student WHERE NAME = \'" + searchtextfield.getText().trim() + "\'"; mytablemodel = new MyTableModel(db.getData(query), db.getColumnNameFromStudent()); } else if (searchcombobox.getSelectedIndex() == 1 && !allfieldcheckbox.isSelected()) { String query = "SELECT ID, NAME, GENDER, GUARDIAN_ROLE, GUARDIAN_NAME, PRESENT_ADDRESS, PRESENT_CITY, PRESENT_PHONE FROM Student WHERE NAME = \'" + searchtextfield.getText().trim() + "\'"; mytablemodel = new MyTableModel(db.getData(query), column); } else if (searchcombobox.getSelectedIndex() == 2 && allfieldcheckbox.isSelected()) { String query = "SELECT * FROM Student WHERE GUARDIAN_NAME = \'" + searchtextfield.getText().trim() + "\'"; mytablemodel = new MyTableModel(db.getData(query), db.getColumnNameFromStudent()); } else if (searchcombobox.getSelectedIndex() == 2 && !allfieldcheckbox.isSelected()) { String query = "SELECT ID, NAME, GENDER, GUARDIAN_ROLE, GUARDIAN_NAME, PRESENT_ADDRESS, PRESENT_CITY, PRESENT_PHONE FROM Student WHERE GUARDIAN_NAME = \'" + searchtextfield.getText().trim() + "\'"; mytablemodel = new MyTableModel(db.getData(query), column); } else if (searchcombobox.getSelectedIndex() == 3 && allfieldcheckbox.isSelected()) { String query = "SELECT * FROM Student WHERE ID = ANY(SELECT SID FROM Fee WHERE CID = ANY(SELECT ID FROM CourseInfo WHERE NAME = \'" + searchtextfield.getText().trim() + "\'))"; mytablemodel = new MyTableModel(db.getData(query), db.getColumnNameFromStudent()); } else if (searchcombobox.getSelectedIndex() == 3 && !allfieldcheckbox.isSelected()) { String query = "SELECT ID, NAME, GENDER, GUARDIAN_ROLE, GUARDIAN_NAME, PRESENT_ADDRESS, PRESENT_CITY, PRESENT_PHONE FROM Student WHERE ID = ANY(SELECT SID FROM Fee WHERE CID = ANY(SELECT ID FROM CourseInfo WHERE NAME = \'" + searchtextfield.getText().trim() + "\'))"; mytablemodel = new MyTableModel(db.getData(query), column); } else if (searchcombobox.getSelectedIndex() == 4 && allfieldcheckbox.isSelected()) { String query = "SELECT * FROM Student WHERE ID = ANY(SELECT SID FROM Fee WHERE TOTAL_FEES - FEES_PAYED >= 0)"; mytablemodel = new MyTableModel(db.getData(query), db.getColumnNameFromStudent()); } else { String query = "SELECT ID, NAME, GENDER, GUARDIAN_ROLE, GUARDIAN_NAME, PRESENT_ADDRESS, PRESENT_CITY, PRESENT_PHONE FROM Student WHERE ID = ANY(SELECT SID FROM Fee WHERE TOTAL_FEES - FEES_PAYED >= 0)"; mytablemodel = new MyTableModel(db.getData(query), column); } table = new JTable(mytablemodel); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); // Add list selection listener to table table.getSelectionModel().addListSelectionListener(this); TableColumn col = null; for (int i = 3; i < table.getColumnCount(); i++) { col = table.getColumnModel().getColumn(i); col.setPreferredWidth(200); } scrollpane = new JScrollPane(table); panel_3.removeAll(); panel_3.add(scrollpane); // Update total student label int total = db.getTotalStudent(); totalstudentlabel.setText("Total Student = " + total); // Clear search combo box searchtextfield.setText(""); this.revalidate(); } catch (Exception e) { JOptionPane.showMessageDialog(this, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } }
public int getSelectedMethod() { return ChooseMethod.getSelectedIndex(); }
@Override protected String getEnabledValue() { return choices[comboBox.getSelectedIndex()].getValue(); }