예제 #1
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);
  }
예제 #2
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();
  }