public CustomIconDemo() {
    Icon leftButtonIcon = new ArrowIcon(SwingConstants.RIGHT);
    Icon middleButtonIcon = createImageIcon("images/middle.gif", "the middle button");
    Icon rightButtonIcon = new ArrowIcon(SwingConstants.LEFT);

    b1 = new JButton("Disable middle button", leftButtonIcon);
    b1.setVerticalTextPosition(AbstractButton.CENTER);
    b1.setHorizontalTextPosition(AbstractButton.LEADING);
    b1.setMnemonic(KeyEvent.VK_D);
    b1.setActionCommand("disable");

    b2 = new JButton("Middle button", middleButtonIcon);
    b2.setVerticalTextPosition(AbstractButton.BOTTOM);
    b2.setHorizontalTextPosition(AbstractButton.CENTER);
    b2.setMnemonic(KeyEvent.VK_M);

    b3 = new JButton("Enable middle button", rightButtonIcon);
    // Use the default text position of CENTER, TRAILING (RIGHT).
    b3.setMnemonic(KeyEvent.VK_E);
    b3.setActionCommand("enable");
    b3.setEnabled(false);

    // Listen for actions on buttons 1 and 3.
    b1.addActionListener(this);
    b3.addActionListener(this);

    b1.setToolTipText("Click this button to disable the middle button.");
    b2.setToolTipText("This middle button does nothing when you click it.");
    b3.setToolTipText("Click this button to enable the middle button.");

    // Add Components to this container, using the default FlowLayout.
    add(b1);
    add(b2);
    add(b3);
  }
Ejemplo n.º 2
0
  /**
   * El constructor es el encargado de generar los diferentes componentes del JFrame (botones,
   * textos...).
   */
  public Menu() {

    setSize(250, 150);
    setTitle("Menu");
    setResizable(false);
    setLayout(new GridLayout(5, 5));
    setPreferredSize(new Dimension(250, 100));

    lblDecision = new JLabel("¿Que desea hacer?");
    add(lblDecision);

    butIngresarHora = new JButton("Ingresar Tiempo");
    butIngresarVehiculo = new JButton("Ingresar un Vehiculo");
    butRetirarVehiculo = new JButton("Retirar un Vehiculo");

    add(butIngresarHora);
    add(butIngresarVehiculo);
    add(butRetirarVehiculo);

    butIngresarHora.setActionCommand(IngresarHora);
    butIngresarVehiculo.setActionCommand(IngresarVehiculo);
    butRetirarVehiculo.setActionCommand(RetirarVehiculo);

    butIngresarHora.addActionListener(this);
    butIngresarVehiculo.addActionListener(this);
    butRetirarVehiculo.addActionListener(this);
  }
  public UpgradesPanel(ORUIManager orUIManager) {
    super(BoxLayout.Y_AXIS);

    this.orUIManager = orUIManager;

    preferredSize = new Dimension((int) Math.round(100 * (2 + Scale.getFontScale()) / 3), 200);
    setSize(preferredSize);
    setVisible(true);

    upgradePanel = new JPanel();

    upgradePanel.setOpaque(true);
    upgradePanel.setBackground(Color.DARK_GRAY);
    upgradePanel.setBorder(border);
    upgradePanel.setLayout(new GridLayout(defaultNbPanelElements, 1));

    scrollPane = new JScrollPane(upgradePanel);
    scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    scrollPane.setSize(getPreferredSize());

    doneButton.setActionCommand("Done");
    doneButton.setMnemonic(KeyEvent.VK_D);
    doneButton.addActionListener(this);
    cancelButton.setActionCommand("Cancel");
    cancelButton.setMnemonic(KeyEvent.VK_C);
    cancelButton.addActionListener(this);

    add(scrollPane);
  }
Ejemplo n.º 4
0
 private Object[] buttons() {
   ResourceBundle bundle = NbBundle.getBundle(PropertyAction.class);
   JButton okButton = new JButton();
   Mnemonics.setLocalizedText(okButton, bundle.getString("CTL_OK")); // NOI18N
   okButton
       .getAccessibleContext()
       .setAccessibleDescription(bundle.getString("ACSD_CTL_OK")); // NOI18N
   okButton.setActionCommand(OK_COMMAND);
   JButton cancelButton = new JButton();
   Mnemonics.setLocalizedText(cancelButton, bundle.getString("CTL_Cancel")); // NOI18N
   cancelButton
       .getAccessibleContext()
       .setAccessibleDescription(bundle.getString("ACSD_CTL_Cancel")); // NOI18N
   cancelButton.setActionCommand(CANCEL_COMMAND);
   if (property.isDefaultValue()) {
     if ("Aqua".equals(UIManager.getLookAndFeel().getID())) {
       return new Object[] {cancelButton, okButton};
     } else {
       return new Object[] {okButton, cancelButton};
     }
   } else {
     JButton restoreButton = new JButton();
     Mnemonics.setLocalizedText(restoreButton, bundle.getString("CTL_RestoreDefault")); // NOI18N
     restoreButton
         .getAccessibleContext()
         .setAccessibleDescription(bundle.getString("ACSD_CTL_RestoreDefault")); // NOI18N
     restoreButton.setActionCommand(RESTORE_COMMAND);
     if ("Aqua".equals(UIManager.getLookAndFeel().getID())) {
       return new Object[] {restoreButton, cancelButton, okButton};
     } else {
       return new Object[] {okButton, restoreButton, cancelButton};
     }
   }
 }
Ejemplo n.º 5
0
  // Constructor
  public FileWindow() {

    myWindow = new JFrame("New File");
    myWindow.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    Container contentPane = myWindow.getContentPane();
    contentPane.setLayout(new BorderLayout());

    saveButton = new JButton("Save File");
    saveButton.setSelected(false);
    saveButton.setActionCommand("save");
    saveButton.setMnemonic('S');
    // saveButton.addActionListener(new ScriptWindowButtonListener());

    clearButton = new JButton("Clear Contents");
    clearButton.setSelected(false);
    clearButton.setActionCommand("clear");
    clearButton.setMnemonic('B');
    clearButton.addActionListener(new ScriptWindowButtonListener());

    cancelButton = new JButton("Quit");
    cancelButton.setSelected(false);
    cancelButton.setActionCommand("quit");
    cancelButton.setMnemonic('Q');
    cancelButton.addActionListener(new ScriptWindowButtonListener());

    //		loadButton = new JButton("Load Script");
    //		loadButton.setSelected(false);
    //		loadButton.setActionCommand("load");
    //		loadButton.setMnemonic('L');
    //		loadButton.addActionListener(new ScriptWindowButtonListener());
    //
    //		runButton = new JButton("Run Script");
    //		runButton.setSelected(false);
    //		runButton.setActionCommand("run");
    //		runButton.setMnemonic('L');
    //		runButton.addActionListener(new ScriptWindowButtonListener());

    buttonPanel = new JPanel();
    buttonPanel.setLayout(new GridLayout(1, 0));
    // buttonPanel.add(runButton);
    buttonPanel.add(saveButton);
    // buttonPanel.add(loadButton);
    buttonPanel.add(clearButton);
    // buttonPanel.add(cancelButton);

    fileChooser = new JFileChooser();

    scriptArea = new JTextArea(35, 30);
    JScrollPane scroller = new JScrollPane(scriptArea);

    textHolder = new JPanel();
    textHolder.setLayout(new BorderLayout());
    textHolder.add(scroller, BorderLayout.CENTER);

    contentPane.add(buttonPanel, BorderLayout.NORTH);
    contentPane.add(textHolder, BorderLayout.CENTER);
    myWindow.pack();
  }
Ejemplo n.º 6
0
 public ErrorDialog(Frame owner, Throwable t) {
   super(owner);
   this.cause = t;
   initComponents();
   this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
   Compatibility.setIconImage(this, Toolkit.getDefaultToolkit().getImage(spoutcraftIcon));
   populateException(this.cause);
   reportButton.addActionListener(this);
   reportButton.setActionCommand(REPORT_ACTION);
   closeButton.addActionListener(this);
   closeButton.setActionCommand(CLOSE_ACTION);
 }
  protected JPanel createButtonPanel() {
    JPanel bP = new JPanel(new FlowLayout(FlowLayout.CENTER));
    okB = new JButton(LanguageBundle.getInstance().getMessage("label.ok"));
    okB.setActionCommand("ok");
    okB.addActionListener(this);
    JButton cancelB = new JButton(LanguageBundle.getInstance().getMessage("label.cancel"));
    cancelB.setActionCommand("cancel");
    cancelB.addActionListener(this);

    bP.add(okB);
    bP.add(cancelB);
    return bP;
  }
