public void testMnemonic() throws Exception { JPanel panel = (JPanel) getInstrumentedRootComponent("TestMnemonics.form", "BindingTest"); JLabel label = (JLabel) panel.getComponent(0); assertEquals("Mnemonic", label.getText()); assertEquals('M', label.getDisplayedMnemonic()); assertEquals(3, label.getDisplayedMnemonicIndex()); }
private JPanel makeSlider(JLabel label, JSlider slider, JLabel value, String color) { JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); label.setDisplayedMnemonic(label.getText().charAt(0)); label.setLabelFor(slider); String tip = color + " color component slider"; label.setToolTipText(tip); slider.setToolTipText(tip); value.setToolTipText(tip); p.add(label); slider.setMaximumSize(new Dimension(128, slider.getMaximumSize().height)); slider.addChangeListener(this); p.add(slider); p.add(value); return p; }
/** * A helper function that obtains the total number of hours for the selected period. * * @return Total number of hours. * @throws InsufficientDataException Thrown if the total is zero. */ private double checkTotal() throws InsufficientDataException { double total = Double.parseDouble(totalLabel.getText()); if (total == 0) throw new InsufficientDataException("Cannot submit data with no logged hours."); return total; }
public String toString() { return who.getText(); }