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());
 }
Ejemplo n.º 2
0
 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;
 }
Ejemplo n.º 3
0
 /**
  * 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;
 }
Ejemplo n.º 4
0
 public String toString() {
   return who.getText();
 }