Example #1
0
  @Override
  public JPopupMenu getComponentPopupMenu() {
    if (popupMenu == null) {
      popupMenu = new JPopupMenu(Messages.CHART_COLON);
      timeRangeMenu = new JMenu(Messages.PLOTTER_TIME_RANGE_MENU);
      timeRangeMenu.setMnemonic(Resources.getMnemonicInt(Messages.PLOTTER_TIME_RANGE_MENU));
      popupMenu.add(timeRangeMenu);
      menuRBs = new JRadioButtonMenuItem[rangeNames.length];
      ButtonGroup rbGroup = new ButtonGroup();
      for (int i = 0; i < rangeNames.length; i++) {
        menuRBs[i] = new JRadioButtonMenuItem(rangeNames[i]);
        rbGroup.add(menuRBs[i]);
        menuRBs[i].addActionListener(this);
        if (viewRange == rangeValues[i]) {
          menuRBs[i].setSelected(true);
        }
        timeRangeMenu.add(menuRBs[i]);
      }

      popupMenu.addSeparator();

      saveAsMI = new JMenuItem(Messages.PLOTTER_SAVE_AS_MENU_ITEM);
      saveAsMI.setMnemonic(Resources.getMnemonicInt(Messages.PLOTTER_SAVE_AS_MENU_ITEM));
      saveAsMI.addActionListener(this);
      popupMenu.add(saveAsMI);
    }
    return popupMenu;
  }
Example #2
0
  private JPanel getJContentPane() {
    if (jContentPane == null) {
      jLabel6 = new JLabel();
      jLabel6.setBounds(new Rectangle(11, 72, 218, 19));
      jLabel6.setText("Install log directory:");
      jLabel5 = new JLabel();
      jLabel5.setBounds(new Rectangle(11, 2, 394, 26));
      jLabel5.setText("Advanced Install. Please select your preferences");
      ButtonGroup group = new ButtonGroup();
      pathSuffix = new JTextArea();
      pathSuffix.setBounds(new Rectangle(232, 48, 61, 21));
      pathSuffix.setText("BIRCH");
      jLabel4 = new JLabel();
      jLabel4.setBounds(new Rectangle(22, 351, 312, 20));
      jLabel4.setText("* - Automatically detected, recommended.");
      jLabel3 = new JLabel();
      jLabel3.setBounds(new Rectangle(220, 48, 10, 21));
      jLabel3.setText(" /");
      jLabel2 = new JLabel();
      jLabel2.setBounds(new Rectangle(18, 250, 132, 18));
      jLabel2.setText("Binaries:");
      jLabel1 = new JLabel();
      jLabel1.setBounds(new Rectangle(11, 115, 127, 21));
      jLabel1.setText("Framework Type:");
      jLabel = new JLabel();
      jLabel.setBounds(new Rectangle(11, 28, 131, 17));
      jLabel.setText("Install directory:");
      jContentPane = new JPanel();
      jContentPane.setLayout(null);
      jContentPane.setSize(new Dimension(464, 376));
      jContentPane.add(jLabel, null);
      jContentPane.add(getJButton(), null);
      jContentPane.add(getJTextArea(), null);
      jContentPane.add(jLabel3, null);
      jContentPane.add(pathSuffix, null);
      jContentPane.add(jLabel1, null);
      jContentPane.add(getJCheckBox(), null);
      jContentPane.add(getJCheckBox1(), null);
      jContentPane.add(jLabel2, null);
      jContentPane.add(getJCheckBox2(), null);
      jContentPane.add(getJCheckBox3(), null);
      jContentPane.add(getJCheckBox4(), null);
      jContentPane.add(getJCheckBox5(), null);
      jContentPane.add(getJCheckBox6(), null);

      jContentPane.add(getLogTextField(), null);
      jContentPane.add(getLogButton(), null);
      jContentPane.add(jLabel4, null);
      jContentPane.add(getWindows32Checkbox(), null);
      jContentPane.add(getJRadioButton(), null);
      jContentPane.add(jLabel5, null);
      jContentPane.add(jLabel6, null);
      jContentPane.add(getGitRadioButton(), null);
      jContentPane.add(getGitComboBox(), null);
      group.add(releaseRadioButton);
      group.add(developmentRadioButton);
      group.add(gitRadioButton);
    }
    return jContentPane;
  }
 private OffsetPanel(Component comp) {
   this.setLayout(new BorderLayout(0, 0));
   TitledBorder tb = BorderFactory.createTitledBorder(b.getString("kOffsetBy"));
   if (JOAConstants.ISMAC) {
     // tb.setTitleFont(new Font("Helvetica", Font.PLAIN, 11));
   }
   this.setBorder(tb);
   JPanel controls = new JPanel();
   controls.setLayout(new GridLayout(3, 1, 5, 0));
   b1 = new JOAJRadioButton(b.getString("kSequence"));
   b2 = new JOAJRadioButton(b.getString("kDistance"), true);
   b3 = new JOAJRadioButton(b.getString("kTime"));
   controls.add(b2);
   controls.add(b1);
   controls.add(b3);
   controls.add(new JOAJLabel("       "));
   ButtonGroup bg = new ButtonGroup();
   bg.add(b1);
   bg.add(b2);
   bg.add(b3);
   this.add("Center", controls);
   b1.addItemListener((ItemListener) comp);
   b2.addItemListener((ItemListener) comp);
   b3.addItemListener((ItemListener) comp);
 }
 /** Show the filter dialog */
 public void showDialog() {
   empty_border = new EmptyBorder(5, 5, 0, 5);
   indent_border = new EmptyBorder(5, 25, 5, 5);
   include_panel =
       new ServiceFilterPanel("Include messages based on target service:", filter_include_list);
   exclude_panel =
       new ServiceFilterPanel("Exclude messages based on target service:", filter_exclude_list);
   status_box = new JCheckBox("Filter messages based on status:");
   status_box.addActionListener(this);
   status_active = new JRadioButton("Active messages only");
   status_active.setSelected(true);
   status_active.setEnabled(false);
   status_complete = new JRadioButton("Complete messages only");
   status_complete.setEnabled(false);
   status_group = new ButtonGroup();
   status_group.add(status_active);
   status_group.add(status_complete);
   if (filter_active || filter_complete) {
     status_box.setSelected(true);
     status_active.setEnabled(true);
     status_complete.setEnabled(true);
     if (filter_complete) {
       status_complete.setSelected(true);
     }
   }
   status_options = new JPanel();
   status_options.setLayout(new BoxLayout(status_options, BoxLayout.Y_AXIS));
   status_options.add(status_active);
   status_options.add(status_complete);
   status_options.setBorder(indent_border);
   status_panel = new JPanel();
   status_panel.setLayout(new BorderLayout());
   status_panel.add(status_box, BorderLayout.NORTH);
   status_panel.add(status_options, BorderLayout.CENTER);
   status_panel.setBorder(empty_border);
   ok_button = new JButton("Ok");
   ok_button.addActionListener(this);
   cancel_button = new JButton("Cancel");
   cancel_button.addActionListener(this);
   buttons = new JPanel();
   buttons.setLayout(new FlowLayout());
   buttons.add(ok_button);
   buttons.add(cancel_button);
   panel = new JPanel();
   panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
   panel.add(include_panel);
   panel.add(exclude_panel);
   panel.add(status_panel);
   panel.add(buttons);
   dialog = new JDialog();
   dialog.setTitle("SOAP Monitor Filter");
   dialog.setContentPane(panel);
   dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
   dialog.setModal(true);
   dialog.pack();
   Dimension d = dialog.getToolkit().getScreenSize();
   dialog.setLocation((d.width - dialog.getWidth()) / 2, (d.height - dialog.getHeight()) / 2);
   ok_pressed = false;
   dialog.show();
 }
  /**
   * Adds a JLabel and three JRadioButton instances in a ButtonGroup to the given panel with a
   * GridBagLayout, and returns the buttons in an array.
   */
  private JRadioButton[] addRadioButtonTriplet(String labelText, JPanel panel) {
    GridBagConstraints labelConstraints = new GridBagConstraints();
    labelConstraints.anchor = GridBagConstraints.WEST;
    labelConstraints.insets = new Insets(2, 10, 2, 10);

    GridBagConstraints buttonConstraints = new GridBagConstraints();
    buttonConstraints.insets = labelConstraints.insets;

    GridBagConstraints lastGlueConstraints = new GridBagConstraints();
    lastGlueConstraints.gridwidth = GridBagConstraints.REMAINDER;
    lastGlueConstraints.weightx = 1.0;

    // Create the radio buttons.
    JRadioButton radioButton0 = new JRadioButton();
    JRadioButton radioButton1 = new JRadioButton();
    JRadioButton radioButton2 = new JRadioButton();

    // Put them in a button group.
    ButtonGroup buttonGroup = new ButtonGroup();
    buttonGroup.add(radioButton0);
    buttonGroup.add(radioButton1);
    buttonGroup.add(radioButton2);

    // Add the label and the buttons to the panel.
    panel.add(new JLabel(labelText), labelConstraints);
    panel.add(radioButton0, buttonConstraints);
    panel.add(radioButton1, buttonConstraints);
    panel.add(radioButton2, buttonConstraints);
    panel.add(Box.createGlue(), lastGlueConstraints);

    return new JRadioButton[] {radioButton0, radioButton1, radioButton2};
  }
  /** TabbedPaneDemo Constructor */
  public TabbedPaneDemo(SwingSet2 swingset) {
    // Set the title for this demo, and an icon used to represent this
    // demo inside the SwingSet2 app.
    super(swingset, "TabbedPaneDemo", "toolbar/JTabbedPane.gif");

    // create tab position controls
    JPanel tabControls = new JPanel();
    tabControls.add(new JLabel(getString("TabbedPaneDemo.label")));
    top = (JRadioButton) tabControls.add(new JRadioButton(getString("TabbedPaneDemo.top")));
    left = (JRadioButton) tabControls.add(new JRadioButton(getString("TabbedPaneDemo.left")));
    bottom = (JRadioButton) tabControls.add(new JRadioButton(getString("TabbedPaneDemo.bottom")));
    right = (JRadioButton) tabControls.add(new JRadioButton(getString("TabbedPaneDemo.right")));
    getDemoPanel().add(tabControls, BorderLayout.NORTH);

    group = new ButtonGroup();
    group.add(top);
    group.add(bottom);
    group.add(left);
    group.add(right);

    top.setSelected(true);

    top.addActionListener(this);
    bottom.addActionListener(this);
    left.addActionListener(this);
    right.addActionListener(this);

    // create tab
    tabbedpane = new JTabbedPane();
    getDemoPanel().add(tabbedpane, BorderLayout.CENTER);

    String name = getString("TabbedPaneDemo.laine");
    JLabel pix = new JLabel(createImageIcon("tabbedpane/laine.jpg", name));
    tabbedpane.add(name, pix);

    name = getString("TabbedPaneDemo.ewan");
    pix = new JLabel(createImageIcon("tabbedpane/ewan.jpg", name));
    tabbedpane.add(name, pix);

    name = getString("TabbedPaneDemo.hania");
    pix = new JLabel(createImageIcon("tabbedpane/hania.jpg", name));
    tabbedpane.add(name, pix);

    name = getString("TabbedPaneDemo.bounce");
    spin = new HeadSpin();
    tabbedpane.add(name, spin);

    tabbedpane
        .getModel()
        .addChangeListener(
            new ChangeListener() {
              public void stateChanged(ChangeEvent e) {
                SingleSelectionModel model = (SingleSelectionModel) e.getSource();
                if (model.getSelectedIndex() == tabbedpane.getTabCount() - 1) {
                  spin.go();
                }
              }
            });
  }
  protected JMenu buildSpeedMenu() {
    JMenu speed = new JMenu("Drag");

    JRadioButtonMenuItem live = new JRadioButtonMenuItem("Live");
    JRadioButtonMenuItem outline = new JRadioButtonMenuItem("Outline");

    JRadioButtonMenuItem slow = new JRadioButtonMenuItem("Old and Slow");

    ButtonGroup group = new ButtonGroup();

    group.add(live);
    group.add(outline);
    group.add(slow);

    live.setSelected(true);

    slow.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // for right now I'm saying if you set the mode
            // to something other than a specified mode
            // it will revert to the old way
            // This is mostly for comparison's sake
            desktop.setDragMode(-1);
          }
        });

    live.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            desktop.setDragMode(JDesktopPane.LIVE_DRAG_MODE);
          }
        });

    outline.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
          }
        });

    speed.add(live);
    speed.add(outline);
    speed.add(slow);
    return speed;
  }
