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);
  }
Ejemplo n.º 3
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};
     }
   }
 }
  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.º 5
0
  public ButtonDemo() {
    ImageIcon leftButtonIcon = new ImageIcon("src/images/right.png");
    ImageIcon middleButtonIcon = new ImageIcon("src/images/middle.png");
    ImageIcon rightButtonIcon = new ImageIcon("src/images/left.png");

    b1 = new JButton("가운데 버튼은 사용 불가", leftButtonIcon);
    b1.setVerticalTextPosition(AbstractButton.CENTER);
    b1.setHorizontalTextPosition(AbstractButton.LEADING); // aka LEFT, for left-to-right locales
    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.º 6
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();
  }
  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
    /** 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.º 10
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.º 11
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.º 12
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.º 13
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.º 14
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);
  }
    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;
    }
Ejemplo n.º 16
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.º 18
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.º 19
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.º 20
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);
    }
Ejemplo n.º 21
0
  // 部屋に入室していない状態のコンポーネント設定
  private void exitedRoom() {
    roomName = null;
    setTitle(APPNAME);

    msgTextField.setEnabled(false);
    submitButton.setEnabled(false);

    addRoomButton.setEnabled(true);
    enterRoomButton.setText("入室");
    enterRoomButton.setActionCommand("enterRoom");
    userList.setModel(new DefaultListModel());
  }
Ejemplo n.º 22
0
  /**
   * ************************************************
   *
   * <pre>
   * Summary: Constructor, Add buttons to dialog box
   *
   * </pre>
   *
   * *************************************************
   */
  public TagAddRemoveDialog() {
    super(Util.getLabel("_Locator_Add_Remove"));

    // Make a panel for the buttons
    panelForBtns = new JPanel();
    // It looks better with a border
    panelForBtns.setBorder(BorderFactory.createEmptyBorder(20, 35, 20, 35));

    // Create the two items.
    addButton = new JButton("Add to Group");
    removeButton = new JButton("Remove From Group");

    // Add items to panel
    panelForBtns.add(addButton);
    panelForBtns.add(removeButton);

    // Add the panel top of the dialog.
    getContentPane().add(panelForBtns, BorderLayout.NORTH);

    // Set the buttons and the text item up with Listeners
    cancelButton.setActionCommand("cancel");
    cancelButton.addActionListener(this);
    helpButton.setActionCommand("help");
    helpButton.addActionListener(this);
    addButton.setActionCommand("add");
    addButton.addActionListener(this);
    addButton.setMnemonic('a');
    removeButton.setActionCommand("remove");
    removeButton.addActionListener(this);
    removeButton.setMnemonic('r');

    // OK disabled.
    okButton.setEnabled(false);

    setBgColor(Util.getBgColor());
    DisplayOptions.addChangeListener(this);

    // Make the frame fit its contents.
    pack();
  }
Ejemplo n.º 23
0
 public void runFinished() {
   // program execution finished so update
   // status and run button accordingly
   if (runThread == null) {
     // _runThread = null only if
     // execution stopped by user via
     // run button
     statusView.setText(" Stopped.");
   } else {
     statusView.setText(" Done.");
   }
   runButton.setActionCommand("Run");
   runButton.setIcon(runImage);
 }
Ejemplo n.º 24
0
 /**
  * The class constructor.
  *
  * <p>Adds and creates a message saying bye.
  */
 public Instruction2() {
   setLayout(null);
   JButton back = new JButton(new ImageIcon("Back.png"));
   back.setOpaque(false);
   back.setContentAreaFilled(false);
   back.setBorderPainted(false);
   back.setFocusable(false);
   back.setRolloverIcon(new ImageIcon("Backrollover.png"));
   back.setActionCommand("Back");
   back.addActionListener(this);
   JLabel pic = new JLabel(new ImageIcon("Instructions2.png"));
   pic.setBounds(0, 0, pic.getPreferredSize().width, pic.getPreferredSize().height);
   back.setBounds(5, 200, back.getPreferredSize().width, back.getPreferredSize().height);
   add(pic);
   add(back);
 }
Ejemplo n.º 25
0
  /**
   * Create the 'Connect' button.
   *
   * @return The connect button.
   */
  protected JComponent getConnectButton() {
    JButton connectBtn = new JButton("Connect");
    connectBtn.setActionCommand(CMD_CONNECT);
    connectBtn.addActionListener(this);
    JComponent buttonComp = connectBtn;
    registerStatusComp("connect", buttonComp);
    if (canDoCancel()) {
      cancelButton = GuiUtils.getImageButton("/auxdata/ui/icons/Exit16.gif", getClass());
      cancelButton.setEnabled(false);
      cancelButton.setActionCommand(GuiUtils.CMD_CANCEL);
      cancelButton.addActionListener(this);
      buttonComp = GuiUtils.hbox(buttonComp, cancelButton);
    }

    return buttonComp;
    //        return connectBtn;
  }
Ejemplo n.º 26
0
 // ------------------------------------------------------------------------------------------------
 // 描述:
 // 设计: Skyline(2001.12.29)
 // 实现: Skyline
 // 修改:
 // ------------------------------------------------------------------------------------------------
 private void jbInit() throws Exception {
   bnAutoColor.setFont(new java.awt.Font("Dialog", 0, 12));
   bnAutoColor.setActionCommand("bnAutoColor");
   bnAutoColor.setText(res.getString("String_3"));
   jPanel1.setLayout(borderLayout1);
   jPanel3.setLayout(gridLayout1);
   gridLayout1.setColumns(8);
   gridLayout1.setRows(7);
   jPanel2.setLayout(borderLayout2);
   this.getContentPane().add(jPanel1, BorderLayout.CENTER);
   jPanel1.add(jPanel3, BorderLayout.CENTER);
   jPanel1.add(jPanel2, BorderLayout.NORTH);
   jPanel2.add(bnAutoColor, BorderLayout.CENTER);
   //    this.setDefaultCloseOperation();
   setSize(200, 220);
   setTitle(res.getString("String_4"));
   this.addWindowFocusListener(this);
   InitButton();
 }
Ejemplo n.º 27
0
    private void initButton() {
      int actionCommandId = 1;
      for (int i = 0; i < 6; i++) {
        for (int j = 0; j < 7; j++) {
          JButton numberButton = new JButton();
          numberButton.setBorder(BorderFactory.createEmptyBorder());
          numberButton.setHorizontalAlignment(SwingConstants.CENTER);
          numberButton.setActionCommand(String.valueOf(actionCommandId));

          numberButton.addMouseListener(this);

          numberButton.setBackground(palletTableColor);
          numberButton.setForeground(dateFontColor);
          numberButton.setText(String.valueOf(actionCommandId));
          numberButton.setPreferredSize(new Dimension(25, 25));
          daysButton[i][j] = numberButton;
          actionCommandId++;
        }
      }
    }
Ejemplo n.º 28
0
  public Splitter() {
    super(new BorderLayout());

    // Create the demo's UI.
    startButton = new JButton("Start");
    startButton.setActionCommand("start");
    startButton.addActionListener(this);
    startButton.setVisible(false);

    taskOutput = new JTextArea(30, 130);
    taskOutput.setMargin(new Insets(5, 5, 5, 5));
    taskOutput.setEditable(false);

    JPanel panel = new JPanel();
    panel.add(startButton);

    add(panel, BorderLayout.PAGE_START);
    add(new JScrollPane(taskOutput), BorderLayout.CENTER);
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));

    startButton.doClick();
  }
Ejemplo n.º 29
0
  public void actionPerformed(ActionEvent even) {

    Object respuesta = even.getSource(); // se esta diciendo que respuesta sea un objeto.

    if (respuesta == b1) {

      txt = new JTextField(4 + 4);
      setTitle("sumar");
    } else if (respuesta == b2) {

      // txt=new JTextField (4-1);

      txt.setActionCommand("4");
      setTitle("Restar");
    }

    // cambiar el boton b2

    b2.setActionCommand("LOL");
    b2.setLabel(b2.getActionCommand());

    repaint();
  }
Ejemplo n.º 30
0
 public void setCommands(String[] names) {
   panel.removeAll();
   panel.add(Box.createHorizontalGlue());
   for (int i = 0; i < names.length; i++) {
     JButton b = new XButton("");
     if (shownames) b.setText(names[i]);
     else b.setToolTipText(names[i]);
     b.setActionCommand(names[i]);
     b.addActionListener(this);
     b.setMargin(new InsetsUIResource(0, 6, 0, 6));
     panel.add(b);
     if (i < names.length - 1) {
       if (isHorisontal()) {
         panel.add(Box.createHorizontalStrut(9));
       } else {
         panel.add(Box.createVerticalStrut(5));
       }
     }
     buttons.put(names[i], b);
   }
   setButtonsSize();
   panel.validate();
 }