Results 1 to 5 of 5
Thread: JButtons
- 10-16-2008, 03:15 PM #1
Member
- Join Date
- Oct 2008
- Posts
- 12
- Rep Power
- 0
- 10-16-2008, 03:29 PM #2
Create a JButton ,add it to your JComponent,then add action listener to your JButton which will have the method actionPerformed(ActionEvent e) in which you will launch your preferred application
- 10-16-2008, 03:45 PM #3
Member
- Join Date
- Oct 2008
- Posts
- 12
- Rep Power
- 0
The code I'm using is as follows:public void actionPerformed(ActionEvent event) {
if(event.getSource() == homeButton){
Search.setVisible(true);
}
Search is the class I would like to open from another class call register
- 10-16-2008, 06:07 PM #4
When you run the application,so Search object is also created ,but you set it as unvisible, so it should be like this:
Java Code:JButton homeButton=new JButton( "home button"); Search s=new Search(); homeButton.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ s.setVisible(true); } });
-
Sounds like you would benefit greatly by going through the Sun Swing tutorial. You can find it here: Trail: Graphical User Interfaces (The Java™ Tutorials)
Similar Threads
-
2D Array of JButtons
By stevemcc in forum AWT / SwingReplies: 1Last Post: 02-16-2008, 11:42 PM -
JButtons
By fgasimzade in forum SWT / JFaceReplies: 1Last Post: 12-25-2007, 05:39 AM -
how to change the appearance of jbuttons
By katie in forum AWT / SwingReplies: 1Last Post: 08-06-2007, 10:26 PM -
JButtons in a straight line on the BOTTOM
By paul in forum AWT / SwingReplies: 0Last Post: 07-16-2007, 04:47 PM -
disabling JButtons after win in TicTacToe
By noisepoet in forum New To JavaReplies: 1Last Post: 05-18-2007, 11:01 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks