Example #1
0
  private void initUI() {
    names.add("帐号");
    names.add("金额");
    defaultTableModel = new MyDefaultTableModel(names, 0);
    table = new MyTable(defaultTableModel);

    this.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.insets = new Insets(10, 10, 10, 10);
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    gbc.fill = GridBagConstraints.BOTH;

    gbc.gridx = gbc.gridy = 0;
    gbc.gridwidth = 4;
    this.add(new JScrollPane(table), gbc);

    // gbc.weightx=gbc.weighty=0.0;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.gridwidth = 1;
    gbc.gridy++;
    gbc.gridx = 1;
    this.add(addbt, gbc);
    gbc.gridx++;
    this.add(deletebt, gbc);
    gbc.gridx++;
    this.add(refreshbt, gbc);

    gbc.gridy++;
    gbc.gridx = 1;
    this.add(new BlankBlock(), gbc);
  }
  /**
   * Creates a new NewStringPopupDialog object.
   *
   * @param parent DOCUMENT ME!
   * @param title DOCUMENT ME!
   */
  public NewStringPopupDialog(Frame parent, String title) {
    super(parent, true);
    setTitle(title);
    textField = new JTextField();
    textField.setPreferredSize(new Dimension(200, 25));
    theString = null;

    JButton okButton = new JButton("OK");
    JButton cancelButton = new JButton("Cancel");
    okButton.addActionListener(new OkAction());
    cancelButton.addActionListener(new CancelAction());

    JPanel panel = new JPanel();
    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    panel.setLayout(gridbag);
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 2;
    gridbag.setConstraints(textField, c);
    panel.add(textField);
    c.gridx = 0;
    c.gridy = 1;
    c.gridwidth = 1;
    gridbag.setConstraints(okButton, c);
    panel.add(okButton);
    c.gridx = 1;
    c.gridy = 1;
    gridbag.setConstraints(cancelButton, c);
    panel.add(cancelButton);
    setContentPane(panel);
    pack();
    setLocationRelativeTo(parent);
    setVisible(true);
  }
  private JPanel getMainPanel() {
    if (mainPanel == null) {
      mainPanel = new JPanel();
      mainPanel.setPreferredSize(new Dimension(550, 300));
      GridBagLayout layout = new GridBagLayout();

      mainPanel.setLayout(layout);

      GridBagConstraints constraints = new GridBagConstraints();

      constraints.fill = GridBagConstraints.BOTH;
      constraints.weightx = 2;
      constraints.weighty = 1;
      constraints.anchor = GridBagConstraints.NORTHWEST;
      constraints.gridwidth = 2;
      layout.setConstraints(getAvailableRobotsPanel(), constraints);
      mainPanel.add(getAvailableRobotsPanel());
      constraints.gridwidth = 1;
      constraints.weightx = 0;
      constraints.weighty = 0;
      constraints.anchor = GridBagConstraints.CENTER;
      layout.setConstraints(getButtonsPanel(), constraints);
      mainPanel.add(getButtonsPanel());
      constraints.gridwidth = GridBagConstraints.REMAINDER;
      constraints.weightx = 1;
      constraints.weighty = 1;
      constraints.anchor = GridBagConstraints.NORTHWEST;
      layout.setConstraints(getSelectedRobotsPanel(), constraints);
      mainPanel.add(getSelectedRobotsPanel());
    }
    return mainPanel;
  }
  private JPanel getPredefinedSettingsPanel() {
    if (predefinedSettingsPanel == null) {
      predefinedSettingsPanel = new JPanel();
      predefinedSettingsPanel.setBorder(
          BorderFactory.createTitledBorder(
              BorderFactory.createEtchedBorder(), "Predefined settings"));
      predefinedSettingsPanel.setLayout(new GridBagLayout());

      GridBagConstraints c = new GridBagConstraints();

      c.fill = GridBagConstraints.HORIZONTAL;
      c.insets = new Insets(5, 5, 5, 5);
      c.anchor = GridBagConstraints.PAGE_START;

      c.gridx = 0;
      c.gridy = 0;
      c.gridwidth = 3;
      predefinedSettingsPanel.add(new JLabel("Set all rendering settings towards:"), c);

      c.weightx = 1f / 3;
      c.gridwidth = 1;
      c.gridy = 2;
      predefinedSettingsPanel.add(getPredefinedPlatformDefaultButton(), c);
      c.gridx = 1;
      predefinedSettingsPanel.add(getPredefinedSpeedButton(), c);
      c.gridx = 2;
      predefinedSettingsPanel.add(getPredefinedQualityButton(), c);
    }
    return predefinedSettingsPanel;
  }
    public DisplayUserDirectory() {
      GridBagLayout gbl = new GridBagLayout();
      GridBagConstraints gbc = new GridBagConstraints();
      setLayout(gbl);

      gbc.anchor = GridBagConstraints.NORTHWEST;
      gbc.fill = GridBagConstraints.HORIZONTAL;

      hmlabel.setForeground(Color.black);
      add(hmlabel, gbc);
      add(Box.createHorizontalStrut(10), gbc);
      gbc.gridwidth = GridBagConstraints.REMAINDER;
      add(hmdir, gbc);
      add(Box.createVerticalStrut(15), gbc);

      gbc.gridwidth = 1;
      vjlabel.setForeground(Color.black);
      add(vjlabel, gbc);
      add(Box.createHorizontalStrut(10), gbc);
      gbc.gridwidth = GridBagConstraints.REMAINDER;
      add(vjdir, gbc);
      add(Box.createVerticalStrut(0), gbc);

      gbc.gridwidth = 1;
      vjlabel2.setForeground(Color.black);
      add(vjlabel2, gbc);
      setBorder(
          new CompoundBorder(
              // i18n
              // BorderFactory.createTitledBorder(" User_Directories "),
              BorderFactory.createTitledBorder(Util.getAdmLabel("_admin_User_Directories")),
              BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    }
Example #6
0
  public void initComponents() {
    GridBagLayout gridBag = new GridBagLayout();
    GridBagConstraints constraints = new GridBagConstraints();

    JLabel label;
    JPanel panel;
    Dimension size;

    setBorder(new javax.swing.border.EtchedBorder());
    setLayout(gridBag);

    label = new JLabel(name);
    constraints.anchor = GridBagConstraints.WEST;
    constraints.gridwidth = GridBagConstraints.REMAINDER;
    gridBag.setConstraints(label, constraints);
    add(label);

    panel = filterOptions();
    gridBag.setConstraints(panel, constraints);
    add(panel);

    sliderCutoff = new JSlider(JSlider.VERTICAL);
    sliderCutoff.setPaintTicks(true);
    sliderCutoff.setToolTipText("Cutoff Frequency");
    sliderCutoff.setMinimum(0);
    sliderCutoff.setMaximum(500);
    sliderCutoff.setMinorTickSpacing(25);
    sliderCutoff.setMajorTickSpacing(100);
    sliderCutoff.setValue(100);
    sliderCutoff.addChangeListener(new CutoffListener(filter));
    constraints.anchor = GridBagConstraints.CENTER;
    constraints.gridwidth = 1;
    gridBag.setConstraints(sliderCutoff, constraints);
    add(sliderCutoff);

    sliderResonance = new JSlider(JSlider.VERTICAL);
    sliderResonance.setPaintTicks(true);
    sliderResonance.setToolTipText("Resonance (Pass-band Ripple)");
    sliderResonance.setMinimum(1);
    sliderResonance.setMaximum(58);
    sliderResonance.setMinorTickSpacing(3);
    sliderResonance.setMajorTickSpacing(57);
    sliderResonance.setValue(1);
    sliderResonance.addChangeListener(new ResonanceListener(filter));
    constraints.gridwidth = GridBagConstraints.REMAINDER;
    gridBag.setConstraints(sliderResonance, constraints);
    add(sliderResonance);

    label = new JLabel("Cutoff");
    constraints.gridwidth = 1;
    constraints.ipadx = 10;
    gridBag.setConstraints(label, constraints);
    add(label);

    label = new JLabel("Resonance");
    constraints.gridwidth = GridBagConstraints.REMAINDER;
    gridBag.setConstraints(label, constraints);
    add(label);
  }
  protected JComponent createNorthPanel() {
    myNameField = new NameSuggestionsField(myProject);
    myNameChangedListener =
        new NameSuggestionsField.DataChanged() {
          public void dataChanged() {
            updateOkStatus();
          }
        };
    myNameField.addDataChangedListener(myNameChangedListener);

    JPanel panel = new JPanel(new GridBagLayout());
    GridBagConstraints gbConstraints = new GridBagConstraints();

    gbConstraints.insets = JBUI.insets(4);
    gbConstraints.anchor = GridBagConstraints.WEST;
    gbConstraints.fill = GridBagConstraints.BOTH;

    gbConstraints.gridwidth = 1;
    gbConstraints.weightx = 0;
    gbConstraints.weighty = 0;
    gbConstraints.gridx = 0;
    gbConstraints.gridy = 0;
    JLabel type = new JLabel(RefactoringBundle.message("variable.of.type"));
    panel.add(type, gbConstraints);

    gbConstraints.gridx++;
    myTypeSelector = myTypeSelectorManager.getTypeSelector();
    panel.add(myTypeSelector.getComponent(), gbConstraints);

    gbConstraints.gridwidth = 1;
    gbConstraints.weightx = 0;
    gbConstraints.weighty = 0;
    gbConstraints.gridx = 0;
    gbConstraints.gridy = 1;
    JLabel namePrompt = new JLabel(RefactoringBundle.message("name.prompt"));
    namePrompt.setLabelFor(myNameField.getComponent());
    panel.add(namePrompt, gbConstraints);

    gbConstraints.gridwidth = 1;
    gbConstraints.weightx = 1;
    gbConstraints.gridx = 1;
    gbConstraints.gridy = 1;
    panel.add(myNameField.getComponent(), gbConstraints);

    myNameSuggestionsManager =
        new NameSuggestionsManager(
            myTypeSelector,
            myNameField,
            new NameSuggestionsGenerator() {
              public SuggestedNameInfo getSuggestedNameInfo(PsiType type) {
                return IntroduceVariableBase.getSuggestedName(type, myExpression);
              }
            });
    myNameSuggestionsManager.setLabelsFor(type, namePrompt);

    return panel;
  }
Example #8
0
  public JFrame buildFrame() {

    f = new JFrame("AMSA World");
    f.setSize(800, 600);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setLayout(new GridBagLayout());

    textArea.setFocusable(false);
    JScrollPane scrollPane = new JScrollPane(textArea);
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

    ActionListener listener =
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            checkInput();
          }
        };
    inputText.addActionListener(listener);

    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.insets = new Insets(5, 5, 5, 5);
    c.weightx = 1.0;
    c.gridwidth = 3;
    c.weighty = 0.025;
    c.gridx = 0;
    c.gridy = 0;
    f.add(topPanel, c);

    c.fill = GridBagConstraints.BOTH;
    c.weighty = 1.0;
    c.gridwidth = 2;
    c.gridx = 0;
    c.gridy = 1;
    f.add(scrollPane, c);

    c.fill = GridBagConstraints.BOTH;
    c.weighty = 1.0;
    c.gridwidth = 1;
    c.gridx = 2;
    c.gridy = 1;
    f.add(sidePanel, c);
    sidePanel.setVisible(false);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.weighty = 0.025;
    c.gridwidth = 3;
    c.gridx = 0;
    c.gridy = 2;
    f.add(inputText, c);

    f.setVisible(true);

    return f;
  }
Example #9
0
  public FormBuilder addLabeledComponent(
      @Nullable JComponent label, @NotNull JComponent component, int topInset, boolean labelOnTop) {
    GridBagConstraints c = new GridBagConstraints();
    topInset = myLineCount > 0 ? topInset : 0;

    if (myVertical || labelOnTop || label == null) {
      c.gridwidth = 2;
      c.gridx = 0;
      c.gridy = myLineCount;
      c.weightx = 0;
      c.weighty = 0;
      c.fill = NONE;
      c.anchor = getLabelAnchor(component, false);
      c.insets = new Insets(topInset, myIndent, DEFAULT_VGAP, 0);

      if (label != null) myPanel.add(label, c);

      c.gridx = 0;
      c.gridy = myLineCount + 1;
      c.weightx = 1.0;
      c.weighty = getWeightY(component);
      c.fill = getFill(component);
      c.anchor = WEST;
      c.insets = new Insets(label == null ? topInset : 0, myIndent, 0, 0);

      myPanel.add(component, c);

      myLineCount += 2;
    } else {
      c.gridwidth = 1;
      c.gridx = 0;
      c.gridy = myLineCount;
      c.weightx = 0;
      c.weighty = 0;
      c.fill = NONE;
      c.anchor = getLabelAnchor(component, true);
      c.insets = new Insets(topInset, myIndent, 0, myHorizontalGap);

      myPanel.add(label, c);

      c.gridx = 1;
      c.weightx = 1;
      c.weighty = getWeightY(component);
      c.fill = getFill(component);
      c.anchor = WEST;
      c.insets = new Insets(topInset, myIndent, 0, 0);

      myPanel.add(component, c);

      myLineCount++;
    }

    return this;
  }
  private JPanel getSpecificSettingsPanel() {
    if (specificSettingsPanel == null) {
      specificSettingsPanel = new JPanel();
      specificSettingsPanel.setBorder(
          BorderFactory.createTitledBorder(
              BorderFactory.createEtchedBorder(), "Specific settings"));
      specificSettingsPanel.setLayout(new GridBagLayout());

      GridBagConstraints c = new GridBagConstraints();

      c.fill = GridBagConstraints.HORIZONTAL;
      c.insets = new Insets(5, 5, 5, 5);
      c.anchor = GridBagConstraints.PAGE_START;

      c.weightx = 0;

      c.gridwidth = 2;

      c.gridx = 0;
      c.gridy = 0;
      specificSettingsPanel.add(new JLabel("Set individual rendering options:"), c);

      c.gridwidth = 1;

      c.gridy = 1;
      specificSettingsPanel.add(new JLabel("Antialiasing", SwingConstants.RIGHT), c);
      c.gridx = 1;
      specificSettingsPanel.add(getOptionsRenderingAntialiasingComboBox(), c);

      c.gridx = 0;
      c.gridy = 2;
      specificSettingsPanel.add(new JLabel("Text Antialiasing", SwingConstants.RIGHT), c);
      c.gridx = 1;
      specificSettingsPanel.add(getOptionsRenderingTextAntialiasingComboBox(), c);

      c.gridx = 0;
      c.gridy = 3;
      specificSettingsPanel.add(new JLabel("Rendering Method", SwingConstants.RIGHT), c);
      c.gridx = 1;
      specificSettingsPanel.add(getOptionsRenderingMethodComboBox(), c);

      c.gridx = 0;
      c.gridy = 4;
      specificSettingsPanel.add(new JLabel(" "), c);

      c.gridx = 0;
      c.gridy = 5;
      specificSettingsPanel.add(new JLabel("Number of buffers", SwingConstants.RIGHT), c);
      c.gridx = 1;
      specificSettingsPanel.add(getOptionsRenderingNoBuffersComboBox(), c);
    }
    return specificSettingsPanel;
  }
  /**
   * Adds contact entry labels.
   *
   * @param nameLabelGridWidth the grid width of the contact entry name label
   */
  private void addLabels(int nameLabelGridWidth) {
    remove(nameLabel);
    remove(rightLabel);
    remove(displayDetailsLabel);

    if (treeNode != null && !(treeNode instanceof GroupNode))
      constraints.insets = new Insets(0, 0, V_GAP, H_GAP);
    else constraints.insets = new Insets(0, 0, 0, H_GAP);

    constraints.anchor = GridBagConstraints.WEST;
    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 1;
    constraints.gridy = 0;
    constraints.weightx = 1f;
    constraints.weighty = 0f;
    constraints.gridheight = 1;
    constraints.gridwidth = nameLabelGridWidth;
    this.add(nameLabel, constraints);

    constraints.anchor = GridBagConstraints.NORTHEAST;
    constraints.fill = GridBagConstraints.VERTICAL;
    constraints.gridx = nameLabelGridWidth + 1;
    constraints.gridy = 0;
    constraints.gridheight = 3;
    constraints.weightx = 0f;
    constraints.weighty = 1f;
    this.add(rightLabel, constraints);

    if (treeNode != null && treeNode instanceof ContactNode) {
      constraints.anchor = GridBagConstraints.WEST;
      constraints.fill = GridBagConstraints.NONE;
      constraints.gridx = 1;
      constraints.gridy = 1;
      constraints.weightx = 1f;
      constraints.weighty = 0f;
      constraints.gridwidth = nameLabelGridWidth;
      constraints.gridheight = 1;

      this.add(displayDetailsLabel, constraints);
    } else if (treeNode != null && treeNode instanceof GroupNode) {
      constraints.anchor = GridBagConstraints.WEST;
      constraints.fill = GridBagConstraints.NONE;
      constraints.gridx = 1;
      constraints.gridy = 1;
      constraints.weightx = 1f;
      constraints.weighty = 0f;
      constraints.gridwidth = nameLabelGridWidth;
      constraints.gridheight = 1;

      this.add(displayDetailsLabel, constraints);
    }
  }
