0
   

How do I implement program so that it uses actionListener - class and actionPerformed - method

 
 
Reply Thu 29 Mar, 2012 03:19 am
I following code:


import javax.swing.JLabel;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.JFrame;
import java.awt.FlowLayout;
import java.awt.*;

public class ShowFlowLayout extends JFrame {
public ShowFlowLayout() {
// Set FlowLayout, aligned left with horizontal gap 10
// and vertical gap 20 between components
setLayout(new FlowLayout(FlowLayout.LEFT, 10, 20));

// alustetaan swing olio pnlNorth
JPanel pnlNorth = new JPanel();
// Painike laitettavaksi paneeliin
JButton btnNorth = new JButton("North");

// Add labels and text fields to the frame
add(new JLabel("First Name"));

add(new JTextField(8));
add(new JLabel("MI"));
add(new JTextField(1));
add(new JLabel("Last Name"));
add(new JTextField(8));
add(new JButton("lähetä"));

pnlNorth.add(btnNorth);
add(pnlNorth);
}


/** Main method */
public static void main(String[] args) {
ShowFlowLayout frame = new ShowFlowLayout();
frame.setTitle("ShowFlowLayout");
frame.setSize(200, 200);
frame.setLocationRelativeTo(null); // Center the frame
frame.setDefaultCloseOperation(JFrame.EX…
frame.setVisible(true);
}
}


How do I implement program so that it uses actionListener - class and actionPerformed - method in collecting data that user has written into textfield First Name, textfield MI and textfield Lastname. It collects data from user, when user presses JButton lähetä.
  • Topic Stats
  • Top Replies
  • Link to this Topic
Type: Question • Score: 0 • Views: 1,359 • Replies: 0
No top replies

 
 

Related Topics

Clone of Micosoft Office - Question by Advocate
Do You Turn Off Your Computer at Night? - Discussion by Phoenix32890
The "Death" of the Computer Mouse - Discussion by Phoenix32890
Windows 10... - Discussion by Region Philbis
Surface Pro 3: What do you think? - Question by neologist
Windows 8 tips thread - Discussion by Wilso
GOOGLE CHROME - Question by Setanta
.Net and Firefox... - Discussion by gungasnake
Hacking a computer and remote access - Discussion by trying2learn
 
  1. Forums
  2. » How do I implement program so that it uses actionListener - class and actionPerformed - method
Copyright © 2020 MadLab, LLC :: Terms of Service :: Privacy Policy :: Page generated in 0.04 seconds on 08/09/2020 at 05:45:03