protected void displayNewTxf(String strLabel, String strValue) {
      strLabel = (strLabel == null) ? "" : strLabel.trim();
      strValue = (strValue == null) ? "" : strValue.trim();

      JCheckBox chkBox1 = new JCheckBox(Util.getImageIcon("boxGray.gif"));
      DataField txf1 = new DataField(strLabel);
      DataField txf2 = new DataField(strValue);
      JPanel pnlTxf = new JPanel(m_gbl);
      m_nRow = m_nRow + 1;

      txf1.setName("label");
      txf2.setName("value");

      /* 1st line of text field*/
      m_gbc.weightx = 0;
      showComp(m_gbl, m_gbc, 0, m_nRow, 1, chkBox1);
      m_gbc.weightx = 1;
      showComp(m_gbl, m_gbc, GridBagConstraints.RELATIVE, m_nRow, 1, txf1);
      // showSpaces( gbl, gbc, 2, 6 );
      showComp(m_gbl, m_gbc, GridBagConstraints.RELATIVE, m_nRow, 1, txf2);
      m_gbc.weightx = 0;
      txf1.addFocusListener(this);
      txf2.addFocusListener(this);

      m_objTxfValue.addToLabel(txf1);
      m_objTxfValue.addToValue(txf2);
    }
Example #2
0
 private void addView() {
   GridBagConstraints gbc = new GridBagConstraints();
   gbc.gridwidth = 1;
   gbc.gridx = 6;
   gbc.gridy = 0;
   add((JComponent) _secondaryView, gbc);
 }
Example #3
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);
  }
Example #4
0
  protected void addComp(JPanel panel, Component comp, GridBagConstraints gbc, int x, int y) {
    gbc.gridx = x;
    gbc.gridy = y;
    gbc.fill = GridBagConstraints.HORIZONTAL;

    panel.add(comp, gbc);
  }
    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 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);
  }
  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));
        }
      }
    }
  }
  public NotificacioGenerica(String missatge) {
    frame = new JFrame("Notificació");
    frame.getContentPane().setLayout(new GridBagLayout());
    label = new JTextArea(missatge);
    label.setEnabled(false);
    label.setEditable(false);
    button = new JButton("D'acord!");
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    frame.getContentPane().add(label, c);
    c.gridy = 1;
    frame.getContentPane().add(button, c);
    button.requestFocusInWindow();

    button.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent actionEvent) {
            frame.dispose();
          }
        });

    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    pack();
    mostra(true);
  }
  /**
   * Creates the <tt>Component</tt> hierarchy of the area of status-related information such as
   * <tt>CallPeer</tt> display name, call duration, security status.
   *
   * @return the root of the <tt>Component</tt> hierarchy of the area of status-related information
   *     such as <tt>CallPeer</tt> display name, call duration, security status
   */
  private Component createStatusBar() {
    // stateLabel
    callStatusLabel.setForeground(Color.WHITE);
    dtmfLabel.setForeground(Color.WHITE);
    callStatusLabel.setText(callPeer.getState().getLocalizedStateString());

    PeerStatusPanel statusPanel = new PeerStatusPanel(new GridBagLayout());

    GridBagConstraints constraints = new GridBagConstraints();

    constraints.gridx = 0;
    constraints.gridy = 0;
    statusPanel.add(securityStatusLabel, constraints);
    initSecurityStatusLabel();

    constraints.gridx++;
    statusPanel.add(holdStatusLabel, constraints);

    constraints.gridx++;
    statusPanel.add(muteStatusLabel, constraints);

    constraints.gridx++;
    callStatusLabel.setBorder(BorderFactory.createEmptyBorder(2, 3, 2, 12));
    statusPanel.add(callStatusLabel, constraints);

    constraints.gridx++;
    constraints.weightx = 1f;
    statusPanel.add(dtmfLabel, constraints);

    return statusPanel;
  }