Example #12
0
  public LoginScreen(DBConnectionFactory factory) {
    this.factory = factory;

    loginFrame = new JFrame("Login");
    loginFrame.setSize(500, 450);
    loginFrame.setVisible(true);

    Container content = loginFrame.getContentPane();
    JPanel panel = new JPanel(new GridBagLayout());
    GridBagConstraints cs = new GridBagConstraints();
    cs.fill = GridBagConstraints.HORIZONTAL;

    lbUsername = new JLabel("Username: "******"Password: "******"Login");
    loginButton.addActionListener(this);

    cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(this);

    JPanel buttonPanel = new JPanel();
    buttonPanel.add(loginButton);
    buttonPanel.add(cancelButton);

    content.add(panel, BorderLayout.CENTER);
    content.add(buttonPanel, BorderLayout.SOUTH);

    loginFrame.addWindowListener(new ExitListener());
  }
Example #13
0
  /** Créer les composants */
  private void initComponents() {

    text = new JTextArea();
    button_licence = new JButton();
    button_close = new JButton();
    logo = new LogoComponent();

    // Ajout des actions listeners
    button_licence.addActionListener(new ButtonLicenceActionListener());
    button_close.addActionListener(new ButtonCloseActionListener(this));

    logo.setPreferredSize(new Dimension(128, 128));

    text.setText(
        "Version : 1.0b \n"
            + "\n"
            + "Copyright © 2008-2012 Sipieter Clément \n"
            + "Copyright © 2011-2012 Sellem Lev-Arcady");
    text.setBackground(this.getBackground());

    button_licence.setText("Licence");
    button_close.setText("Fermer");

    this.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.HORIZONTAL;

    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.gridwidth = 1;
    this.add(logo, gbc);

    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.gridwidth = 3;
    gbc.insets = new Insets(20, 20, 20, 20);
    this.add(text, gbc);

    gbc.gridx = 1;
    gbc.gridy = 2;
    gbc.gridwidth = 1;
    gbc.insets = new Insets(5, 5, 20, 5);

    this.add(button_licence, gbc);

    gbc.gridx = 2;
    gbc.gridy = 2;
    this.add(button_close, gbc);
    this.pack();
  }