Ejemplo n.º 8
0
  private void jbInit() throws Exception {
    pageNrPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
    firstButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            firstButton_actionPerformed(e);
          }
        });
    prevButton.setActionCommand(PREV_BUTTON);
    prevButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            prevButton_actionPerformed(e);
          }
        });
    prevPgButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            prevPgButton_actionPerformed(e);
          }
        });
    nextPgButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            nextPgButton_actionPerformed(e);
          }
        });
    nextButton.setActionCommand(NEXT_BUTTON);
    nextButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            nextButton_actionPerformed(e);
          }
        });
    lastButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            lastButton_actionPerformed(e);
          }
        });

    this.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
    this.add(firstButton, null);
    if (showPaginationButtons) this.add(prevPgButton, null);
    this.add(prevButton, null);
    this.add(pageNrPanel, null);
    this.add(nextButton, null);
    if (showPaginationButtons) this.add(nextPgButton, null);
    this.add(lastButton, null);
  }
Ejemplo n.º 9
0
  public void redrawCommande() {
    itemPanel.removeAll();
    OrderedItem orders[] = commande.getOrders();
    GridBagConstraints c = new GridBagConstraints();
    c.gridy = GridBagConstraints.RELATIVE;
    c.fill = GridBagConstraints.BOTH;
    for (int i = 0; i < orders.length; i++) {
      c.gridx = 0;

      JPanel itemLabelHolder = new JPanel();
      itemLabelHolder.add(new JLabel(orders[i].getItem().getNom()));
      itemLabelHolder.setBackground(Color.WHITE);
      itemLabelHolder.setBorder(BorderFactory.createLineBorder(Color.BLUE));

      itemPanel.add(itemLabelHolder, c);
      c.gridx = 1;
      itemPanel.add(new OrderedItemPanel(orders[i]), c);
      c.gridx = 2;
      JButton killButton = new JButton("\u2716");
      killButton.setBackground(Color.RED);
      killButton.setForeground(Color.WHITE);
      killButton.addActionListener(getHandler());
      killButton.setActionCommand("CDelete" + i);
      JPanel buttonHolder = new JPanel();
      buttonHolder.add(killButton);

      itemPanel.add(buttonHolder, c);
    }
    validate();
    repaint();
  }
Ejemplo n.º 10
0
    /** Returns the tool bar for the panel. */
    protected JComponent getToolBar() {
      JToolBar tbarDir = new JToolBar();
      JButton btnNew = new JButton();
      // m_btnSave = new JButton("Save File");
      // i118n
      // btnNew.setText("New Label");
      btnNew.setText(Util.getAdmLabel("_adm_New_Label"));
      btnNew.setActionCommand("new");
      // m_btnSave.setActionCommand("save");

      ActionListener alTool =
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              doAction(e);
            }
          };

      btnNew.addActionListener(alTool);
      // m_btnSave.addActionListener(alTool);

      tbarDir.setFloatable(false);
      tbarDir.add(btnNew);
      /*tbarDir.add(new JLabel("        "));
      tbarDir.add(m_btnSave);*/

      return tbarDir;
    }
Ejemplo n.º 11
0
  public PasswordDialog(final JFrame owner) {
    super(owner, "Login", true);
    setSize(280, 150);
    user = new JTextField(10);
    user.addActionListener(this);
    password = new JPasswordField(10);
    password.addActionListener(this);
    JPanel center = new JPanel();
    center.setLayout(new GridLayout(3, 2));
    center.add(new JLabel("Enter UserName:"******"Enter Password: "******"Submit");
    submitButton.setActionCommand("SUBMIT");
    submitButton.addActionListener(this);

    JButton helpButton = new JButton("Help");
    south.add(submitButton);
    south.add(helpButton);
    helpButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent aEvent) {
            JOptionPane.showMessageDialog(
                owner,
                "Your username and password are the same as those\n"
                    + "you use to access your O'Reilly School of Technology courses. \n");
          }
        });
    Container contentPane = getContentPane();
    contentPane.add(center, BorderLayout.CENTER);
    contentPane.add(south, BorderLayout.SOUTH);
  }