Example #10
0
  private void updateDebugPanelState(String result, boolean debug, boolean test) {
    result = result == null ? "nothing" : result;

    List<Component> componentList = Arrays.asList(getComponents());
    if (!componentList.contains(p_debug)) {

      choice = new Label(String.format("Your choice is: %s", result));
      isDebug = new Label(String.format("Debug mode: %b", debug));
      isTest = new Label(String.format("Test mode: %b", test));
      GridBagLayout layout = new GridBagLayout();
      GridBagConstraints constraints = new GridBagConstraints();
      layout.setConstraints(choice, constraints);
      constraints.gridy = 1;
      layout.setConstraints(isDebug, constraints);
      constraints.gridy = 2;
      layout.setConstraints(isTest, constraints);

      p_debug.setLayout(layout);
      p_debug.add(choice);
      p_debug.add(isDebug);
      p_debug.add(isTest);
      add(p_debug, BorderLayout.SOUTH);

    } else {
      choice.setText(String.format("Your choice is: %s", result));
      isDebug.setText(String.format("Debug mode: %b", debug));
      isTest.setText(String.format("Test mode: %b", test));
    }
  }
Example #11
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++;
 }
 private void showSpaces(GridBagLayout gbl, GridBagConstraints gbc, int gridx, int gridy) {
   JLabel spaces = new JLabel("     ");
   gbc.gridx = gridx;
   gbc.gridy = gridy;
   gbl.setConstraints(spaces, gbc);
   m_pnlDisplay.add(spaces);
 }
Example #13
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);
  }
    private void initComponents() {
      RaceButton = new JButton();
      InfoNum = new JLabel();
      setLayout(new GridBagLayout());
      RaceButton.setBackground(new Color(0, 0, 0));
      RaceButton.setForeground(new Color(222, 200, 120)); // Text color for buttons
      RaceButton.setText("Name Place Holder");
      RaceButton.setHorizontalAlignment(2);
      RaceButton.setPreferredSize(new Dimension(240, 52));
      RaceButton.addActionListener(
          new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
              RaceButtonActionPerformed(evt);
            }
          });
      GridBagConstraints gridBagConstraints = new GridBagConstraints();
      gridBagConstraints.fill = 2;
      add(RaceButton, gridBagConstraints);
      InfoNum.setText("Num");
      gridBagConstraints = new GridBagConstraints();
      gridBagConstraints.gridx = 0;
      gridBagConstraints.gridy = 0;
      add(InfoNum, gridBagConstraints);
    }
Example #15
0
  LoginFrame(String name, String dbhost, String dbname, String tbname) {
    gb = new GridBagLayout();
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    this.setLayout(gb);
    this.setTitle(name);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.content = (JPanel) this.getContentPane();
    this.host = new JTextField(20);
    this.database = new JTextField(20);
    this.username = new JTextField(20);
    this.password = new JPasswordField(20);
    this.table = new JTextField(20);
    this.login = new JButton("Login");
    this.exit = new JButton("Exit");

    this.host.setText(dbhost);
    this.host.setEditable(false);
    this.database.setText(dbname);
    this.database.setEditable(false);
    this.table.setText(tbname);
    this.table.setEditable(false);
    this.addFields();
    this.requestFocus();
    this.username.requestFocusInWindow();
    this.pack();
    this.setLocationRelativeTo(null);
  }
