예제 #1
2
 /**
  * This function is used to re-run the analyser, and re-create the rows corresponding the its
  * results.
  */
 private void refreshReviewTable() {
   reviewPanel.removeAll();
   rows.clear();
   GridBagLayout gbl = new GridBagLayout();
   reviewPanel.setLayout(gbl);
   GridBagConstraints gbc = new GridBagConstraints();
   gbc.fill = GridBagConstraints.HORIZONTAL;
   gbc.gridy = 0;
   try {
     Map<String, Long> sums =
         analyser.processLogFile(config.getLogFilename(), fromDate.getDate(), toDate.getDate());
     for (Entry<String, Long> entry : sums.entrySet()) {
       String project = entry.getKey();
       double hours = 1.0 * entry.getValue() / (1000 * 3600);
       addRow(gbl, gbc, project, hours);
     }
     for (String project : main.getProjectsTree().getTopLevelProjects())
       if (!rows.containsKey(project)) addRow(gbl, gbc, project, 0);
     gbc.insets = new Insets(10, 0, 0, 0);
     addLeftLabel(gbl, gbc, "TOTAL");
     gbc.gridx = 1;
     gbc.weightx = 1;
     totalLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 3));
     gbl.setConstraints(totalLabel, gbc);
     reviewPanel.add(totalLabel);
     gbc.weightx = 0;
     addRightLabel(gbl, gbc);
   } catch (IOException e) {
     e.printStackTrace();
   }
   recomputeTotal();
   pack();
 }
예제 #2
0
  private JPanel getUpdatePanel() {
    if (updatePanel == null) {
      updatePanel = new JPanel(new GridBagLayout());
      updatePanel.setBorder(new EmptyBorder(0, 30, 0, 5));
      final GridBagConstraints constraints = new GridBagConstraints();
      constraints.insets = new Insets(0, 5, 5, 5);
      constraints.weighty = 0;
      constraints.weightx = 0;
      constraints.anchor = GridBagConstraints.NORTHWEST;
      constraints.gridy = 0;

      constraints.fill = GridBagConstraints.HORIZONTAL;
      constraints.gridx = 0;
      constraints.weightx = 0.5;
      updatePanel.add(minimumIntervalLabel, constraints);
      constraints.fill = GridBagConstraints.NONE;
      constraints.gridx = 1;
      constraints.weightx = 1;
      updatePanel.add(minimumIntervalTextField, constraints);

      constraints.insets =
          new Insets(0, 5, 0, 5); // we have a bottom inset in the containing layout!
      constraints.fill = GridBagConstraints.HORIZONTAL;
      constraints.gridx = 0;
      constraints.gridy++;
      constraints.weightx = 0.5;
      updatePanel.add(concurrentUpdatesLabel, constraints);
      constraints.fill = GridBagConstraints.NONE;
      constraints.gridx = 1;
      constraints.weightx = 1;
      updatePanel.add(concurrentUpdatesTextField, constraints);
    }
    return updatePanel;
  }
  /**
   * 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};
  }
  /** Get the panel for a given form. * */
  public JPanel getPanelFor(ArrayList elements) {
    JPanel p = new JPanel(new GridBagLayout());
    int maxCols = 1;
    int elementSize = elements.size();
    for (int i = 0; i < elementSize; i++) { // count max number of cols
      // ((XmlUIElement)elements.get(i)).setEditable(true);//by jai
      int cols = ((XmlUIElement) elements.get(i)).getNumberOfColumns();
      if (cols > maxCols) {
        maxCols = cols;
      }
    }
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1.0;
    c.gridx = 0;
    c.gridy = 0;
    if (elementSize < 5) c.insets = new Insets(8, 8, 8, 14);
    else if (elementSize < 20) c.insets = new Insets(4, 4, 4, 10);
    else if ((elementSize > 40 && maxCols == 2) || (elementSize > 80 && maxCols == 4))
      c.insets = new Insets(1, 1, 1, 8);
    else c.insets = new Insets(2, 2, 2, 8);

    int rowsAdded = 0;
    for (int i = 0; i < elementSize; i++) {
      elementsAndPanels.put(elements.get(i), p);
      rowsAdded += ((XmlUIElement) elements.get(i)).addComponents(p, c, 0, rowsAdded, maxCols);
    }
    return p;
  }
