Ejemplo n.º 1
0
  public void insert(Container cont, GridBagLayout gbl, int x, int y) {
    GridBagConstraints gbc = new GridBagConstraints();

    gbc.gridx = x;
    gbc.gridy = y;
    gbc.gridwidth = 1;
    gbc.gridheight = 1;
    gbc.weightx = 1;
    gbc.weighty = 1;
    gbc.anchor = GridBagConstraints.EAST;
    gbc.fill = GridBagConstraints.NONE;

    gbl.setConstraints(name, gbc);
    cont.add(name);

    gbc.gridx = x + 1;
    gbc.weightx = 10;
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.fill = GridBagConstraints.HORIZONTAL;

    gbl.setConstraints(scroll, gbc);
    cont.add(scroll);

    gbc.gridx = x + 2;
    gbc.weightx = 1;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.fill = GridBagConstraints.NONE;

    gbl.setConstraints(field, gbc);
    cont.add(field);
  }
Ejemplo n.º 2
0
  public void actionPerformed(ActionEvent ae) {

    int y = 0;
    GridBagConstraints tmp;
    JButton srcButton = (JButton) ae.getSource();
    for (JButton button : buttons) {
      String buttonText = button.getText();
      if (button == srcButton) {
        button.setText(boldButtonTitles.get(button));
      } else {
        button.setText(buttonTitles.get(button));
      }
    }
    for (int i = 0; i < buttons.size(); i++) {
      JButton jb = (JButton) buttons.get(i);
      clear();
      tmp = gbl.getConstraints(jb);
      tmp.gridy = y++;
      gbl.setConstraints(jb, tmp);
      if (srcButton == jb) {
        tmp = gbl.getConstraints(panels);
        tmp.gridy = y++;
        gbl.setConstraints(panels, tmp);
      }
    }
    cl.show(panels, buttonTitles.get(srcButton));
  }
  private void createCellType_2() {
    gbConstraints.gridx = 0;
    gbConstraints.gridy = 1;
    gbConstraints.gridwidth = 1;
    gbConstraints.gridheight = 1;
    gbConstraints.fill = GridBagConstraints.BOTH;
    gbConstraints.weightx = 1;
    gbConstraints.weighty = 0;
    gbConstraints.anchor = GridBagConstraints.NORTH;
    gbConstraints.insets = new Insets(1, 1, 1, 1);
    gbLayout.setConstraints((JTextField) al.get(0), gbConstraints);
    add((JTextField) al.get(0));

    gbConstraints.gridx = 0;
    gbConstraints.gridy = 2;
    gbConstraints.gridwidth = 1;
    gbConstraints.gridheight = 1;
    gbConstraints.fill = GridBagConstraints.BOTH;
    gbConstraints.weightx = 1;
    gbConstraints.weighty = 0;
    gbConstraints.anchor = GridBagConstraints.NORTH;
    gbConstraints.insets = new Insets(1, 1, 1, 1);
    gbLayout.setConstraints((JTextField) al.get(1), gbConstraints);
    add((JTextField) al.get(1));
  }
Ejemplo n.º 4
0
  public DialogBox(Frame parent, String frametitle, String line1, String line2) {
    super(parent, frametitle, true);

    GridBagLayout gb = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    setLayout(gb);

    // line 1
    c.gridy = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    Label line1Label = new Label(line1, Label.CENTER);
    gb.setConstraints(line1Label, c);
    line1Label.setForeground(Color.blue);
    line1Label.setFont(new Font("arial", Font.BOLD | Font.ITALIC, 16));
    add(line1Label);

    // line 2
    c.gridy = 1;
    Label line2Label = new Label(line2, Label.CENTER);
    gb.setConstraints(line2Label, c);
    add(line2Label);

    // Button
    c.gridy = 2;
    c.fill = GridBagConstraints.NONE;
    Button okButton = new Button("OK");
    gb.setConstraints(okButton, c);
    okButton.addActionListener(this);
    add(okButton);

    setLocation(400, 200);
    pack();
    setVisible(true);
    toFront();
  }
  protected void showDefaultAccountWarning() {
    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    GridBagLayout mainLayout = new GridBagLayout();
    GridBagConstraints mainConstraints = new GridBagConstraints();

    setLayout(mainLayout);

    mainConstraints.gridwidth = GridBagConstraints.REMAINDER;
    mainConstraints.anchor = GridBagConstraints.NORTHWEST;
    mainConstraints.weightx = 1.0;
    mainConstraints.insets = new Insets(0, 10, 5, 0);
    mainLayout.setConstraints(defaultAccountCheckBox, mainConstraints);
    add(defaultAccountCheckBox);

    mainConstraints = new GridBagConstraints();
    mainConstraints.weighty = 1.0;
    mainConstraints.gridwidth = GridBagConstraints.REMAINDER;

    /*
     * mainConstraints.fill = GridBagConstraints.BOTH;
     * mainConstraints.insets = new Insets(0, 0, 0, 0);
     * mainConstraints.gridwidth = GridBagConstraints.REMAINDER;
     * mainConstraints.weightx = 1.0; mainConstraints.weighty = 1.0;
     */
    JLabel label =
        new JLabel(
            MailResourceLoader.getString("dialog", "account", "using_default_account_settings"));
    Font newFont = label.getFont().deriveFont(Font.BOLD);
    label.setFont(newFont);
    mainLayout.setConstraints(label, mainConstraints);
    add(label);
  }