Ejemplo n.º 12
0
  ConnectorWindow(Bot client, WindowListener listener) {
    super("Texas Hold'em - connecting to server");
    this.client = client;
    addWindowListener(listener);
    setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 20));
    setLayout(new GridLayout(4, 2));
    imie = new JTextField(20);
    adres = new JTextField("localhost");
    port = new JTextField("65025");
    Limie = new JLabel();
    Ladres = new JLabel();
    Lport = new JLabel();
    wyslij = new JButton("wyslij");
    wyslij.setActionCommand("connect");

    Lport.setText(" port:");
    Ladres.setText(" adres:");
    Limie.setText(" imię:");

    add(Limie);
    add(imie);
    add(Ladres);
    add(adres);
    add(Lport);
    add(port);
    add(wyslij);

    wyslij.addActionListener(client.listener);
    pack();
    setLocationRelativeTo(null);
    setVisible(true);
  }
Ejemplo n.º 13
0
 public void evaluate() {
   try {
     // clear problems and console messages
     problemsView.setText("");
     consoleView.setText("");
     // update status view
     statusView.setText(" Parsing ...");
     tabbedPane.setSelectedIndex(0);
     LispExpr root = Parser.parse(textView.getText());
     statusView.setText(" Running ...");
     tabbedPane.setSelectedIndex(1);
     // update run button
     runButton.setIcon(stopImage);
     runButton.setActionCommand("Stop");
     // start run thread
     runThread = new RunThread(root);
     runThread.start();
   } catch (SyntaxError e) {
     tabbedPane.setSelectedIndex(0);
     System.err.println(
         "Syntax Error at " + e.getLine() + ", " + e.getColumn() + " : " + e.getMessage());
   } catch (Error e) {
     // parsing error
     System.err.println(e.getMessage());
     statusView.setText(" Errors.");
   }
 }
Ejemplo n.º 14
0
  /**
   * Instantiates a new help search panel.
   *
   * @param root the root
   * @param dialog the dialog
   */
  public HelpSearchPanel(HelpIndexRoot root, HelpDialog dialog) {
    this.root = root;
    this.dialog = dialog;

    setLayout(new BorderLayout());

    JPanel queryPanel = new JPanel();
    queryPanel.setLayout(new BorderLayout());
    queryPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
    queryField = new JTextField();
    queryField.setActionCommand(MenuUtils.SEARCH_BUTTON);
    queryField.addActionListener(this);
    queryPanel.add(queryField, BorderLayout.CENTER);
    searchButton = new JButton(MenuUtils.SEARCH_BUTTON);
    searchButton.setActionCommand(MenuUtils.SEARCH_BUTTON);
    searchButton.addActionListener(this);
    queryPanel.add(searchButton, BorderLayout.EAST);
    add(queryPanel, BorderLayout.NORTH);

    listModel = new DefaultListModel();
    listModel.addElement("[No search results]");
    resultList = new JList(listModel);
    resultList.addListSelectionListener(this);
    resultList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    resultsScrollPane = new JScrollPane(resultList);
    add(resultsScrollPane, BorderLayout.CENTER);
  }
Ejemplo n.º 15
0
  /**
   * Create a button to go inside of the toolbar. By default this will load an image resource. The
   * image filename is relative to the classpath (including the '.' directory if its a part of the
   * classpath), and may either be in a JAR file or a separate file.
   *
   * @param key The key in the resource file to serve as the basis of lookups.
   */
  protected JButton createToolbarButton(String key) {
    URL url = getResource(key + imageSuffix);
    JButton b =
        new JButton(new ImageIcon(url)) {

          @Override
          public float getAlignmentY() {
            return 0.5f;
          }
        };
    b.setRequestFocusEnabled(false);
    b.setMargin(new Insets(1, 1, 1, 1));

    String astr = getProperty(key + actionSuffix);
    if (astr == null) {
      astr = key;
    }
    Action a = getAction(astr);
    if (a != null) {
      b.setActionCommand(astr);
      b.addActionListener(a);
    } else {
      b.setEnabled(false);
    }

    String tip = getResourceString(key + tipSuffix);
    if (tip != null) {
      b.setToolTipText(tip);
    }

    return b;
  }