Example #16
0
 /**
  * Adds a label that shows the percentage of hours spent on a particular project.
  *
  * @param gbl The layout to add the label to.
  * @param gbc The layout constraints to use.
  * @param row The row to link against.
  * @see {@link #addRow(GridBagLayout, GridBagConstraints, String, double)}
  */
 private void addPercentLabel(GridBagLayout gbl, GridBagConstraints gbc, Row row) {
   gbc.gridx = 3;
   gbc.ipadx = 5;
   gbl.setConstraints(row.percentL, gbc);
   gbc.ipadx = 0;
   reviewPanel.add(row.percentL);
 }
  protected JPanel buildVersionBasedUpdatePolicyPanel() {
    JPanel pnl = new JPanel(new GridBagLayout());
    GridBagConstraints gc = new GridBagConstraints();
    gc.anchor = GridBagConstraints.NORTHWEST;
    gc.fill = GridBagConstraints.HORIZONTAL;
    gc.weightx = 1.0;

    bgVersionBasedUpdatePolicy = new ButtonGroup();
    rbVersionBasedUpatePolicy = new HashMap<Policy, JRadioButton>();
    JRadioButton btn = new JRadioButton(tr("Ask before updating"));
    rbVersionBasedUpatePolicy.put(Policy.ASK, btn);
    bgVersionBasedUpdatePolicy.add(btn);

    btn = new JRadioButton(tr("Always update withouth asking"));
    rbVersionBasedUpatePolicy.put(Policy.ALWAYS, btn);
    bgVersionBasedUpdatePolicy.add(btn);

    btn = new JRadioButton(tr("Never update"));
    rbVersionBasedUpatePolicy.put(Policy.NEVER, btn);
    bgVersionBasedUpdatePolicy.add(btn);

    JMultilineLabel lbl =
        new JMultilineLabel(
            tr(
                "Please decide whether JOSM shall automatically update active plugins at startup after an update of JOSM itself."));
    gc.gridy = 0;
    pnl.add(lbl, gc);
    for (Policy p : Policy.values()) {
      gc.gridy++;
      pnl.add(rbVersionBasedUpatePolicy.get(p), gc);
    }
    return pnl;
  }
Example #18
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 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);
  }
Example #20
0
 /**
  * Adds a simple 'h' to show that the time period is specified in hours.
  *
  * @param gbl The layout to add the label to.
  * @param gbc The layout constraints to use.
  * @see {@link #addRow(GridBagLayout, GridBagConstraints, String, double)}
  */
 private void addRightLabel(GridBagLayout gbl, GridBagConstraints gbc) {
   JLabel hLabel = new JLabel("h", SwingConstants.CENTER);
   gbc.gridx = 2;
   gbc.ipadx = 5;
   gbl.setConstraints(hLabel, gbc);
   gbc.ipadx = 0;
   reviewPanel.add(hLabel);
 }
Example #21
0
 /**
  * Adds an editable text field containing the hours spent on a project.
  *
  * @param gbl The layout to add the text field to.
  * @param gbc The layout constraints to use.
  * @param row The row to link against.
  * @param hours The number of hours spent on the project.
  * @see {@link #addRow(GridBagLayout, GridBagConstraints, String, double)}
  */
 private void addMiddleField(GridBagLayout gbl, GridBagConstraints gbc, Row row, double hours) {
   row.hoursTF.setText(decimalFormat.format(hours));
   gbc.gridx = 1;
   gbc.weightx = 1;
   gbl.setConstraints(row.hoursTF, gbc);
   gbc.weightx = 0;
   reviewPanel.add(row.hoursTF);
 }
  private void setTextFieldByGridBagConstraints() {
    GridBagConstraints gbc = new GridBagConstraints();

    gbc.weightx = 0;
    gbc.insets = new Insets(0, 0, 0, 5);
    gbc.anchor = GridBagConstraints.LINE_END;
    add(nextRepetitionDateTextField, gbc);
  }
  private void setLabelByGridBagConstraints() {
    GridBagConstraints gbc = new GridBagConstraints();

    gbc.weightx = 1;
    gbc.insets = new Insets(0, 5, 0, 5);
    gbc.anchor = GridBagConstraints.LINE_START;
    add(repetitionNameLabel, gbc);
  }
Example #24
0
 private void addSpacer() {
   JPanel spacer = new JPanel();
   GridBagConstraints gbc = new GridBagConstraints();
   gbc.gridwidth = 1;
   gbc.gridx = 5;
   gbc.gridy = 0;
   add(spacer, gbc);
 }
 /**
  * Gets the constraints for the specified component. A copy of the actual <code>GridBagConstraints
  * </code> object is returned.
  *
  * @param comp the component to be queried
  * @return the constraint for the specified component in this grid bag layout; a copy of the
  *     actual constraint object is returned
  */
 public GridBagConstraints getConstraints(Component comp) {
   GridBagConstraints constraints = (GridBagConstraints) comptable.get(comp);
   if (constraints == null) {
     setConstraints(comp, defaultConstraints);
     constraints = (GridBagConstraints) comptable.get(comp);
   }
   return (GridBagConstraints) constraints.clone();
 }