예제 #5
0
 /**
  * Adds a popup menu.
  *
  * @param label the label
  * @param items the menu items
  * @param defaultItem the menu item initially selected
  */
 public void addChoice(String label, String[] items, String defaultItem) {
   String label2 = label;
   if (label2.indexOf('_') != -1) label2 = label2.replace('_', ' ');
   Label theLabel = makeLabel(label2);
   c.gridx = 0;
   c.gridy = y;
   c.anchor = GridBagConstraints.EAST;
   c.gridwidth = 1;
   if (choice == null) {
     choice = new Vector(4);
     defaultChoiceIndexes = new Vector(4);
     c.insets = getInsets(5, 0, 5, 0);
   } else c.insets = getInsets(0, 0, 5, 0);
   grid.setConstraints(theLabel, c);
   add(theLabel);
   Choice thisChoice = new Choice();
   thisChoice.addKeyListener(this);
   thisChoice.addItemListener(this);
   for (int i = 0; i < items.length; i++) thisChoice.addItem(items[i]);
   if (defaultItem != null) thisChoice.select(defaultItem);
   else thisChoice.select(0);
   c.gridx = 1;
   c.gridy = y;
   c.anchor = GridBagConstraints.WEST;
   grid.setConstraints(thisChoice, c);
   add(thisChoice);
   choice.addElement(thisChoice);
   int index = thisChoice.getSelectedIndex();
   defaultChoiceIndexes.addElement(new Integer(index));
   if (Recorder.record || macro) saveLabel(thisChoice, label);
   y++;
 }
예제 #6
0
  /**
   * public MutableStatusBar(String s1, String s2, String s3) { super(); status_1 = new JLabel(s1);
   * status_2 = new JLabel(s2); status_3 = new JLabel(s3); this.init(); }.
   */
  protected void init() {
    this.setLayout(new GridBagLayout());
    this.setBorder(BorderFactory.createEmptyBorder(3, 2, 1, 1));
    final GridBagConstraints constraints = new GridBagConstraints();

    // status_1.setHorizontalAlignment(JLabel.CENTER);
    status_1.setBorder(
        new CompoundBorder(
            new SoftBevelBorder(SoftBevelBorder.LOWERED), new EmptyBorder(0, 2, 0, 2)));
    status_1.setPreferredSize(new Dimension(180, 16));

    status_2.setBorder(
        new CompoundBorder(
            new SoftBevelBorder(SoftBevelBorder.LOWERED), new EmptyBorder(0, 2, 0, 2)));
    status_2.setPreferredSize(new Dimension(200, 16));

    status_3.setBorder(
        new CompoundBorder(
            new SoftBevelBorder(SoftBevelBorder.LOWERED), new EmptyBorder(0, 2, 0, 2)));
    status_3.setPreferredSize(new Dimension(300, 16));

    greenStatusIcon =
        new MutableImageLabel(resource.getIcon("green_off.gif"), resource.getIcon("green_on.gif"));
    greenStatusIcon.setBorder(new EmptyBorder(2, 2, 2, 1));

    redStatusIcon =
        new MutableImageLabel(resource.getIcon("red_off.gif"), resource.getIcon("red_on.gif"));
    redStatusIcon.setBorder(new EmptyBorder(2, 1, 2, 3));
    // =====================================================================

    constraints.insets = new Insets(0, 0, 0, 4);
    constraints.anchor = GridBagConstraints.EAST;
    constraints.fill = GridBagConstraints.VERTICAL;

    constraints.weightx = 1.0;
    constraints.weighty = 1.0;
    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    this.add(status_1, constraints);

    constraints.weightx = 0.0;
    constraints.gridx++;
    this.add(status_2, constraints);

    constraints.gridx = 2;
    this.add(status_3, constraints);

    constraints.gridx++;
    if (greenStatusIcon != null) {
      this.add(greenStatusIcon, constraints);
    }

    constraints.insets = new Insets(0, 0, 0, 0);
    constraints.gridx++;
    if (redStatusIcon != null) {
      this.add(redStatusIcon, constraints);
    }
  }
예제 #7
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;
    }
예제 #8
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);
  }
