// -----------------------------------------------------------------
  //  Sets up a panel with a label and a set of radio buttons
  //  that control its text.
  // -----------------------------------------------------------------
  public QuoteOptionsPanel() {
    comedyQuote = "Take my wife, please.";
    philosophyQuote = "I think, therefore I am.";
    carpentryQuote = "Measure twice. Cut once.";

    quote = new JLabel(comedyQuote);
    quote.setFont(new Font("Helvetica", Font.BOLD, 24));
    comedy = new JRadioButton("Comedy", true);
    comedy.setBackground(Color.green);
    philosophy = new JRadioButton("Philosophy");
    philosophy.setBackground(Color.green);
    carpentry = new JRadioButton("Carpentry");
    carpentry.setBackground(Color.green);

    ButtonGroup group = new ButtonGroup();
    group.add(comedy);
    group.add(philosophy);
    group.add(carpentry);

    QuoteListener listener = new QuoteListener();
    comedy.addActionListener(listener);
    philosophy.addActionListener(listener);
    carpentry.addActionListener(listener);

    add(quote);
    add(comedy);
    add(philosophy);
    add(carpentry);

    setBackground(Color.green);
    setPreferredSize(new Dimension(300, 100));
  }
示例#2
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;
  }
 /** 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();
 }
示例#4
0
  private JPanel createFoodTypeButtons(String[] array) {

    JPanel radioPanel = new JPanel();
    typeOfFood = new ArrayList<JRadioButton>();
    JRadioButton type0Radio = new JRadioButton(this.e.nonPerishableFood);
    JRadioButton type1Radio = new JRadioButton(this.e.perishableFood);

    typeOfFood.add(type0Radio);
    typeOfFood.add(type1Radio);

    type0Radio.setActionCommand(this.e.nonPerishableFood);
    type1Radio.setActionCommand(this.e.perishableFood);

    // Register a listener for the radio buttons.
    RadioListener myListener =
        new RadioListener(type0Radio, type1Radio, newCreatureButton, newJewelButton);
    type0Radio.addActionListener(myListener);
    type1Radio.addActionListener(myListener);

    // Group the radio buttons.
    group = new ButtonGroup();
    group.add(type0Radio);
    group.add(type1Radio);

    model = new DefaultButtonModel();
    group.setSelected(model, false);

    radioPanel.setLayout(new GridLayout(0, 1));
    radioPanel.add(type0Radio);
    radioPanel.add(type1Radio);

    return radioPanel;
  }
  public MapDesigner(int row, int col) {
    this.row = row; // 設置行數
    this.col = col; // 設置列數	
    this.setTitle("3D迷宮重力球地圖設計器"); // 設置標題
    icrystal = new ImageIcon("img/Diamond.png").getImage(); // 圓孔的標誌圖
    mdp = new MapDesignPanel(row, col, this); // 創建地圖設計器面板
    jsp = new JScrollPane(mdp); // 創建JScrollPane面板

    this.add(jsp); // 添加JScrollPane面板

    jp.add(jbGenerate); // 添加生成地圖按鈕
    jp.add(jbGenerateD); // 添加生成圓孔按鈕
    jp.add(jrBlack);
    bg.add(jrBlack); // 向jp中添加黑色單選按鈕
    jp.add(jrWhite);
    bg.add(jrWhite); // 向jp中添加白色單選按鈕
    jp.add(jrCrystal);
    bg.add(jrCrystal); // 向jp中添加圓孔單選按鈕
    this.add(jp, BorderLayout.NORTH); // jp添加進窗體中
    jbGenerate.addActionListener(this); // 生成地圖按鈕設置監聽
    jbGenerateD.addActionListener(this); // 生成圓孔按鈕設置監聽
    this.setBounds(10, 10, 800, 600); // 設置窗口大小
    this.setVisible(true); // 設置可見
    this.mdp.requestFocus(true); // MapDesignPanel獲取焦點
  }
  /** Return a menu for DesktopWindow and add a special listener. */
  public static JMenu getCurrencyMenu(ActionListener listener) {
    JRadioButtonMenuItem menuItem;
    String defaultCurrency = Money.getCurrencyFor(Money.getDefaultCurrency());

    JMenu menu = new JMenu("Währung");
    ButtonGroup group = new ButtonGroup();

    JMenu europeanMenu = new JMenu("Europa");
    String europeanCurrencies[] = Money.getEuropeanCurrencyList();

    for (int i = 0; i < europeanCurrencies.length; i++) {
      menuItem = new RadioCurrencyMenuItem(europeanCurrencies[i]);
      menuItem.addActionListener(listener);
      europeanMenu.add(menuItem);

      group.add(menuItem);

      if (europeanCurrencies[i].startsWith(defaultCurrency)) {
        menuItem.setSelected(true);
      }

      if (i == 0) {
        europeanMenu.addSeparator();
      }
    }

    menu.add(europeanMenu);

    return menu;
  }
 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);
 }
示例#8
0
  void jbInit() throws Exception {

    setLayout(new AlignLayout(2, 5, 5));

    all = new JRadioButton("All");

    all.setSelected(true);

    select = new JRadioButton("User Data");
    select.setSelected(false);
    select.addItemListener(
        new java.awt.event.ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            select_itemStateChanged(e);
          }
        });

    userData = new JTextField(15);
    //      userData.setEnabled(false);
    ToggleDocument td = new ToggleDocument();
    td.addToggleDocumentListener(this);
    userData.setDocument(td);

    ButtonGroup bg = new ButtonGroup();
    bg.add(all);
    bg.add(select);

    add(all);
    add(new JLabel(""));
    add(select);
    add(userData);

    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
  }
  /**
   * 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};
  }
示例#10
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;
  }
示例#11
0
  SurveyPanel(String ques, String[] resp, int def) {
    super();
    setSize(160, 110);
    question = new JLabel(ques);
    response = new JRadioButton[resp.length];
    JPanel sub1 = new JPanel();
    ButtonGroup group = new ButtonGroup();
    JLabel quesLabel = new JLabel(ques);
    sub1.add(quesLabel);
    JPanel sub2 = new JPanel();
    for (int i = 0; i < resp.length; i++) {

      if (def == i) {

        response[i] = new JRadioButton(resp[i], true);
      } else {
        response[i] = new JRadioButton(resp[i], false);
      }

      group.add(response[i]);
      sub2.add(response[i]);
    }

    JPanel sub3 = new JPanel();
    nextButton.setEnabled(true);
    sub3.add(nextButton);
    finalButton.setEnabled(false);
    sub3.add(finalButton);
    GridLayout grid = new GridLayout(3, 1);
    setLayout(grid);
    add(sub1);
    add(sub2);
    add(sub3);
  }
  /** 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();
                }
              }
            });
  }
  /** Builds the MenuBar */
  private void buildUI() {
    // Construct menu items
    JMenu lookAndFeel = new JMenu("Look and feel");
    JRadioButtonMenuItem nativeLaF = new JRadioButtonMenuItem("Native", true);
    JRadioButtonMenuItem javaLaF = new JRadioButtonMenuItem("Java (Metal)");
    JRadioButtonMenuItem motifLaF = new JRadioButtonMenuItem("Motif");
    JMenu help = new JMenu("Help");
    JMenuItem about = new JMenuItem("About");

    // Add menu items to menu bar
    add(lookAndFeel);
    lookAndFeel.add(nativeLaF);
    lookAndFeel.add(javaLaF);
    lookAndFeel.add(motifLaF);
    add(Box.createHorizontalGlue());
    add(help);
    help.add(about);

    // Add buttons to button group
    ButtonGroup laFGroup = new ButtonGroup();
    laFGroup.add(nativeLaF);
    laFGroup.add(javaLaF);
    laFGroup.add(motifLaF);

    // Set action listeners
    nativeLaF.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            UIUtilities.setLookAndFeel(owner, UIManager.getSystemLookAndFeelClassName());
            owner.pack();
          }
        });

    javaLaF.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            UIUtilities.setLookAndFeel(owner, UIManager.getCrossPlatformLookAndFeelClassName());
            owner.pack();
          }
        });

    motifLaF.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            UIUtilities.setLookAndFeel(owner, "com.sun.java.swing.plaf.motif.MotifLookAndFeel");
            owner.pack();
          }
        });

    about.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            UIUtilities.showAboutDialog(owner);
          }
        });
  }