Ejemplo n.º 16
0
  public void init() { // a grid to layout the screen nicely
    JLabel title = new JLabel("THE GAME OF NIM!");
    title.setFont(new Font("Times New Roman", Font.PLAIN, 48));
    Panel p = new Panel();
    resize(500, 100);
    // declare a new array of buttons
    a = new JButton[row];
    // initialize each of the buttons in the array
    // with an empty label
    for (int nNum = 0; nNum < row; nNum++) {
      a[nNum] = new JButton("8");
      p.add(a[nNum]);
      // each button will have an action listener
      a[nNum].addActionListener(this);
      a[nNum].setBackground(Color.yellow);
      // each button will send a message with its number
      a[nNum].setActionCommand("" + nNum);
    }

    name = JOptionPane.showInputDialog("Enter name Player 1: ");
    name2 = JOptionPane.showInputDialog("Enter name Player 2:  ");

    JButton reset = new JButton("Reset");
    reset.addActionListener(this);
    reset.setActionCommand("re");

    status = new JLabel("Welcome! The player to remove the final stones is the loser!");
    add(title);
    add(status);
    add(p);
    add(reset);
  }
Ejemplo n.º 17
0
  private void initDialog() {
    setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
    setTitle("");

    list.setVisibleRowCount(4);
    list.setEnabled(true);
    listPanel.add(new JScrollPane(list));

    JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    JPanel buttonPanel2 = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    String[] buttonNames = {"delete", "add", "cancel", "add"};
    for (int i = 0; i < buttonNames.length; i++) {
      JButton b = new JButton(buttonNames[i]);
      b.setActionCommand(Integer.toString(i));
      b.addActionListener(this);
      if (i < CANCEL) buttonPanel.add(b);
      else buttonPanel2.add(b);
    }
    listPanel.add(buttonPanel, BorderLayout.SOUTH);

    addElementPanel.add(buttonPanel2, BorderLayout.SOUTH);
    addElementPanel.setBorder(BorderFactory.createTitledBorder("add"));
    addElementPanel.setVisible(false);

    add(listPanel);
    add(addElementPanel);
  }