Example #8
0
    private JPanel makeShapeSelectionPanel() {
      final Info[] surfaceShapeInfos = this.buildSurfaceShapes();
      GridLayout layout = new GridLayout(surfaceShapeInfos.length, 1);
      JPanel ssPanel = new JPanel(layout);
      ButtonGroup group = new ButtonGroup();
      for (final Info info : surfaceShapeInfos) {
        JRadioButton b = new JRadioButton(info.name);
        b.addActionListener(
            new ActionListener() {
              public void actionPerformed(ActionEvent actionEvent) {
                currentShape = (Renderable) info.object;
                update();
              }
            });
        group.add(b);
        ssPanel.add(b);
        if (info.name.equalsIgnoreCase("none")) b.setSelected(true);
      }
      ssPanel.setBorder(this.createTitleBorder("Surface Shapes"));

      final Info[] freeShapeInfos = this.buildFreeShapes();
      layout = new GridLayout(freeShapeInfos.length, 1);
      JPanel fsPanel = new JPanel(layout);
      for (final Info info : freeShapeInfos) {
        JRadioButton b = new JRadioButton(info.name);
        b.addActionListener(
            new ActionListener() {
              public void actionPerformed(ActionEvent actionEvent) {
                currentShape = (Renderable) info.object;
                update();
              }
            });
        group.add(b);
        fsPanel.add(b);
        if (info.name.equalsIgnoreCase("none")) b.setSelected(true);
      }
      fsPanel.setBorder(this.createTitleBorder("Path Shapes"));

      JPanel shapesPanel = new JPanel(new GridLayout(1, 2, 8, 1));
      shapesPanel.add(fsPanel);
      shapesPanel.add(ssPanel);

      return shapesPanel;
    }
Example #9
0
  /**
   * Show the saved results on the server.
   *
   * @param mysettings jemboss settings
   * @param frameName title name for frame
   */
  public ShowSavedResults(final JembossParams mysettings, final JFrame f) {

    this("Saved results list" + (Jemboss.withSoap ? " on server" : ""));

    try {
      final ResultList reslist = new ResultList(mysettings);
      JMenu resFileMenu = new JMenu("File");
      resMenu.add(resFileMenu);

      final JCheckBoxMenuItem listByProgram = new JCheckBoxMenuItem("List by program");
      listByProgram.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              listByProgramName();
            }
          });
      resFileMenu.add(listByProgram);

      JCheckBoxMenuItem listByDate = new JCheckBoxMenuItem("List by date", true);
      listByDate.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              listByDateRun(reslist, false);
            }
          });
      resFileMenu.add(listByDate);

      ButtonGroup group = new ButtonGroup();
      group.add(listByProgram);
      group.add(listByDate);

      JButton refresh = new JButton(rfii);
      refresh.setMargin(new Insets(0, 1, 0, 1));
      refresh.setToolTipText("Refresh");
      resMenu.add(refresh);

      refresh.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              try {
                setCursor(cbusy);
                ResultList newlist = new ResultList(mysettings);
                setCursor(cdone);
                if (newlist.getStatus().equals("0")) {
                  reslist.updateRes(newlist.hash());
                  datasets.removeAllElements();

                  StringTokenizer tok = new StringTokenizer((String) reslist.get("list"), "\n");
                  while (tok.hasMoreTokens()) datasets.addElement(convertToPretty(tok.nextToken()));

                  if (listByProgram.isSelected()) listByProgramName();
                  else listByDateRun(reslist, false);
                } else {
                  JOptionPane.showMessageDialog(
                      null, newlist.getStatusMsg(), "Soap Error", JOptionPane.ERROR_MESSAGE);
                }
              } catch (JembossSoapException eae) {
                AuthPopup ap = new AuthPopup(mysettings, f);
                ap.setBottomPanel();
                ap.setSize(380, 170);
                ap.pack();
                ap.setVisible(true);
              }
            }
          });

      resFileMenu.addSeparator();
      JMenuItem resFileMenuExit = new JMenuItem("Close");
      resFileMenuExit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, ActionEvent.CTRL_MASK));

      resFileMenuExit.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              dispose();
            }
          });
      resFileMenu.add(resFileMenuExit);
      setJMenuBar(resMenu);

      // this is the list of saved results
      listByDateRun(reslist, true);

      final JList st = new JList(datasets);
      st.setCellRenderer(new TabListCellRenderer());

      st.addListSelectionListener(
          new ListSelectionListener() {
            public void valueChanged(ListSelectionEvent e) {
              if (e.getValueIsAdjusting()) return;

              JList theList = (JList) e.getSource();
              if (theList.isSelectionEmpty()) {
                System.out.println("Empty selection");
              } else {
                int index = theList.getSelectedIndex();
                String thisdata = convertToOriginal(datasets.elementAt(index));
                aboutRes.setText((String) reslist.get(thisdata));
                aboutRes.setCaretPosition(0);
              }
            }
          });

      st.addMouseListener(
          new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
              if (e.getClickCount() == 2) {
                try {
                  setCursor(cbusy);
                  String project = convertToOriginal(st.getSelectedValue());
                  ResultList thisres = new ResultList(mysettings, project, "show_saved_results");
                  new ShowResultSet(thisres.hash(), project, mysettings);
                  setCursor(cdone);
                } catch (JembossSoapException eae) {
                  AuthPopup ap = new AuthPopup(mysettings, f);
                  ap.setBottomPanel();
                  ap.setSize(380, 170);
                  ap.pack();
                  ap.setVisible(true);
                }
              }
            }
          });
      sp.add(st);

      // display retrieves all files and shows them in a window
      JPanel resButtonPanel = new JPanel();
      JButton showResButton = new JButton("Display");
      showResButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              String sel = convertToOriginal(st.getSelectedValue());
              if (sel != null) {
                try {
                  setCursor(cbusy);
                  ResultList thisres = new ResultList(mysettings, sel, "show_saved_results");
                  if (thisres.hash().size() == 0)
                    JOptionPane.showMessageDialog(
                        sp,
                        "This application launch '" + sel + "' didn't produce any result files.");
                  else new ShowResultSet(thisres.hash(), sel, mysettings);
                  setCursor(cdone);
                } catch (JembossSoapException eae) {
                  AuthPopup ap = new AuthPopup(mysettings, f);
                  ap.setBottomPanel();
                  ap.setSize(380, 170);
                  ap.pack();
                  ap.setVisible(true);
                }
              } else {
                statusField.setText("Nothing selected to be displayed.");
              }
            }
          });

      // add a users note for that project
      JButton addNoteButton = new JButton("Edit Notes");
      addNoteButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              String sel = convertToOriginal(st.getSelectedValue());
              if (sel != null) {
                try {
                  setCursor(cbusy);
                  ResultList thisres =
                      new ResultList(mysettings, sel, "Notes", "show_saved_results");
                  new ShowResultSet(thisres.hash(), sel, mysettings);
                  setCursor(cdone);
                } catch (JembossSoapException eae) {
                  AuthPopup ap = new AuthPopup(mysettings, f);
                  ap.setBottomPanel();
                  ap.setSize(380, 170);
                  ap.pack();
                  ap.setVisible(true);
                }
              } else {
                statusField.setText("Selected a project!");
              }
            }
          });

      // delete removes the file on the server & edits the list
      JButton delResButton = new JButton("Delete");
      delResButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              Object sel[] = st.getSelectedValues();
              if (sel != null) {
                String selList = new String("");
                JTextPane delList = new JTextPane();
                FontMetrics fm = delList.getFontMetrics(delList.getFont());
                int maxWidth = 0;
                for (int i = 0; i < sel.length; i++) {
                  if (i == sel.length - 1) selList = selList.concat((String) sel[i]);
                  else selList = selList.concat(sel[i] + "\n");

                  int width = fm.stringWidth((String) sel[i]);
                  if (width > maxWidth) maxWidth = width;
                }
                int ok = JOptionPane.OK_OPTION;
                if (sel.length > 1) {
                  JScrollPane scrollDel = new JScrollPane(delList);
                  delList.setText(selList);
                  delList.setEditable(false);
                  delList.setCaretPosition(0);

                  Dimension d1 = delList.getPreferredSize();
                  int maxHeight = (int) d1.getHeight() + 5;
                  if (maxHeight > 350) maxHeight = 350;
                  else if (maxHeight < 50) maxHeight = 50;

                  scrollDel.setPreferredSize(new Dimension(maxWidth + 30, maxHeight));

                  ok =
                      JOptionPane.showConfirmDialog(
                          null, scrollDel, "Confirm Deletion", JOptionPane.YES_NO_OPTION);
                }
                if (ok == JOptionPane.OK_OPTION) {
                  try // ask the server to delete these results
                  {
                    setCursor(cbusy);
                    selList = convertToOriginal(selList);
                    new ResultList(mysettings, selList, "delete_saved_results");
                    setCursor(cdone);

                    // amend the list
                    for (int i = 0; i < sel.length; i++) datasets.removeElement(sel[i]);

                    statusField.setText("Deleted " + sel.length + "  result(s)");

                    aboutRes.setText("");
                    st.setSelectedIndex(-1);
                  } catch (JembossSoapException eae) {
                    AuthPopup ap = new AuthPopup(mysettings, f);
                    ap.setBottomPanel();
                    ap.setSize(380, 170);
                    ap.pack();
                    ap.setVisible(true);
                  }
                }
              } else {
                statusField.setText("Nothing selected for deletion.");
              }
            }
          });
      resButtonPanel.add(delResButton);
      resButtonPanel.add(addNoteButton);
      resButtonPanel.add(showResButton);
      resButtonStatus.add(resButtonPanel, BorderLayout.CENTER);
      resButtonStatus.add(statusField, BorderLayout.SOUTH);

      Container c = getContentPane();
      c.add(ss, BorderLayout.WEST);
      c.add(aboutScroll, BorderLayout.CENTER);
      c.add(resButtonStatus, BorderLayout.SOUTH);
      pack();

      setVisible(true);
    } catch (JembossSoapException eae) {
      AuthPopup ap = new AuthPopup(mysettings, f);
      ap.setBottomPanel();
      ap.setSize(380, 170);
      ap.pack();
      ap.setVisible(true);
    }
  }
  /**
   * Creates a new <code>AddPersonDialog</code> with a given owner <code>JFrame</code> and <code>
   * FamilyTree</code>.
   */
  public AddPersonDialog(JFrame owner, FamilyTree tree) {
    super(owner, "Add New Person", true /* modal */);

    Container pane = this.getContentPane();
    pane.setLayout(new BorderLayout());

    JPanel infoPanel = new JPanel();
    infoPanel.setLayout(new GridLayout(0, 2));
    Border infoBorder = BorderFactory.createEmptyBorder(5, 5, 5, 5);
    infoPanel.setBorder(infoBorder);

    infoPanel.add(new JLabel("id:"));
    final JTextField idField = new JTextField();
    infoPanel.add(idField);

    final ButtonGroup group = new ButtonGroup();

    final JRadioButton male = new JRadioButton("male", true);
    group.add(male);
    infoPanel.add(male);

    final JRadioButton female = new JRadioButton("female");
    group.add(female);
    infoPanel.add(female);

    infoPanel.add(new JLabel("First name:"));
    final JTextField firstNameField = new JTextField();
    infoPanel.add(firstNameField);

    infoPanel.add(new JLabel("Middle name:"));
    final JTextField middleNameField = new JTextField();
    infoPanel.add(middleNameField);

    infoPanel.add(new JLabel("Last name:"));
    final JTextField lastNameField = new JTextField();
    infoPanel.add(lastNameField);

    infoPanel.add(new JLabel("Date of Birth:"));
    final JTextField dobField = new JTextField();
    infoPanel.add(dobField);

    infoPanel.add(new JLabel("Date of Death:"));
    final JTextField dodField = new JTextField();
    infoPanel.add(dodField);

    infoPanel.add(new JLabel("Father:"));
    JPanel fatherPanel = new JPanel();
    fatherPanel.setLayout(new FlowLayout());
    final JTextField fatherText = new JTextField("Click to choose");
    fatherText.setEditable(false);
    fatherText.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            // Pop up a PersonChooseDialog, place name in TextField
            System.out.println("Clicked father");
          }
        });
    fatherPanel.add(fatherText);
    infoPanel.add(fatherPanel);

    infoPanel.add(new JLabel("Mother:"));
    JPanel motherPanel = new JPanel();
    motherPanel.setLayout(new FlowLayout());
    final JTextField motherText = new JTextField("Click to choose");
    motherText.setEditable(false);
    motherText.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            // Pop up a PersonChooseDialog, place name in TextField
            System.out.println("Clicked mother");
          }
        });
    motherPanel.add(motherText);
    infoPanel.add(motherPanel);

    pane.add(infoPanel, BorderLayout.NORTH);

    // "Add" and "Cancel" buttons
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
    buttonPanel.add(Box.createHorizontalGlue());

    JButton addButton = new JButton("Add");
    addButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Create a new person based on the information entered in
            // this dialog
            int id = 0;
            try {
              id = Integer.parseInt(idField.getText());

            } catch (NumberFormatException ex) {
              error("Invalid id: " + idField.getText());
              return;
            }

            String text = null;

            text = dobField.getText();
            Date dob = null;
            if (text != null && !text.equals("")) {
              dob = parseDate(dobField.getText());
              if (dob == null) {
                // Parse error
                return;
              }
            }

            text = dodField.getText();
            Date dod = null;
            if (text != null && !text.equals("")) {
              dod = parseDate(dodField.getText());
              if (dod == null) {
                // Parse error
                return;
              }
            }

            Person.Gender gender;
            if (group.getSelection().equals(male)) {
              gender = Person.MALE;

            } else {
              gender = Person.FEMALE;
            }

            // Okay, everything parsed alright
            newPerson = new Person(id, gender);
            newPerson.setFirstName(firstNameField.getText());
            newPerson.setMiddleName(middleNameField.getText());
            newPerson.setLastName(lastNameField.getText());
            newPerson.setDateOfBirth(dob);
            newPerson.setDateOfDeath(dod);

            if (mother != null) {
              newPerson.setMother(mother);
            }

            if (father != null) {
              newPerson.setFather(father);
            }

            // We're all happy
            AddPersonDialog.this.dispose();
          }
        });
    buttonPanel.add(addButton);

    buttonPanel.add(Box.createHorizontalGlue());

    JButton cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Read my lips, no new Person!

            AddPersonDialog.this.newPerson = null;

            AddPersonDialog.this.dispose();
          }
        });
    buttonPanel.add(cancelButton);

    buttonPanel.add(Box.createHorizontalGlue());

    pane.add(buttonPanel, BorderLayout.SOUTH);
  }