Ejemplo n.º 6
0
  /**
   * 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);
  }
Ejemplo n.º 7
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));
    }
  }
Ejemplo n.º 8
0
  /** 初始化面板布局 */
  private void initLayout() {
    GridBagConstraints c = new GridBagConstraints();
    GridBagLayout gridbag = new GridBagLayout();
    this.setLayout(gridbag);

    JPanel controlTopPanel = this.getControlTopPanel();
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 0.8;
    c.anchor = GridBagConstraints.WEST;
    gridbag.setConstraints(controlTopPanel, c);
    this.add(controlTopPanel);

    JPanel controlBottomPanel = this.getControlBottomPanel();
    c.gridy = GridBagConstraints.RELATIVE;
    gridbag.setConstraints(controlBottomPanel, c);
    this.add(controlBottomPanel);

    JButton comboButton = this.comboButton;
    comboButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ev) {
            combo();
          }
        });

    c.gridx = GridBagConstraints.RELATIVE;
    c.gridheight = 2;
    c.weightx = 0.2;
    c.fill = GridBagConstraints.BOTH;
    gridbag.setConstraints(comboButton, c);
    this.add(comboButton);
  }
Ejemplo n.º 9
0
  private JPanel getMainPanel() {
    if (mainPanel == null) {
      mainPanel = new JPanel();
      mainPanel.setPreferredSize(new Dimension(550, 300));
      GridBagLayout layout = new GridBagLayout();

      mainPanel.setLayout(layout);

      GridBagConstraints constraints = new GridBagConstraints();

      constraints.fill = GridBagConstraints.BOTH;
      constraints.weightx = 2;
      constraints.weighty = 1;
      constraints.anchor = GridBagConstraints.NORTHWEST;
      constraints.gridwidth = 2;
      layout.setConstraints(getAvailableRobotsPanel(), constraints);
      mainPanel.add(getAvailableRobotsPanel());
      constraints.gridwidth = 1;
      constraints.weightx = 0;
      constraints.weighty = 0;
      constraints.anchor = GridBagConstraints.CENTER;
      layout.setConstraints(getButtonsPanel(), constraints);
      mainPanel.add(getButtonsPanel());
      constraints.gridwidth = GridBagConstraints.REMAINDER;
      constraints.weightx = 1;
      constraints.weighty = 1;
      constraints.anchor = GridBagConstraints.NORTHWEST;
      layout.setConstraints(getSelectedRobotsPanel(), constraints);
      mainPanel.add(getSelectedRobotsPanel());
    }
    return mainPanel;
  }
  /** Creates the panel with the optional components. */
  private void _setupOptionsPanel(JComponent[] components) {
    JPanel mainButtons = new JPanel();
    JPanel emptyPanel = new JPanel();
    GridBagLayout gbLayout = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    mainButtons.setLayout(gbLayout);

    for (JComponent b : components) {
      mainButtons.add(b);
    }
    mainButtons.add(emptyPanel);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.NORTH;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weightx = 1.0;

    for (JComponent b : components) {
      gbLayout.setConstraints(b, c);
    }

    c.fill = GridBagConstraints.BOTH;
    c.anchor = GridBagConstraints.SOUTH;
    c.gridheight = GridBagConstraints.REMAINDER;
    c.weighty = 1.0;

    gbLayout.setConstraints(emptyPanel, c);

    _optionsPanel.add(mainButtons, BorderLayout.CENTER);
  }
