New Posts  All Forums:Forum Nav:

Java GUI Question - Page 2

post #11 of 16
to me it looks like your logging into the app and want to validate the entered info then continue to the reset of the app?

Since your already logged in, the context of the app is based on the user, so you do not need any info from that login screen. Simple get a handle to the login window and dispose. Assuming the actionPerformed is part of the login window, you can do something like

public void actionPerformed(ActionEvent evt) {
Frame window = null;
if (evt.getSource() == empLogin) {
employeeLogin emp = new employeeLogin();
emp.init();

window = new Frame("Employee");
window.add("Center", emp);
window.pack();
window.setVisible(false);

}

if (window != null) {
//context based on login window
this.dispose();
window.setVisible(true);
}
}

of course you may have to play around, as i haven't done swing in a couple years. Web services ftw

Keep us posted.
My System
(13 items)
 
  
CPUMotherboardGraphicsRAM
i7-2600k Asus P8Z68-V eVga 8800 gts sc 320 Kingston HyperX 8GB 1600 
Hard DriveOptical DriveOSMonitor
wd 320 sataII, WD 250 PATA, WD 2TB green LG HT w7 x64 Sammy 22 ws LCD 
PowerCase
Corsair HX620W Coolmaster Elite 
  hide details  
Reply
My System
(13 items)
 
  
CPUMotherboardGraphicsRAM
i7-2600k Asus P8Z68-V eVga 8800 gts sc 320 Kingston HyperX 8GB 1600 
Hard DriveOptical DriveOSMonitor
wd 320 sataII, WD 250 PATA, WD 2TB green LG HT w7 x64 Sammy 22 ws LCD 
PowerCase
Corsair HX620W Coolmaster Elite 
  hide details  
Reply
post #12 of 16
Thread Starter 
Code:
this.dispose();
is not valid.

But yes, Once the user types in the correct login/password then it will (in theory) close the login screen and open the logged on screen.
The Sivmiester
(13 items)
 
  
CPUMotherboardGraphicsRAM
i7 875k @ 4.0ghz EVGA p55 FTW EVGA GTX 480 - 875/1750/2100 Mushkin Redline DDR3 1600 (2x2gb) 
Hard DriveOptical DriveOSMonitor
Intel X25-M 80GB SSD, 640 WD Black, 2TB WD Green Asus 24x DVD RW+/- Win7 Ultimate x64 Asus 24" 
KeyboardPowerCaseMouse
Logitech G15v2 Silverstone Strider 1000w Obsidian 700d undecided 
Mouse Pad
Razer Destructor 
  hide details  
Reply
The Sivmiester
(13 items)
 
  
CPUMotherboardGraphicsRAM
i7 875k @ 4.0ghz EVGA p55 FTW EVGA GTX 480 - 875/1750/2100 Mushkin Redline DDR3 1600 (2x2gb) 
Hard DriveOptical DriveOSMonitor
Intel X25-M 80GB SSD, 640 WD Black, 2TB WD Green Asus 24x DVD RW+/- Win7 Ultimate x64 Asus 24" 
KeyboardPowerCaseMouse
Logitech G15v2 Silverstone Strider 1000w Obsidian 700d undecided 
Mouse Pad
Razer Destructor 
  hide details  
Reply
post #13 of 16
Quote:
Originally Posted by Sivsta View Post
Code:
this.dispose();
is not valid.

But yes, Once the user types in the correct login/password then it will (in theory) close the login screen and open the logged on screen.
(**getLoginWindow**).dispose();

that is why you need the context of the login window. Once you have it you can dispose it from the windows manager and it's ready for garbage collection.
My System
(13 items)
 
  
CPUMotherboardGraphicsRAM
i7-2600k Asus P8Z68-V eVga 8800 gts sc 320 Kingston HyperX 8GB 1600 
Hard DriveOptical DriveOSMonitor
wd 320 sataII, WD 250 PATA, WD 2TB green LG HT w7 x64 Sammy 22 ws LCD 
PowerCase
Corsair HX620W Coolmaster Elite 
  hide details  
Reply
My System
(13 items)
 
  
CPUMotherboardGraphicsRAM
i7-2600k Asus P8Z68-V eVga 8800 gts sc 320 Kingston HyperX 8GB 1600 
Hard DriveOptical DriveOSMonitor
wd 320 sataII, WD 250 PATA, WD 2TB green LG HT w7 x64 Sammy 22 ws LCD 
PowerCase
Corsair HX620W Coolmaster Elite 
  hide details  
