Пример #1
1
  /** Initializes contained components. */
  private void initComponents() {
    final SimpleDateFormat format = new SimpleDateFormat("mm:ss");
    final Calendar c = Calendar.getInstance();
    final JLabel counter = new JLabel();

    counter.setForeground(Color.red);
    counter.setFont(counter.getFont().deriveFont((float) (counter.getFont().getSize() + 5)));

    setLayout(new GridBagLayout());
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));

    GridBagConstraints constraints = new GridBagConstraints();

    JLabel messageLabel =
        new JLabel(
            GuiActivator.getResources().getI18NString("service.gui.security.SECURITY_ALERT"));

    messageLabel.setForeground(Color.WHITE);

    constraints.anchor = GridBagConstraints.CENTER;
    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 0;
    constraints.gridy = 0;
    add(messageLabel, constraints);

    constraints.anchor = GridBagConstraints.CENTER;
    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 0;
    constraints.gridy = 1;
    add(counter, constraints);

    ZrtpControl zrtpControl = null;
    if (securityControl instanceof ZrtpControl) zrtpControl = (ZrtpControl) securityControl;

    long initialSeconds = 0;

    if (zrtpControl != null) initialSeconds = zrtpControl.getTimeoutValue();

    c.setTimeInMillis(initialSeconds);

    counter.setText(format.format(c.getTime()));

    if (initialSeconds > 0)
      timer.schedule(
          new TimerTask() {
            @Override
            public void run() {
              if (c.getTimeInMillis() - 1000 > 0) {
                c.add(Calendar.SECOND, -1);
                counter.setText(format.format(c.getTime()));
              }
            }
          },
          1000,
          1000);
  }
Пример #2
0
  public ManageBankView() {
    GridBagLayout gridBagLayout = new GridBagLayout();
    gridBagLayout.columnWidths = new int[] {0, 0, 0, 0, 0};
    gridBagLayout.rowHeights = new int[] {0, 0, 0, 0, 0};
    gridBagLayout.columnWeights = new double[] {0.0, 0.0, 0.0, 1.0, Double.MIN_VALUE};
    gridBagLayout.rowWeights = new double[] {0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
    getContentPane().setLayout(gridBagLayout);

    JLabel lblEnterBank = new JLabel("Enter Bank");
    GridBagConstraints gbc_lblEnterBank = new GridBagConstraints();
    gbc_lblEnterBank.insets = new Insets(0, 0, 5, 5);
    gbc_lblEnterBank.gridx = 1;
    gbc_lblEnterBank.gridy = 1;
    getContentPane().add(lblEnterBank, gbc_lblEnterBank);

    txtBankName = new JTextField();
    GridBagConstraints gbc_txtBankName = new GridBagConstraints();
    gbc_txtBankName.insets = new Insets(0, 0, 5, 0);
    gbc_txtBankName.fill = GridBagConstraints.HORIZONTAL;
    gbc_txtBankName.gridx = 3;
    gbc_txtBankName.gridy = 1;
    getContentPane().add(txtBankName, gbc_txtBankName);
    txtBankName.setColumns(10);

    JButton btnAdd = new JButton("Add");
    GridBagConstraints gbc_btnAdd = new GridBagConstraints();
    gbc_btnAdd.insets = new Insets(0, 0, 0, 5);
    gbc_btnAdd.gridx = 1;
    gbc_btnAdd.gridy = 3;
    getContentPane().add(btnAdd, gbc_btnAdd);
  }
Пример #3
0
        {
          setLayout(new GridBagLayout()); // Elrendezés beállítása
          GridBagConstraints c = new GridBagConstraints(); // Szükséges konstans

          JLabel lbUsername = new JLabel("Felhasználónév"); // A felhasználónév címkéje
          JLabel lbPassword = new JLabel("Jelszó"); // A jelszó címkéje

          lbUsername.setIcon(RM.getUsernameIcon()); // "felhasználónév" címke Ikonjának beállítása
          lbPassword.setIcon(RM.getPasswordIcon()); // "Jelszó" címke Ikonjának beállítása

          lbUsername.setPreferredSize(new Dimension(120, 25)); // Címke átméretezése
          lbPassword.setPreferredSize(new Dimension(120, 25)); // Címke átméretezése

          // [0,0]
          c.gridx = 0; // oszlop
          c.gridy = 0; // sor
          add(lbUsername, c); // a "Felhasználónév" címke hozzáadása

          // [1,0]
          c.gridx = 1;
          add(tfUsername, c); // A "felhasználónév" szövegmező hozzáadása

          // [0,1]
          c.gridx = 0;
          c.gridy = 1;
          add(lbPassword, c); // A "Jelszó" címke hozzáadása

          // [1,1]
          c.gridx = 1;
          c.gridy = 1;
          add(pfPassword, c); // A "jelszó" jelszómező hozzáadása
        }
  public static void addToPane(Container pane) {
    pane.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;

    c.gridy = 0;
    pane.add(input, c);
    c.gridy = 1;
    pane.add(output, c);
    c.gridy = 2;
    analyze.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            table = new HashTable();
            String toAnalyze = input.getText();
            Scanner in = new Scanner(toAnalyze);
            in.useDelimiter("[^\\p{Alpha}']+");
            while (in.hasNext()) {
              table.add(in.next().toLowerCase());
            }

            output.setText(table.toString());
            // output.setText("" + table.uniqueWords);
          }
        });
    pane.add(analyze, c);
  }
Пример #5
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);
  }
Пример #6
0
 /**
  * This method initializes AggButtonPanel
  *
  * @return javax.swing.JPanel
  */
 private JPanel getAggButtonPanel() {
   if (AggButtonPanel == null) {
     GridBagConstraints gridBagConstraints21 = new GridBagConstraints();
     gridBagConstraints21.gridx = 0;
     gridBagConstraints21.gridy = 4;
     GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
     gridBagConstraints11.gridx = 0;
     gridBagConstraints11.gridy = 3;
     GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
     gridBagConstraints2.gridx = 0;
     gridBagConstraints2.gridy = 2;
     GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
     gridBagConstraints1.gridx = 0;
     gridBagConstraints1.gridy = 1;
     GridBagConstraints gridBagConstraints = new GridBagConstraints();
     gridBagConstraints.gridx = 0;
     gridBagConstraints.gridy = 0;
     AggButtonPanel = new JPanel();
     AggButtonPanel.setLayout(new GridBagLayout());
     AggButtonPanel.add(getAggAdd(), gridBagConstraints);
     AggButtonPanel.add(getAggRemove(), gridBagConstraints1);
     AggButtonPanel.add(getAggEdit(), gridBagConstraints2);
     AggButtonPanel.add(getDoneButton(), gridBagConstraints11);
     AggButtonPanel.add(getAbort(), gridBagConstraints21);
   }
   return AggButtonPanel;
 }
  /**
   * 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);
  }
Пример #8
0
  private static JPanel makePanel(String title, String href) {
    JPanel p = new JPanel(new GridBagLayout());
    p.setBorder(BorderFactory.createTitledBorder(title));

    JLabel label = new JLabel(href);

    JEditorPane editor = new JEditorPane("text/html", href);
    editor.setOpaque(false);
    editor.setEditable(false);
    editor.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);

    GridBagConstraints c = new GridBagConstraints();
    c.gridheight = 1;

    c.gridx = 0;
    c.insets = new Insets(5, 5, 5, 0);
    c.anchor = GridBagConstraints.EAST;
    c.gridy = 0;
    p.add(new JLabel("JLabel: "), c);
    c.gridy = 2;
    p.add(new JLabel("JEditorPane: "), c);

    c.gridx = 1;
    c.weightx = 1d;
    c.anchor = GridBagConstraints.WEST;
    c.gridy = 0;
    p.add(label, c);
    c.gridy = 2;
    p.add(editor, c);

    return p;
  }
  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;
  }
  private void initLayout() {
    this.setLayout(new GridBagLayout());
    GridBagConstraints c = null;

    c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 0.5;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.insets = new Insets(10, 0, 10, 0);
    this.add(this.initControllPanel(), c);

    c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = 1;
    c.weightx = 0.5;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.insets = new Insets(10, 0, 10, 0);
    this.add(this.initClassPanel(), c);

    c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = 2;
    c.weightx = 0.5;
    c.fill = GridBagConstraints.HORIZONTAL;
    this.add(this.initRelationPanel(), c);

    c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = 3;
    c.weightx = 0.5;
    c.weighty = 0.5;
    c.fill = GridBagConstraints.BOTH;
    this.add(new JPanel(), c);
  }
Пример #11
0
    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;
    }
    private OptionsPanel() {
      super(new GridBagLayout());

      GridBagConstraints gc = new GridBagConstraints();
      gc.fill = GridBagConstraints.HORIZONTAL;
      gc.weightx = 1;
      gc.weighty = 0;
      gc.anchor = GridBagConstraints.NORTHWEST;

      myPackageLocalForMembersCheckbox =
          new JCheckBox(InspectionsBundle.message("inspection.visibility.option"));
      myPackageLocalForMembersCheckbox.setSelected(SUGGEST_PACKAGE_LOCAL_FOR_MEMBERS);
      myPackageLocalForMembersCheckbox
          .getModel()
          .addChangeListener(
              new ChangeListener() {
                @Override
                public void stateChanged(ChangeEvent e) {
                  SUGGEST_PACKAGE_LOCAL_FOR_MEMBERS = myPackageLocalForMembersCheckbox.isSelected();
                }
              });

      gc.gridy = 0;
      add(myPackageLocalForMembersCheckbox, gc);

      myPackageLocalForTopClassesCheckbox =
          new JCheckBox(InspectionsBundle.message("inspection.visibility.option1"));
      myPackageLocalForTopClassesCheckbox.setSelected(SUGGEST_PACKAGE_LOCAL_FOR_TOP_CLASSES);
      myPackageLocalForTopClassesCheckbox
          .getModel()
          .addChangeListener(
              new ChangeListener() {
                @Override
                public void stateChanged(ChangeEvent e) {
                  SUGGEST_PACKAGE_LOCAL_FOR_TOP_CLASSES =
                      myPackageLocalForTopClassesCheckbox.isSelected();
                }
              });

      gc.gridy = 1;
      add(myPackageLocalForTopClassesCheckbox, gc);

      myPrivateForInnersCheckbox =
          new JCheckBox(InspectionsBundle.message("inspection.visibility.option2"));
      myPrivateForInnersCheckbox.setSelected(SUGGEST_PRIVATE_FOR_INNERS);
      myPrivateForInnersCheckbox
          .getModel()
          .addChangeListener(
              new ChangeListener() {
                @Override
                public void stateChanged(ChangeEvent e) {
                  SUGGEST_PRIVATE_FOR_INNERS = myPrivateForInnersCheckbox.isSelected();
                }
              });

      gc.gridy = 2;
      gc.weighty = 1;
      add(myPrivateForInnersCheckbox, gc);
    }
  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;
  }
Пример #14
0
  private void repaintContent() {
    if (content != null) {
      remove(content);
    }
    content = new JPanel();

    content.setLayout(new GridBagLayout());
    content.setBackground(Colors.TEMPLATE);
    int gridY = 0;
    GridBagConstraints c;
    for (Parameter p : shownParams.getParamList()) {
      c = new GridBagConstraints();
      c.gridx = 0;
      c.gridy = gridY;
      c.anchor = GridBagConstraints.WEST;
      c.fill = GridBagConstraints.NONE;
      c.insets = new Insets(0, 0, 0, 8);
      content.add(new JLabel(p.getName()), c);

      c = new GridBagConstraints();
      c.gridx = 1;
      c.gridy = gridY++;
      c.fill = GridBagConstraints.HORIZONTAL;
      c.weightx = 1;
      final Parameter pFinal = p;
      final JTextField jTextField = new DJTextField();
      jTextField.setText(p.getValue());
      jTextField.addKeyListener(
          new KeyListener() {
            public void keyTyped(KeyEvent keyEvent) {
              // TODO
            }

            public void keyPressed(KeyEvent keyEvent) {
              // TODO
            }

            public void keyReleased(KeyEvent keyEvent) {
              pFinal.setValue(jTextField.getText());
            }
          });
      content.add(jTextField, c);
    }

    GridBagConstraints nc = new GridBagConstraints();
    nc.gridx = 0;
    nc.gridy = 0;
    nc.weightx = 1;
    nc.fill = GridBagConstraints.HORIZONTAL;

    add(content, nc);

    content.updateUI();
    content.repaint();
    this.repaint();
  }
Пример #15
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;
  }
Пример #16
0
  /**
   * Used to create the top panel describing the current feedback question
   *
   * @param fb Feedback question to describe
   * @return Panel with title and description
   */
  public JPanel createQuestionDataPanel(AbstractFeedbackType fb) {
    JPanel questionPanel = new JPanel();
    questionPanel.setLayout(new GridBagLayout());
    questionPanel.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));

    GridBagConstraints leftBoxConst = new GridBagConstraints();
    leftBoxConst.anchor = GridBagConstraints.LINE_START;
    leftBoxConst.gridx = 0;
    leftBoxConst.gridy = 0;
    leftBoxConst.gridheight = 2;

    JLabel titleLabel = new JLabel(fb.getTitle());
    GridBagConstraints titleLabelConst = new GridBagConstraints();
    titleLabelConst.anchor = GridBagConstraints.CENTER;
    titleLabelConst.gridx = 1;
    titleLabelConst.gridy = 0;
    titleLabelConst.weightx = 1.0;
    Font titleLabelFont = titleLabel.getFont();
    titleLabel.setFont(
        new Font(
            titleLabelFont.getName(),
            Font.BOLD,
            titleLabelFont.getSize() + 4)); // increase label font size by 2

    JLabel descLabel = new JLabel(fb.getDescription());
    GridBagConstraints descLabelConst = new GridBagConstraints();
    descLabelConst.anchor = GridBagConstraints.CENTER;
    descLabelConst.gridx = 1;
    descLabelConst.gridy = 1;
    descLabelConst.weightx = 1.0;

    JLabel exclLabel = new JLabel("!");
    exclLabel.setAlignmentX(RIGHT_ALIGNMENT);
    exclLabel.setToolTipText("Response is mandatory");
    try {
      exclLabel.setFont(loadGlyphFont(titleLabelFont.getSize() + 4));
      exclLabel.setText("\ue101");
    } catch (FontFormatException | IOException e) {
      e.printStackTrace();
    }
    GridBagConstraints rightBoxConst = new GridBagConstraints();
    rightBoxConst.anchor = GridBagConstraints.LINE_END;
    rightBoxConst.gridx = 2;
    rightBoxConst.gridy = 0;
    rightBoxConst.gridheight = 2;
    rightBoxConst.ipadx = 4;

    questionPanel.add(new JPanel(), leftBoxConst);
    questionPanel.add(titleLabel, titleLabelConst);
    questionPanel.add(descLabel, descLabelConst);
    questionPanel.add(fb.isMandatory() ? exclLabel : new JPanel(), rightBoxConst);

    return questionPanel;
  }
Пример #17
0
  public static void main(String args[]) {

    JFrame f = new JFrame("JPasswordField3");
    Container contentPane = f.getContentPane();
    contentPane.setLayout(new BorderLayout());

    JPanel p1 = new JPanel();
    // p1.setLayout(new GridLayout(4,2));
    p1.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.WEST; // 设定Layout的位置
    gbc.insets = new Insets(2, 2, 2, 2); // 设定与边界的距离(上,左,下,右)

    p1.setBorder(BorderFactory.createTitledBorder("您的基本数据"));
    JLabel l1 = new JLabel("姓名:");
    JLabel l2 = new JLabel("性别:");
    JLabel l3 = new JLabel("身高:");
    JLabel l4 = new JLabel("体重:");
    JPasswordField t1 = new JPasswordField(new JPasswordField3_OnlyNumberDocument(10), "", 10);
    JPasswordField t2 = new JPasswordField(new JPasswordField3_OnlyNumberDocument(1), "", 2);
    JPasswordField t3 = new JPasswordField(new JPasswordField3_OnlyNumberDocument(5), "", 5);
    JPasswordField t4 = new JPasswordField(new JPasswordField3_OnlyNumberDocument(5), "", 5);

    gbc.gridy = 1;
    gbc.gridx = 0;
    p1.add(l1, gbc);
    gbc.gridx = 1;
    p1.add(t1, gbc);
    gbc.gridy = 2;
    gbc.gridx = 0;
    p1.add(l2, gbc);
    gbc.gridx = 1;
    p1.add(t2, gbc);
    gbc.gridy = 3;
    gbc.gridx = 0;
    p1.add(l3, gbc);
    gbc.gridx = 1;
    p1.add(t3, gbc);
    gbc.gridy = 4;
    gbc.gridx = 0;
    p1.add(l4, gbc);
    gbc.gridx = 1;
    p1.add(t4, gbc);

    contentPane.add(p1);
    f.pack();
    f.show();
    f.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });
  }
  public MavenProjectImportStep(WizardContext wizardContext) {
    super(wizardContext);

    myImportingSettingsForm =
        new MavenImportingSettingsForm(true, wizardContext.isCreatingNewProject()) {
          public String getDefaultModuleDir() {
            return myRootPathComponent.getPath();
          }
        };

    myRootPathComponent =
        new NamePathComponent(
            "",
            ProjectBundle.message("maven.import.label.select.root"),
            ProjectBundle.message("maven.import.title.select.root"),
            "",
            false,
            false);

    JButton envSettingsButton =
        new JButton(ProjectBundle.message("maven.import.environment.settings"));
    envSettingsButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            ShowSettingsUtil.getInstance()
                .editConfigurable(myPanel, new MavenEnvironmentConfigurable());
          }
        });

    myPanel = new JPanel(new GridBagLayout());
    myPanel.setBorder(BorderFactory.createEtchedBorder());

    GridBagConstraints c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.insets = JBUI.insets(4, 4, 0, 4);

    myPanel.add(myRootPathComponent, c);

    c.gridy = 1;
    c.insets = JBUI.insets(4, 4, 0, 4);
    myPanel.add(myImportingSettingsForm.createComponent(), c);

    c.gridy = 2;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.NORTHEAST;
    c.weighty = 1;
    c.insets = JBUI.insets(4 + envSettingsButton.getPreferredSize().height, 4, 4, 4);
    myPanel.add(envSettingsButton, c);

    myRootPathComponent.setNameComponentVisible(false);
  }