Example #26
0
 private void setRow(GridBagConstraints c, GridBagLayout gridbag, Component obj1, Component obj2) {
   c.gridwidth = GridBagConstraints.RELATIVE;
   gridbag.setConstraints(obj1, c);
   add(obj1);
   c.gridwidth = GridBagConstraints.REMAINDER; // end row
   gridbag.setConstraints(obj2, c);
   add(obj2);
   c.fill = GridBagConstraints.BOTH;
 }
 /** Creates a grid bag layout pnlMain using the specified insets constraints. */
 public GriddedPanel(JPanel panel, Insets insets) {
   this.panel = panel;
   panel.setLayout(new GridBagLayout());
   // creates the constraints object and set the desired
   // default values
   constraints = new GridBagConstraints();
   constraints.anchor = GridBagConstraints.WEST;
   constraints.insets = insets;
 }
Example #28
0
 /**
  * Adds a group of checkboxs using a grid layout.
  *
  * @param rows the number of rows
  * @param columns the number of columns
  * @param labels the labels
  * @param defaultValues the initial states
  * @param headings the column headings Example:
  *     http://imagej.nih.gov/ij/plugins/multi-column-dialog/index.html
  */
 public void addCheckboxGroup(
     int rows, int columns, String[] labels, boolean[] defaultValues, String[] headings) {
   Panel panel = new Panel();
   int nRows = headings != null ? rows + 1 : rows;
   panel.setLayout(new GridLayout(nRows, columns, 6, 0));
   int startCBIndex = cbIndex;
   if (checkbox == null) checkbox = new Vector(12);
   if (headings != null) {
     Font font = new Font("SansSerif", Font.BOLD, 12);
     for (int i = 0; i < columns; i++) {
       if (i > headings.length - 1 || headings[i] == null) panel.add(new Label(""));
       else {
         Label label = new Label(headings[i]);
         label.setFont(font);
         panel.add(label);
       }
     }
   }
   int i1 = 0;
   int[] index = new int[labels.length];
   for (int row = 0; row < rows; row++) {
     for (int col = 0; col < columns; col++) {
       int i2 = col * rows + row;
       if (i2 >= labels.length) break;
       index[i1] = i2;
       String label = labels[i1];
       if (label == null || label.length() == 0) {
         Label lbl = new Label("");
         panel.add(lbl);
         i1++;
         continue;
       }
       if (label.indexOf('_') != -1) label = label.replace('_', ' ');
       Checkbox cb = new Checkbox(label);
       checkbox.addElement(cb);
       cb.setState(defaultValues[i1]);
       cb.addItemListener(this);
       if (Recorder.record || macro) saveLabel(cb, labels[i1]);
       if (IJ.isLinux()) {
         Panel panel2 = new Panel();
         panel2.setLayout(new BorderLayout());
         panel2.add("West", cb);
         panel.add(panel2);
       } else panel.add(cb);
       i1++;
     }
   }
   c.gridx = 0;
   c.gridy = y;
   c.gridwidth = 2;
   c.anchor = GridBagConstraints.WEST;
   c.insets = getInsets(10, 0, 0, 0);
   grid.setConstraints(panel, c);
   add(panel);
   y++;
 }
 private void customInit() {
   reportPanel.setLayout(new GridBagLayout());
   progressPanels = new ArrayList<ReportProgressPanel>();
   c = new GridBagConstraints();
   c.fill = GridBagConstraints.BOTH;
   c.gridx = 0;
   c.gridy = 0;
   c.weightx = 1.0;
   glue = Box.createVerticalGlue();
 }
Example #30
0
  private void addComponent(Component c, int row, int col, int width, int height) {
    gbContraints.gridx = col;
    gbContraints.gridy = row;

    gbContraints.gridwidth = width;
    gbContraints.gridheight = height;

    layout1.setConstraints(c, gbContraints);
    add(c);
  }