Ejemplo n.º 18
0
    public MyDemoPanel() {
      super(new BorderLayout());
      lastValue = new double[3];
      CombinedDomainXYPlot combineddomainxyplot = new CombinedDomainXYPlot(new DateAxis("Time"));
      datasets = new TimeSeriesCollection[3];
      for (int i = 0; i < 3; i++) {
        lastValue[i] = 100D;
        TimeSeries timeseries = new TimeSeries("Random " + i);
        datasets[i] = new TimeSeriesCollection(timeseries);
        NumberAxis numberaxis = new NumberAxis("Y" + i);
        numberaxis.setAutoRangeIncludesZero(false);
        XYPlot xyplot = new XYPlot(datasets[i], null, numberaxis, new StandardXYItemRenderer());
        xyplot.setBackgroundPaint(Color.lightGray);
        xyplot.setDomainGridlinePaint(Color.white);
        xyplot.setRangeGridlinePaint(Color.white);
        combineddomainxyplot.add(xyplot);
      }

      JFreeChart jfreechart = new JFreeChart("Dynamic Data Demo 3", combineddomainxyplot);
      addChart(jfreechart);
      LegendTitle legendtitle = (LegendTitle) jfreechart.getSubtitle(0);
      legendtitle.setPosition(RectangleEdge.RIGHT);
      legendtitle.setMargin(new RectangleInsets(UnitType.ABSOLUTE, 0.0D, 4D, 0.0D, 4D));
      jfreechart.setBorderPaint(Color.black);
      jfreechart.setBorderVisible(true);
      ValueAxis valueaxis = combineddomainxyplot.getDomainAxis();
      valueaxis.setAutoRange(true);
      valueaxis.setFixedAutoRange(20000D);
      ChartUtilities.applyCurrentTheme(jfreechart);
      ChartPanel chartpanel = new ChartPanel(jfreechart);
      add(chartpanel);
      JPanel jpanel = new JPanel(new FlowLayout());
      for (int j = 0; j < 3; j++) {
        JButton jbutton1 = new JButton("Series " + j);
        jbutton1.setActionCommand("ADD_DATA_" + j);
        jbutton1.addActionListener(this);
        jpanel.add(jbutton1);
      }

      JButton jbutton = new JButton("ALL");
      jbutton.setActionCommand("ADD_ALL");
      jbutton.addActionListener(this);
      jpanel.add(jbutton);
      add(jpanel, "South");
      chartpanel.setPreferredSize(new Dimension(500, 470));
      chartpanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    }
    protected JPanel createForm() {
      JPanel panel = new JPanel();
      panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
      // Time
      JPanel pT = new JPanel(new FlowLayout());
      pT.setBorder(BorderFactory.createTitledBorder("Start Time"));
      hh = new JSpinner(new SpinnerNumberModel(Util.getHours(myrow.getTime()), 0, 99, 1));
      hh.setEditor(new JSpinner.NumberEditor(hh, "00"));
      pT.add(hh);
      pT.add(new JLabel("h "));
      mm = new JSpinner(new SpinnerNumberModel(Util.getMinutes(myrow.getTime()), 0, 59, 1));
      mm.setEditor(new JSpinner.NumberEditor(mm, "00"));
      pT.add(mm);
      pT.add(new JLabel("m "));
      ss = new JSpinner(new SpinnerNumberModel(Util.getSeconds(myrow.getTime()), 0, 59, 1));
      ss.setEditor(new JSpinner.NumberEditor(ss, "00"));
      pT.add(ss);
      pT.add(new JLabel("s"));
      panel.add(pT);
      // Green
      JPanel pG = new JPanel(new BorderLayout());
      pG.setBorder(BorderFactory.createTitledBorder("Green (sec.)"));
      green = new JSpinner(new SpinnerNumberModel(myrow.getGreen() * conversion, 0.0, 99999.99, 1));
      green.setEditor(new JSpinner.NumberEditor(green, "####0.##"));
      pG.add(green);
      panel.add(pG);
      // Red
      JPanel pR = new JPanel(new BorderLayout());
      pR.setBorder(BorderFactory.createTitledBorder("Red (sec.)"));
      red = new JSpinner(new SpinnerNumberModel(myrow.getRed() * conversion, 0.0, 99999.99, 1));
      red.setEditor(new JSpinner.NumberEditor(red, "####0.##"));
      pR.add(red);
      panel.add(pR);

      JPanel bp = new JPanel(new FlowLayout());
      JButton bOK = new JButton("    OK    ");
      bOK.setActionCommand(cmdOK);
      bOK.addActionListener(new ButtonEventsListener());
      JButton bCancel = new JButton("Cancel");
      bCancel.setActionCommand(cmdCancel);
      bCancel.addActionListener(new ButtonEventsListener());
      bp.add(bOK);
      bp.add(bCancel);
      panel.add(bp);
      return panel;
    }
 private void addButton(JPanel container, Action action, Hashtable actions, Icon icon) {
   String actionName = (String) action.getValue(Action.NAME);
   String actionCommand = (String) action.getValue(Action.ACTION_COMMAND_KEY);
   JButton button = new JButton(icon);
   button.setActionCommand(actionCommand);
   button.addActionListener(DeepaMehtaClientUtils.getActionByName(actionName, actions));
   container.add(button);
   toolbarButtons[buttonIndex++] = button;
 }
Ejemplo n.º 21
0
  private JButton makeToolbarButton(String name, String toolTipText, String action) {
    // Create and initialize the button.
    JButton button = new JButton(makeImageIcon(name));
    button.setToolTipText(toolTipText);
    button.setActionCommand(action);
    button.addActionListener(this);

    return button;
  }
  public ListDemo() {
    super(new BorderLayout());

    listModel = new DefaultListModel();

    // Create the list and put it in a scroll pane.
    list = new JList(listModel);
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    list.setSelectedIndex(0);
    list.addListSelectionListener(this);
    list.setVisibleRowCount(5);
    JScrollPane listScrollPane = new JScrollPane(list);

    JButton hireButton = new JButton(hireString);
    HireListener hireListener = new HireListener(hireButton);
    hireButton.setActionCommand(hireString);
    hireButton.addActionListener(hireListener);
    hireButton.setEnabled(false);

    loadButton = new JButton(loadString);
    loadButton.setActionCommand(loadString);
    loadButton.addActionListener(new loadListener());

    employeeName = new JTextField(10);
    employeeName.addActionListener(hireListener);
    employeeName.getDocument().addDocumentListener(hireListener);
    String name;
    if (listModel.size() > 0) {
      name = listModel.getElementAt(list.getSelectedIndex()).toString();
    }
    // Create a panel that uses BoxLayout.
    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));
    buttonPane.add(loadButton);
    buttonPane.add(Box.createHorizontalStrut(5));
    buttonPane.add(new JSeparator(SwingConstants.VERTICAL));
    buttonPane.add(Box.createHorizontalStrut(5));
    buttonPane.add(employeeName);
    buttonPane.add(hireButton);
    buttonPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    add(listScrollPane, BorderLayout.CENTER);
    add(buttonPane, BorderLayout.PAGE_END);
  }
Ejemplo n.º 23
0
  /** Constructor */
  public WPart11Dialog() {
    super(null);
    setVisible(false);

    m_pnlDisplay = new JPanel();
    m_pcsTypesMgr = new PropertyChangeSupport(this);
    JScrollPane spDisplay = new JScrollPane(m_pnlDisplay);
    m_pnlDisplay.setLayout(new WGridLayout(0, 2));
    addComp(spDisplay);
    initBlink();

    buttonPane.removeAll();
    // Add the buttons to the panel with space between buttons.
    m_btnChecksum = new JButton("Make new checksum");
    buttonPane.add(m_btnChecksum);
    buttonPane.add(Box.createRigidArea(new Dimension(5, 0)));
    buttonPane.add(validateButton);
    buttonPane.add(Box.createRigidArea(new Dimension(5, 0)));
    buttonPane.add(closeButton);
    buttonPane.add(Box.createRigidArea(new Dimension(5, 0)));
    buttonPane.add(abandonButton);
    buttonPane.add(Box.createRigidArea(new Dimension(5, 0)));
    buttonPane.add(helpButton);
    setHelpEnabled(false);

    closeButton.setActionCommand("close");
    closeButton.addActionListener(this);
    validateButton.setActionCommand("validate");
    validateButton.addActionListener(this);
    abandonButton.setActionCommand("cancel");
    abandonButton.addActionListener(this);
    helpButton.setActionCommand("help");
    helpButton.addActionListener(this);
    m_btnChecksum.setActionCommand("checksum");
    m_btnChecksum.addActionListener(this);

    setCloseEnabled(true);
    setAbandonEnabled(true);

    setTitle("Configuration");
    setLocation(300, 500);
    setResizable(true);
    setSize(450, 300);
  }
Ejemplo n.º 24
0
 /* create a new button and add the respective coordinates */
 public void createNewButton(int x, int y) {
   this.x = x; // Autoboxing!
   this.y = y;
   button = new JButton();
   button.setPreferredSize(new Dimension(20, 20));
   // for leftclicks
   button.setActionCommand(this.x.toString() + " " + this.y.toString());
   // for rightclicks
   button.setName(this.x.toString() + " " + this.y.toString());
 }
  public FindAndReplaceDemo() {

    JPanel cp = new JPanel(new BorderLayout());

    textArea = new RSyntaxTextArea(20, 60);
    textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
    textArea.setCodeFoldingEnabled(true);
    textArea.setAntiAliasingEnabled(true);
    RTextScrollPane sp = new RTextScrollPane(textArea);
    sp.setFoldIndicatorEnabled(true);
    cp.add(sp);

    // Create a toolbar with searching options.
    JPanel toolBar = new JPanel();
    searchField = new JTextField(30);
    toolBar.add(searchField);
    final JButton nextButton = new JButton("Find Next");
    nextButton.setActionCommand("FindNext");
    nextButton.addActionListener(this);
    toolBar.add(nextButton);
    searchField.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            nextButton.doClick(0);
          }
        });
    JButton prevButton = new JButton("Find Previous");
    prevButton.setActionCommand("FindPrev");
    prevButton.addActionListener(this);
    toolBar.add(prevButton);
    regexCB = new JCheckBox("Regex");
    toolBar.add(regexCB);
    matchCaseCB = new JCheckBox("Match Case");
    toolBar.add(matchCaseCB);
    cp.add(toolBar, BorderLayout.NORTH);

    setContentPane(cp);
    setTitle("Find and Replace Demo");
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    pack();
    setLocationRelativeTo(null);
  }