示例#14
0
 /**
  * Adds a radio button to select an algorithm.
  *
  * @param c the container into which to place the button
  * @param name the algorithm name
  * @param g the button group
  */
 public void addRadioButton(Container c, final String name, ButtonGroup g) {
   ActionListener listener =
       new ActionListener() {
         public void actionPerformed(ActionEvent event) {
           setAlgorithm(name);
         }
       };
   JRadioButton b = new JRadioButton(name, g.getButtonCount() == 0);
   c.add(b);
   g.add(b);
   b.addActionListener(listener);
 }
示例#15
0
  private JMenuBar createMenuBar() {
    JMenu menu = new JMenu("Menu");

    disablingItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.ALT_MASK));

    menu.add(disablingItem);
    menu.addSeparator();

    blurItem.setSelected(true);
    blurItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_1, InputEvent.ALT_MASK));
    menu.add(blurItem);

    embossItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_2, InputEvent.ALT_MASK));
    menu.add(embossItem);

    busyPainterItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_3, InputEvent.ALT_MASK));
    menu.add(busyPainterItem);

    ButtonGroup group = new ButtonGroup();
    group.add(blurItem);
    group.add(embossItem);
    group.add(busyPainterItem);

    ItemListener menuListener =
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            if (blurItem.isSelected()) {
              //                    layer.setUI(blurUI);
            } else if (embossItem.isSelected()) {
              //                    layer.setUI(embossUI);
            } else if (busyPainterItem.isSelected()) {
              layer.setUI(busyPainterUI);
            }
          }
        };

    blurItem.addItemListener(menuListener);
    embossItem.addItemListener(menuListener);
    busyPainterItem.addItemListener(menuListener);

    //        embossUI.getUnlockButton().addActionListener(new ActionListener() {
    //            public void actionPerformed(ActionEvent e) {
    //                disablingItem.doClick();
    //            }
    //        });

    JMenuBar bar = new JMenuBar();
    bar.add(menu);

    bar.add(new LafMenu());
    return bar;
  }
  /**
   * @param shortcut dialog will be initialized with this <code>shortcut</code>. It can be <code>
   *     null</code> if dialog is used to create new mouse shortcut.
   */
  public MouseShortcutDialog(
      JComponent parentComponent,
      MouseShortcut shortcut,
      @NotNull Keymap keymap,
      @NotNull String actiondId,
      @NotNull Group mainGroup) {
    super(parentComponent, true);
    setTitle(KeyMapBundle.message("mouse.shortcut.dialog.title"));

    myKeymap = keymap;
    myActionId = actiondId;
    myMainGroup = mainGroup;

    myRbSingleClick =
        new JRadioButton(KeyMapBundle.message("mouse.shortcut.dialog.single.click.radio"));
    myRbDoubleClick =
        new JRadioButton(KeyMapBundle.message("mouse.shortcut.dialog.double.click.radio"));
    ButtonGroup buttonGroup = new ButtonGroup();
    buttonGroup.add(myRbSingleClick);
    buttonGroup.add(myRbDoubleClick);

    myLblPreview = new JLabel(" ");

    myClickPad = new MyClickPad();

    myTarConflicts = new JTextArea();
    myTarConflicts.setFocusable(false);
    myTarConflicts.setEditable(false);
    myTarConflicts.setBackground(UIUtil.getPanelBackground());
    myTarConflicts.setLineWrap(true);
    myTarConflicts.setWrapStyleWord(true);

    if (shortcut != null) {
      if (shortcut.getClickCount() == 1) {
        myRbSingleClick.setSelected(true);
      } else {
        myRbDoubleClick.setSelected(true);
      }
      myButton = shortcut.getButton();
      myModifiers = shortcut.getModifiers();
    } else {
      myRbSingleClick.setSelected(true);
      myButton = -1;
      myModifiers = -1;
    }

    updatePreviewAndConflicts();

    init();
  }
示例#17
0
 public RadioButtons() {
   rb1.addActionListener(al);
   rb2.addActionListener(al);
   rb3.addActionListener(al);
   g.add(rb1);
   g.add(rb2);
   g.add(rb3);
   t.setEditable(false);
   setLayout(new FlowLayout());
   add(t);
   add(rb1);
   add(rb2);
   add(rb3);
 }
  private void initUI() {

    JPanel infoPanel = new JPanel();
    infoPanel.setLayout(new FlowLayout(FlowLayout.LEFT));

    infoPanel.setBackground(Color.WHITE);
    infoPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    infoPanel.add(
        new JLabel(
            new ImageIcon(Thread.currentThread().getContextClassLoader().getResource("xmi.gif"))),
        FlowLayout.LEFT);

    JLabel textLabel = new JLabel(options[mode][0]);

    infoPanel.add(textLabel);

    ButtonGroup group = new ButtonGroup();

    optionButton1 = new JRadioButton(options[mode][1]);
    optionButton2 = new JRadioButton(options[mode][2]);

    optionButton1.setSelected(true);

    group.add(optionButton1);
    group.add(optionButton2);

    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new GridLayout(0, 1));

    buttonPanel.add(new JLabel("Semantic Connector will tag the XMI document with concepts."));

    buttonPanel.add(optionButton1);
    buttonPanel.add(optionButton2);

    progressPanel = new ProgressPanel(goal);

    if (isProgress) {
      progressPanel.setVisible(true);
      optionButton1.setEnabled(false);
      optionButton2.setEnabled(false);
    } else {
      progressPanel.setVisible(false);
    }

    this.setLayout(new BorderLayout());
    this.add(infoPanel, BorderLayout.NORTH);
    this.add(buttonPanel, BorderLayout.CENTER);
    this.add(progressPanel, BorderLayout.SOUTH);
  }
示例#19
0
 public MainPanel() {
   super(new BorderLayout());
   BufferedImage bi = null;
   try {
     bi = ImageIO.read(getClass().getResource("test.jpg"));
   } catch (IOException ioe) {
     ioe.printStackTrace();
   }
   bufferedImage = bi;
   List<AbstractAction> list =
       Arrays.asList(
           new AbstractAction("NONE") {
             @Override
             public void actionPerformed(ActionEvent e) {
               mode = Flip.NONE;
               repaint();
             }
           },
           new AbstractAction("VERTICAL") {
             @Override
             public void actionPerformed(ActionEvent e) {
               mode = Flip.VERTICAL;
               repaint();
             }
           },
           new AbstractAction("HORIZONTAL") {
             @Override
             public void actionPerformed(ActionEvent e) {
               mode = Flip.HORIZONTAL;
               repaint();
             }
           });
   Box box = Box.createHorizontalBox();
   box.add(Box.createHorizontalGlue());
   box.add(new JLabel("Flip: "));
   for (AbstractAction a : list) {
     JRadioButton rb = new JRadioButton(a);
     if (bg.getButtonCount() == 0) {
       rb.setSelected(true);
     }
     box.add(rb);
     bg.add(rb);
     box.add(Box.createHorizontalStrut(5));
   }
   add(p);
   add(box, BorderLayout.SOUTH);
   setOpaque(false);
   setPreferredSize(new Dimension(320, 240));
 }