Ejemplo n.º 11
0
  public MessageDialog(String message, Dialog owner) {
    super(owner);

    // WindowClosw時にリソースを開放してダイアログを閉じる
    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            dispose();
          }
        });

    setTitle("MessageDialog");

    setBounds(200, 200, 0, 0);
    setLayout(gbl);

    // (0, 0) 幅=50, 高さ=1
    Label label = new Label(message);
    gbl.setConstraints(label, MainFrame.setGBC(0, 0, 50, 1));
    add(label);

    // (0, 1) 幅=50, 高さ=1
    Button ok_btn = new Button("OK");
    gbl.setConstraints(ok_btn, MainFrame.setGBC(0, 1, 50, 1));
    add(ok_btn);

    ok_btn.addActionListener(this);

    pack();
    setModal(true);
    setVisible(true);
  }
Ejemplo n.º 12
0
  public void init() {
    GridBagConstraints gbc;
    GridBagLayout gbl = new GridBagLayout();

    resourcesLabel = new Label("Resources");
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 1;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbl.setConstraints(resourcesLabel, gbc);

    idLabel = new Label("Id", Label.RIGHT);
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 2;
    gbl.setConstraints(idLabel, gbc);

    availableLabel = new Label("Available", Label.RIGHT);
    gbc = new GridBagConstraints();
    gbc.gridx = 2;
    gbc.gridy = 2;
    gbl.setConstraints(availableLabel, gbc);

    for (int i = 0; i < resourceCount; i++) {
      Label idLabel;
      Label availableLabel;
      // create the labels
      // add labels to the vectors
      // set constraints
      idLabel = new Label();
      idLabel.setAlignment(Label.RIGHT);
      resourceIdLabelVector.insertElementAt(idLabel, i);
      gbc = new GridBagConstraints();
      gbc.gridx = 1;
      gbc.gridy = 3 + i;
      gbl.setConstraints(idLabel, gbc);

      availableLabel = new Label();
      availableLabel.setAlignment(Label.RIGHT);
      resourceAvailableLabelVector.insertElementAt(availableLabel, i);
      gbc = new GridBagConstraints();
      gbc.gridx = 2;
      gbc.gridy = 3 + i;
      gbl.setConstraints(availableLabel, gbc);
    }

    setLayout(gbl);

    add(resourcesLabel);
    add(idLabel);
    add(availableLabel);
    for (int i = 0; i < resourceCount; i++) {
      Label idLabel;
      Label availableLabel;
      idLabel = (Label) resourceIdLabelVector.elementAt(i);
      availableLabel = (Label) resourceAvailableLabelVector.elementAt(i);
      add(idLabel);
      add(availableLabel);
    }
  }
    public void layoutConverters() {
      GridBagLayout gridbag = (GridBagLayout) getLayout();
      int x = 0;
      int y = 0;

      GridBagConstraints c = createConstraints(x, y++);
      ImageIcon icon = createImageIcon("images/lb.png", "EU");
      JLabel label = new JLabel(icon);
      gridbag.setConstraints(label, c);
      add(label);

      int ignore_metric = 0;
      for (WeightMultipliers wm : WeightMultipliers.values()) {
        /*
        values returns all enum values in order of declartion but we
        want to ingore the first 6 (metric) values.
        */
        if (ignore_metric > 5) {
          newTextPane(
              createConstraints(x, y++),
              gridbag,
              new DocumentPositiveNumberFilter(cValue, wm, frame),
              labels[ignore_metric - 6]);
        }
        ignore_metric++;
      }
      // FIXME: Is there a cleaner way to iterate over a chunk of what values() returns?
    }