Ejemplo n.º 26
0
  /**
   * List of Local Variables: azure: Color object to set as background buttonFont: Font object to
   * use in buttons newGame: JButton object switchPlayer: JButton object quit: JButton object
   *
   * <p>Explanation: default constructor
   */
  public Board() {
    Color azure = new Color(240, 255, 255); // create colour

    // enable custom resizing (java sets components in ratios by default)
    this.setLayout(null);

    // add mouse listener
    this.addMouseListener(this);
    // change background colour
    this.setBackground(azure);

    // create font to use for buttons
    Font buttonFont = new Font("Times New Roman", Font.BOLD, 18);

    // create+add new Game button
    // String with some basic HTML for multi-line/centering
    JButton newGame = new JButton("<html><center>New<br>Game</center></html>");
    newGame.setFont(buttonFont);
    newGame.setHorizontalAlignment(SwingConstants.CENTER);
    newGame.setActionCommand("New Game");
    newGame.setBounds(570, 135, 80, 75);
    newGame.addActionListener(this);
    this.add(newGame);

    // create+add switch Player Button
    JButton switchPlayer = new JButton("<html><center>Switch<br>Player</center></html>");
    switchPlayer.setFont(buttonFont);
    switchPlayer.setHorizontalAlignment(SwingConstants.CENTER);
    switchPlayer.setActionCommand("Switch Player");
    switchPlayer.setBounds(570, 220, 80, 75);
    switchPlayer.addActionListener(this);
    this.add(switchPlayer);

    // create+add quit Button
    JButton quit = new JButton("<html><center>Quit</center></html>");
    quit.setFont(buttonFont);
    quit.setHorizontalAlignment(SwingConstants.CENTER);
    quit.setActionCommand("Quit");
    quit.setBounds(570, 305, 80, 75);
    quit.addActionListener(this);
    this.add(quit);
  }
Ejemplo n.º 27
0
  // 部屋に入室している状態のコンポーネント設定
  private void enteredRoom(String roomName) {
    this.roomName = roomName;
    setTitle(APPNAME + " " + roomName);

    msgTextField.setEnabled(true);
    submitButton.setEnabled(true);

    addRoomButton.setEnabled(false);
    enterRoomButton.setText("退室");
    enterRoomButton.setActionCommand("exitRoom");
  }
Ejemplo n.º 28
0
    protected void addMyControls() {
      // add browser-style control buttons
      JButton home = new JButton(new ImageIcon("data/Home24.gif"));
      JButton back = new JButton(new ImageIcon("data/Back24.gif"));
      JButton fwd = new JButton(new ImageIcon("data/Forward24.gif"));

      home.setToolTipText("Home");
      home.addActionListener(this);
      home.setActionCommand(homeCmd);

      back.setToolTipText("Back");
      back.addActionListener(this);
      back.setActionCommand(backCmd);
      back.setEnabled(false); // initially disabled

      fwd.setToolTipText("Forward");
      fwd.addActionListener(this);
      fwd.setActionCommand(forwardCmd);
      fwd.setEnabled(false); // initially disabled

      add(home);
      add(back);
      add(fwd);
      add(new JToolBar.Separator());

      // set built-in index variables
      homeIndex = getComponentIndex(home);
      backIndex = getComponentIndex(back);
      forwardIndex = getComponentIndex(fwd);

      JComboBox comboBox = new JComboBox();
      comboBox.setEditable(true);
      comboBox.addActionListener(this);
      comboBox.setActionCommand(comboCmd);
      comboBox.setMaximumRowCount(3); // don't let it get too long
      comboBox.insertItemAt(mainBrowserURL, 0); // don't start it out empty

      add(comboBox);

      comboBoxIndex = getComponentIndex(comboBox);
    }
 /**
  * Gets the instance of the CenterButton
  *
  * @return The instance of the CenterButton
  */
 public static JButton getCenterButton() {
   if (centerButton == null) {
     centerButton = new JButton();
     centerButton.setText(Constants.CENTER);
     centerButton.setHorizontalAlignment(SwingConstants.CENTER);
     centerButton.setFont(new Font("Dialog", Font.BOLD, 14));
     centerButton.setAlignmentX(Component.CENTER_ALIGNMENT);
     centerButton.setActionCommand(Constants.CENTER);
     centerButton.addActionListener(ButtonListener.getInstance());
   }
   return centerButton;
 }
 /**
  * Gets the instance of the SlowButton
  *
  * @return The instance of the SlowButton
  */
 public static JButton getSlowButton() {
   if (slowButton == null) {
     slowButton = new JButton();
     slowButton.setText(Constants.STOP);
     slowButton.setHorizontalAlignment(SwingConstants.CENTER);
     slowButton.setFont(Constants.DEFAULT_BUTTON_FONT);
     slowButton.setAlignmentX(Component.CENTER_ALIGNMENT);
     slowButton.setActionCommand(Constants.SLOW);
     slowButton.addActionListener(ButtonListener.getInstance());
   }
   return slowButton;
 }