Пример #19
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;
  }
Пример #20
0
 public void drawItems() {
   itemList.removeAll();
   OrderedItem orders[] = commande.getOrders();
   for (int i = 0; i < orders.length; i++) {
     GridBagConstraints constraintLeft = new GridBagConstraints(),
         constraintRight = new GridBagConstraints();
     constraintLeft.gridx = 0;
     constraintLeft.gridy = GridBagConstraints.RELATIVE;
     constraintLeft.fill = GridBagConstraints.HORIZONTAL;
     constraintRight.gridx = 1;
     constraintRight.gridy = GridBagConstraints.RELATIVE;
     constraintRight.fill = GridBagConstraints.HORIZONTAL;
     String itemText = orders[i].getItem().getNom();
     if (itemText.length() > 15) {
       itemText = itemText.substring(0, 12) + "...";
     }
     JLabel item = new JLabel(itemText);
     JPanel itemTextHolder = new JPanel();
     itemTextHolder.setBorder(BorderFactory.createLineBorder(Color.BLUE));
     itemTextHolder.setBackground(Color.WHITE);
     itemTextHolder.add(item);
     itemList.add(itemTextHolder, constraintLeft);
     Color bg = Color.WHITE;
     String statusIcon = "";
     JLabel itemStatus = new JLabel();
     JPanel statusHolder = new JPanel();
     switch (orders[i].getStatus()) {
       case 0:
         bg = Color.RED;
         statusIcon = "\u2718";
         break;
       case 1:
         bg = Color.YELLOW;
         statusIcon = "\u2718";
         break;
       case 2:
         bg = Color.GREEN;
         statusIcon = "\u2718";
         break;
       case 3:
         bg = Color.GRAY;
         statusIcon = "\u2713";
         break;
     }
     itemStatus.setText(statusIcon);
     statusHolder.setBackground(bg);
     statusHolder.setBorder(BorderFactory.createLineBorder(Color.BLUE));
     statusHolder.add(itemStatus);
     itemList.add(statusHolder, constraintRight);
   }
   validate();
   repaint();
 }
  /**
   * 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);
    }
  }
Пример #22
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());
  }
Пример #23
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();
  }
Пример #24
0
  private void packDevices() {
    int i, j;
    GridBagLayout gbl = new GridBagLayout();
    getContentPane().setLayout(gbl);
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.insets = new Insets(2, 2, 2, 2);

    for (i = 0, j = 0; i < cnt; i++) {
      if (devArray[i].isSpecial) continue;

      gbc.weightx = 0.8;
      gbc.fill = GridBagConstraints.HORIZONTAL;
      gbc.gridx = 0;
      gbc.gridy = j;
      gbc.ipadx = 5;
      gbc.ipady = 5;
      gbl.setConstraints(devArray[i].widgetset.l1, gbc);
      getContentPane().add(devArray[i].widgetset.l1);

      gbc.weightx = 1.0;
      gbc.gridx = 1;
      gbc.gridy = j;
      gbc.ipadx = 0;
      gbc.ipady = 0;
      gbl.setConstraints(devArray[i].widgetset.wc, gbc);
      getContentPane().add(devArray[i].widgetset.wc);

      gbc.weightx = 0.8;
      gbc.gridx = 2;
      gbc.gridy = j;
      gbc.ipadx = 5;
      gbc.ipady = 5;
      gbl.setConstraints(devArray[i].widgetset.l2, gbc);
      getContentPane().add(devArray[i].widgetset.l2);

      gbc.gridx = 3;
      gbc.gridy = j;
      gbl.setConstraints(devArray[i].widgetset.ln, gbc);
      getContentPane().add(devArray[i].widgetset.ln);

      gbc.gridx = 4;
      gbc.gridy = j;
      gbl.setConstraints(devArray[i].widgetset.lval, gbc);
      getContentPane().add(devArray[i].widgetset.lval);

      j++;
    }

    pack();
  }
Пример #25
0
    protected void layoutUIComponents(String strPath, boolean bDefaultFile) {
      JLabel label = null;

      // i18n
      // label = new JLabel( "File names can be constructed from a template. The LABEL field is " );
      label =
          new JLabel(
              Util.getAdmLabel(
                  "_admin_File_names_can_be_constructed_from_a_template._The_LABEL_field_is_"));
      label.setForeground(Color.black);
      // m_gbc.weightx = 0.5;
      showInstruction(m_gbl, m_gbc, 0, 0, 7, label);

      // i18n
      // label = new JLabel( "presented as the choice to the user in the \"Data save\" pop-up." );
      label =
          new JLabel(
              Util.getAdmLabel(
                  "_admin_presented_as_the_choice_to_the_user_in_the_Data_save_pop-up."));
      showInstruction(m_gbl, m_gbc, 0, 1, 7, label);
      showInstruction(m_gbl, m_gbc, 0, 2, 1, new JLabel(""));

      label = new JLabel(Util.getAdmLabel("_adm_LABEL"));
      label.setForeground(Color.black);
      m_gbc.gridx = 1;
      m_gbc.gridy = 2;
      m_gbc.ipadx = 10;
      m_gbl.setConstraints(label, m_gbc);
      m_pnlDisplay.add(label);

      label = new JLabel("     ");
      m_gbc.gridx = 2;
      m_gbc.gridy = 2;
      m_gbc.ipadx = 0; // reset to default
      m_gbc.gridwidth = 5;
      m_gbl.setConstraints(label, m_gbc);
      // add( label );

      showInstruction(m_gbl, m_gbc, 2, 2, 1, new JLabel(Util.getAdmLabel("_admin_TEMPLATE")));

      m_nRow = 3;
      m_bDefaultFile = bDefaultFile;
      m_objTxfValue.clearArrays();
      displayNewTxf(strPath);

      m_pnlDisplay.setBorder(
          new CompoundBorder(
              BorderFactory.createTitledBorder(Util.getAdmLabel("_admin_User_Directories")),
              BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    }
Пример #26
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);
  }
Пример #27
0
  protected JComponent createCenterPanel() {
    JPanel panel = new JPanel(new GridBagLayout());
    GridBagConstraints constr;

    // list label
    constr = new GridBagConstraints();
    constr.gridy = 0;
    constr.anchor = GridBagConstraints.WEST;
    constr.insets = new Insets(5, 5, 0, 5);
    panel.add(new JLabel(IdeBundle.message("label.macros")), constr);

    // macros list
    constr = new GridBagConstraints();
    constr.gridy = 1;
    constr.weightx = 1;
    constr.weighty = 1;
    constr.insets = new Insets(0, 5, 0, 5);
    constr.fill = GridBagConstraints.BOTH;
    constr.anchor = GridBagConstraints.WEST;
    panel.add(new JScrollPane(myMacrosList), constr);
    myMacrosList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    myMacrosList.setPreferredSize(null);

    // preview label
    constr = new GridBagConstraints();
    constr.gridx = 0;
    constr.gridy = 2;
    constr.anchor = GridBagConstraints.WEST;
    constr.insets = new Insets(5, 5, 0, 5);
    panel.add(new JLabel(IdeBundle.message("label.macro.preview")), constr);

    // preview
    constr = new GridBagConstraints();
    constr.gridx = 0;
    constr.gridy = 3;
    constr.weightx = 1;
    constr.weighty = 1;
    constr.fill = GridBagConstraints.BOTH;
    constr.anchor = GridBagConstraints.WEST;
    constr.insets = new Insets(0, 5, 5, 5);
    panel.add(new JScrollPane(myPreviewTextarea), constr);
    myPreviewTextarea.setEditable(false);
    myPreviewTextarea.setLineWrap(true);
    myPreviewTextarea.setPreferredSize(null);

    panel.setPreferredSize(new Dimension(400, 500));

    return panel;
  }
Пример #28
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);
  }
Пример #29
0
  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 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);
  }