示例#20
0
 // Set up the quiz window
 Quiz() {
   initializeData();
   setTitle("FOSS Quiz App");
   setDefaultCloseOperation(EXIT_ON_CLOSE);
   setSize(440, 400);
   setLocation(300, 100);
   setResizable(true);
   Container cont = getContentPane();
   cont.setLayout(null);
   cont.setBackground(Color.WHITE);
   bg = new ButtonGroup();
   choice1 = new JRadioButton("Choice1", true);
   choice2 = new JRadioButton("Choice2", false);
   choice3 = new JRadioButton("Choice3", false);
   choice4 = new JRadioButton("Choice4", false);
   bg.add(choice1);
   bg.add(choice2);
   bg.add(choice3);
   bg.add(choice4);
   lblmess = new JLabel("Choose a correct anwswer");
   lblmess.setForeground(Color.BLACK);
   lblmess.setFont(new Font("Sans_Serif", Font.BOLD, 15));
   btnext = new JButton("Next");
   btnext.setForeground(Color.WHITE);
   btnext.setFont(new Font("Sans_Serif", Font.BOLD, 17));
   btnext.setBackground(Color.DARK_GRAY);
   btnext.addActionListener(this);
   panel = new JPanel();
   panel.setBackground(Color.WHITE);
   panel.setLocation(10, 60);
   panel.setSize(400, 300);
   panel.setLayout(new GridLayout(0, 1));
   title = new JPanel();
   title.setBackground(Color.WHITE);
   title.setLocation(10, 10);
   title.setSize(1000, 50);
   title.setLayout(new GridLayout(1, 0));
   title.add(lblmess);
   panel.add(choice1);
   panel.add(choice2);
   panel.add(choice3);
   panel.add(choice4);
   panel.add(btnext);
   cont.add(title);
   cont.add(panel);
   setVisible(true);
   quizAnswerID = 0;
   readQuestionAnswer(quizAnswerID);
 }
示例#21
0
  public DemoCheckBox() {

    // Set title
    setTitle("Check Box and Radio Button Demo");

    // Mark the default check box and radio button
    cbDriver.setSelected(true);
    rbSingle.setSelected(true);

    // Add the radio buttons to a button group
    ButtonGroup bgMaritalStatus = new ButtonGroup();
    bgMaritalStatus.add(rbMarried);
    bgMaritalStatus.add(rbSingle);
    bgMaritalStatus.add(rbDivorced);

    // Create container and layout
    Container contentPane = getContentPane();
    EasyGridLayout layout = new EasyGridLayout();
    contentPane.setLayout(layout);

    // Set constraints
    layout.setConstraints(lbCheck, 1, 1, 1, 1);
    layout.setConstraints(lbRadio, 2, 1, 1, 1);
    layout.setConstraints(tfCheck, 1, 2, 1, 1);
    layout.setConstraints(tfRadio, 2, 2, 1, 1);
    layout.setConstraints(cbDriver, 3, 1, 1, 1);
    layout.setConstraints(cbPassenger, 4, 1, 1, 1);
    layout.setConstraints(rbMarried, 3, 2, 1, 1);
    layout.setConstraints(rbSingle, 4, 2, 1, 1);
    layout.setConstraints(rbDivorced, 5, 2, 1, 1);
    layout.setConstraints(btGetStates, 6, 1, 2, 1);

    // Add controls to container
    contentPane.add(lbCheck);
    contentPane.add(lbRadio);
    contentPane.add(tfCheck);
    contentPane.add(tfRadio);
    contentPane.add(cbDriver);
    contentPane.add(cbPassenger);
    contentPane.add(rbMarried);
    contentPane.add(rbSingle);
    contentPane.add(rbDivorced);
    contentPane.add(btGetStates);

    // Specify listeners
    btGetStates.addActionListener(new GetStatesListener());
    addWindowListener(new MyWindowAdapter());
  }
示例#22
0
  public static void main(String[] args) {
    JFrame frame = new JFrame("DriveThrough v1.0");

    JPanel entreePanel = new JPanel();
    final ButtonGroup entreeGroup = new ButtonGroup();
    JRadioButton radioButton;
    entreePanel.add(radioButton = new JRadioButton("Beef"));
    radioButton.setActionCommand("Beef");
    entreeGroup.add(radioButton);
    entreePanel.add(radioButton = new JRadioButton("Chicken"));
    radioButton.setActionCommand("Chicken");
    entreeGroup.add(radioButton);
    entreePanel.add(radioButton = new JRadioButton("Veggie", true));
    radioButton.setActionCommand("Veggie");
    entreeGroup.add(radioButton);

    final JPanel condimentsPanel = new JPanel();
    condimentsPanel.add(new JCheckBox("Ketchup"));
    condimentsPanel.add(new JCheckBox("Mustard"));
    condimentsPanel.add(new JCheckBox("Pickles"));

    JPanel orderPanel = new JPanel();
    JButton orderButton = new JButton("Place Order");
    orderPanel.add(orderButton);

    Container content = frame.getContentPane(); // unecessary in 1.5+
    content.setLayout(new GridLayout(3, 1));
    content.add(entreePanel);
    content.add(condimentsPanel);
    content.add(orderPanel);

    orderButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            String entree = entreeGroup.getSelection().getActionCommand();
            System.out.println(entree + " sandwich");
            Component[] components = condimentsPanel.getComponents();
            for (Component c : components) {
              JCheckBox cb = (JCheckBox) c;
              if (cb.isSelected()) System.out.println("With " + cb.getText());
            }
          }
        });

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(300, 150);
    frame.setVisible(true);
  }
示例#23
0
 private static JRadioButtonMenuItem createLookAndFeelItem(
     String lafName, String lafClassName, final ButtonGroup lookAndFeelRadioGroup) {
   JRadioButtonMenuItem lafItem = new JRadioButtonMenuItem();
   lafItem.setSelected(lafClassName.equals(lookAndFeel));
   lafItem.setHideActionText(true);
   lafItem.setAction(
       new AbstractAction() {
         @Override
         public void actionPerformed(ActionEvent e) {
           ButtonModel m = lookAndFeelRadioGroup.getSelection();
           try {
             setLookAndFeel(m.getActionCommand());
           } catch (ClassNotFoundException
               | InstantiationException
               | IllegalAccessException
               | UnsupportedLookAndFeelException ex) {
             ex.printStackTrace();
           }
         }
       });
   lafItem.setText(lafName);
   lafItem.setActionCommand(lafClassName);
   lookAndFeelRadioGroup.add(lafItem);
   return lafItem;
 }
示例#24
0
  private JRadioButton makeSearchInRadioButton(String label) {

    JRadioButton button = new JRadioButton(label, false);
    button.setActionCommand(label);
    searchIn.add(button);
    return button;
  }
示例#25
0
  /**
   * adds a {@link com.tomtessier.scrollabledesktop.BaseRadioButtonMenuItem BaseRadioButtonMenuItem}
   * to the menu and associates it with an internal frame
   *
   * @param associatedFrame the internal frame to associate with the menu item
   */
  public void add(BaseInternalFrame associatedFrame) {

    int displayedCount = getItemCount() - baseItemsEndIndex + 1;
    int currentMenuCount = displayedCount;

    // compute the key mnemonic based upon the currentMenuCount
    if (currentMenuCount > 9) {
      currentMenuCount /= 10;
    }

    BaseRadioButtonMenuItem menuButton =
        new BaseRadioButtonMenuItem(
            this,
            displayedCount + " " + associatedFrame.getTitle(),
            KeyEvent.VK_0 + currentMenuCount,
            -1,
            true,
            associatedFrame);

    associatedFrame.setAssociatedMenuButton(menuButton);

    add(menuButton);
    frameRadioButtonMenuItemGroup.add(menuButton);

    menuButton.setSelected(true); // and reselect here, so that the
    // buttongroup recognizes the change

  }
  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;
  }
