private void updateResult() {

    if (iResult == 0) {

      // in case 'help' has removed the grid
      if (bHelp) {
        pResult.removeAll();
        pResult.add(gScrollPane, BorderLayout.CENTER);
        pResult.doLayout();
        gResult.fireTableChanged(null);
        pResult.repaint();

        bHelp = false;
      }
    } else {
      showResultInText();
    }

    txtCommand.selectAll();
    txtCommand.requestFocus();
  }
  private void go() {
    JFrame frame = new JFrame();
    JPanel panel = new JPanel();
    panel.setBackground(Color.lightGray);

    JLabel label = new JLabel("Tell me something interesting.");

    JButton button = new JButton("Click it!");
    button.addActionListener(this);

    textArea = new JTextArea(10, 20);
    textArea.setText("Not all who are lost are wandering.");
    textArea.selectAll();

    panel.add(button);
    panel.add(textArea);

    frame.getContentPane().add(BorderLayout.NORTH, label);
    frame.getContentPane().add(BorderLayout.CENTER, panel);
    frame.getContentPane().add(BorderLayout.SOUTH, button);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(400, 300);
    frame.setVisible(true);
  }
Example #3
0
 public void selectAllMenuAction(ActionEvent event) {
   if (sourceArea != null) {
     sourceArea.selectAll();
   }
 }