예제 #9
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);
  }
  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 Channels() {
    super("Channels");
    if (instance != null) {
      instance.toFront();
      return;
    }
    WindowManager.addWindow(this);
    instance = this;
    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    setLayout(gridbag);
    int y = 0;
    c.gridx = 0;
    c.gridy = y++;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.BOTH;
    c.anchor = GridBagConstraints.CENTER;
    int margin = 32;
    if (IJ.isMacOSX()) margin = 20;
    c.insets = new Insets(10, margin, 10, margin);
    choice = new Choice();
    for (int i = 0; i < modes.length; i++) choice.addItem(modes[i]);
    choice.select(0);
    choice.addItemListener(this);
    add(choice, c);

    CompositeImage ci = getImage();
    int nCheckBoxes = ci != null ? ci.getNChannels() : 3;
    if (nCheckBoxes > CompositeImage.MAX_CHANNELS) nCheckBoxes = CompositeImage.MAX_CHANNELS;
    checkbox = new Checkbox[nCheckBoxes];
    for (int i = 0; i < nCheckBoxes; i++) {
      checkbox[i] = new Checkbox("Channel " + (i + 1), true);
      c.insets = new Insets(0, 25, i < nCheckBoxes - 1 ? 0 : 10, 5);
      c.gridy = y++;
      add(checkbox[i], c);
      checkbox[i].addItemListener(this);
    }

    c.insets = new Insets(0, 15, 10, 15);
    c.fill = GridBagConstraints.NONE;
    c.gridy = y++;
    moreButton = new Button(moreLabel);
    moreButton.addActionListener(this);
    add(moreButton, c);
    update();

    pm = new PopupMenu();
    for (int i = 0; i < menuItems.length; i++) addPopupItem(menuItems[i]);
    add(pm);

    addKeyListener(IJ.getInstance()); // ImageJ handles keyboard shortcuts
    setResizable(false);
    pack();
    if (location == null) {
      GUI.center(this);
      location = getLocation();
    } else setLocation(location);
    show();
  }
예제 #12
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;
  }
  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);
  }
  /**
   * 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);
    }
  }
예제 #15
0
 /**
  * Adds a numeric field. The first word of the label must be unique or command recording will not
  * work.
  *
  * @param label the label
  * @param defaultValue value to be initially displayed
  * @param digits number of digits to right of decimal point
  * @param columns width of field in characters
  * @param units a string displayed to the right of the field
  */
 public void addNumericField(
     String label, double defaultValue, int digits, int columns, String units) {
   String label2 = label;
   if (label2.indexOf('_') != -1) label2 = label2.replace('_', ' ');
   Label theLabel = makeLabel(label2);
   c.gridx = 0;
   c.gridy = y;
   c.anchor = GridBagConstraints.EAST;
   c.gridwidth = 1;
   if (firstNumericField) c.insets = getInsets(5, 0, 3, 0);
   else c.insets = getInsets(0, 0, 3, 0);
   grid.setConstraints(theLabel, c);
   add(theLabel);
   if (numberField == null) {
     numberField = new Vector(5);
     defaultValues = new Vector(5);
     defaultText = new Vector(5);
   }
   if (IJ.isWindows()) columns -= 2;
   if (columns < 1) columns = 1;
   String defaultString = IJ.d2s(defaultValue, digits);
   if (Double.isNaN(defaultValue)) defaultString = "";
   TextField tf = new TextField(defaultString, columns);
   if (IJ.isLinux()) tf.setBackground(Color.white);
   tf.addActionListener(this);
   tf.addTextListener(this);
   tf.addFocusListener(this);
   tf.addKeyListener(this);
   numberField.addElement(tf);
   defaultValues.addElement(new Double(defaultValue));
   defaultText.addElement(tf.getText());
   c.gridx = 1;
   c.gridy = y;
   c.anchor = GridBagConstraints.WEST;
   tf.setEditable(true);
   // if (firstNumericField) tf.selectAll();
   firstNumericField = false;
   if (units == null || units.equals("")) {
     grid.setConstraints(tf, c);
     add(tf);
   } else {
     Panel panel = new Panel();
     panel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
     panel.add(tf);
     panel.add(new Label(" " + units));
     grid.setConstraints(panel, c);
     add(panel);
   }
   if (Recorder.record || macro) saveLabel(tf, label);
   y++;
 }
예제 #16
0
  private JPanel getPredicatePanel() {

    GridBagLayout gbl = new GridBagLayout();
    GridBagConstraints gbc = new GridBagConstraints();

    JPanel panel = new JPanel(gbl);
    panel.setBorder(new EmptyBorder(12, 12, 0, 11));

    // TODO: make variable query widget set a package for this and ParameterUpdateDialog

    gbc.gridy = 0;
    gbc.gridx = 0;
    gbc.weighty = 0;
    gbc.weightx = 0.333;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.EAST;

    gbc.insets = new Insets(0, 0, 5, 5);

    useXQuery = new JCheckBox("Use XQuery");
    useXQuery.setMnemonic('X');
    useXQuery.addActionListener(this);
    panel.add(useXQuery, gbc);

    JLabel inputVariableLabel = new JLabel("Variable:");
    inputVariableLabel.setHorizontalAlignment(JLabel.RIGHT);
    inputVariableLabel.setDisplayedMnemonic('v');

    panel.add(inputVariableLabel, gbc);

    gbc.gridx++;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.insets = new Insets(0, 5, 5, 5);
    panel.add(getInputVariableComboBox(), gbc);
    inputVariableLabel.setLabelFor(inputVariableComboBox);

    gbc.gridx++;
    gbc.anchor = GridBagConstraints.CENTER;
    panel.add(getNewInputVariableQueryButton(), gbc);

    gbc.gridx = 0;
    gbc.gridy++;
    gbc.gridwidth = 3;
    gbc.weighty = 1;
    gbc.weightx = 1;
    gbc.fill = GridBagConstraints.BOTH;

    panel.add(getXQueryEditor(), gbc);

    return panel;
  }
