Esempio n. 1
0
  public MainPanel() {
    super(new BorderLayout());
    JPanel p = new JPanel(new GridLayout(2, 1));
    final JComboBox<String> c0 = makeComboBox(true, false);
    final JComboBox<String> c1 = makeComboBox(false, false);
    final JComboBox<String> c2 = makeComboBox(true, true);
    final JComboBox<String> c3 = makeComboBox(false, true);

    p.add(makeTitlePanel("setEditable(false)", Arrays.asList(c0, c1)));
    p.add(makeTitlePanel("setEditable(true)", Arrays.asList(c2, c3)));
    p.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    add(p, BorderLayout.NORTH);
    add(
        new JButton(
            new AbstractAction("add") {
              @Override
              public void actionPerformed(ActionEvent e) {
                String str = new Date().toString();
                for (JComboBox<String> c : Arrays.asList(c0, c1, c2, c3)) {
                  MutableComboBoxModel<String> m = (MutableComboBoxModel<String>) c.getModel();
                  m.insertElementAt(str, m.getSize());
                }
              }
            }),
        BorderLayout.SOUTH);
    setPreferredSize(new Dimension(320, 240));
  }
Esempio n. 2
0
 private JComponent makeTitlePanel(String title, List<? extends JComponent> list) {
   JPanel p = new JPanel(new GridBagLayout());
   p.setBorder(BorderFactory.createTitledBorder(title));
   GridBagConstraints c = new GridBagConstraints();
   c.fill = GridBagConstraints.HORIZONTAL;
   c.insets = new Insets(5, 5, 5, 5);
   c.weightx = 1d;
   c.gridy = 0;
   for (JComponent cmp : list) {
     p.add(cmp, c);
     c.gridy++;
   }
   return p;
 }
Esempio n. 3
0
  private static JComponent makeUI() {
    // final JProgressBar progressBar = new JProgressBar(SwingConstants.VERTICAL);
    final JProgressBar progressBar = new JProgressBar();
    progressBar.setOpaque(false);
    progressBar.setUI(new GradientPalletProgressBarUI());

    GridBagConstraints c = new GridBagConstraints();
    JPanel p = new JPanel(new GridBagLayout());
    p.setBorder(BorderFactory.createEmptyBorder(32, 8, 0, 8));

    c.gridheight = 1;
    c.gridwidth = 1;
    c.gridy = 0;

    c.gridx = 0;
    c.insets = new Insets(0, 0, 0, 4);
    c.weightx = 1d;
    c.fill = GridBagConstraints.HORIZONTAL;
    p.add(progressBar, c);

    c.gridx = 1;
    c.weightx = 0d;
    p.add(
        new JButton(
            new AbstractAction("Start") {
              @Override
              public void actionPerformed(ActionEvent e) {
                final JButton b = (JButton) e.getSource();
                b.setEnabled(false);
                SwingWorker<Void, Void> worker =
                    new Task() {
                      @Override
                      public void done() {
                        if (b.isDisplayable()) {
                          b.setEnabled(true);
                        }
                      }
                    };
                worker.addPropertyChangeListener(new ProgressListener(progressBar));
                worker.execute();
              }
            }),
        c);
    return p;
  }
Esempio n. 4
0
  protected void setPref() {
    Color color = DisplayOptions.getColor("PlainText");
    Font font = DisplayOptions.getFont("PlainText");
    m_lblUsername.setForeground(color);
    m_lblUsername.setFont(font);
    m_lblPassword.setForeground(color);
    m_lblPassword.setFont(font);
    m_cmbUser.getEditor().getEditorComponent().setForeground(color);
    m_cmbUser.getEditor().getEditorComponent().setFont(font);
    m_passwordField.setForeground(color);
    m_passwordField.setFont(font);

    color = DisplayOptions.getColor("Heading3");
    font = DisplayOptions.getFont("Heading3");
    m_lblSampleName.setForeground(color);
    m_pnlTrays.setBorder(
        BorderDeli.createBorder("Empty", "Sample Trays", "Bottom", "Center", color, font));
    VBox.setforeground(color);
    VBox.setfont(font);
  }