示例#27
0
  private static JRadioButton[] buildLangButtons() {
    java.util.List<JRadioButton> btns = new java.util.ArrayList<JRadioButton>();

    for (Language lng : LANGS) {
      JRadioButton btn = new JRadioButton(lng.toString());
      btn.setText(lng.toString());
      btns.add(btn);
    }

    final ButtonGroup group = new ButtonGroup();
    for (final JRadioButton jrb : btns) {
      group.add(jrb);
    }

    JRadioButton[] res = new JRadioButton[btns.size()];
    return btns.toArray(res);
  }
示例#28
0
  public FileManager2() {
    super("Simple File Manager 2");
    add(txt, BorderLayout.NORTH);

    JPanel layout = new JPanel(new GridLayout(0, 1));
    group.add(radioRead);
    layout.add(radioRead);
    group.add(radioEncrypt);
    layout.add(radioEncrypt);
    add(layout, BorderLayout.CENTER);
    add(btn, BorderLayout.SOUTH);
    btn.addActionListener(this);

    pack();
    setDefaultCloseOperation(3);
    setVisible(true);
  }
  /** grouping PKCS7-[XXX]-[XXX] files */
  private boolean _addGroup() {
    String strMethod = "_addGroup()";

    // adding radioButtons/labelChecks for selecting in between JAR, and JHR, and RCR files

    if (this._btnTypeFileShkDer == null) {
      MySystem.s_printOutError(this, strMethod, "nil this._btnTypeFileShk[xxx]");
      return false;
    }

    // ----

    ButtonGroup bgp = new ButtonGroup();
    // bgp.add(this._btnTypeFileShkPkcs7);

    if (this._btnTypeFileShkPem != null) bgp.add(this._btnTypeFileShkPem);

    bgp.add(this._btnTypeFileShkDer);

    if (bgp.getButtonCount() < 2) {
      this._btnTypeFileShkDer.setEnabled(false);
    }

    // selecting first button
    this._btnTypeFileShkDer.setSelected(true);

    // else label: done at construction time

    // --
    JPanel pnlTypeFileShk = new JPanel();
    pnlTypeFileShk.setLayout(new BoxLayout(pnlTypeFileShk, BoxLayout.Y_AXIS));
    pnlTypeFileShk.add(this._btnTypeFileShkDer); // default

    if (this._btnTypeFileShkPem != null) pnlTypeFileShk.add(this._btnTypeFileShkPem);

    // --
    if (super._pnl_ == null) {
      MySystem.s_printOutError(this, strMethod, "nil super._pnl_");
      return false;
    }

    super._pnl_.add(pnlTypeFileShk);

    // ending
    return true;
  }
示例#30
0
  public void init() {
    Container contentPane = f.getContentPane();
    JPanel p = new JPanel();
    // 將兩個元件及 JPanel 加入 JFrame
    contentPane.add(degree, "North");
    contentPane.add(p, "Center");
    contentPane.add(go, "South");

    // 將 JPanel 設定為使用 GridLayout (4 列、2 行)
    p.setLayout(new GridLayout(4, 2));
    // 將各元件加到 JPanel 中
    p.add(deg);
    p.add(rad);
    p.add(sinlab);
    p.add(sintxt);
    p.add(coslab);
    p.add(costxt);
    p.add(tanlab);
    p.add(tantxt);

    // 設定選擇角度單位的快捷鍵
    deg.setMnemonic(KeyEvent.VK_D);
    rad.setMnemonic(KeyEvent.VK_R);

    // 將兩個單選鈕設為一組
    ButtonGroup group = new ButtonGroup();
    group.add(deg);
    group.add(rad);
    deg.setSelected(true); // 將 deg 設為預設選取的項目

    go.addActionListener(this);
    degree.addKeyListener(this);

    // 單選鈕的選取事件之處理方法
    deg.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) convert = 180 / Math.PI;
            else convert = 1;
          }
        });

    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setSize(250, 200);
    f.setVisible(true);
  }