예제 #17
0
파일: APropos.java 프로젝트: sipi/memento
  /** 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();
  }
예제 #18
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;
  }
  private JPanel initRelationPanel() {
    JPanel res = new JPanel();
    res.setBorder(new LineBorder(Color.DARK_GRAY));
    res.setLayout(new GridBagLayout());
    GridBagConstraints c = null;

    c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 3;
    c.weightx = 0.5;
    res.add(new JLabel(LABEL_RELATION_PANEL), c);

    c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = 1;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 3, 0, 0);
    res.add(this.addRelationButton, c);

    c = new GridBagConstraints();
    c.gridx = 1;
    c.weightx = 0.5;
    c.gridy = 1;
    res.add(this.addGeneralizationButton, c);

    c = new GridBagConstraints();
    c.gridx = 2;
    c.gridy = 1;
    c.anchor = GridBagConstraints.LINE_END;
    c.insets = new Insets(0, 0, 0, 3);
    res.add(this.addRealisationButton, c);

    c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = 2;
    c.insets = new Insets(0, 3, 0, 0);
    c.anchor = GridBagConstraints.LINE_START;
    res.add(this.addCompositionButton, c);

    c = new GridBagConstraints();
    c.gridx = 2;
    c.gridy = 2;
    c.insets = new Insets(0, 0, 0, 3);
    c.anchor = GridBagConstraints.LINE_END;
    res.add(this.addAgregationButton, c);

    return res;
  }
예제 #20
0
  public Plot2Da() {
    check_ = new JCheckBox("Hold on");
    plot_ = new Plot2D();

    setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.insets = new Insets(2, 2, 2, 2);
    c.weightx = 1.0;
    c.weighty = 1.0;

    c.gridheight = 1;
    c.gridwidth = 1;
    c.gridx = 0;
    c.gridy = 0;
    add(check_, c);

    c.gridwidth = 1;
    c.gridheight = 1;
    c.gridx = 0;
    c.gridy = 1;
    c.fill = GridBagConstraints.REMAINDER;
    c.ipadx = plot_.getSize().width + 100;
    c.ipady = plot_.getSize().height + 100;
    plot_.setBackground(Color.WHITE);

    add(plot_, c);

    setBorder(BorderFactory.createEtchedBorder());
  }
예제 #21
0
파일: Utilities.java 프로젝트: bily/fsxp
 public static void addComponent(
     Container container,
     Component component,
     int gridx,
     int gridy,
     int gridwidth,
     int gridheight,
     int fill,
     int anchor,
     Insets insets,
     int ipadx,
     int ipady,
     double weightx,
     double weighty) {
   java.awt.LayoutManager lm = container.getLayout();
   GridBagConstraints gbc = new GridBagConstraints();
   gbc.gridx = gridx;
   gbc.gridy = gridy;
   gbc.gridwidth = gridwidth;
   gbc.gridheight = gridheight;
   gbc.fill = fill;
   gbc.anchor = anchor;
   gbc.insets = insets;
   gbc.ipadx = ipadx;
   gbc.ipady = ipady;
   gbc.weightx = weightx;
   gbc.weighty = weighty;
   ((GridBagLayout) lm).setConstraints(component, gbc);
   container.add(component);
 }
예제 #22
0
  HelpDialog() {
    setTitle("Help");
    setSize(400, 200);
    setModal(true);
    setLocationRelativeTo(null);
    setResizable(false);

    propertyLabel = new JLabel("Alt + Enter : Show property");
    exitLabel = new JLabel("Ctrl + W    : Exit clock");
    helpLabel = new JLabel("Ctrl + H    : Show help");
    rightDoubleClickLabel = new JLabel("Right Double Click: Reverse color");
    leftDoubleClickLabel = new JLabel("Left  Double Click: Toggle menu bar visible");
    propertyLabel.setFont(LABEL_FONT);
    exitLabel.setFont(LABEL_FONT);
    helpLabel.setFont(LABEL_FONT);
    rightDoubleClickLabel.setFont(LABEL_FONT);
    leftDoubleClickLabel.setFont(LABEL_FONT);

    layout = new GridBagLayout();
    setLayout(layout);
    constraints = new GridBagConstraints();
    constraints.insets = new Insets(5, 5, 5, 5);

    constraints.anchor = GridBagConstraints.WEST;
    addComponent(propertyLabel, 0, 0);
    addComponent(exitLabel, 0, 1);
    addComponent(helpLabel, 0, 2);
    addComponent(rightDoubleClickLabel, 0, 3);
    addComponent(leftDoubleClickLabel, 0, 4);
  }
예제 #23
0
  public PleaseWaitFrame() throws HeadlessException {

    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    int locationX = (int) (screenSize.getWidth() - FRAME_SIZE.getWidth()) / 2;
    int locationY = (int) (screenSize.getHeight() - FRAME_SIZE.getHeight()) / 2;
    this.setSize(FRAME_SIZE);
    this.setLocation(locationX, locationY);
    this.setUndecorated(true);
    this.setResizable(false);
    JPanel panel = new JPanel();

    GridBagLayout gbl = new GridBagLayout();
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.insets = new Insets(0, 0, 0, 0);
    gbc.fill = GridBagConstraints.CENTER;
    panel.setLayout(gbl);
    messageLabel = new JLabel(message);
    messageLabel.setFont(new Font(null, Font.BOLD, 25));
    panel.add(messageLabel, gbc);

    Border border = new LineBorder(Color.BLACK, 1);

    panel.setSize(FRAME_SIZE);

    panel.setBorder(border);

    this.setContentPane(panel);

    // super.setVisible(true);
    super.setVisible(false);
  }
  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();
  }
예제 #25
0
 /**
  * Adds a radio button group.
  *
  * @param label group label (or null)
  * @param items radio button labels
  * @param rows number of rows
  * @param columns number of columns
  * @param defaultItem button initially selected
  */
 public void addRadioButtonGroup(
     String label, String[] items, int rows, int columns, String defaultItem) {
   Panel panel = new Panel();
   int n = items.length;
   panel.setLayout(new GridLayout(rows, columns, 0, 0));
   CheckboxGroup cg = new CheckboxGroup();
   for (int i = 0; i < n; i++) {
     Checkbox cb = new Checkbox(items[i], cg, items[i].equals(defaultItem));
     cb.addItemListener(this);
     panel.add(cb);
   }
   if (radioButtonGroups == null) radioButtonGroups = new Vector();
   radioButtonGroups.addElement(cg);
   Insets insets = getInsets(5, 10, 0, 0);
   if (label == null || label.equals("")) {
     label = "rbg" + radioButtonGroups.size();
     insets.top += 5;
   } else {
     setInsets(10, insets.left, 0);
     addMessage(label);
     insets.top = 2;
     insets.left += 10;
   }
   c.gridx = 0;
   c.gridy = y;
   c.gridwidth = 2;
   c.anchor = GridBagConstraints.WEST;
   c.insets = new Insets(insets.top, insets.left, 0, 0);
   grid.setConstraints(panel, c);
   add(panel);
   if (Recorder.record || macro) saveLabel(cg, label);
   y++;
 }
예제 #26
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);
  }
예제 #27
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;
  }
예제 #28
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);
  }
예제 #29
0
  /** Description of the Method */
  public void init() {
    // super.init();
    size = new Dimension(570, 570);
    contentPane = (JPanel) this.getContentPane();
    contentPane.setLayout(borderLayout1);

    Dimension d = messagePanel.getSize();
    d.height += 20;
    messagePanel.setPreferredSize(d);
    contentPane.add(messagePanel, BorderLayout.SOUTH);

    contentPane.setOpaque(true);
    userPanel.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(2, 2, 2, 2);

    messagePanel.setLayout(borderLayout5);
    contentPane.setOpaque(true);
    contentPane.setBackground(Color.white);
    this.setSize(size);

    messagePanel.add(labelMessage, BorderLayout.NORTH);
    // Logg.logg("MhClient: Före XttTree-skapande", 6);
    this.mhTable = new MhTable(root, false, this.labelMessage);
    // Logg.logg("MhClient: mhTable-skapande klart", 6);
    this.contentPane.add(this.mhTable.splitPane, BorderLayout.CENTER);
  }
예제 #30
0
  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));
        }
      }
    }
  }