Example #11
0
  /** Creates the GUI. */
  public void majorLayout() {
    //
    // Setup Menu
    //
    JMenuBar menuBar = new JMenuBar();
    JMenu file = new JMenu(ResourceHandler.getMessage("menu.file"));
    file.setMnemonic(ResourceHandler.getAcceleratorKey("menu.file"));

    file.add(exitMenuItem = new JMenuItem(ResourceHandler.getMessage("menu.exit")));
    exitMenuItem.setMnemonic(ResourceHandler.getAcceleratorKey("menu.exit"));
    exitMenuItem.addActionListener(this);
    menuBar.add(file);

    JMenu edit = new JMenu(ResourceHandler.getMessage("menu.edit"));
    edit.setMnemonic(ResourceHandler.getAcceleratorKey("menu.edit"));

    edit.add(optionMenuItem = new JMenuItem(ResourceHandler.getMessage("menu.option")));
    optionMenuItem.setMnemonic(ResourceHandler.getAcceleratorKey("menu.option"));
    optionMenuItem.addActionListener(this);
    menuBar.add(edit);

    JMenu help = new JMenu(ResourceHandler.getMessage("menu.help"));
    help.setMnemonic(ResourceHandler.getAcceleratorKey("menu.help"));

    help.add(helpMenuItem = new JMenuItem(ResourceHandler.getMessage("menu.help")));
    helpMenuItem.setMnemonic(ResourceHandler.getAcceleratorKey("menu.help"));

    help.add(new JSeparator());
    help.add(aboutMenuItem = new JMenuItem(ResourceHandler.getMessage("menu.about")));
    aboutMenuItem.setMnemonic(ResourceHandler.getAcceleratorKey("menu.about"));
    helpMenuItem.addActionListener(this);
    aboutMenuItem.addActionListener(this);
    menuBar.add(help);

    setJMenuBar(menuBar);

    //
    // Setup main GUI
    //

    dirLabel = new JLabel(ResourceHandler.getMessage("converter_gui.lablel0"));
    dirTF = new JTextField();
    dirBttn = new JButton(ResourceHandler.getMessage("button.browse.dir"));
    dirBttn.setMnemonic(ResourceHandler.getAcceleratorKey("button.browse.dir"));

    matchingLabel = new JLabel(ResourceHandler.getMessage("converter_gui.lablel1"));
    matchingTF = new JTextField(ResourceHandler.getMessage("converter_gui.lablel2"));
    recursiveCheckBox = new JCheckBox(ResourceHandler.getMessage("converter_gui.lablel3"));
    recursiveCheckBox.setMnemonic(ResourceHandler.getAcceleratorKey("converter_gui.lablel3"));

    backupLabel = new JLabel(ResourceHandler.getMessage("converter_gui.lablel5"));
    backupTF = new JTextField();
    backupBttn = new JButton(ResourceHandler.getMessage("button.browse.backup"));
    backupBttn.setMnemonic(ResourceHandler.getAcceleratorKey("button.browse.backup"));

    templateLabel = new JLabel(ResourceHandler.getMessage("converter_gui.lablel7"));
    templateCh = new TemplateFileChoice();

    staticVersioningLabel = new JLabel(ResourceHandler.getMessage("static.versioning.label"));
    String version = System.getProperty("java.version");
    if (version.indexOf("-") > 0) {
      version = version.substring(0, version.indexOf("-"));
    }
    int dotIndex = version.indexOf(".");
    dotIndex = version.indexOf(".", dotIndex + 1);
    String familyVersion = version.substring(0, dotIndex);

    MessageFormat formatter =
        new MessageFormat(ResourceHandler.getMessage("static.versioning.radio.button"));
    staticVersioningRadioButton = new JRadioButton(formatter.format(new Object[] {version}));
    staticVersioningRadioButton.setMnemonic(
        ResourceHandler.getAcceleratorKey("static.versioning.radio.button"));

    formatter = new MessageFormat(ResourceHandler.getMessage("dynamic.versioning.radio.button"));
    dynamicVersioningRadioButton = new JRadioButton(formatter.format(new Object[] {familyVersion}));
    dynamicVersioningRadioButton.setMnemonic(
        ResourceHandler.getAcceleratorKey("dynamic.versioning.radio.button"));

    staticVersioningTextArea = new JTextArea(ResourceHandler.getMessage("static.versioning.text"));

    formatter = new MessageFormat(ResourceHandler.getMessage("dynamic.versioning.text"));
    dynamicVersioningTextArea = new JTextArea(formatter.format(new Object[] {familyVersion}));

    ButtonGroup versioningButtonGroup = new ButtonGroup();
    versioningButtonGroup.add(staticVersioningRadioButton);
    versioningButtonGroup.add(dynamicVersioningRadioButton);

    runBttn = new JButton(ResourceHandler.getMessage("button.convert"));
    runBttn.setMnemonic(ResourceHandler.getAcceleratorKey("button.convert"));

    recursiveCheckBox.setOpaque(false);
    staticVersioningRadioButton.setOpaque(false);
    dynamicVersioningRadioButton.setOpaque(false);

    staticVersioningTextArea.setEditable(false);
    staticVersioningTextArea.setLineWrap(true);
    staticVersioningTextArea.setWrapStyleWord(true);
    dynamicVersioningTextArea.setEditable(false);
    dynamicVersioningTextArea.setLineWrap(true);
    dynamicVersioningTextArea.setWrapStyleWord(true);

    staticVersioningPanel.setLayout(new BorderLayout());
    staticVersioningPanel.add(staticVersioningTextArea, "Center");
    staticVersioningPanel.setBorder(new LineBorder(Color.black));

    dynamicVersioningPanel.setLayout(new BorderLayout());
    dynamicVersioningPanel.add(dynamicVersioningTextArea, "Center");
    dynamicVersioningPanel.setBorder(new LineBorder(Color.black));

    if (converter.isStaticVersioning()) {
      staticVersioningRadioButton.setSelected(true);
    } else {
      dynamicVersioningRadioButton.setSelected(true);
    }

    addListeners();

    final int buf = 10, // Buffer (between components and form)
        sp = 10, // Space between components
        vsp = 5, // Vertical space
        indent = 20; // Indent between form (left edge) and component

    GridBagConstraints gbc = new GridBagConstraints();
    GridBagLayout gbl = new GridBagLayout();
    getContentPane().setLayout(gbl);

    //
    // Setup top panel
    //
    GridBagLayout topLayout = new GridBagLayout();
    JPanel topPanel = new JPanel();
    topPanel.setOpaque(false);
    topPanel.setLayout(topLayout);

    topLayout.setConstraints(
        dirLabel,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(10, 0, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        dirTF,
        new GridBagConstraints(
            1,
            0,
            1,
            1,
            1,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(vsp, 2, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        dirBttn,
        new GridBagConstraints(
            2,
            0,
            1,
            1,
            0,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(10, sp, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        matchingLabel,
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            0,
            0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(10, 0, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        matchingTF,
        new GridBagConstraints(
            1,
            1,
            1,
            1,
            1,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(vsp, 2, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        recursiveCheckBox,
        new GridBagConstraints(
            2,
            1,
            GridBagConstraints.REMAINDER,
            1,
            1,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(vsp, 10, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        backupLabel,
        new GridBagConstraints(
            0,
            3,
            1,
            1,
            0,
            0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(10, 0, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        backupTF,
        new GridBagConstraints(
            1,
            3,
            1,
            1,
            1,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(vsp, 2, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        backupBttn,
        new GridBagConstraints(
            2,
            3,
            1,
            1,
            0,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(10, sp, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        templateLabel,
        new GridBagConstraints(
            0,
            4,
            1,
            1,
            0,
            0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(10, 0, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        templateCh,
        new GridBagConstraints(
            1,
            4,
            1,
            1,
            0,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(vsp, 2, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        sep1,
        new GridBagConstraints(
            0,
            5,
            GridBagConstraints.REMAINDER,
            1,
            1,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(10, 10, 10, 10),
            0,
            0));
    topLayout.setConstraints(
        staticVersioningLabel,
        new GridBagConstraints(
            0,
            6,
            1,
            1,
            0,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(10, 0, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        staticVersioningRadioButton,
        new GridBagConstraints(
            0,
            7,
            GridBagConstraints.REMAINDER,
            1,
            1,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(vsp, 10, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        staticVersioningPanel,
        new GridBagConstraints(
            0,
            8,
            GridBagConstraints.REMAINDER,
            1,
            0,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.BOTH,
            new Insets(vsp, 25, 10, 0),
            0,
            0));
    topLayout.setConstraints(
        dynamicVersioningRadioButton,
        new GridBagConstraints(
            0,
            9,
            GridBagConstraints.REMAINDER,
            1,
            1,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(vsp, 10, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        dynamicVersioningPanel,
        new GridBagConstraints(
            0,
            10,
            GridBagConstraints.REMAINDER,
            1,
            0,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.BOTH,
            new Insets(vsp, 25, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        sep2,
        new GridBagConstraints(
            0,
            11,
            GridBagConstraints.REMAINDER,
            1,
            1,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(10, 10, 0, 10),
            0,
            0));

    invisibleBttn = new JButton();
    invisibleBttn.setVisible(false);
    topLayout.setConstraints(
        invisibleBttn,
        new GridBagConstraints(
            2,
            6,
            1,
            1,
            0,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.CENTER,
            new Insets(indent, sp, 0, 0),
            0,
            0));

    topPanel.add(dirLabel);
    topPanel.add(dirTF);
    topPanel.add(dirBttn);
    topPanel.add(matchingLabel);
    topPanel.add(matchingTF);
    topPanel.add(recursiveCheckBox);
    topPanel.add(backupLabel);
    topPanel.add(backupTF);
    topPanel.add(backupBttn);
    topPanel.add(templateLabel);
    topPanel.add(templateCh);
    topPanel.add(sep1);
    topPanel.add(staticVersioningLabel);
    topPanel.add(staticVersioningRadioButton);
    topPanel.add(staticVersioningPanel);
    topPanel.add(dynamicVersioningRadioButton);
    topPanel.add(dynamicVersioningPanel);
    topPanel.add(sep2);
    topPanel.add(invisibleBttn);

    //
    // Setup bottom panel
    //
    GridBagLayout buttomLayout = new GridBagLayout();
    JPanel buttomPanel = new JPanel();
    buttomPanel.setOpaque(false);
    buttomPanel.setLayout(buttomLayout);

    buttomLayout.setConstraints(
        runBttn,
        new GridBagConstraints(
            3,
            0,
            1,
            1,
            0,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(sp, 0, 0, 0),
            0,
            0));
    buttomPanel.add(runBttn);

    //
    // Setup main panel
    //
    GridBagLayout mainLayout = new GridBagLayout();
    JPanel mainPanel = new JPanel();

    mainPanel.setOpaque(false);
    mainPanel.setLayout(mainLayout);

    mainLayout.setConstraints(
        topPanel,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            1,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(buf, buf, 0, buf),
            0,
            0));
    mainLayout.setConstraints(
        buttomPanel,
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            1,
            1,
            GridBagConstraints.SOUTH,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, buf, buf, buf),
            0,
            0));
    mainPanel.add(topPanel);
    mainPanel.add(buttomPanel);

    Border border = BorderFactory.createEtchedBorder();
    mainPanel.setBorder(border);

    GridBagLayout layout = new GridBagLayout();
    getContentPane().setLayout(layout);

    layout.setConstraints(
        mainPanel,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            1,
            1,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 0),
            0,
            0));

    getContentPane().add(mainPanel);

    pack();
    setResizable(false);
  }
  private void initComponents() {
    // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
    scrollPane2 = new JScrollPane();
    dialogPane = new JPanel();
    contentPanel = new JPanel();
    panel3 = new JPanel();
    layeredPane1 = new JLayeredPane();
    spinner2 = new JSpinner();
    spinner4 = new JSpinner();
    spinner5 = new JSpinner();
    spinner3 = new JSpinner();
    labelImage = new JLabel();
    panel2 = new JPanel();
    panel5 = new JPanel();
    label2 = new JLabel();
    label10 = new JLabel();
    panel4 = new JPanel();
    label4 = new JLabel();
    panel1 = new JPanel();
    label1 = new JLabel();
    textFieldNome = new JTextField();
    panel6 = new JPanel();
    radioButtonX = new JRadioButton();
    radioButtonY = new JRadioButton();
    panel7 = new JPanel();
    label8 = new JLabel();
    ranhuraRug = new JSpinner();
    label9 = new JLabel();
    buttonBar = new JPanel();
    okButton = new JButton();
    cancelButton = new JButton();

    // ======== this ========
    setTitle("Criar Ranhura com perfil U arredondado");
    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());

    // ======== scrollPane2 ========
    {

      // ======== dialogPane ========
      {
        dialogPane.setBorder(new EmptyBorder(12, 12, 12, 12));
        dialogPane.setLayout(new BorderLayout());

        // ======== contentPanel ========
        {
          contentPanel.setBorder(new EtchedBorder(EtchedBorder.RAISED));
          contentPanel.setLayout(new GridBagLayout());
          ((GridBagLayout) contentPanel.getLayout()).columnWidths = new int[] {0, 0, 0};
          ((GridBagLayout) contentPanel.getLayout()).rowHeights = new int[] {0, 0, 0, 0};
          ((GridBagLayout) contentPanel.getLayout()).columnWeights =
              new double[] {0.0, 0.0, 1.0E-4};
          ((GridBagLayout) contentPanel.getLayout()).rowWeights =
              new double[] {0.0, 0.0, 0.0, 1.0E-4};

          // ======== panel3 ========
          {
            panel3.setBorder(new TitledBorder("Dimens\u00f5es em mim\u00edmetros"));
            panel3.setLayout(new GridBagLayout());
            ((GridBagLayout) panel3.getLayout()).columnWidths = new int[] {0, 517, 0, 0};
            ((GridBagLayout) panel3.getLayout()).rowHeights = new int[] {0, 397, 0, 0};
            ((GridBagLayout) panel3.getLayout()).columnWeights =
                new double[] {0.0, 0.0, 0.0, 1.0E-4};
            ((GridBagLayout) panel3.getLayout()).rowWeights = new double[] {1.0, 0.0, 1.0, 1.0E-4};

            // ======== layeredPane1 ========
            {

              // ---- spinner2 ----
              spinner2.setModel(new SpinnerNumberModel(5.0, 0.0, null, 1.0));
              layeredPane1.add(spinner2, JLayeredPane.DEFAULT_LAYER);
              spinner2.setBounds(170, 95, 35, spinner2.getPreferredSize().height);

              // ---- spinner4 ----
              spinner4.setModel(new SpinnerNumberModel(20.0, 0.0, null, 1.0));
              layeredPane1.add(spinner4, JLayeredPane.DEFAULT_LAYER);
              spinner4.setBounds(130, 150, 40, spinner4.getPreferredSize().height);

              // ---- spinner5 ----
              spinner5.setModel(new SpinnerNumberModel(5.0, 0.0, null, 1.0));
              layeredPane1.add(spinner5, JLayeredPane.DEFAULT_LAYER);
              spinner5.setBounds(135, 300, 40, spinner5.getPreferredSize().height);

              // ---- spinner3 ----
              spinner3.setModel(new SpinnerNumberModel(0.0, 0.0, null, 1.0));
              layeredPane1.add(spinner3, JLayeredPane.DEFAULT_LAYER);
              spinner3.setBounds(10, 275, 40, spinner3.getPreferredSize().height);

              // ---- labelImage ----
              labelImage.setIcon(
                  new ImageIcon(getClass().getResource("/images/RanhuraPerfilRoundedU.png")));
              layeredPane1.add(labelImage, JLayeredPane.DEFAULT_LAYER);
              labelImage.setBounds(new Rectangle(new Point(0, 0), labelImage.getPreferredSize()));
            }
            panel3.add(
                layeredPane1,
                new GridBagConstraints(
                    1,
                    1,
                    1,
                    1,
                    0.0,
                    0.0,
                    GridBagConstraints.CENTER,
                    GridBagConstraints.BOTH,
                    new Insets(0, 0, 5, 5),
                    0,
                    0));
          }
          contentPanel.add(
              panel3,
              new GridBagConstraints(
                  0,
                  1,
                  1,
                  1,
                  0.0,
                  0.0,
                  GridBagConstraints.CENTER,
                  GridBagConstraints.BOTH,
                  new Insets(0, 0, 5, 5),
                  0,
                  0));

          // ======== panel2 ========
          {
            panel2.setLayout(new GridBagLayout());
            ((GridBagLayout) panel2.getLayout()).columnWidths = new int[] {0, 0, 0};
            ((GridBagLayout) panel2.getLayout()).rowHeights = new int[] {0, 0, 0, 0, 0, 0};
            ((GridBagLayout) panel2.getLayout()).columnWeights = new double[] {0.0, 0.0, 1.0E-4};
            ((GridBagLayout) panel2.getLayout()).rowWeights =
                new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4};

            // ======== panel5 ========
            {
              panel5.setLayout(new GridBagLayout());
              ((GridBagLayout) panel5.getLayout()).columnWidths = new int[] {0, 0, 0, 0, 0};
              ((GridBagLayout) panel5.getLayout()).rowHeights = new int[] {0, 0};
              ((GridBagLayout) panel5.getLayout()).columnWeights =
                  new double[] {1.0, 0.0, 0.0, 1.0, 1.0E-4};
              ((GridBagLayout) panel5.getLayout()).rowWeights = new double[] {0.0, 1.0E-4};

              // ---- label2 ----
              label2.setText("Ranhura na face");
              panel5.add(
                  label2,
                  new GridBagConstraints(
                      1,
                      0,
                      1,
                      1,
                      0.0,
                      0.0,
                      GridBagConstraints.CENTER,
                      GridBagConstraints.BOTH,
                      new Insets(0, 0, 0, 5),
                      0,
                      0));

              // ---- label10 ----
              label10.setText("XY");
              label10.setFont(new Font("Tahoma", Font.BOLD, 16));
              label10.setForeground(Color.red);
              panel5.add(
                  label10,
                  new GridBagConstraints(
                      2,
                      0,
                      1,
                      1,
                      0.0,
                      0.0,
                      GridBagConstraints.CENTER,
                      GridBagConstraints.BOTH,
                      new Insets(0, 0, 0, 5),
                      0,
                      0));
            }
            panel2.add(
                panel5,
                new GridBagConstraints(
                    1,
                    0,
                    1,
                    1,
                    0.0,
                    0.0,
                    GridBagConstraints.CENTER,
                    GridBagConstraints.BOTH,
                    new Insets(0, 0, 5, 0),
                    0,
                    0));

            // ======== panel4 ========
            {
              panel4.setBorder(new TitledBorder("Perfil"));
              panel4.setLayout(new GridBagLayout());
              ((GridBagLayout) panel4.getLayout()).columnWidths = new int[] {0, 0, 0, 0};
              ((GridBagLayout) panel4.getLayout()).rowHeights = new int[] {0, 0, 0, 0};
              ((GridBagLayout) panel4.getLayout()).columnWeights =
                  new double[] {1.0, 0.0, 1.0, 1.0E-4};
              ((GridBagLayout) panel4.getLayout()).rowWeights =
                  new double[] {0.0, 0.0, 0.0, 1.0E-4};

              // ---- label4 ----
              label4.setIcon(new ImageIcon(getClass().getResource("/images/PerfilRoundedU.gif")));
              panel4.add(
                  label4,
                  new GridBagConstraints(
                      1,
                      1,
                      1,
                      1,
                      0.0,
                      0.0,
                      GridBagConstraints.CENTER,
                      GridBagConstraints.BOTH,
                      new Insets(0, 0, 5, 5),
                      0,
                      0));
            }
            panel2.add(
                panel4,
                new GridBagConstraints(
                    1,
                    1,
                    1,
                    1,
                    0.0,
                    0.0,
                    GridBagConstraints.CENTER,
                    GridBagConstraints.BOTH,
                    new Insets(0, 0, 5, 0),
                    0,
                    0));

            // ======== panel1 ========
            {
              panel1.setLayout(new GridBagLayout());
              ((GridBagLayout) panel1.getLayout()).columnWidths = new int[] {0, 0, 0};
              ((GridBagLayout) panel1.getLayout()).rowHeights = new int[] {0, 0, 0, 0};
              ((GridBagLayout) panel1.getLayout()).columnWeights = new double[] {0.0, 1.0, 1.0E-4};
              ((GridBagLayout) panel1.getLayout()).rowWeights =
                  new double[] {0.0, 0.0, 0.0, 1.0E-4};

              // ---- label1 ----
              label1.setText("nome:");
              panel1.add(
                  label1,
                  new GridBagConstraints(
                      0,
                      1,
                      1,
                      1,
                      0.0,
                      0.0,
                      GridBagConstraints.CENTER,
                      GridBagConstraints.BOTH,
                      new Insets(0, 0, 5, 5),
                      0,
                      0));

              // ---- textFieldNome ----
              textFieldNome.setText("ranhura com perfil U arredondado");
              textFieldNome.setFont(new Font("Berlin Sans FB", Font.PLAIN, 13));
              panel1.add(
                  textFieldNome,
                  new GridBagConstraints(
                      1,
                      1,
                      1,
                      1,
                      0.0,
                      0.0,
                      GridBagConstraints.CENTER,
                      GridBagConstraints.BOTH,
                      new Insets(0, 0, 5, 0),
                      0,
                      0));
            }
            panel2.add(
                panel1,
                new GridBagConstraints(
                    1,
                    2,
                    1,
                    1,
                    0.0,
                    0.0,
                    GridBagConstraints.CENTER,
                    GridBagConstraints.BOTH,
                    new Insets(0, 0, 5, 0),
                    0,
                    0));

            // ======== panel6 ========
            {
              panel6.setBorder(new TitledBorder("Dire\u00e7\u00e3o"));
              panel6.setLayout(new GridBagLayout());
              ((GridBagLayout) panel6.getLayout()).columnWidths = new int[] {0, 0, 0, 0, 0};
              ((GridBagLayout) panel6.getLayout()).rowHeights = new int[] {0, 0, 0, 0};
              ((GridBagLayout) panel6.getLayout()).columnWeights =
                  new double[] {1.0, 0.0, 0.0, 1.0, 1.0E-4};
              ((GridBagLayout) panel6.getLayout()).rowWeights =
                  new double[] {0.0, 0.0, 0.0, 1.0E-4};

              // ---- radioButtonX ----
              radioButtonX.setText("horizontal");
              radioButtonX.setSelected(true);
              panel6.add(
                  radioButtonX,
                  new GridBagConstraints(
                      1,
                      1,
                      1,
                      1,
                      0.0,
                      0.0,
                      GridBagConstraints.CENTER,
                      GridBagConstraints.BOTH,
                      new Insets(0, 0, 5, 5),
                      0,
                      0));

              // ---- radioButtonY ----
              radioButtonY.setText("vertical");
              panel6.add(
                  radioButtonY,
                  new GridBagConstraints(
                      2,
                      1,
                      1,
                      1,
                      0.0,
                      0.0,
                      GridBagConstraints.CENTER,
                      GridBagConstraints.BOTH,
                      new Insets(0, 0, 5, 5),
                      0,
                      0));
            }
            panel2.add(
                panel6,
                new GridBagConstraints(
                    1,
                    3,
                    1,
                    1,
                    0.0,
                    0.0,
                    GridBagConstraints.CENTER,
                    GridBagConstraints.BOTH,
                    new Insets(0, 0, 5, 0),
                    0,
                    0));

            // ======== panel7 ========
            {
              panel7.setBorder(
                  new CompoundBorder(
                      new TitledBorder("Par\u00e2metros adicionais"), new EmptyBorder(5, 5, 5, 5)));
              panel7.setLayout(new GridBagLayout());
              ((GridBagLayout) panel7.getLayout()).columnWidths = new int[] {0, 0, 45, 0, 50, 0};
              ((GridBagLayout) panel7.getLayout()).rowHeights = new int[] {0, 0, 0, 0, 0};
              ((GridBagLayout) panel7.getLayout()).columnWeights =
                  new double[] {1.0, 0.0, 0.0, 1.0, 0.0, 1.0E-4};
              ((GridBagLayout) panel7.getLayout()).rowWeights =
                  new double[] {0.0, 0.0, 0.0, 0.0, 1.0E-4};

              // ---- label8 ----
              label8.setText("textura das superf\u00edcies");
              label8.setHorizontalAlignment(SwingConstants.RIGHT);
              panel7.add(
                  label8,
                  new GridBagConstraints(
                      1,
                      1,
                      1,
                      1,
                      0.0,
                      0.0,
                      GridBagConstraints.CENTER,
                      GridBagConstraints.BOTH,
                      new Insets(0, 0, 5, 5),
                      0,
                      0));

              // ---- ranhuraRug ----
              ranhuraRug.setModel(new SpinnerNumberModel(50.0, 0.0, 50.0, 1.0));
              panel7.add(
                  ranhuraRug,
                  new GridBagConstraints(
                      2,
                      1,
                      1,
                      1,
                      0.0,
                      0.0,
                      GridBagConstraints.CENTER,
                      GridBagConstraints.BOTH,
                      new Insets(0, 0, 5, 5),
                      0,
                      0));

              // ---- label9 ----
              label9.setText("(um)");
              label9.setHorizontalAlignment(SwingConstants.RIGHT);
              panel7.add(
                  label9,
                  new GridBagConstraints(
                      3,
                      1,
                      1,
                      1,
                      0.0,
                      0.0,
                      GridBagConstraints.CENTER,
                      GridBagConstraints.BOTH,
                      new Insets(0, 0, 5, 5),
                      0,
                      0));
            }
            panel2.add(
                panel7,
                new GridBagConstraints(
                    1,
                    4,
                    1,
                    1,
                    0.0,
                    0.0,
                    GridBagConstraints.CENTER,
                    GridBagConstraints.BOTH,
                    new Insets(0, 0, 0, 0),
                    0,
                    0));
          }
          contentPanel.add(
              panel2,
              new GridBagConstraints(
                  1,
                  1,
                  1,
                  1,
                  0.0,
                  0.0,
                  GridBagConstraints.CENTER,
                  GridBagConstraints.BOTH,
                  new Insets(0, 0, 5, 0),
                  0,
                  0));
        }
        dialogPane.add(contentPanel, BorderLayout.CENTER);

        // ======== buttonBar ========
        {
          buttonBar.setBorder(new EmptyBorder(12, 0, 0, 0));
          buttonBar.setLayout(new GridBagLayout());
          ((GridBagLayout) buttonBar.getLayout()).columnWidths = new int[] {0, 85, 80};
          ((GridBagLayout) buttonBar.getLayout()).columnWeights = new double[] {1.0, 0.0, 0.0};

          // ---- okButton ----
          okButton.setText("OK");
          buttonBar.add(
              okButton,
              new GridBagConstraints(
                  1,
                  0,
                  1,
                  1,
                  0.0,
                  0.0,
                  GridBagConstraints.CENTER,
                  GridBagConstraints.BOTH,
                  new Insets(0, 0, 0, 5),
                  0,
                  0));

          // ---- cancelButton ----
          cancelButton.setText("Cancel");
          buttonBar.add(
              cancelButton,
              new GridBagConstraints(
                  2,
                  0,
                  1,
                  1,
                  0.0,
                  0.0,
                  GridBagConstraints.CENTER,
                  GridBagConstraints.BOTH,
                  new Insets(0, 0, 0, 0),
                  0,
                  0));
        }
        dialogPane.add(buttonBar, BorderLayout.SOUTH);
      }
      scrollPane2.setViewportView(dialogPane);
    }
    contentPane.add(scrollPane2, BorderLayout.CENTER);
    pack();
    setLocationRelativeTo(getOwner());

    // ---- buttonGroup1 ----
    ButtonGroup buttonGroup1 = new ButtonGroup();
    buttonGroup1.add(radioButtonX);
    buttonGroup1.add(radioButtonY);
    // JFormDesigner - End of component initialization  //GEN-END:initComponents
  }
Example #13
0
  private void jbInit() throws Exception {
    confirm = new JButton(ls.getString(16));
    cancel = new JButton(ls.getString(18));
    pauseRB = new JRadioButton(ls.getString(22));
    leftRB = new JRadioButton(ls.getString(13));
    rightRB = new JRadioButton(ls.getString(14));

    Container container = this.getContentPane();
    titledBorder1 = new TitledBorder(ls.getString(11));
    container.setLayout(null);
    leftL.setEditable(false);
    leftL.setBounds(new Rectangle(116, 24, 84, 20));
    leftL.setText(
        gameconfigure.getLeftKeyCode() + " " + KeyEvent.getKeyText(gameconfigure.getLeftKeyCode()));
    leftRB.setBounds(new Rectangle(5, 23, 97, 20));
    leftRB.addActionListener(new KeyOptionDialog_leftRB_actionAdapter(this));

    rightRB.setBounds(new Rectangle(5, 48, 97, 20));
    rightRB.addActionListener(new KeyOptionDialog_rightRB_actionAdapter(this));

    rightL.setText(
        gameconfigure.getRightKeyCode()
            + " "
            + KeyEvent.getKeyText(gameconfigure.getRightKeyCode()));
    rightL.setEditable(false);
    rightL.setBounds(new Rectangle(116, 49, 84, 20));

    confirm.setBounds(new Rectangle(110, 114, 85, 20));

    confirm.addActionListener(new KeyOptionDialog_confirm_actionAdapter(this));
    cancel.setBounds(new Rectangle(18, 114, 85, 20));
    cancel.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            cancel_actionPerformed(e);
          }
        });

    pauseRB.setBounds(new Rectangle(6, 74, 97, 20));
    pauseRB.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            pauseRB_actionPerformed(e);
          }
        });
    pauseL.setText(
        gameconfigure.getPausekeyCode()
            + " "
            + KeyEvent.getKeyText(gameconfigure.getPausekeyCode()));
    pauseL.setBounds(new Rectangle(117, 75, 84, 20));
    pauseL.setEditable(false);
    container.add(leftL, null);
    container.add(rightL, null);
    container.add(rightRB, null);
    container.add(leftRB, null);
    container.add(pauseL, null);
    container.add(confirm, null);
    container.add(cancel, null);
    container.add(pauseRB, null);
    keylistener =
        new KeyAdapter() {
          public void keyPressed(KeyEvent e) {

            switch (KeyOptionDialog.this.selecti) {
              case 1:
                leftL.setText(e.getKeyCode() + " " + e.getKeyText(e.getKeyCode()));
                gameconfigure.setLeftKeyCode(e.getKeyCode());
                break;
              case 2:
                rightL.setText(e.getKeyCode() + " " + e.getKeyText(e.getKeyCode()));
                gameconfigure.setRightKeyCode(e.getKeyCode());
                break;

              case 6:
                pauseL.setText(e.getKeyCode() + " " + e.getKeyText(e.getKeyCode()));
                gameconfigure.setPausekeyCode(e.getKeyCode());
                break;
            }
          }
        };

    Component[] com = container.getComponents();
    for (int i = 0; i < com.length; i++) {
      com[i].addKeyListener(keylistener);
    }
    buttonGroup.add(leftRB);
    buttonGroup.add(rightRB);
    buttonGroup.add(pauseRB);
  }
  /** Creates new form. */
  public PopupMenuTest() {
    initComponents();

    ActionListener a =
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            System.out.println(evt);
          }
        };

    JPopupMenu pm = new JPopupMenu();
    JMenu m;
    JMenuItem mi;
    JCheckBoxMenuItem cbmi;
    JRadioButtonMenuItem crmi;
    mi = new JMenuItem("Menu Item 1");
    mi.addActionListener(a);
    pm.add(mi);
    mi = new JMenuItem("Menu Item 2");
    mi.addActionListener(a);
    pm.add(mi);
    mi = new JMenuItem("Menu Item 3");
    mi.addActionListener(a);
    pm.add(mi);

    m = new JMenu("Menu 1");
    mi = new JMenuItem("Menu Item 1.1");
    mi.addActionListener(a);
    m.add(mi);
    mi = new JMenuItem("Menu Item 1.2");
    mi.addActionListener(a);
    m.add(mi);
    pm.add(m);

    pm.addSeparator();
    cbmi = new JCheckBoxMenuItem("Checkbox Menu Item");
    pm.add(cbmi);

    pm.addSeparator();
    ButtonGroup group = new ButtonGroup();
    crmi = new JRadioButtonMenuItem("Radio Menu Item 1");
    crmi.setSelected(true);
    group.add(crmi);
    pm.add(crmi);

    crmi = new JRadioButtonMenuItem("Radio Menu Item 2");
    group.add(crmi);
    pm.add(crmi);
    popupMenu = pm;

    /*
    //setComponentPopupMenu(pm);
    //jLabel1.setComponentPopupMenu(pm);
    JButton button = new JButton("Hi");
    // button.setComponentPopupMenu(pm);
    button.setInheritsPopupMenu(true);
    add(button, BorderLayout.SOUTH);
     */
    MouseAdapter popper1 =
        new MouseAdapter() {
          public void mousePressed(MouseEvent evt) {
            if (evt.isPopupTrigger()) {
              showPopupMenu(evt);
            }
          }

          public void mouseReleased(MouseEvent evt) {
            if (evt.isPopupTrigger()) {
              showPopupMenu(evt);
            }
          }

          protected void showPopupMenu(MouseEvent evt) {
            popupMenu.show((Component) evt.getSource(), evt.getX(), evt.getY());
          }
        };

    popupLabel1.addMouseListener(popper1);
    popupField.addMouseListener(popper1);

    MouseAdapter popper2 =
        new MouseAdapter() {
          public void mousePressed(MouseEvent evt) {
            if (evt.isPopupTrigger()) {
              showPopupMenu(evt);
            }
          }

          public void mouseReleased(MouseEvent evt) {
            if (evt.isPopupTrigger()) {
              showPopupMenu(evt);
            }
          }

          protected void showPopupMenu(MouseEvent evt) {
            Dimension ps = popupMenu.getPreferredSize();
            popupMenu.show(popupLabel2, evt.getX() - ps.width / 2, evt.getY() - ps.height / 2);
          }
        };

    popupLabel2.addMouseListener(popper2);
  }
Example #15
0
  public void launchChess() {

    mainWindow = new JFrame("网络黑白棋	作者:张炀");
    jpWest = new JPanel();
    jpEast = new JPanel();
    jpNorth = new JPanel();
    jpSouth = new JPanel();
    jpCenter = new JPanel();

    turnLabel = new JLabel();
    blackNumberLabel = new JLabel("黑棋:\n" + black + "		");
    whiteNumberLabel = new JLabel("白棋:\n" + white + "		");
    timeLabel = new JLabel("时间:  " + time + "		s");
    noticeLabel = new JLabel();

    noticeLabel = new JLabel("请选择:");
    numberPane = new JPanel();
    readyPane = new JPanel();
    jt1 = new JTextField(18); // 发送信息框
    jt2 = new JTextArea(3, 30); // 显示信息框
    js = new JScrollPane(jt2);
    jt2.setLineWrap(true);
    jt2.setEditable(false);
    //		jt1.setLineWrap(true);

    send = new JButton("发送");
    cancel = new JButton("取消");
    regret = new JButton("悔棋");
    submit = new JButton("退出");
    begin = new JButton("开始");
    save = new JButton("存盘");

    save.setEnabled(true);
    begin.setEnabled(true);

    fighter = new JRadioButton("下棋");
    audience = new JRadioButton("观看");
    group = new ButtonGroup();
    group.add(audience);
    group.add(fighter);
    group.add(AIPlayer);

    submit.addActionListener(this);
    begin.addActionListener(this);
    save.addActionListener(this);
    send.addActionListener(this);
    cancel.addActionListener(this);
    regret.addActionListener(this);
    fighter.addActionListener(this);
    audience.addActionListener(this);

    jpNorth.setLayout(new BorderLayout());
    jpNorth.add(turnLabel, BorderLayout.NORTH);
    jpNorth.add(jpCenter, BorderLayout.CENTER);
    jpSouth.add(js);
    jpSouth.add(jt1);
    jpSouth.add(send);
    jpSouth.add(cancel);
    jpEast.setLayout(new GridLayout(3, 1));
    submit.setBackground(new Color(130, 251, 241));
    panel x = new panel();
    jpEast.add(x);
    jpEast.add(numberPane);
    jpEast.add(readyPane);

    numberPane.add(blackNumberLabel);
    numberPane.add(whiteNumberLabel);
    numberPane.add(timeLabel);
    numberPane.add(submit);
    numberPane.add(begin);
    numberPane.add(save);
    numberPane.add(regret);

    readyPane.add(noticeLabel);
    readyPane.add(fighter);
    readyPane.add(audience);
    //		readyPane.add(save);
    //		readyPane.add(regret);

    jpCenter.setSize(400, 400);
    jmb = new JMenuBar();
    document = new JMenu("游戏		");
    edit = new JMenu("设置		");
    insert = new JMenu("棋盘			");
    help = new JMenu("帮助		");
    jmb.add(document);
    jmb.add(edit);
    jmb.add(insert);
    jmb.add(help);
    // mainWindow.setJMenuBar(jmb);

    mainWindow.setBounds(80, 80, 600, 600);
    mainWindow.setResizable(false);

    jsLeft = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, jpNorth, jpSouth);
    jsBase = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, jsLeft, jpEast);

    mainWindow.add(jsBase);
    mainWindow.setVisible(true);
    mainWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    jsBase.setDividerLocation(0.7);
    jsLeft.setDividerLocation(0.78);

    jpCenter.setLayout(new GridLayout(8, 8, 0, 0));
    ImageIcon key = new ImageIcon("chess1.jpg");
    for (int i = 0; i < cell.length; i++)
      for (int j = 0; j < cell.length; j++) {
        cell[i][j] = new ChessBoard(i, j);
        cell[i][j].addMouseListener(this);
        jpCenter.add(cell[i][j]);
      }

    cell[3][3].state = cell[4][4].state = '黑';
    cell[4][3].state = cell[3][4].state = '白';
    cell[3][3].taken = cell[4][4].taken = true;
    cell[4][3].taken = cell[3][4].taken = true;

    RememberState();

    new Thread(new TurnLabel(this)).start();

    file = new File("D:/" + myRole);
    try {
      fout = new FileOutputStream(file);
      out = new ObjectOutputStream(fout);
    } catch (IOException e1) {
      e1.printStackTrace();
    }

    Connect();

    try {
      out99 = new ObjectOutputStream(socket99.getOutputStream());
      in99 = new ObjectInputStream(socket99.getInputStream());

      out66 = new ObjectOutputStream(socket66.getOutputStream());
      in66 = new ObjectInputStream(socket66.getInputStream());

      out88 = new DataOutputStream(socket88.getOutputStream());
    } catch (IOException e) {
      e.printStackTrace();
    }

    new Thread(new Client9999(this)).start();
    new Thread(new Client6666(this)).start();
  }
Example #16
0
  private void setUpMenuBar() {
    // Set Up Menu Bar
    JMenuBar menu = new JMenuBar();

    // Game Menu
    JMenu gameMenu = new JMenu("Game");
    menu.add(gameMenu);

    JMenuItem newRandom = new JMenuItem("New Game");
    gameMenu.add(newRandom);
    newRandom.setAccelerator(
        KeyStroke.getKeyStroke(
            KeyEvent.VK_N, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    newRandom.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            newGame();
          }
        });

    gameMenu.addSeparator();

    ButtonGroup bg = new ButtonGroup();
    JRadioButtonMenuItem size4 = new JRadioButtonMenuItem("4x4 board");
    size4.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            myBoardSize = 4;
          }
        });
    size4.setSelected(true);
    bg.add(size4);
    gameMenu.add(size4);
    JRadioButtonMenuItem size5 = new JRadioButtonMenuItem("5x5 board");
    size5.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            myBoardSize = 5;
          }
        });
    bg.add(size5);
    gameMenu.add(size5);
    gameMenu.addSeparator();

    JMenuItem gameTime = new JMenuItem("Time (secs)");
    gameMenu.add(gameTime);
    gameTime.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String secs = JOptionPane.showInputDialog(BoggleGUI.this, "time in seconds");
            try {
              int len = Integer.parseInt(secs);
              myGameLength = len;
              myProgress.setMaximum(myGameLength);
            } catch (NumberFormatException e1) {
              if (secs != null) {
                showError(secs + " not valid integer value");
              }
            }
          }
        });
    gameMenu.addSeparator();
    JMenuItem quitGame = new JMenuItem("Quit");
    gameMenu.add(quitGame);
    quitGame.setMnemonic('Q');
    quitGame.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            System.exit(0);
          }
        });

    // Help menu
    JMenu helpMenu = new JMenu("Help");
    menu.add(helpMenu);
    helpMenu.setMnemonic(KeyEvent.VK_H);

    JMenuItem aboutGame = new JMenuItem("About...");
    helpMenu.add(aboutGame);
    aboutGame.setMnemonic(KeyEvent.VK_A);
    aboutGame.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            JOptionPane.showMessageDialog(
                BoggleGUI.this,
                "Compsci Boggle, brought to you\n"
                    + "by educators and students\n"
                    + "including, of course, you.",
                "About Game",
                JOptionPane.PLAIN_MESSAGE);
          }
        });
    setJMenuBar(menu);
  }