Ejemplo n.º 14
0
  public void fPassive() {
    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints constraints = new GridBagConstraints();
    removeAll();
    invalidate();
    repaint();
    setLayout(gridbag);
    constraints.fill = GridBagConstraints.HORIZONTAL;

    buildConstraints(constraints, 0, 0, 5, 1, 1, 1);
    gridbag.setConstraints(verLabel, constraints);
    add(verLabel);

    buildConstraints(constraints, 0, 1, 5, 1, 1, 1);
    gridbag.setConstraints(autLabel, constraints);
    add(autLabel);

    buildConstraints(constraints, 0, 16, 5, 1, 1, 1);
    gridbag.setConstraints(in, constraints);
    add(in);

    imageCanvas = new SEMCanvas(512, 512, url, this);
    imageCanvas.addMouseListener(this);
    imageCanvas.read_Overlay(0);

    buildConstraints(constraints, 5, 0, 1, 17, 1, 1);
    gridbag.setConstraints(imageCanvas, constraints);
    add(imageCanvas);

    validate();
    repaint();
  }
    public void layoutConverters() {
      GridBagLayout gridbag = (GridBagLayout) getLayout();
      int x = 0;
      int y = 0;

      GridBagConstraints c = createConstraints(x, y++);
      ImageIcon icon = createImageIcon("images/kg.png", "EU");
      JLabel label = new JLabel(icon);
      gridbag.setConstraints(label, c);
      add(label);

      int just_metric = 0;
      for (WeightMultipliers wm : WeightMultipliers.values()) {
        if (just_metric > 5) {
          return;
        }

        newTextPane(
            createConstraints(x, y++),
            gridbag,
            new DocumentPositiveNumberFilter(cValue, wm, frame),
            labels[just_metric]);
        just_metric++;
      }
    }
Ejemplo n.º 16
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++;
 }
  private void initializeLocalePanel() {
    localeP = new JPanel();
    GridBagLayout gbl = new GridBagLayout();
    GridBagConstraints gbc = new GridBagConstraints();
    localeP.setLayout(gbl);

    JLabel localeL = new JLabel("Locale of the application:");
    localeCh = new ChoiceString();
    localeCh.setItems(
        Constants.getSupportedLocales(null)); // TODO replace null with real RessourceBundle
    localeCh.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            onChange();
          }
        });
    localeL.setLabelFor(localeCh);

    // layout
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.gridwidth = 1;
    gbc.gridheight = 1;
    gbc.anchor = GridBagConstraints.FIRST_LINE_START;
    gbl.setConstraints(localeL, gbc);
    localeP.add(localeL);
    // ----
    gbc.gridx = 1;
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    gbc.insets = new Insets(0, DingsSwingConstants.SP_H_G, 0, 0);
    gbl.setConstraints(localeCh, gbc);
    localeP.add(localeCh);
  } // END private void initializeLocalePanel()
  private void initializeFileEncodingPanel() {
    fileEncodingP = new JPanel();
    GridBagLayout gbl = new GridBagLayout();
    GridBagConstraints gbc = new GridBagConstraints();
    fileEncodingP.setLayout(gbl);

    JLabel fileEncodingL = new JLabel("File encoding:");
    fileEncodingCB = new JComboBox(Preferences.FILE_ENCODINGS);
    fileEncodingCB.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            onChange();
          }
        });
    fileEncodingL.setLabelFor(fileEncodingCB);

    // layout
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.gridwidth = 1;
    gbc.gridheight = 1;
    gbc.anchor = GridBagConstraints.FIRST_LINE_START;
    gbl.setConstraints(fileEncodingL, gbc);
    fileEncodingP.add(fileEncodingL);
    // ----
    gbc.gridx = 1;
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    gbc.insets = new Insets(0, DingsSwingConstants.SP_H_G, 0, 0);
    gbl.setConstraints(fileEncodingCB, gbc);
    fileEncodingP.add(fileEncodingCB);
  } // END private void initializeFileEncodingPanel()
Ejemplo n.º 19
0
  void buildLayout() {
    GridBagLayout layout = new GridBagLayout();
    GridBagConstraints constraints = new GridBagConstraints();
    panel.setLayout(layout);

    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.insets.top = 50;
    constraints.insets.bottom = 0;
    constraints.anchor = GridBagConstraints.CENTER;
    layout.setConstraints(loginPanel, constraints);

    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 0;
    constraints.gridy = 1;
    constraints.insets.top = 0;
    constraints.insets.bottom = 15;
    constraints.anchor = GridBagConstraints.CENTER;
    layout.setConstraints(lblWashU, constraints);

    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 0;
    constraints.gridy = 2;
    constraints.insets.top = 0;
    constraints.insets.bottom = 10;
    constraints.anchor = GridBagConstraints.CENTER;
    layout.setConstraints(lblHost, constraints);
  }