Example #14
0
  private void make_dice_and_JCheckBoxes(final DiceBoard db, boolean cheat) {
    diceSet.setBackground(Color.white);
    GridBagLayout gb = new GridBagLayout();
    GridBagConstraints gc;
    diceSet.setLayout(gb);
    for (int die = 0; die < DiceBoard.NUMDIE; die++) {
      dice[die] = new GuiDice(db.getDie(die), cheat);
      gc = new GridBagConstraints();
      gc.gridy = 0;
      gc.gridx = die;
      gb.setConstraints(dice[die], gc);
      diceSet.add(dice[die]);
    }
    // Add the roll JButton
    gc = new GridBagConstraints();
    gc.gridy = 0;
    gc.gridx = DiceBoard.NUMDIE;
    gc.gridwidth = GridBagConstraints.REMAINDER;
    gc.fill = GridBagConstraints.HORIZONTAL;
    gc.weightx = 1.0;
    gb.setConstraints(rollButton, gc);
    diceSet.add(rollButton);

    for (int die = 0; die < DiceBoard.NUMDIE; die++) {
      final int which = die;
      chbs[which] = new JCheckBox();
      chbs[which].setEnabled(false);
      chbs[which].addItemListener(
          new ItemListener() {
            // This method is called when the user clicks the JCheckBox
            public void itemStateChanged(ItemEvent e) {
              if (e.getStateChange() == ItemEvent.DESELECTED) db.getDie(which).setLock(false);
              else db.getDie(which).setLock(true);
            }
          });
      gc = new GridBagConstraints();
      gc.gridy = 1;
      gc.gridx = die;
      gb.setConstraints(chbs[die], gc);
      diceSet.add(chbs[which]);
    }

    gc = new GridBagConstraints();
    gc.gridy = 1;
    gc.gridx = DiceBoard.NUMDIE;
    gc.gridwidth = GridBagConstraints.REMAINDER;
    gb.setConstraints(nextPlayerJButton, gc);
    diceSet.add(nextPlayerJButton);
  }
