protected void layoutUIComponents(String strPath, boolean bDefaultFile) {
      JLabel label = null;

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

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

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

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

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

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

      m_pnlDisplay.setBorder(
          new CompoundBorder(
              BorderFactory.createTitledBorder(Util.getAdmLabel("_admin_User_Directories")),
              BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    }
    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)));
    }
示例#3
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;
  }
 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);
 }
  /**
   * 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);
    }
  }
    public void addForDisplay(CTalkativeTextPane pane, LabelPair<String, String> lp) {
      GridBagLayout gridbag = (GridBagLayout) getLayout();
      labelPair = lp;
      label = new JLabel(labelPair.getSingular(), JLabel.LEFT);
      pane.getDocument().addDocumentListener(this);

      GridBagConstraints c = new GridBagConstraints();
      c.gridx = 0;
      c.gridy = 0;
      c.gridwidth = 1;
      c.gridheight = 1;
      c.weightx = 0.1;
      c.weighty = 0.1;
      c.anchor = GridBagConstraints.LINE_START;
      c.insets = new Insets(0, 20, 0, 00);
      gridbag.setConstraints(pane, c);
      add(pane);

      c = new GridBagConstraints();
      c.gridx = 1;
      c.gridy = 0;
      c.gridwidth = 1;
      c.gridheight = 1;
      c.weightx = 0.1;
      c.weighty = 0.1;
      c.anchor = GridBagConstraints.LINE_START;
      c.insets = new Insets(0, 0, 0, 20);
      gridbag.setConstraints(label, c);
      add(label);

      JPanel filler = new JPanel();
      filler.setBackground(white);
      c = new GridBagConstraints();
      c.gridx = 2;
      c.gridy = 0;
      c.gridwidth = 1;
      c.gridheight = 1;
      c.weightx = 0.8;
      c.weighty = 0.8;
      c.fill = GridBagConstraints.BOTH;
      c.anchor = GridBagConstraints.LINE_END;
      gridbag.setConstraints(filler, c);
      add(filler);

      filler = null;
      c = null;
    }
    protected void layoutUIComponents(String strPath, boolean bDefaultFile) {
      // gbc.weightx = 0.5;

      showInstructions(m_gbl, m_gbc, 0, 0, 7, infoLabel1);
      showInstructions(m_gbl, m_gbc, 0, 1, 7, infoLabel2);
      showInstructions(m_gbl, m_gbc, 0, 2, 7, infoLabel3);
      /*showInstructions( gbl, gbc, 0, 3, 7, infoLabel4 );
      showInstructions( gbl, gbc, 0, 4, 7, infoLabel5 );*/
      showInstructions(m_gbl, m_gbc, 0, 5, 1, new JLabel(""));

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

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

      // i18n
      // showInstructions( m_gbl, m_gbc, 2, 5, 1, new JLabel( "DIRECTORY" ));
      showInstructions(m_gbl, m_gbc, 2, 5, 1, new JLabel(Util.getAdmLabel("_adm_DIRECTORY")));

      m_nRow = 5;

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

      m_pnlDisplay.setBorder(
          new CompoundBorder(
              // i18n
              // BorderFactory.createTitledBorder( "  Parent Directories  "),
              BorderFactory.createTitledBorder(Util.getAdmLabel("_adm_Parent_Directories")),
              BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    }
示例#8
0
 // put image into box at specified (x, y)
 public void addImage(ClickableImage image, int x, int y, Border border) {
   image.setRow(x);
   image.setColumn(y);
   image.setBorder(border);
   gbc.gridx = y; // ?? why backwards
   gbc.gridy = x;
   gbag.setConstraints(image, gbc);
   add(image);
   images[x][y] = image;
 }
 private void showComp(
     GridBagLayout gbl,
     GridBagConstraints gbc,
     int gridx,
     int gridy,
     int gridwidth,
     JComponent comp) {
   gbc.gridx = gridx;
   gbc.gridy = gridy;
   gbl.setConstraints(comp, gbc);
   m_pnlDisplay.add(comp);
 }
 protected GridBagConstraints createConstraints(int x, int y) {
   GridBagConstraints c = new GridBagConstraints();
   c.gridx = x;
   c.gridy = y;
   c.gridwidth = 2;
   c.gridheight = 1;
   c.ipadx = 1;
   c.weightx = 0.5;
   c.weighty = 0.5;
   c.fill = GridBagConstraints.BOTH;
   c.anchor = GridBagConstraints.CENTER;
   return c;
 }
示例#11
0
  private static JPanel createTextFieldAndListPanel(
      String label, JTextField textField, JList list) {
    GridBagLayout layout = new GridBagLayout();
    JPanel panel = new JPanel(layout);

    GridBagConstraints cons = new GridBagConstraints();
    cons.gridx = cons.gridy = 0;
    cons.gridwidth = cons.gridheight = 1;
    cons.fill = GridBagConstraints.BOTH;
    cons.weightx = 1.0f;

    JLabel _label = new JLabel(jEdit.getProperty(label));
    layout.setConstraints(_label, cons);
    panel.add(_label);

    cons.gridy = 1;
    Component vs = Box.createVerticalStrut(6);
    layout.setConstraints(vs, cons);
    panel.add(vs);

    cons.gridy = 2;
    layout.setConstraints(textField, cons);
    panel.add(textField);

    cons.gridy = 3;
    vs = Box.createVerticalStrut(6);
    layout.setConstraints(vs, cons);
    panel.add(vs);

    cons.gridy = 4;
    cons.gridheight = GridBagConstraints.REMAINDER;
    cons.weighty = 1.0f;
    JScrollPane scroller = new JScrollPane(list);
    layout.setConstraints(scroller, cons);
    panel.add(scroller);

    return panel;
  }
 private void showInstruction(
     GridBagLayout gbl,
     GridBagConstraints gbc,
     int gridx,
     int gridy,
     int gridwidth,
     JLabel instruction) {
   gbc.gridwidth = gridwidth;
   gbc.gridx = gridx;
   gbc.gridy = gridy;
   gbl.setConstraints(instruction, gbc);
   instruction.setForeground(Color.black);
   m_pnlDisplay.add(instruction);
 }
示例#13
0
  VerificationDlg(JFrame par, String pwd) {
    super(par, "Password Keeper - Enter Password", true); // Modal Dialog

    this.par = par;
    this.pwd = pwd;

    okButton = new JButton("OK");
    okButton.addActionListener(this);

    dlgPanel = new JPanel();
    dlgPanel.setLayout(new GridBagLayout());
    cns = new GridBagConstraints();

    cns.gridx = cns.gridy = 0;
    cns.insets = new Insets(2, 2, 2, 2);

    dlgPanel.add(new JLabel("Password"), cns);

    cns.gridx++;

    passField = new TextField(30);

    dlgPanel.add(passField, cns);

    cns.gridy++;
    // cns.gridx = 0;

    dlgPanel.add(okButton, cns);

    cancelButton = new JButton("Cancel");

    cns.gridx++;

    dlgPanel.add(cancelButton, cns);

    Container cp = this.getContentPane();

    Border rb = BorderFactory.createEtchedBorder();
    dlgPanel.setBorder(
        BorderFactory.createTitledBorder(
            rb, "Enter Password", TitledBorder.LEFT, TitledBorder.TOP));

    cp.add(dlgPanel);

    pack();
  }
示例#14
0
 public Test(int columns, Insets insets, JComponent[] components) {
   super(GridBagLayout.class.getName());
   GridBagLayout layout = new GridBagLayout();
   JPanel panel = new JPanel(layout);
   // --- code needed to add the components
   GridBagConstraints constraints = new GridBagConstraints();
   constraints.anchor = GridBagConstraints.WEST;
   constraints.insets = insets;
   constraints.fill = GridBagConstraints.BOTH;
   int i = 0;
   for (JComponent component : components) {
     constraints.gridx = i % columns;
     constraints.gridy = i / columns;
     layout.setConstraints(component, constraints);
     panel.add(component);
     i++;
   }
   // ---
   panel.setBorder(new EtchedBorder());
   setContentPane(panel);
   pack();
   show();
 }
  /**
   * The consturctor Constructor instantiates all the panels, convertible value instance, and the
   * frame. And adds the panels to the frame. And sets a proper size for the frame.
   */
  public HappyHackingConverter() {
    CFrame frame = new CFrame();
    frame.setBackground(white);

    ConvertibleValue temperatures = new ConvertibleValue();
    ConvertibleValue distances = new ConvertibleValue();
    ConvertibleValue weights = new ConvertibleValue();

    GridBagLayout leftSideLayout = new GridBagLayout();
    JPanel leftSide = new JPanel(leftSideLayout);
    leftSide.setBackground(white);

    GridBagLayout rightSideLayout = new GridBagLayout();
    JPanel rightSide = new JPanel(rightSideLayout);
    rightSide.setBackground(white);

    GridBagConstraints metricTemperatureConstraints = new GridBagConstraints();
    metricTemperatureConstraints.gridx = 0;
    metricTemperatureConstraints.gridy = 0;
    metricTemperatureConstraints.weighty = 0.1;
    metricTemperatureConstraints.weightx = 1;
    metricTemperatureConstraints.fill = GridBagConstraints.BOTH;
    metricTemperatureConstraints.anchor = GridBagConstraints.FIRST_LINE_START;
    JPanel metricTemperaturePanel =
        new TemperaturePanel(frame, temperatures, TemperatureScales.CENTIGRADE);
    leftSideLayout.setConstraints(metricTemperaturePanel, metricTemperatureConstraints);
    leftSide.add(metricTemperaturePanel);

    GridBagConstraints metricDistancesPanelConstraints = new GridBagConstraints();
    metricDistancesPanelConstraints.gridx = 0;
    metricDistancesPanelConstraints.gridy = 1;
    metricDistancesPanelConstraints.weighty = 0.3;
    metricDistancesPanelConstraints.weightx = 1;
    metricDistancesPanelConstraints.fill = GridBagConstraints.BOTH;
    metricDistancesPanelConstraints.anchor = GridBagConstraints.FIRST_LINE_START;
    JPanel metricDistancesPanel = new MetricDistancesPanel(frame, distances);
    leftSideLayout.setConstraints(metricDistancesPanel, metricDistancesPanelConstraints);
    leftSide.add(metricDistancesPanel);

    GridBagConstraints fahrenheitConstraints = new GridBagConstraints();
    fahrenheitConstraints.gridx = 0;
    fahrenheitConstraints.gridy = 0;
    fahrenheitConstraints.weighty = 0.1;
    fahrenheitConstraints.weightx = 1;
    fahrenheitConstraints.fill = GridBagConstraints.BOTH;
    fahrenheitConstraints.anchor = GridBagConstraints.FIRST_LINE_START;
    JPanel fahrenheitTemperaturePanel =
        new TemperaturePanel(frame, temperatures, TemperatureScales.FAHRENHEIT);
    rightSideLayout.setConstraints(fahrenheitTemperaturePanel, fahrenheitConstraints);
    rightSide.add(fahrenheitTemperaturePanel);

    GridBagConstraints imperialDistancesPanelConstraints = new GridBagConstraints();
    imperialDistancesPanelConstraints.gridx = 0;
    imperialDistancesPanelConstraints.gridy = 1;
    imperialDistancesPanelConstraints.weighty = 0.3;
    imperialDistancesPanelConstraints.weightx = 1;
    imperialDistancesPanelConstraints.fill = GridBagConstraints.BOTH;
    imperialDistancesPanelConstraints.anchor = GridBagConstraints.FIRST_LINE_START;
    JPanel imperialDistancesPanel = new ImperialDistancesPanel(frame, distances);
    rightSideLayout.setConstraints(imperialDistancesPanel, imperialDistancesPanelConstraints);
    rightSide.add(imperialDistancesPanel);

    GridBagConstraints metricWeightsConstraints = new GridBagConstraints();
    metricWeightsConstraints.gridx = 0;
    metricWeightsConstraints.gridy = 2;
    metricWeightsConstraints.weighty = 0.6;
    metricWeightsConstraints.weightx = 1;
    metricWeightsConstraints.fill = GridBagConstraints.BOTH;
    metricWeightsConstraints.anchor = GridBagConstraints.FIRST_LINE_START;
    MetricWeightsPanel metricWeightsPanel = new MetricWeightsPanel(frame, weights);
    leftSideLayout.setConstraints(metricWeightsPanel, metricWeightsConstraints);
    leftSide.add(metricWeightsPanel);

    GridBagConstraints imperialWeightsConstraints = new GridBagConstraints();
    imperialWeightsConstraints.gridx = 0;
    imperialWeightsConstraints.gridy = 2;
    imperialWeightsConstraints.weighty = 0.6;
    imperialWeightsConstraints.weightx = 1;
    imperialWeightsConstraints.fill = GridBagConstraints.BOTH;
    imperialWeightsConstraints.anchor = GridBagConstraints.FIRST_LINE_START;
    ImperialWeightsPanel imperialWeightsPanel = new ImperialWeightsPanel(frame, weights);
    rightSideLayout.setConstraints(imperialWeightsPanel, imperialWeightsConstraints);
    rightSide.add(imperialWeightsPanel);

    CSplit split = new CSplit(JSplitPane.HORIZONTAL_SPLIT, true, leftSide, rightSide);
    Container contentPane = frame.getContentPane();
    contentPane.add(split);
    frame.validate();
    frame.pack();
    frame.setSize(600, 997);
    split.setResizeWeight(0.5);
    split.setDividerLocation(0.5);
  } // end of HappyHackingConverter constructor
示例#16
0
  private void init(EditorPatternButton imgBtn, JLabel msgApplied) {
    _imgBtn = imgBtn;
    JLabel lblPath = new JLabel(_I("lblPath"));
    JLabel lblFilename = new JLabel(_I("lblFilename"));

    String filename = _imgBtn.getFilename();
    File f = new File(filename);
    String fullpath = f.getParent();
    filename = getFilenameWithoutExt(f);
    _oldFilename = filename;

    BufferedImage thumb = _imgBtn.createThumbnailImage(THUMB_MAX_HEIGHT);
    Border border = LineBorder.createGrayLineBorder();
    JLabel lblThumb = new JLabel(new ImageIcon(thumb));
    lblThumb.setBorder(border);

    _txtPath = new JTextField(fullpath, TXT_FILENAME_LENGTH);
    _txtPath.setEditable(false);
    _txtPath.setEnabled(false);

    String[] candidates = new String[] {filename};
    // <editor-fold defaultstate="collapsed" desc="OCR --- not used">
    /*
    String ocrText = getFilenameFromImage(thumb);
    if(ocrText.length()>0 && !ocrText.equals(filename))
    candidates = new String[] {filename, ocrText};
    */
    // </editor-fold>
    _txtFilename = new AutoCompleteCombo(candidates);

    _txtFileExt = new JTextField(getFileExt(f), TXT_FILE_EXT_LENGTH);
    _txtFileExt.setEditable(false);
    _txtFileExt.setEnabled(false);

    GridBagConstraints c = new GridBagConstraints();

    c.gridy = 0;
    c.insets = new Insets(100, 0, 0, 0);
    this.add(new JLabel(""), c);

    c = new GridBagConstraints();
    c.fill = 0;
    c.gridwidth = 3;
    c.gridy = 1;
    c.insets = new Insets(0, 10, 20, 10);
    this.add(lblThumb, c);

    c = new GridBagConstraints();
    c.fill = 1;
    c.gridy = 2;
    this.add(lblPath, c);
    c.gridx = 1;
    c.gridwidth = 2;
    this.add(_txtPath, c);

    c = new GridBagConstraints();
    c.gridy = 3;
    c.fill = 0;
    this.add(lblFilename, c);
    this.add(_txtFilename, c);
    this.add(_txtFileExt, c);

    c = new GridBagConstraints();
    c.gridy = 4;
    c.gridx = 1;
    c.insets = new Insets(200, 0, 0, 0);
    this.add(msgApplied, c);
  }
  public WizStepManyTextFields(Wizard w, String instr, Vector strings) {
    // store wizard?
    _instructions.setText(instr);
    _instructions.setWrapStyleWord(true);
    _instructions.setEditable(false);
    _instructions.setBorder(null);
    _instructions.setBackground(_mainPanel.getBackground());

    _mainPanel.setBorder(new EtchedBorder());

    GridBagLayout gb = new GridBagLayout();
    _mainPanel.setLayout(gb);

    GridBagConstraints c = new GridBagConstraints();
    c.ipadx = 3;
    c.ipady = 3;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.anchor = GridBagConstraints.EAST;

    JLabel image = new JLabel("");
    // image.setMargin(new Insets(0, 0, 0, 0));
    image.setIcon(WIZ_ICON);
    image.setBorder(null);
    c.gridx = 0;
    c.gridheight = GridBagConstraints.REMAINDER;
    c.gridy = 0;
    c.anchor = GridBagConstraints.NORTH;
    gb.setConstraints(image, c);
    _mainPanel.add(image);

    c.weightx = 0.0;
    c.gridx = 2;
    c.gridheight = 1;
    c.gridwidth = 3;
    c.gridy = 0;
    c.fill = GridBagConstraints.NONE;
    gb.setConstraints(_instructions, c);
    _mainPanel.add(_instructions);

    c.gridx = 1;
    c.gridy = 1;
    c.weightx = 0.0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    SpacerPanel spacer = new SpacerPanel();
    gb.setConstraints(spacer, c);
    _mainPanel.add(spacer);

    c.gridx = 2;
    c.weightx = 1.0;
    c.anchor = GridBagConstraints.WEST;
    c.gridwidth = 1;
    int size = strings.size();
    for (int i = 0; i < size; i++) {
      c.gridy = 2 + i;
      String s = (String) strings.elementAt(i);
      JTextField tf = new JTextField(s, 50);
      tf.setMinimumSize(new Dimension(200, 20));
      tf.getDocument().addDocumentListener(this);
      _fields.addElement(tf);
      gb.setConstraints(tf, c);
      _mainPanel.add(tf);
    }

    c.gridx = 1;
    c.gridy = 3 + strings.size();
    c.weightx = 0.0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    SpacerPanel spacer2 = new SpacerPanel();
    gb.setConstraints(spacer2, c);
    _mainPanel.add(spacer2);
  }
示例#18
0
  public SaveDialog(Frame parent) {
    super(parent, true);
    this.setLayout(new BorderLayout());
    // gather unsaved tab
    Set<Tab> unsaved = new LinkedHashSet<>();
    for (Tab tab : MainPanel.getAllTab()) {
      if (!tab.isSaved()) {
        unsaved.add(tab);
      }
    }
    if (unsaved.isEmpty()) {
      // close directly
      this.setTitle("Confirm close");
      // upper labels
      JPanel labels = new JPanel(new FlowLayout(FlowLayout.LEFT, 11, 7));
      labels.add(iconLabel);
      labels.add(new MyLabel(" Do you really want to close RefluxEdit?"));
      // buttons
      JPanel buttons = new JPanel(new FlowLayout(FlowLayout.CENTER, 4, 7));
      buttons.add(
          new MyButton("YES") {
            {
              SaveDialog.this.getRootPane().setDefaultButton(this);
              this.setFocusPainted(true);
            }

            @Override
            public void actionPerformed(ActionEvent ev) {
              close = true;
              SaveDialog.this.setVisible(false);
            }
          });
      buttons.add(
          new MyButton("NO") {
            {
              this.setFocusPainted(true);
            }

            @Override
            public void actionPerformed(ActionEvent ev) {
              close = false;
              SaveDialog.this.setVisible(false);
            }
          });
      buttons.setBorder(new EmptyBorder(0, 0, 5, 0));
      //
      this.add(labels, BorderLayout.CENTER);
      this.add(buttons, BorderLayout.PAGE_END);
    } else {
      // ask save changes
      this.setTitle("Unsaved changes");
      // upper components: icon and list
      JPanel upper = new JPanel(new GridBagLayout());
      JPanel listPane = new JPanel(new BorderLayout());
      final DefaultListModel<Tab> listModel = new DefaultListModel<>();
      final JList<Tab> tabList = new JList<>(listModel);
      tabList.setFont(f13);
      tabList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
      tabList.setCellRenderer(
          new DefaultListCellRenderer() {
            @Override
            public Component getListCellRendererComponent(
                JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
              JLabel label =
                  (JLabel)
                      (super.getListCellRendererComponent(
                          list, value, index, isSelected, cellHasFocus));
              if (value instanceof Tab) {
                String text = ((Tab) value).getTabLabel().getText();
                label.setText(text.substring(1)); // remove "*"
              }
              return label;
            }
          });
      for (Tab tab : unsaved) {
        listModel.addElement(tab);
      }
      tabList.getSelectionModel().setSelectionInterval(0, listModel.size() - 1);
      JScrollPane scrollPane = new JScrollPane(tabList);
      scrollPane.setPreferredSize(new Dimension(350, 170));
      listPane.add(new MyLabel("The following tabs are unsaved:"), BorderLayout.PAGE_START);
      listPane.add(scrollPane, BorderLayout.CENTER);
      // setup upper
      GridBagConstraints c = new GridBagConstraints();
      c.gridx = 0;
      c.gridy = 0;
      c.weightx = 0;
      c.weighty = 1;
      c.insets = new Insets(5, 5, 5, 5);
      c.anchor = GridBagConstraints.FIRST_LINE_START;
      upper.add(iconLabel, c);
      //
      c.gridx = 1;
      c.weightx = 1;
      c.fill = GridBagConstraints.BOTH;
      upper.add(listPane, c);
      // lower components: buttons
      JPanel buttons = new JPanel(new FlowLayout(FlowLayout.CENTER, 4, 7));
      buttons.add(
          new MyButton("Save") {
            {
              this.setFocusPainted(true);
              this.setToolTipText("Save selected tab(s)");
              SaveDialog.this.getRootPane().setDefaultButton(this);
              if (isMetal) {
                this.setPreferredSize(METAL_BUTTON_DIZE);
              }
            }

            @Override
            public void actionPerformed(ActionEvent ev) {
              for (Tab tab : tabList.getSelectedValuesList()) {
                if (tab.getFile() != null) {
                  try {
                    tab.save();
                    MainPanel.close(tab);
                    listModel.removeElement(tab);
                  } catch (Exception ex) {
                    exception(ex);
                    break;
                  }
                } else {
                  File file =
                      FileChooser.showPreferredFileDialog(
                          RefluxEdit.getInstance(), FileChooser.SAVE, new String[0]);
                  if (file != null) {
                    try {
                      tab.save(file, false);
                      MainPanel.close(tab);
                      listModel.removeElement(tab);
                    } catch (Exception ex) {
                      exception(ex);
                      break;
                    }
                  }
                }
              }
              if (listModel.size() == 0) {
                RefluxEdit.getInstance().close();
              }
            }
          });
      buttons.add(
          new MyButton("Discard") {
            {
              this.setFocusPainted(true);
              this.setToolTipText("Discard selected tab(s)");
              if (isMetal) {
                this.setPreferredSize(METAL_BUTTON_DIZE);
              }
            }

            @Override
            public void actionPerformed(ActionEvent ev) {
              for (Tab tab : tabList.getSelectedValuesList()) {
                MainPanel.close(tab);
                listModel.removeElement(tab);
              }
              if (listModel.size() == 0) {
                RefluxEdit.getInstance().close();
              }
            }
          });
      buttons.add(
          new MyButton("Close") {
            {
              this.setFocusPainted(true);
              this.setToolTipText("Close RefluxEdit");
              if (isMetal) {
                this.setPreferredSize(METAL_BUTTON_DIZE);
              }
            }

            @Override
            public void actionPerformed(ActionEvent ev) {
              SaveDialog.this.close = true;
              SaveDialog.this.setVisible(false);
            }
          });
      buttons.add(
          new MyButton("Cancel") {
            {
              this.setFocusPainted(true);
              if (isMetal) {
                this.setPreferredSize(METAL_BUTTON_DIZE);
              }
            }

            @Override
            public void actionPerformed(ActionEvent ev) {
              SaveDialog.this.close = false;
              SaveDialog.this.setVisible(false);
            }
          });
      this.add(upper, BorderLayout.CENTER);
      this.add(buttons, BorderLayout.PAGE_END);
    }
  }
示例#19
0
  private void initialize() {
    setName("NewsPanel");
    setLayout(new GridBagLayout());
    refreshLanguage();

    // We create the components
    new TextComponentClipboardMenu(uploadPrioTextField, language);
    new TextComponentClipboardMenu(downloadPrioTextField, language);
    new TextComponentClipboardMenu(displayDaysTextField, language);
    new TextComponentClipboardMenu(downloadDaysTextField, language);
    new TextComponentClipboardMenu(messageBaseTextField, language);
    new TextComponentClipboardMenu(minimumIntervalTextField, language);
    new TextComponentClipboardMenu(concurrentUpdatesTextField, language);
    new TextComponentClipboardMenu(altEditTextField, language);

    // Adds all of the components
    final GridBagConstraints constraints = new GridBagConstraints();
    constraints.fill = GridBagConstraints.NONE;
    constraints.anchor = GridBagConstraints.WEST;
    constraints.weighty = 0.0;
    constraints.weightx = 0;

    constraints.insets = new Insets(0, 5, 5, 5);
    constraints.gridy = 0;

    constraints.gridx = 0;
    add(displayDaysLabel, constraints);
    constraints.gridx = 1;
    add(displayDaysTextField, constraints);

    constraints.gridx = 0;
    constraints.gridy++;
    add(downloadDaysLabel, constraints);
    constraints.gridx = 1;
    add(downloadDaysTextField, constraints);

    constraints.gridx = 0;
    constraints.gridy++;
    constraints.gridwidth = 2;
    add(alwaysDownloadBackloadCheckBox, constraints);
    constraints.gridwidth = 1;

    constraints.gridx = 0;
    constraints.gridy++;
    add(messageBaseLabel, constraints);
    constraints.gridx = 1;
    add(messageBaseTextField, constraints);

    constraints.gridy++;
    constraints.gridx = 0;
    add(uploadPrioLabel, constraints);
    constraints.gridx = 1;
    add(uploadPrioTextField, constraints);

    constraints.gridy++;
    constraints.gridx = 0;
    add(downloadPrioLabel, constraints);
    constraints.gridx = 1;
    add(downloadPrioTextField, constraints);
    constraints.gridx = 0;

    constraints.gridwidth = 2;

    constraints.gridy++;
    add(automaticBoardUpdateCheckBox, constraints);

    constraints.gridy++;
    add(getUpdatePanel(), constraints);

    constraints.gridy++;
    add(useOneConnectionForMessagesCheckBox, constraints);

    constraints.gridy++;
    add(storeSentMessagesCheckBox, constraints);

    constraints.gridy++;
    add(silentlyRetryCheckBox, constraints);

    constraints.gridwidth = 1;

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

    constraints.gridy++;
    constraints.gridx = 0;
    add(altEditCheckBox, constraints);
    constraints.gridx = 1;
    constraints.weightx = 1;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    add(altEditTextField, constraints);
    constraints.weightx = 0;
    constraints.fill = GridBagConstraints.NONE;

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

    // Add listeners
    automaticBoardUpdateCheckBox.addActionListener(listener);
    altEditCheckBox.addChangeListener(listener);
  }
示例#20
0
  // Public constructor
  public ElectronicOrganFrame(String title) {
    // Call parent constructor to give title to frame
    super(title);

    // Make this frame its own window listener
    addWindowListener(windowListener);

    // Panel components: waveformPanel
    waveformPanel.setBorder(
        new TitledBorder(new BevelBorder(BevelBorder.RAISED), "Waveform Options"));
    GridBagLayout waveformPanelGridBag = new GridBagLayout();
    GridBagConstraints waveformPanelConstr = new GridBagConstraints();
    waveformPanel.setLayout(waveformPanelGridBag);
    waveformPanelConstr.anchor = GridBagConstraints.CENTER;
    waveformPanelConstr.weightx = 1.0;
    waveformPanelConstr.weighty = 1.0;
    waveformPanelConstr.fill = GridBagConstraints.BOTH;
    waveformPanelConstr.gridx = 0;
    waveformPanelConstr.gridy = 0;
    waveformPanelConstr.gridwidth = 1;
    waveformPanelConstr.gridheight = 1;
    waveformPanelGridBag.setConstraints(sineButton, waveformPanelConstr);
    waveformPanel.add(sineButton);
    waveformPanelRadio.add(sineButton);
    sineButton.addActionListener(actionListener);
    waveformPanelConstr.gridx = 1;
    waveformPanelConstr.gridy = 0;
    waveformPanelConstr.gridwidth = 1;
    waveformPanelConstr.gridheight = 1;
    waveformPanelGridBag.setConstraints(squareButton, waveformPanelConstr);
    waveformPanel.add(squareButton);
    waveformPanelRadio.add(squareButton);
    squareButton.addActionListener(actionListener);
    waveformPanelConstr.gridx = 2;
    waveformPanelConstr.gridy = 0;
    waveformPanelConstr.gridwidth = 1;
    waveformPanelConstr.gridheight = 1;
    waveformPanelGridBag.setConstraints(sawtoothButton, waveformPanelConstr);
    waveformPanel.add(sawtoothButton);
    waveformPanelRadio.add(sawtoothButton);
    sawtoothButton.addActionListener(actionListener);
    waveformPanelConstr.gridx = 3;
    waveformPanelConstr.gridy = 0;
    waveformPanelConstr.gridwidth = 1;
    waveformPanelConstr.gridheight = 1;
    waveformPanelGridBag.setConstraints(triangleButton, waveformPanelConstr);
    waveformPanel.add(triangleButton);
    waveformPanelRadio.add(triangleButton);
    triangleButton.addActionListener(actionListener);

    // Panel components: exitPanel
    exitPanel.setLayout(new GridLayout(1, 5));
    exitPanel.add(label1);
    exitPanel.add(label2);
    exitPanel.add(exitButton);
    exitButton.addActionListener(actionListener);
    exitPanel.add(label3);
    exitPanel.add(label4);
    GridBagLayout thisGridBag = new GridBagLayout();
    GridBagConstraints thisConstr = new GridBagConstraints();
    this.getContentPane().setLayout(thisGridBag);
    thisConstr.anchor = GridBagConstraints.CENTER;
    thisConstr.weightx = 1.0;
    thisConstr.weighty = 1.0;
    thisConstr.fill = GridBagConstraints.BOTH;
    thisConstr.gridx = 0;
    thisConstr.gridy = 0;
    thisConstr.gridwidth = 3;
    thisConstr.gridheight = 1;
    thisGridBag.setConstraints(label5, thisConstr);
    this.getContentPane().add(label5);
    thisConstr.gridx = 0;
    thisConstr.gridy = 1;
    thisConstr.gridwidth = 1;
    thisConstr.gridheight = 1;
    thisGridBag.setConstraints(label6, thisConstr);
    this.getContentPane().add(label6);
    thisConstr.gridx = 1;
    thisConstr.gridy = 1;
    thisConstr.gridwidth = 1;
    thisConstr.gridheight = 1;
    thisGridBag.setConstraints(waveformPanel, thisConstr);
    this.getContentPane().add(waveformPanel);
    thisConstr.gridx = 2;
    thisConstr.gridy = 1;
    thisConstr.gridwidth = 1;
    thisConstr.gridheight = 1;
    thisGridBag.setConstraints(label7, thisConstr);
    this.getContentPane().add(label7);
    thisConstr.gridx = 1;
    thisConstr.gridy = 2;
    thisConstr.gridwidth = 1;
    thisConstr.gridheight = 1;
    thisGridBag.setConstraints(exitPanel, thisConstr);
    this.getContentPane().add(exitPanel);

    // Set frame size and show it
    setSize(500, 200);
    setVisible(true);
  } // Frame constructor ElectronicOrganFrame ()
示例#21
0
  private void initComponents() {
    setLayout(new BorderLayout());
    final JPanel mainPanel = new TransparentPanel();
    add(mainPanel, BorderLayout.NORTH);

    mainPanel.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 1;
    c.anchor = GridBagConstraints.LINE_START;
    c.fill = GridBagConstraints.HORIZONTAL;

    // general encryption option
    enableDefaultEncryption =
        new SIPCommCheckBox(
            UtilActivator.getResources()
                .getI18NString("plugin.sipaccregwizz.ENABLE_DEFAULT_ENCRYPTION"),
            regform.isDefaultEncryption());
    enableDefaultEncryption.addActionListener(this);
    mainPanel.add(enableDefaultEncryption, c);

    // warning message and button to show advanced options
    JLabel lblWarning = new JLabel();
    lblWarning.setBorder(new EmptyBorder(10, 5, 10, 0));
    lblWarning.setText(
        UtilActivator.getResources()
            .getI18NString(
                "plugin.sipaccregwizz.SECURITY_WARNING",
                new String[] {
                  UtilActivator.getResources().getSettingsString("service.gui.APPLICATION_NAME")
                }));
    c.gridy++;
    mainPanel.add(lblWarning, c);

    cmdExpandAdvancedSettings = new JLabel();
    cmdExpandAdvancedSettings.setBorder(new EmptyBorder(0, 5, 0, 0));
    cmdExpandAdvancedSettings.setIcon(
        UtilActivator.getResources().getImage("service.gui.icons.RIGHT_ARROW_ICON"));
    cmdExpandAdvancedSettings.setText(
        UtilActivator.getResources().getI18NString("plugin.sipaccregwizz.SHOW_ADVANCED"));
    cmdExpandAdvancedSettings.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            cmdExpandAdvancedSettings.setIcon(
                UtilActivator.getResources()
                    .getImage(
                        pnlAdvancedSettings.isVisible()
                            ? "service.gui.icons.RIGHT_ARROW_ICON"
                            : "service.gui.icons.DOWN_ARROW_ICON"));

            pnlAdvancedSettings.setVisible(!pnlAdvancedSettings.isVisible());

            pnlAdvancedSettings.revalidate();
          }
        });
    c.gridy++;
    mainPanel.add(cmdExpandAdvancedSettings, c);

    pnlAdvancedSettings = new TransparentPanel();
    pnlAdvancedSettings.setLayout(new GridBagLayout());
    pnlAdvancedSettings.setVisible(false);
    c.gridy++;
    mainPanel.add(pnlAdvancedSettings, c);

    c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 2;
    c.gridheight = 1;
    c.anchor = GridBagConstraints.LINE_START;
    c.fill = GridBagConstraints.HORIZONTAL;
    pnlAdvancedSettings.add(new JSeparator(), c);

    // Encryption protcol preferences.
    JLabel lblEncryptionProtocolPreferences = new JLabel();
    lblEncryptionProtocolPreferences.setText(
        UtilActivator.getResources()
            .getI18NString("plugin.sipaccregwizz.ENCRYPTION_PROTOCOL_PREFERENCES"));
    c.gridy++;
    pnlAdvancedSettings.add(lblEncryptionProtocolPreferences, c);

    int nbEncryptionProtocols = ENCRYPTION_PROTOCOLS.length;
    String[] encryptions = new String[nbEncryptionProtocols];
    boolean[] selectedEncryptions = new boolean[nbEncryptionProtocols];

    this.encryptionConfigurationTableModel =
        new EncryptionConfigurationTableModel(encryptions, selectedEncryptions);
    loadEncryptionProtocols(new HashMap<String, Integer>(), new HashMap<String, Boolean>());
    this.encryptionProtocolPreferences =
        new PriorityTable(this.encryptionConfigurationTableModel, 60);
    this.encryptionConfigurationTableModel.addTableModelListener(this);
    c.gridy++;
    pnlAdvancedSettings.add(this.encryptionProtocolPreferences, c);

    // ZRTP
    JLabel lblZrtpOption = new JLabel();
    lblZrtpOption.setBorder(new EmptyBorder(5, 5, 5, 0));
    lblZrtpOption.setText(
        UtilActivator.getResources().getI18NString("plugin.sipaccregwizz.ZRTP_OPTION"));
    c.gridx = 0;
    c.gridy++;
    c.gridwidth = 1;
    pnlAdvancedSettings.add(lblZrtpOption, c);
    c.gridx = 1;
    pnlAdvancedSettings.add(new JSeparator(), c);

    enableSipZrtpAttribute =
        new SIPCommCheckBox(
            UtilActivator.getResources()
                .getI18NString("plugin.sipaccregwizz.ENABLE_SIPZRTP_ATTRIBUTE"),
            regform.isSipZrtpAttribute());
    c.gridx = 0;
    c.gridy++;
    c.gridwidth = 2;
    pnlAdvancedSettings.add(enableSipZrtpAttribute, c);

    // SDES
    JLabel lblSDesOption = new JLabel();
    lblSDesOption.setBorder(new EmptyBorder(5, 5, 5, 0));
    lblSDesOption.setText(
        UtilActivator.getResources().getI18NString("plugin.sipaccregwizz.SDES_OPTION"));
    c.gridx = 0;
    c.gridy++;
    c.gridwidth = 1;
    pnlAdvancedSettings.add(lblSDesOption, c);
    c.gridx = 1;
    pnlAdvancedSettings.add(new JSeparator(), c);

    JLabel lblCipherInfo = new JLabel();
    lblCipherInfo.setText(
        UtilActivator.getResources().getI18NString("plugin.sipaccregwizz.CIPHER_SUITES"));
    c.gridx = 0;
    c.gridy++;
    c.gridwidth = 2;
    pnlAdvancedSettings.add(lblCipherInfo, c);

    cipherModel = new CipherTableModel(regform.getSDesCipherSuites());
    tabCiphers = new JTable(cipherModel);
    tabCiphers.setShowGrid(false);
    tabCiphers.setTableHeader(null);
    TableColumnModel tableColumnModel = tabCiphers.getColumnModel();
    TableColumn tableColumn = tableColumnModel.getColumn(0);
    tableColumn.setMaxWidth(tableColumn.getMinWidth());
    JScrollPane scrollPane = new JScrollPane(tabCiphers);
    scrollPane.setPreferredSize(new Dimension(tabCiphers.getWidth(), 100));
    c.gridy++;
    pnlAdvancedSettings.add(scrollPane, c);

    // SAVP selection
    c.gridx = 0;
    c.gridwidth = 1;
    JLabel lblSavpOption = new JLabel();
    lblSavpOption.setBorder(new EmptyBorder(5, 5, 5, 0));
    lblSavpOption.setText(
        UtilActivator.getResources().getI18NString("plugin.sipaccregwizz.SAVP_OPTION"));
    if (this.displaySavpOtions) {
      c.gridy++;
      pnlAdvancedSettings.add(lblSavpOption, c);
    }
    c.gridx = 1;
    if (this.displaySavpOtions) {
      pnlAdvancedSettings.add(new JSeparator(), c);
    }

    cboSavpOption =
        new JComboBox(new SavpOption[] {new SavpOption(0), new SavpOption(1), new SavpOption(2)});
    c.gridx = 0;
    c.gridwidth = 2;
    c.insets = new Insets(0, 20, 0, 0);
    if (this.displaySavpOtions) {
      c.gridy++;
      pnlAdvancedSettings.add(cboSavpOption, c);
    }
  }