Ejemplo n.º 20
0
  private JPanel createAudioPane() {
    JPanel audioPane = new JPanel();

    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();

    audioPane.setLayout(gridbag);

    c.gridx = 0;
    c.gridy = 0;
    c.insets = new Insets(3, 3, 3, 3);
    gridbag.setConstraints(lAudioDevice, c);
    audioPane.add(lAudioDevice);

    c.gridx = 1;
    c.gridy = 0;
    gridbag.setConstraints(cbAudioDevice, c);
    audioPane.add(cbAudioDevice);

    btnAudioProps.setMargin(new Insets(0, 0, 0, 0));
    c.gridx = 2;
    c.gridy = 0;
    c.insets = new Insets(3, 9, 3, 3);
    gridbag.setConstraints(btnAudioProps, c);
    audioPane.add(btnAudioProps);

    String s = i18n.getLabel("ChannelProperties.audioPane");
    audioPane.setBorder(BorderFactory.createTitledBorder(s));

    return audioPane;
  }
Ejemplo n.º 21
0
  protected void addIconsToPanel(HashMap<String, NamedIcon> iconMap) {
    if (iconMap == null) {
      log.warn("iconMap is null for type " + _itemType + " family " + _family);
      return;
    }
    GridBagLayout gridbag = new GridBagLayout();
    _iconPanel.setLayout(gridbag);

    int numCol = 4;
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.CENTER;
    c.weightx = 1.0;
    c.weighty = 1.0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.gridx = -1;
    c.gridy = 0;

    int cnt = iconMap.size();
    Iterator<Entry<String, NamedIcon>> it = iconMap.entrySet().iterator();
    while (it.hasNext()) {
      Entry<String, NamedIcon> entry = it.next();
      NamedIcon icon = new NamedIcon(entry.getValue()); // make copy for possible reduction
      icon.reduceTo(100, 100, 0.2);
      JPanel panel = new JPanel(new FlowLayout());
      String borderName = getIconBorderName(entry.getKey());
      panel.setBorder(
          BorderFactory.createTitledBorder(
              BorderFactory.createLineBorder(Color.black), borderName));
      JLabel image = new JLabel(icon);
      if (icon.getIconWidth() < 1 || icon.getIconHeight() < 1) {
        image.setText(Bundle.getMessage("invisibleIcon"));
        image.setForeground(Color.lightGray);
      }
      image.setToolTipText(icon.getName());
      panel.add(image);
      int width = Math.max(100, panel.getPreferredSize().width);
      panel.setPreferredSize(new java.awt.Dimension(width, panel.getPreferredSize().height));
      c.gridx += 1;
      if (c.gridx >= numCol) { // start next row
        c.gridy++;
        c.gridx = 0;
        if (cnt < numCol - 1) { // last row
          JPanel p = new JPanel(new FlowLayout());
          p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
          p.add(Box.createHorizontalStrut(100));
          gridbag.setConstraints(p, c);
          // if (log.isDebugEnabled()) log.debug("addIconsToPanel: gridx= "+c.gridx+" gridy=
          // "+c.gridy);
          _iconPanel.add(p);
          c.gridx = 1;
        }
      }
      cnt--;
      gridbag.setConstraints(panel, c);
      _iconPanel.add(panel);
    }
  }
Ejemplo n.º 22
0
  /** Sets out the panel based upon the items passed in via the ArrayList */
  protected void addToPanel(JPanel panel, List<BeanEditItem> items) {
    GridBagLayout gbLayout = new GridBagLayout();
    GridBagConstraints cL = new GridBagConstraints();
    GridBagConstraints cD = new GridBagConstraints();
    GridBagConstraints cR = new GridBagConstraints();
    cL.fill = GridBagConstraints.HORIZONTAL;
    cL.insets = new Insets(2, 0, 0, 15);
    cR.insets = new Insets(0, 10, 15, 15);
    cD.insets = new Insets(2, 0, 0, 0);
    cD.anchor = GridBagConstraints.NORTHWEST;
    cL.anchor = GridBagConstraints.NORTHWEST;

    int y = 0;
    JPanel p = new JPanel();

    for (BeanEditItem it : items) {
      if (it.getDescription() != null && it.getComponent() != null) {
        JLabel decript = new JLabel(it.getDescription() + ":", JLabel.LEFT);
        if (it.getDescription().equals("")) {
          decript.setText("");
        }
        cL.gridx = 0;
        cL.gridy = y;
        cL.ipadx = 3;

        gbLayout.setConstraints(decript, cL);
        p.setLayout(gbLayout);
        p.add(decript, cL);

        cD.gridx = 1;
        cD.gridy = y;

        gbLayout.setConstraints(it.getComponent(), cD);

        p.add(it.getComponent(), cD);

        cR.gridx = 2;
        cR.gridwidth = 1;
        cR.anchor = GridBagConstraints.WEST;

      } else {
        cR.anchor = GridBagConstraints.CENTER;
        cR.gridx = 0;
        cR.gridwidth = 3;
      }
      cR.gridy = y;
      if (it.getHelp() != null) {
        JTextPane help = new JTextPane();
        help.setText(it.getHelp());
        gbLayout.setConstraints(help, cR);
        formatTextAreaAsLabel(help);
        p.add(help, cR);
      }
      y++;
    }

    panel.add(p);
  }
Ejemplo n.º 23
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;
 }
Ejemplo n.º 24
0
  /** init lays out the window and sets up components */
  public void init() {
    /*
     * BorderLayout just makes sure the Object in the Center gets most of
     * the screen
     */
    setLayout(new BorderLayout());
    // Information area where we can put some text occasionally
    info1 = new Label("Welcome !");
    // put it along the top
    add("North", info1);

    // Plotting area - create our own sky class
    theSky = new HealCanvas();
    // put it in the center of the window - most space
    add("Center", theSky);
    theSky.setupScene();
    theSky.showScene();

    // Create a panel to put the controls in - panel is a long strip
    FlowLayout fl = new FlowLayout(FlowLayout.CENTER, 1, 1);
    Panel p = new Panel(fl);

    // Create buttons and add this as Actionlistener - add them to panel
    Button quit = new Button("Quit");
    quit.addActionListener(this);
    p.add("West", quit);
    // put the panel at the bottom of the screen
    add("South", p);

    Panel rp = new Panel();
    rp.setBackground(Color.black);

    // rp.setLayout(new GridLayout(3,1));
    GridBagLayout gridbag = new GridBagLayout();
    rp.setLayout(gridbag);
    GridBagConstraints cons = new GridBagConstraints();
    cons.fill = GridBagConstraints.BOTH;
    cons.gridy = GridBagConstraints.RELATIVE;
    cons.gridx = 0;
    cons.ipadx = 0;
    cons.ipady = 10;

    HealPanel hpan = new HealPanel();
    hpan.setCanvas(theSky);
    gridbag.setConstraints(hpan, cons);
    rp.add(hpan);
    // Create control panel for rotations
    rotPanel = new RotatePanel();
    gridbag.setConstraints(rotPanel, cons);
    rp.add(rotPanel);
    // attach the rotPanel panel to the sky
    rotPanel.setScene(theSky);
    // add to right of screen
    this.add("East", rp);
    rotPanel.start();
  };
 public ImportTexturesTaskPanel(
     String taskMessage,
     TexturesLibraryUserPreferences preferences,
     ThreadedTaskController controller) {
   super(taskMessage, preferences, controller);
   this.preferences = preferences;
   this.imageComponent = new ScaledImageComponent();
   Insets insets = this.imageComponent.getInsets();
   this.imageComponent.setPreferredSize(
       new Dimension(128 + insets.left + insets.right, 128 + insets.top + insets.bottom));
   // Change layout
   GridBagLayout layout = new GridBagLayout();
   setLayout(layout);
   layout.setConstraints(
       getComponent(0),
       new GridBagConstraints(
           1,
           0,
           1,
           1,
           0,
           1,
           GridBagConstraints.SOUTHWEST,
           GridBagConstraints.NONE,
           new Insets(0, 0, 10, 0),
           0,
           0));
   layout.setConstraints(
       getComponent(1),
       new GridBagConstraints(
           1,
           1,
           1,
           1,
           0,
           1,
           GridBagConstraints.NORTHWEST,
           GridBagConstraints.HORIZONTAL,
           new Insets(0, 0, 0, 0),
           0,
           0));
   add(
       this.imageComponent,
       new GridBagConstraints(
           0,
           0,
           1,
           2,
           1,
           1,
           GridBagConstraints.CENTER,
           GridBagConstraints.BOTH,
           new Insets(0, 0, 0, 10),
           0,
           0));
 }
  public MA_ScrollPane(
      Vector period_types, int scrollbarDisplayPolicy, Chart parent_chart, Properties print_props) {
    super(scrollbarDisplayPolicy);

    if (print_props != null) print_properties = print_props;
    MA_Configuration config = MA_Configuration.application_instance();
    chart = parent_chart;
    main_graph = new MainGraph();
    indicator_graph = new LowerGraph(main_graph);
    GridBagLayout gblayout = new GridBagLayout();
    GridBagConstraints gbconstraints = new GridBagConstraints();

    main_panel = new Panel(new BorderLayout());
    add(main_panel, "Center");
    graph_panel = new Panel(gblayout);
    main_panel.add(graph_panel, "Center");

    // Set GridBagLayout constraints such that the main graph is at
    // the top and takes about 2/3 of available height and the
    // indicator graph is below the main graph and takes the remaining
    // 1/3 of the height and both graph panels grow/shrink when the
    // window is resized.
    gbconstraints.gridx = 0;
    gbconstraints.gridy = 0;
    gbconstraints.gridwidth = 9;
    gbconstraints.gridheight = 6;
    gbconstraints.weightx = 1;
    gbconstraints.weighty = 1;
    gbconstraints.fill = GridBagConstraints.BOTH;
    gblayout.setConstraints(main_graph, gbconstraints);
    graph_panel.add(main_graph);
    gbconstraints.gridx = 0;
    gbconstraints.gridy = 6;
    gbconstraints.gridwidth = 9;
    gbconstraints.gridheight = 3;
    gbconstraints.weightx = 1;
    gbconstraints.weighty = 1;
    gbconstraints.fill = GridBagConstraints.BOTH;
    gblayout.setConstraints(indicator_graph, gbconstraints);
    graph_panel.add(indicator_graph);
    main_graph.set_framecolor(new Color(0, 0, 0));
    main_graph.set_borderTop(0);
    main_graph.set_borderBottom(1);
    main_graph.set_borderLeft(0);
    main_graph.set_borderRight(1);
    main_graph.setGraphBackground(config.background_color());
    main_graph.setSize(400, 310);

    indicator_graph.set_framecolor(new Color(0, 0, 0));
    indicator_graph.set_borderTop(0);
    indicator_graph.set_borderBottom(1);
    indicator_graph.set_borderLeft(0);
    indicator_graph.set_borderRight(1);
    indicator_graph.setGraphBackground(config.background_color());
    indicator_graph.setSize(400, 150);
  }
  /** stellt das Datenidentifikationsauswahl-Panel zusammen */
  private void createAndShowGui() {
    GridBagConstraints gbc;

    // Zeile für Zeile hinzufügen
    // Attributgruppe
    gbc = makegbc(0, 0, 1, 1);
    gbc.anchor = GridBagConstraints.NORTHWEST;
    _gridBagLayout.setConstraints(_atgLabel, gbc);
    add(_atgLabel);

    gbc = makegbc(1, 0, 1, 1);
    gbc.weightx = 1;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    _gridBagLayout.setConstraints(_atgTextField, gbc);
    add(_atgTextField);

    // Aspekte
    gbc = makegbc(0, 1, 1, 1);
    gbc.anchor = GridBagConstraints.NORTHWEST;
    _gridBagLayout.setConstraints(_aspLabel, gbc);
    add(_aspLabel);

    gbc = makegbc(1, 1, 1, 1);
    gbc.weightx = 1;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    _gridBagLayout.setConstraints(_aspTextField, gbc);
    add(_aspTextField);

    // Simulationsvariante
    gbc = makegbc(0, 2, 1, 1);
    gbc.anchor = GridBagConstraints.NORTHWEST;
    _gridBagLayout.setConstraints(_simLabel, gbc);
    add(_simLabel);

    gbc = makegbc(1, 2, 1, 1);
    gbc.weightx = 1;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    _gridBagLayout.setConstraints(_simTextField, gbc);
    add(_simTextField);

    // Objekte
    gbc = makegbc(0, 3, 1, 1);
    gbc.anchor = GridBagConstraints.NORTHWEST;
    _gridBagLayout.setConstraints(_objLabel, gbc);
    add(_objLabel);

    JScrollPane scrollPane = new JScrollPane(_objList);
    gbc = makegbc(1, 3, 1, 1);
    gbc.weightx = 1;
    gbc.weighty = 1;
    gbc.fill = GridBagConstraints.BOTH;
    _gridBagLayout.setConstraints(scrollPane, gbc);
    add(scrollPane);

    // Ändern - Button
    gbc = makegbc(2, 0, 1, 4);
    gbc.anchor = GridBagConstraints.SOUTHEAST;
    _gridBagLayout.setConstraints(_changeButton, gbc);
    add(_changeButton);
  }
  // Color gre;
  Rules(String se) {
    email = se;
    conti = new Button("Continue");
    rules = new Button("ClicK Here For Rules");
    p1 = new JOptionPane();
    Icon image = new ImageIcon("books.jpg");
    Icon image1 = new ImageIcon("girl.jpg");
    Icon image2 = new ImageIcon("uit.jpg");
    gl = new GridBagLayout();
    gbc = new GridBagConstraints();
    conti.addActionListener(this);
    rules.addActionListener(this);
    // gre=new Color(117,102,185);
    p = new Panel();
    p2 = new Panel();
    p3 = new Panel();
    p4 = new Panel();
    f = new Frame();
    pic = new JLabel(image);
    pic1 = new JLabel(image1);
    pic2 = new JLabel(image2);
    gbc.anchor = GridBagConstraints.SOUTHWEST;
    gl.setConstraints(pic1, gbc);
    gbc.anchor = GridBagConstraints.SOUTHEAST;
    gl.setConstraints(pic, gbc);
    Insets is = new Insets(30, 30, 30, 30);
    gbc.insets = is;
    gbc.ipadx = 14;
    gbc.ipady = 8;
    gl.setConstraints(rules, gbc);
    gl.setConstraints(conti, gbc);
    p2.setLayout(gl);
    p4.add(pic2);
    p2.add(pic);
    p3.setLayout(gl);
    p3.add(pic1);
    p.add(conti);
    p.add(rules);
    p.setLayout(gl);
    f.add(p4, "North");
    f.add(p3, "East");
    f.add(p2, "West");

    f.add(p, "Center");
    f.setTitle("RULES BOOK");
    // f.setBackground(gre);
    f.setVisible(true);
    f.setSize(900, 600);
    f.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent we) {
            System.exit(0);
          }
        });
  }
 protected void newTextPane(
     GridBagConstraints c,
     GridBagLayout gridbag,
     DocumentTemperatureFilter filter,
     LabelPair names) {
   DisplayPanel panel = new DisplayPanel();
   panel.addForDisplay(new CTalkativeTextPane(cValue, filter), names);
   gridbag.setConstraints(panel, c);
   add(panel);
   panel = null;
 }
  private void initializeLeftPanel() {
    leftP = new JPanel();
    EmptyBorder border =
        new EmptyBorder(DingsSwingConstants.SP_D_TOP, DingsSwingConstants.SP_D_LEFT, 0, 0);
    leftP.setBorder(border);
    GridBagLayout gbl = new GridBagLayout();
    GridBagConstraints gbc = new GridBagConstraints();
    leftP.setLayout(gbl);

    JLabel categoryL = new JLabel(Toolbox.getInstance().getLocalizedString("pev.categories.label"));
    categoryL.setDisplayedMnemonic(
        Toolbox.getInstance().getLocalizedString("pev.categories.mnemonic").charAt(0));
    String[] choices = {
      FILEENC,
      LAF,
      LH,
      LOGGING,
      SELECTION_UPDATE,
      STATS,
      LOCALE,
      TEXT_LINES,
      CHECK_ANSWER,
      SYLLABLE_COLORS
    };
    choiceLi = new JList(choices);
    choiceLi.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    choiceLi.addListSelectionListener(
        new ListSelectionListener() {
          public void valueChanged(ListSelectionEvent evt) {
            switchPreferencePanel();
          }
        });
    categoryL.setLabelFor(choiceLi);
    JScrollPane listScroller = new JScrollPane(choiceLi);
    // listScroller.setPreferredSize(new Dimension(250, 80));
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.gridwidth = 1;
    gbc.gridheight = 1;
    gbc.anchor = GridBagConstraints.LINE_START;
    gbl.setConstraints(categoryL, gbc);
    leftP.add(categoryL);
    // ----
    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    gbc.insets = new Insets(DingsSwingConstants.SP_V_G, 0, 0, 0);
    gbc.fill = GridBagConstraints.BOTH;
    gbc.anchor = GridBagConstraints.CENTER;
    gbl.setConstraints(listScroller, gbc);
    leftP.add(listScroller);
  } // END private void initializeLeftPanel()