Example #15
0
  // Initializing this component.
  private void jbInit() {
    callStackTable.addFocusListener(
        new FocusListener() {
          public void focusGained(FocusEvent e) {
            callStackTable_focusGained(e);
          }

          public void focusLost(FocusEvent e) {
            callStackTable_focusLost(e);
          }
        });
    callStackTable.setTableHeader(null);
    callStackTable.setDefaultRenderer(callStackTable.getColumnClass(0), getCellRenderer());
    scrollPane = new JScrollPane(callStackTable);
    setVisibleRows(DEFAULT_VISIBLE_ROWS);
    scrollPane.setLocation(0, 27);
    setBorder(BorderFactory.createEtchedBorder());
    // this.setLayout(null);
    this.setLayout(new GridBagLayout());
    nameLbl.setText("Call Stack");
    nameLbl.setBounds(new Rectangle(3, 4, 70, 23));
    nameLbl.setFont(Utilities.labelsFont);

    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    c.ipadx = 0;
    c.ipady = 0;
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = 7;
    c.gridheight = 1;
    c.anchor = GridBagConstraints.PAGE_END;
    c.gridx = 0;
    c.gridy = 2;
    this.add(scrollPane, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.ipadx = 0;
    c.ipady = 0;
    c.weightx = 1;
    c.weighty = 0.0;
    c.gridwidth = 3;
    c.gridheight = 1;
    c.anchor = GridBagConstraints.FIRST_LINE_START;
    c.gridx = 0;
    c.gridy = 0;
    c.insets = new Insets(5, 0, 0, 0);
    this.add(nameLbl, c);
  }
  public WelcomePane(String bannerMessage, ActionListener mainFrameActionListener) {

    this.setLayout(new GridBagLayout());
    GridBagConstraints bc = new GridBagConstraints();

    // adding bannerJLable to the WelcomePane
    JLabel bannerJLabel;
    bannerJLabel = new JLabel(bannerMessage);

    bc.gridy = 0;
    bc.gridx = 0;

    bc.gridwidth = 2;
    bc.weightx = 2;
    bc.weighty = 2;
    bc.anchor = GridBagConstraints.CENTER;
    this.add(bannerJLabel, bc);
    // ///////////////////////////////////////////////

    // adding signInButton to WelcomePane
    signInButton = new JButton("Sign-In");
    signInButton.setEnabled(false);
    signInButton.setPreferredSize(new Dimension(200, 50));

    bc.gridy = 1;
    bc.gridx = 0;

    bc.gridwidth = 1;
    bc.anchor = GridBagConstraints.CENTER;
    this.add(signInButton, bc);
    // ///////////////////////////////////////////////

    // adding orderAsGuestButton to WelcomePane
    orderAsGuestButton = new JButton("Order As Guest");
    orderAsGuestButton.setPreferredSize(new Dimension(200, 50));

    bc.gridy = 1;
    bc.gridx = 1;

    bc.gridwidth = 1;
    bc.weighty = 1;
    bc.anchor = GridBagConstraints.CENTER;
    this.add(orderAsGuestButton, bc);
    // ///////////////////////////////////////////////

    /// sets the actionListener to the MainFrame which implements ActionListener
    orderAsGuestButton.addActionListener(mainFrameActionListener);
  } // ends WelcomePane Constructor
    public String[] promptKeyboardInteractive(
        String destination, String name, String instruction, String[] prompt, boolean[] echo) {
      panel = new JPanel();
      panel.setLayout(new GridBagLayout());

      gbc.weightx = 1.0;
      gbc.gridwidth = GridBagConstraints.REMAINDER;
      gbc.gridx = 0;
      panel.add(new JLabel(instruction), gbc);
      gbc.gridy++;

      gbc.gridwidth = GridBagConstraints.RELATIVE;

      JTextField[] texts = new JTextField[prompt.length];
      for (int i = 0; i < prompt.length; i++) {
        gbc.fill = GridBagConstraints.NONE;
        gbc.gridx = 0;
        gbc.weightx = 1;
        panel.add(new JLabel(prompt[i]), gbc);

        gbc.gridx = 1;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.weighty = 1;
        if (echo[i]) {
          texts[i] = new JTextField(20);
        } else {
          texts[i] = new JPasswordField(20);
        }
        panel.add(texts[i], gbc);
        gbc.gridy++;
      }

      if (JOptionPane.showConfirmDialog(
              null,
              panel,
              destination + ": " + name,
              JOptionPane.OK_CANCEL_OPTION,
              JOptionPane.QUESTION_MESSAGE)
          == JOptionPane.OK_OPTION) {
        String[] response = new String[prompt.length];
        for (int i = 0; i < prompt.length; i++) {
          response[i] = texts[i].getText();
        }
        return response;
      } else {
        return null; // cancel
      }
    }
  /**
   * Adds a JLabel and three JRadioButton instances in a ButtonGroup to the given panel with a
   * GridBagLayout, and returns the buttons in an array.
   */
  private JRadioButton[] addRadioButtonTriplet(String labelText, JPanel panel) {
    GridBagConstraints labelConstraints = new GridBagConstraints();
    labelConstraints.anchor = GridBagConstraints.WEST;
    labelConstraints.insets = new Insets(2, 10, 2, 10);

    GridBagConstraints buttonConstraints = new GridBagConstraints();
    buttonConstraints.insets = labelConstraints.insets;

    GridBagConstraints lastGlueConstraints = new GridBagConstraints();
    lastGlueConstraints.gridwidth = GridBagConstraints.REMAINDER;
    lastGlueConstraints.weightx = 1.0;

    // Create the radio buttons.
    JRadioButton radioButton0 = new JRadioButton();
    JRadioButton radioButton1 = new JRadioButton();
    JRadioButton radioButton2 = new JRadioButton();

    // Put them in a button group.
    ButtonGroup buttonGroup = new ButtonGroup();
    buttonGroup.add(radioButton0);
    buttonGroup.add(radioButton1);
    buttonGroup.add(radioButton2);

    // Add the label and the buttons to the panel.
    panel.add(new JLabel(labelText), labelConstraints);
    panel.add(radioButton0, buttonConstraints);
    panel.add(radioButton1, buttonConstraints);
    panel.add(radioButton2, buttonConstraints);
    panel.add(Box.createGlue(), lastGlueConstraints);

    return new JRadioButton[] {radioButton0, radioButton1, radioButton2};
  }
Example #19
0
 private void addView() {
   GridBagConstraints gbc = new GridBagConstraints();
   gbc.gridwidth = 1;
   gbc.gridx = 6;
   gbc.gridy = 0;
   add((JComponent) _secondaryView, gbc);
 }
Example #20
0
  private void initialize() {
    setName("JunkPanel");
    setLayout(new GridBagLayout());
    refreshLanguage();

    // Adds all of the components
    final GridBagConstraints constraints = new GridBagConstraints();
    constraints.anchor = GridBagConstraints.WEST;
    final Insets insets5555 = new Insets(5, 5, 5, 5);
    constraints.insets = insets5555;
    constraints.weightx = 1.0;
    constraints.gridwidth = 1;
    constraints.gridy = 0;

    constraints.insets = insets5555;
    constraints.gridx = 0;

    add(hideJunkMessagesCheckBox, constraints);

    constraints.gridy++;

    add(markJunkIdentityBadCheckBox, constraints);

    constraints.gridy++;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    {
      final JSeparator separator = new JSeparator(SwingConstants.HORIZONTAL);
      add(separator, constraints);
    }
    constraints.fill = GridBagConstraints.NONE;
    constraints.gridy++;

    add(stopBoardUpdatesWhenDosedCheckBox, constraints);

    constraints.gridy++;

    {
      final JPanel subPanel = new JPanel(new GridBagLayout());
      final GridBagConstraints subConstraints = new GridBagConstraints();
      subConstraints.insets = new Insets(0, 10, 0, 10);
      subConstraints.anchor = GridBagConstraints.WEST;
      subConstraints.gridx = 0;
      subPanel.add(LinvalidSubsequentMessagesThreshold, subConstraints);
      subConstraints.gridx = 1;
      subPanel.add(TfInvalidSubsequentMessagesThreshold, subConstraints);

      add(subPanel, constraints);
    }

    // glue
    constraints.gridy++;
    constraints.gridx = 0;
    constraints.fill = GridBagConstraints.BOTH;
    constraints.weightx = 1;
    constraints.weighty = 1;
    add(new JLabel(""), constraints);

    // Add listeners
    stopBoardUpdatesWhenDosedCheckBox.addActionListener(listener);
  }
    public DisplayResults() {
      GridBagLayout gbl = new GridBagLayout();
      GridBagConstraints gbc = new GridBagConstraints();
      setLayout(gbl);

      gbc.anchor = GridBagConstraints.NORTHWEST;
      gbc.fill = GridBagConstraints.HORIZONTAL;

      text.setForeground(Color.black);
      add(text, gbc);
      gbc.gridy = 0;
      gbc.gridwidth = GridBagConstraints.REMAINDER;
      add(emptyLabel, gbc);
      add(Box.createVerticalStrut(0), gbc);
      add(emptyLabel, gbc);

      /*	 gbc.gridy = 1;
      VTextMsg result = new VTextMsg(sshare, vnmrif, null);
      result.setPreferredSize(new Dimension(300, 30));
      result.setForeground(Color.black);
      add( result, gbc );
      */
      setBorder(
          new CompoundBorder(
              BorderFactory.createTitledBorder("  Results  "),
              BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    }
  public void defineOwnConstraints(
      Component c,
      int y,
      int x,
      int w,
      int h,
      int weightx,
      int weighty,
      int fill,
      int anchor,
      int bottomInsets,
      int leftInsets,
      int rightInsets,
      int topInsets) {
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.insets.bottom = bottomInsets;
    gbc.insets.left = leftInsets;
    gbc.insets.right = rightInsets;
    gbc.insets.top = topInsets;

    gbc.weightx = weightx;
    gbc.weighty = weighty;

    gbc.fill = fill;
    gbc.anchor = anchor;

    gbc.gridx = x - 1;
    gbc.gridy = y - 1;

    gbc.gridwidth = w;
    gbc.gridheight = h;

    setConstraints(c, gbc);
  }
Example #23
0
 private void add(Component c, GridBagConstraints gbc, int x, int y, int w, int h) {
   gbc.gridx = x;
   gbc.gridy = y;
   gbc.gridwidth = w;
   gbc.gridheight = h;
   getContentPane().add(c, gbc);
 }
    public void addRow(String label, JComponent component) {
      GridBagConstraints labelConstraints = new GridBagConstraints();
      labelConstraints.gridx = 0;
      labelConstraints.gridy = rowCount;
      labelConstraints.insets = new Insets(0, 0, 5, 5);
      labelConstraints.anchor = GridBagConstraints.LINE_END;

      GridBagConstraints componentConstraints = new GridBagConstraints();
      componentConstraints.gridx = 1;
      componentConstraints.gridy = rowCount;
      componentConstraints.gridwidth = GridBagConstraints.REMAINDER;
      componentConstraints.fill = GridBagConstraints.HORIZONTAL;
      componentConstraints.insets = new Insets(0, 0, 5, 0);
      componentConstraints.anchor = GridBagConstraints.LINE_START;

      JLabel l = new JLabel(label + ":");
      add(l, labelConstraints);
      add(component, componentConstraints);
      rowCount++;

      // Add another column/row that takes up all available space.
      // This moves the layout to the top-left corner.
      layout.columnWidths = new int[] {0, 0, 0};
      layout.columnWeights = new double[] {0.0, 0.0, 1.0E-4};
      layout.rowHeights = new int[rowCount + 1];
      layout.rowWeights = new double[rowCount + 1];
      layout.rowWeights[rowCount] = 1.0E-4;
    }
  public static void addToGridBag(
      GridBagLayout grid,
      Container cont,
      Component comp,
      int x,
      int y,
      int gw,
      int gh,
      double wx,
      double wy,
      int fill,
      int anchor) {
    // now the constraints
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = x;
    gbc.gridy = y;
    gbc.weightx = wx;
    gbc.weighty = wy;
    gbc.fill = fill;
    gbc.gridwidth = gw;
    gbc.gridheight = gh;
    gbc.anchor = anchor;

    cont.add(comp);
    grid.setConstraints(comp, gbc);
  }
  private int addButton(SIPCommButton button, int gridX, int xBounds, boolean isLast) {
    lastAddedButton = button;

    constraints.insets = new Insets(0, 0, V_GAP, 0);
    constraints.anchor = GridBagConstraints.WEST;
    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = gridX;
    constraints.gridy = 2;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    constraints.weightx = 0f;
    constraints.weighty = 0f;
    this.add(button, constraints);

    int yBounds =
        TOP_BORDER
            + BOTTOM_BORDER
            + 2 * V_GAP
            + ComponentUtils.getStringSize(nameLabel, nameLabel.getText()).height
            + ComponentUtils.getStringSize(displayDetailsLabel, displayDetailsLabel.getText())
                .height;

    button.setBounds(xBounds, yBounds, BUTTON_WIDTH, BUTTON_HEIGHT);

    button.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));

    setButtonBg(button, gridX, isLast);

    return button.getWidth();
  }
Example #27
0
  private void createLayout() {
    mViewDocButton.setHorizontalAlignment(SwingConstants.LEFT);
    mViewDocButton.setEnabled(false);
    mLinksScrollPane.getViewport().add(mLinksList);
    setLayout(new GridBagLayout());
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.anchor = GridBagConstraints.CENTER;
    constraints.insets = GUIConstants.INSETS;
    constraints.gridwidth = 1;

    constraints.gridheight = 2;
    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.weightx = 1;
    constraints.weighty = 1;
    constraints.fill = GridBagConstraints.BOTH;
    add(mLinksScrollPane, constraints);

    constraints.weightx = 0;
    constraints.weighty = 0;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.gridheight = 1;
    constraints.gridx = 1;
    add(mViewDocButton, constraints);
  }
  private void buildGUI() {
    // add all page components to grid layout panel
    pagesPanel = new JPanel();
    pagesPanel.setBackground(backgroundColor);
    // one column equals single page view continuous
    GridLayout gridLayout = new GridLayout(0, 1, horizontalSpace, verticalSpace);
    pagesPanel.setLayout(gridLayout);

    // use a grid bag to center the page component panel
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.weighty = 1.0; // allows vertical resizing
    gbc.weightx = 1.0; // allows horizontal resizing
    gbc.insets = // component spacer [top, left, bottom, right]
        new Insets(layoutInserts, layoutInserts, layoutInserts, layoutInserts);
    gbc.gridwidth = GridBagConstraints.REMAINDER; // one component per row

    this.setLayout(new GridBagLayout());
    this.add(pagesPanel, gbc);

    // finally add all the components
    // add components for every page in the document
    List<AbstractPageViewComponent> pageComponents = documentViewModel.getPageComponents();

    if (pageComponents != null) {
      for (PageViewComponent pageViewComponent : pageComponents) {
        if (pageViewComponent != null) {
          pageViewComponent.setDocumentViewCallback(this);
          // add component to layout
          pagesPanel.add(new PageViewDecorator((AbstractPageViewComponent) pageViewComponent));
        }
      }
    }
  }
Example #29
0
  public SettingsFrame() {
    thisFrame = this;
    setTitle(StringConstants.FRAME_SETTINGS);
    setSize(UiConstants.WIN_34_DIM);
    setLocationByPlatform(true);
    setResizable(false);
    setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
    setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();

    // add the content panel
    JTabbedPane tabbedPane = new JTabbedPane();
    tabbedPane.setBackground(Color.WHITE);

    tabbedPane.addTab(StringConstants.TAB_GENERAL, new TabGeneral());

    c.fill = GridBagConstraints.BOTH;
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 100;
    c.weighty = 98;
    add(tabbedPane, c);

    c.fill = GridBagConstraints.BOTH;
    c.gridx = 0;
    c.gridy = 1;
    c.gridwidth = 2;
    c.weightx = 100;
    c.weighty = 0;

    // button panel
    add(new OKPanel(), c);
  }
  public BaseGoogleLoginUI(@NotNull String signinText) {
    setLayout(new GridBagLayout());
    setPreferredSize(new Dimension(MIN_WIDTH, PREFERRED_HEIGHT));
    setOpaque(false);

    JLabel googleIcon = new JBLabel();

    setBorder(BorderFactory.createEmptyBorder(10, 15, 15, 15));
    googleIcon.setHorizontalAlignment(SwingConstants.CENTER);
    googleIcon.setVerticalAlignment(SwingConstants.CENTER);
    googleIcon.setOpaque(false);
    googleIcon.setIcon(GoogleLoginIcons.GOOGLE_LOGO);
    googleIcon.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
    GridBagConstraints c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = 0;
    c.weighty = 0;
    add(googleIcon, c);

    JTextArea signinTextArea = new JTextArea();
    signinTextArea.setFont(UIUtil.getLabelFont());
    signinTextArea.setLineWrap(true);
    signinTextArea.setWrapStyleWord(true);
    signinTextArea.setOpaque(false);
    signinTextArea.setText(signinText);
    c.gridx = 0;
    c.gridy = 1;
    c.weighty = 1;
    c.gridwidth = 2;
    c.weightx = 1;
    c.fill = GridBagConstraints.BOTH;
    c.anchor = GridBagConstraints.CENTER;
    add(signinTextArea, c);
  }