Example #17
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 ()
Example #18
0
  private void jbInit() throws Exception {

    saveButton.setText("Save");
    saveButton.addActionListener(new PrintfTemplateEditor_saveButton_actionAdapter(this));
    cancelButton.setText("Cancel");
    cancelButton.addActionListener(new PrintfTemplateEditor_cancelButton_actionAdapter(this));
    this.setTitle(this.getTitle() + " Template Editor");
    printfPanel.setLayout(gridBagLayout1);
    formatLabel.setFont(new java.awt.Font("DialogInput", 0, 12));
    formatLabel.setText("Format String:");
    buttonPanel.setLayout(flowLayout1);
    printfPanel.setBorder(BorderFactory.createEtchedBorder());
    printfPanel.setMinimumSize(new Dimension(100, 160));
    printfPanel.setPreferredSize(new Dimension(380, 160));
    parameterPanel.setLayout(gridBagLayout2);
    parameterLabel.setText("Parameters:");
    parameterLabel.setFont(new java.awt.Font("DialogInput", 0, 12));
    parameterTextArea.setMinimumSize(new Dimension(100, 25));
    parameterTextArea.setPreferredSize(new Dimension(200, 25));
    parameterTextArea.setEditable(true);
    parameterTextArea.setText("");
    insertButton.setMaximumSize(new Dimension(136, 20));
    insertButton.setMinimumSize(new Dimension(136, 20));
    insertButton.setPreferredSize(new Dimension(136, 20));
    insertButton.setToolTipText(
        "insert the format in the format string and add parameter to list.");
    insertButton.setText("Insert Parameter");
    insertButton.addActionListener(new PrintfTemplateEditor_insertButton_actionAdapter(this));
    formatTextArea.setMinimumSize(new Dimension(100, 25));
    formatTextArea.setPreferredSize(new Dimension(200, 15));
    formatTextArea.setText("");
    parameterPanel.setBorder(null);
    parameterPanel.setMinimumSize(new Dimension(60, 40));
    parameterPanel.setPreferredSize(new Dimension(300, 40));
    insertMatchButton.addActionListener(
        new PrintfTemplateEditor_insertMatchButton_actionAdapter(this));
    insertMatchButton.setText("Insert Match");
    insertMatchButton.setToolTipText(
        "insert the match in the format string and add parameter to list.");
    insertMatchButton.setPreferredSize(new Dimension(136, 20));
    insertMatchButton.setMinimumSize(new Dimension(136, 20));
    insertMatchButton.setMaximumSize(new Dimension(136, 20));
    matchPanel.setPreferredSize(new Dimension(300, 40));
    matchPanel.setBorder(null);
    matchPanel.setMinimumSize(new Dimension(60, 60));
    matchPanel.setLayout(gridBagLayout3);
    InsertPanel.setLayout(gridLayout1);
    gridLayout1.setColumns(1);
    gridLayout1.setRows(2);
    gridLayout1.setVgap(0);
    InsertPanel.setBorder(BorderFactory.createEtchedBorder());
    InsertPanel.setMinimumSize(new Dimension(100, 100));
    InsertPanel.setPreferredSize(new Dimension(380, 120));
    editorPane.setText("");
    editorPane.addKeyListener(new PrintfEditor_editorPane_keyAdapter(this));
    printfTabPane.addChangeListener(new PrintfEditor_printfTabPane_changeAdapter(this));
    parameterPanel.add(
        insertButton,
        new GridBagConstraints(
            1,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(8, 6, 13, 8),
            0,
            10));
    parameterPanel.add(
        paramComboBox,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(8, 8, 13, 0),
            258,
            11));
    paramComboBox.setRenderer(new MyCellRenderer());
    InsertPanel.add(matchPanel, null);
    InsertPanel.add(parameterPanel, null);
    buttonPanel.add(cancelButton, null);
    buttonPanel.add(saveButton, null);
    this.getContentPane().add(printfTabPane, BorderLayout.NORTH);
    this.getContentPane().add(InsertPanel, BorderLayout.CENTER);
    matchPanel.add(
        insertMatchButton,
        new GridBagConstraints(
            1,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(8, 6, 13, 8),
            0,
            10));
    matchPanel.add(
        matchComboBox,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(8, 8, 13, 0),
            258,
            11));
    printfPanel.add(
        parameterLabel,
        new GridBagConstraints(
            0,
            2,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(7, 5, 0, 5),
            309,
            0));
    printfPanel.add(
        formatLabel,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(4, 5, 0, 5),
            288,
            0));
    printfPanel.add(
        formatTextArea,
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(6, 5, 0, 5),
            300,
            34));
    printfPanel.add(
        parameterTextArea,
        new GridBagConstraints(
            0,
            3,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(6, 5, 6, 5),
            300,
            34));
    printfTabPane.addTab("Editor View", null, editorPanel, "View in Editor");
    printfTabPane.addTab("Printf View", null, printfPanel, "Vies as Printf");
    editorPane.setCharacterAttributes(PLAIN_ATTR, true);
    editorPane.addStyle("PLAIN", editorPane.getLogicalStyle());
    editorPanel.getViewport().add(editorPane, null);
    this.getContentPane().add(buttonPanel, BorderLayout.SOUTH);
    buttonGroup.add(cancelButton);
  }
  /** Constructs a <code>StarDetectionSettingDialog</code>. */
  public StarDetectionSettingDialog() {
    components = new Object[2];

    ButtonGroup bg_mode = new ButtonGroup();
    radio_amount = new JRadioButton("", true);
    radio_peak = new JRadioButton("");
    radio_aperture = new JRadioButton("");
    bg_mode.add(radio_amount);
    bg_mode.add(radio_peak);
    bg_mode.add(radio_aperture);

    radio_amount.addActionListener(new ModeListener());
    radio_peak.addActionListener(new ModeListener());
    radio_aperture.addActionListener(new ModeListener());

    JPanel panel_amount = new JPanel();
    panel_amount.add(radio_amount);
    panel_amount.add(new JLabel("Regard amount of pixel values over threshold as brightness."));

    JPanel panel_amount2 = new JPanel();
    panel_amount2.setLayout(new BorderLayout());
    panel_amount2.add(panel_amount, BorderLayout.WEST);

    JPanel panel_peak = new JPanel();
    panel_peak.add(radio_peak);
    panel_peak.add(new JLabel("Regard peak value as brightness."));

    JPanel panel_peak2 = new JPanel();
    panel_peak2.setLayout(new BorderLayout());
    panel_peak2.add(panel_peak, BorderLayout.WEST);

    JPanel panel_aperture = new JPanel();
    panel_aperture.add(radio_aperture);
    panel_aperture.add(new JLabel("Aperture photometry."));

    text_inner_aperture = new JTextField("2");
    text_inner_aperture.setColumns(5);
    text_outer_aperture = new JTextField("4");
    text_outer_aperture.setColumns(5);

    JPanel panel_inner_aperture = new JPanel();
    panel_inner_aperture.add(new JLabel("    Inner aperture: "));
    panel_inner_aperture.add(text_inner_aperture);
    panel_inner_aperture.add(new JLabel("pixels."));

    JPanel panel_outer_aperture = new JPanel();
    panel_outer_aperture.add(new JLabel("    Outer aperture: "));
    panel_outer_aperture.add(text_outer_aperture);
    panel_outer_aperture.add(new JLabel("pixels."));

    JPanel panel_aperture2 = new JPanel();
    panel_aperture2.setLayout(new BoxLayout(panel_aperture2, BoxLayout.Y_AXIS));
    panel_aperture2.add(panel_inner_aperture);
    panel_aperture2.add(panel_outer_aperture);

    JPanel panel_aperture3 = new JPanel();
    panel_aperture3.setLayout(new BorderLayout());
    panel_aperture3.add(panel_aperture, BorderLayout.WEST);

    JPanel panel_aperture4 = new JPanel();
    panel_aperture4.setLayout(new BorderLayout());
    panel_aperture4.add(panel_aperture2, BorderLayout.WEST);

    JPanel panel_mode = new JPanel();
    panel_mode.setLayout(new BoxLayout(panel_mode, BoxLayout.Y_AXIS));
    panel_mode.add(panel_amount2);
    panel_mode.add(panel_peak2);
    panel_mode.add(panel_aperture3);
    panel_mode.add(panel_aperture4);
    panel_mode.setBorder(new TitledBorder("Mode"));
    components[0] = panel_mode;

    checkbox_correct_blooming = new JCheckBox("Correct positions of blooming stars.");
    components[1] = checkbox_correct_blooming;

    setDefaultValues();

    updateComponents();
  }
  /** Constructor allows for set up of the panel */
  public MapCreation() {
    // panel set up
    this.setLayout(new GridLayout(0, 1));

    // set up labels
    smallIcon = new ImageIcon("images/MapCreation/smallWorld.png");
    smallLabel = new JLabel(smallIcon);

    mediumIcon = new ImageIcon("images/MapCreation/mediumWorld.png");
    mediumLabel = new JLabel(mediumIcon);

    largeIcon = new ImageIcon("images/MapCreation/largeWorld.png");
    largeLabel = new JLabel(largeIcon);

    continentIcon = new ImageIcon("images/MapCreation/Continent.png");
    continentLabel = new JLabel(continentIcon);

    variedIcon = new ImageIcon("images/MapCreation/ContinentAndIsland.png");
    variedLabel = new JLabel(variedIcon);

    islandIcon = new ImageIcon("images/MapCreation/Islands.png");
    islandLabel = new JLabel(islandIcon);

    mainLabel = new JLabel("New Map Creation");
    mainLabel.setForeground(new Color(51, 0, 51));
    mainLabel.setFont(new Font("Dialog", 1, 32));
    mainLabel.setHorizontalAlignment(SwingConstants.CENTER);

    // set up the radioButtons
    smallButton = new JRadioButton("Small 50x50");
    mediumButton = new JRadioButton("Medium 75x75");
    largeButton = new JRadioButton("Large 100x100");
    largeButton.setSelected(true);

    sizeGroup = new ButtonGroup();
    sizeGroup.add(smallButton);
    sizeGroup.add(mediumButton);
    sizeGroup.add(largeButton);

    continentButton = new JRadioButton("Continents");
    variedButton = new JRadioButton("Varied");
    variedButton.setSelected(true);
    islandButton = new JRadioButton("Islands");

    styleGroup = new ButtonGroup();
    styleGroup.add(continentButton);
    styleGroup.add(variedButton);
    styleGroup.add(islandButton);

    // set up the panels
    sizePanel = new JPanel(new GridLayout(2, 3));
    sizePanel.setBorder(BorderFactory.createTitledBorder("Please select map size"));
    sizePanel.add(smallLabel);
    sizePanel.add(mediumLabel);
    sizePanel.add(largeLabel);
    sizePanel.add(smallButton);
    sizePanel.add(mediumButton);
    sizePanel.add(largeButton);

    stylePanel = new JPanel(new GridLayout(2, 3));
    stylePanel.setBorder(BorderFactory.createTitledBorder("Please select land style"));
    stylePanel.add(continentLabel);
    stylePanel.add(variedLabel);
    stylePanel.add(islandLabel);
    stylePanel.add(continentButton);
    stylePanel.add(variedButton);
    stylePanel.add(islandButton);

    // add to panel
    this.add(mainLabel);
    this.add(sizePanel);
    this.add(stylePanel);
    // this.add(buttonPanel);
  } // end constructor
  public ToolBarEditDialog(
      Component comp, DefaultComboBoxModel iconListModel, ToolBarOptionPane.Button current) {
    super(
        GUIUtilities.getParentDialog(comp), jEdit.getProperty("options.toolbar.edit.title"), true);

    JPanel content = new JPanel(new BorderLayout());
    content.setBorder(new EmptyBorder(12, 12, 12, 12));
    setContentPane(content);

    ActionHandler actionHandler = new ActionHandler();
    ButtonGroup grp = new ButtonGroup();

    JPanel typePanel = new JPanel(new GridLayout(3, 1, 6, 6));
    typePanel.setBorder(new EmptyBorder(0, 0, 6, 0));
    typePanel.add(new JLabel(jEdit.getProperty("options.toolbar.edit.caption")));

    separator = new JRadioButton(jEdit.getProperty("options.toolbar" + ".edit.separator"));
    separator.addActionListener(actionHandler);
    grp.add(separator);
    typePanel.add(separator);

    action = new JRadioButton(jEdit.getProperty("options.toolbar" + ".edit.action"));
    action.addActionListener(actionHandler);
    grp.add(action);
    typePanel.add(action);

    content.add(BorderLayout.NORTH, typePanel);

    JPanel actionPanel = new JPanel(new BorderLayout(6, 6));

    ActionSet[] actionsList = jEdit.getActionSets();
    Vector vec = new Vector(actionsList.length);
    for (int i = 0; i < actionsList.length; i++) {
      ActionSet actionSet = actionsList[i];
      if (actionSet.getActionCount() != 0) vec.addElement(actionSet);
    }
    combo = new JComboBox(vec);
    combo.addActionListener(actionHandler);
    actionPanel.add(BorderLayout.NORTH, combo);

    list = new JList();
    list.setVisibleRowCount(8);
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    actionPanel.add(BorderLayout.CENTER, new JScrollPane(list));

    JPanel iconPanel = new JPanel(new BorderLayout(0, 3));
    JPanel labelPanel = new JPanel(new GridLayout(2, 1));
    labelPanel.setBorder(new EmptyBorder(0, 0, 0, 12));
    JPanel compPanel = new JPanel(new GridLayout(2, 1));
    grp = new ButtonGroup();
    labelPanel.add(builtin = new JRadioButton(jEdit.getProperty("options.toolbar.edit.builtin")));
    builtin.addActionListener(actionHandler);
    grp.add(builtin);
    labelPanel.add(file = new JRadioButton(jEdit.getProperty("options.toolbar.edit.file")));
    grp.add(file);
    file.addActionListener(actionHandler);
    iconPanel.add(BorderLayout.WEST, labelPanel);
    builtinCombo = new JComboBox(iconListModel);
    builtinCombo.setRenderer(new ToolBarOptionPane.IconCellRenderer());
    compPanel.add(builtinCombo);

    fileButton = new JButton(jEdit.getProperty("options.toolbar.edit.no-icon"));
    fileButton.setMargin(new Insets(1, 1, 1, 1));
    fileButton.setIcon(GUIUtilities.loadIcon("Blank24.gif"));
    fileButton.setHorizontalAlignment(SwingConstants.LEFT);
    fileButton.addActionListener(actionHandler);
    compPanel.add(fileButton);
    iconPanel.add(BorderLayout.CENTER, compPanel);
    actionPanel.add(BorderLayout.SOUTH, iconPanel);

    content.add(BorderLayout.CENTER, actionPanel);

    JPanel southPanel = new JPanel();
    southPanel.setLayout(new BoxLayout(southPanel, BoxLayout.X_AXIS));
    southPanel.setBorder(new EmptyBorder(12, 0, 0, 0));
    southPanel.add(Box.createGlue());
    ok = new JButton(jEdit.getProperty("common.ok"));
    ok.addActionListener(actionHandler);
    getRootPane().setDefaultButton(ok);
    southPanel.add(ok);
    southPanel.add(Box.createHorizontalStrut(6));
    cancel = new JButton(jEdit.getProperty("common.cancel"));
    cancel.addActionListener(actionHandler);
    southPanel.add(cancel);
    southPanel.add(Box.createGlue());

    content.add(BorderLayout.SOUTH, southPanel);

    if (current == null) {
      action.setSelected(true);
      builtin.setSelected(true);
      updateList();
    } else {
      if (current.actionName.equals("-")) {
        separator.setSelected(true);
        builtin.setSelected(true);
      } else {
        action.setSelected(true);
        ActionSet set = jEdit.getActionSetForAction(current.actionName);
        combo.setSelectedItem(set);
        updateList();
        list.setSelectedValue(current, true);

        if (MiscUtilities.isURL(current.iconName)) {
          file.setSelected(true);
          fileIcon = current.iconName;
          try {
            fileButton.setIcon(new ImageIcon(new URL(fileIcon)));
          } catch (MalformedURLException mf) {
            Log.log(Log.ERROR, this, mf);
          }
          fileButton.setText(MiscUtilities.getFileName(fileIcon));
        } else {
          String iconName = MiscUtilities.getFileName(current.iconName);
          builtin.setSelected(true);
          ListModel model = builtinCombo.getModel();
          for (int i = 0; i < model.getSize(); i++) {
            ToolBarOptionPane.IconListEntry entry =
                (ToolBarOptionPane.IconListEntry) model.getElementAt(i);
            if (entry.name.equals(iconName)) {
              builtinCombo.setSelectedIndex(i);
              break;
            }
          }
        }
      }
    }

    updateEnabled();

    pack();
    setLocationRelativeTo(GUIUtilities.getParentDialog(comp));
    show();
  }