Reply
post #14 of 16
I am a bit rusty with AWT (why don't you use Swing, are you compiling using gcj or something) but you should be able to either create the new Frame and close the old one or get the content pane (whatever is the AWT equivalent) and replace its contents rather than creating a new window at all.
Serene Power
(13 items)
 
  
CPUMotherboardGraphicsRAM
Dual Xeon E5620 Supermicro X8DAL-i EVGA 570HD SC 8GiB Corsair DDR3 1333 ECC-R 
Hard DriveOptical DriveOSMonitor
OCZ Agility 3 120GB SSD (+16TB NAS) LG 10x Blu-Ray Windows 7 x64 / Debian x64 Dell 2408WFP, P2411H 
PowerCase
850W CoolerMaster SilentPro M CoolerMaster Cosmos Pure 
  hide details  
Reply
Serene Power
(13 items)
 
  
CPUMotherboardGraphicsRAM
Dual Xeon E5620 Supermicro X8DAL-i EVGA 570HD SC 8GiB Corsair DDR3 1333 ECC-R 
Hard DriveOptical DriveOSMonitor
OCZ Agility 3 120GB SSD (+16TB NAS) LG 10x Blu-Ray Windows 7 x64 / Debian x64 Dell 2408WFP, P2411H 
PowerCase
850W CoolerMaster SilentPro M CoolerMaster Cosmos Pure 
  hide details  
Reply
post #15 of 16
Quote:
Originally Posted by ghell View Post
I am a bit rusty with AWT (why don't you use Swing, are you compiling using gcj or something) but you should be able to either create the new Frame and close the old one or get the content pane (whatever is the AWT equivalent) and replace its contents rather than creating a new window at all.
This is the route I'd take. I like Swing as well. You'd have your main JFrame declared, then just use a collection of JPanel.

Basically you'd just have
Code:
JFrame mainFrame;
JPanel login;
JPanel loggedIn;

// set up all your panels and frame properties

mainFrame.setContentPane(login);
mainFrame.pack();
//do stuff
if(login is successful)
mainFrame.setContentPane(loggedIn);
mainFrame.pack()
This way you keep your main window Frame the same at all times, and you're just swapping out different content panels. You can dispose of the content JPanels afterwards if need be. Be sure to call pack() after changing content panes to redraw the window appropriately.
RAID0R
(14 items)
 
  
CPUMotherboardGraphicsRAM
i5 750 4.0GHz MSI P55-GD80 GTX 470 | 8800GT PhysX 2x2GB G.Skill Ripjaws 
Hard DriveOptical DriveCoolingOS
60GB Agility 2|1TB RAID0|1.5TB Pioneer DVR-217D XSPC Raystorm | XSPC RX240 Windows 7 Professional x64 
MonitorKeyboardPowerCase
27" Dell 2709W | 17" Samsung Logitech G15 Corsair HX850 Corsair 650D 
Mouse
Microsoft IntelliMouse 
  hide details  
Reply
RAID0R
(14 items)
 
  
CPUMotherboardGraphicsRAM
i5 750 4.0GHz MSI P55-GD80 GTX 470 | 8800GT PhysX 2x2GB G.Skill Ripjaws 
Hard DriveOptical DriveCoolingOS
60GB Agility 2|1TB RAID0|1.5TB Pioneer DVR-217D XSPC Raystorm | XSPC RX240 Windows 7 Professional x64 
MonitorKeyboardPowerCase
27" Dell 2709W | 17" Samsung Logitech G15 Corsair HX850 Corsair 650D 
Mouse
Microsoft IntelliMouse 
  hide details  
Reply
post #16 of 16
Another advantage of Swing is that you can ditch the ye olde
Code:
window.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }            
        });
and just use
Code:
myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Serene Power
(13 items)
 
  
CPUMotherboardGraphicsRAM
Dual Xeon E5620 Supermicro X8DAL-i EVGA 570HD SC 8GiB Corsair DDR3 1333 ECC-R 
Hard DriveOptical DriveOSMonitor
OCZ Agility 3 120GB SSD (+16TB NAS) LG 10x Blu-Ray Windows 7 x64 / Debian x64 Dell 2408WFP, P2411H 
PowerCase
850W CoolerMaster SilentPro M CoolerMaster Cosmos Pure 
  hide details  
Reply
Serene Power
(13 items)
 
  
CPUMotherboardGraphicsRAM
Dual Xeon E5620 Supermicro X8DAL-i EVGA 570HD SC 8GiB Corsair DDR3 1333 ECC-R 
Hard DriveOptical DriveOSMonitor
OCZ Agility 3 120GB SSD (+16TB NAS) LG 10x Blu-Ray Windows 7 x64 / Debian x64 Dell 2408WFP, P2411H 
PowerCase
850W CoolerMaster SilentPro M CoolerMaster Cosmos Pure 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming