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: 818 • Replies: 0
No top replies

 
 

Related Topics

Do You Turn Off Your Computer at Night? - Discussion by Phoenix32890
The "Death" of the Computer Mouse - Discussion by Phoenix32890
McAfee: You're Fired! - Question by Joe Nation
GPU processors and internet passwords - Discussion by gungasnake
Conficker worm - Discussion by msolga
how do you type pi? - Question by C99
Computer Background pictures - Discussion by Seed
How does one uninstall a program? - Question by Woollcott
Blue screen of Death - Question by dagmaraka
What Wallpaper Do You Have on Your Computer? - Discussion by Phoenix32890
 
  1. Forums
  2. » How do I implement program so that it uses actionListener - class and actionPerformed - method
Copyright © 2013 MadLab, LLC :: Terms of Service :: Privacy Policy :: Page generated in 0.05 seconds on 06/18/2013 at 09:05:56