Java Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJava Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old October 2nd, 2006, 05:06 AM
Warranty Warranty is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2006
Posts: 2 Warranty User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 12 m 13 sec
Reputation Power: 0
Multiple windows

I'm very new to Java so forgive me the simplicity of the question.

I'm currently working on a school assignment for which i have to program an application. My simple problem is that i don't know how to create multiple windows in java.

I've looked everywhere but can't seem to find it. I hope there is a very simple way to do this.

I just want a button, with an actionlistener to set the window another applet.

Thank you!

Reply With Quote
  #2  
Old October 2nd, 2006, 05:15 AM
costas costas is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2006
Posts: 407 costas User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 Days 3 h 19 m 11 sec
Reputation Power: 3
What you mean is that you want a window with a button with an actionlistener and when you push the button a new window to appear? Or do you mean a multi-windowed windows application?

Reply With Quote
  #3  
Old October 2nd, 2006, 05:26 AM
Warranty Warranty is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2006
Posts: 2 Warranty User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 12 m 13 sec
Reputation Power: 0
I don't know which is easier. I'd rather want one window, with multiple screens yeah.

But if it's easier for new windows to appear that's okay too. Whathever is easier.

Thank you

Reply With Quote
  #4  
Old October 3rd, 2006, 05:17 AM
costas costas is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2006
Posts: 407 costas User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 Days 3 h 19 m 11 sec
Reputation Power: 3
The easier is to create a window with a button that activates a new window when clicked! I'll see what can I do!

Reply With Quote
  #5  
Old October 6th, 2006, 07:55 AM
costas costas is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2006
Posts: 407 costas User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 Days 3 h 19 m 11 sec
Reputation Power: 3
Sorry for not answering earlier but there was a problem with my compiler. Well, here's an example of how to make a window with a button, when pressed show another window:

Here's the code of the main window:

Code:
import javax.swing.*;
import javax.swing.JMenuBar;
import java.awt.*;
import java.awt.event.*;

public class test extends JFrame implements ActionListener
{
	JButton butt1 = new JButton("Test"); // new button 
	JPasswordField pass = new JPasswordField(20);   // new password field
	JMenu mnu = new JMenu("File"); // new menu
	JMenuItem mnu_1 = new JMenuItem("....");  // new menu Item
	JMenuBar bar = new JMenuBar(); // new menu Bar -- to put the menu in
	newWindow test2;  // variable of the other window
	
	public test() // constructor
	{
	    super("Test");  // title
	    setSize(300,100); // size
	    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	    pass.setEchoChar('*');
	    mnu.add(mnu_1); // add the menu items in the menu
	    bar.add(mnu);  // add the menu in the menu bar
	    JPanel panel = new JPanel();  // new Panel
	    butt1.addActionListener(this);  // add ActionListener to the button
	    setJMenuBar(bar);  // set the Menu Bar
	    panel.add(pass);  // add the Password Field
	    panel.add(butt1);  // add the button
	    setContentPane(panel);
	 }
	 
	 public static void main(String args[])  // main function
	 {
	     JFrame ts = new test(); // new object of the class "test"
	     ts.show();
	 }
	 
	 public void actionPerformed(ActionEvent evt)  // function to control the ActionListener
        {
        Object src = evt.getSource();
        if(src == butt1)
        {
            setVisible(false);
            test2 = new newWindow();
            test2.show();
        }
        }
}


Hope I helped!!

Costas

Reply With Quote
  #6  
Old October 16th, 2006, 03:54 AM
azazk azazk is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2006
Posts: 1 azazk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 32 sec
Reputation Power: 0
Smile

thank's

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJava Development > Multiple windows


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT