This week's book giveaway is in the General Computing forum.
We're giving away four copies of Learning Regular Expressions and have Ben Forta on-line!
See this thread for details.
Win a copy of Learning Regular Expressions this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

JFrame - Hidden behind another JFrame  RSS feed

 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey all,

I am making Login\Registration forms.

From the "HTRMain" form I am calling my "DatabaseConnection" form. Both of those doesn't have any design nor can be visible.
After successful connection to database I am calling "LoginForm" with:



That form is now visible and everything is fine.



Now when I call "RegistrationForm" from "LoginForm" it just stays in bacground and I am able to call it as many times as I want.



When I click on "Registration" button it should dispute() "LoginForm" and open "RegistrationForm" and I am not sure what have I done wrong.



I noticed that wherever I click on (Open word, paint,..., other software) it always stay in front of everything. I guess that is some option in that jframe that I should change?
 
Ranch Hand
Posts: 84
3
MS IE Notepad Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well - as this java - GUIs called Frame or Window - calling it "Form" is kinda off and sounds like DotNET

as the screenshot shows you're using a plain window or a frame with decoration disabled - you should start by using regular frames without disabling decoration so you get default titlebar to grab and move them around

also - as you noted it also stays ontop of other programs - you might have enabled alwaysOnTop - wich I even don't know any good use for

may I ask: did you wrote the gui code yourself or did you use a gui-builder?
 
Josip Skako
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Matt Wong wrote:well - as this java - GUIs called Frame or Window - calling it "Form" is kinda off and sounds like DotNET

as the screenshot shows you're using a plain window or a frame with decoration disabled - you should start by using regular frames without disabling decoration so you get default titlebar to grab and move them around
also - as you noted it also stays ontop of other programs - you might have enabled alwaysOnTop - wich I even don't know any good use for

may I ask: did you wrote the gui code yourself or did you use a gui-builder?



Well it was "alwaysOnTop" enabled indeed. Thank You.
Only useful thing to use that function are sticky notes, I think.

One more question, now the "RegistrationForm" is in front of "LoginForm".
What is the best way to "Hide" LoginForm and enable it when user exit or confirm "RegistrationForm".
Should I use ".setVisible(false)" or ".dispute()" and where should I put it if that is best way?

I'll have few more questions while working on this but I guess that would be in other post, thank You
 
Ranch Foreman
Posts: 115
1
Android Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Should I use ".setVisible(false)" or ".dispute()"


I guess you mean .dispose() ?
 
Bartender
Posts: 620
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't say what kind of Class yur LoginForm and RegistrationForm are, but you really should be using JDialog for this, with each JDialog specified to be APPLICATION_MODAL.

Then when the dialog is made visible, the user can only interact with that dialog until the dialog is dismissed.
 
Matt Wong
Ranch Hand
Posts: 84
3
MS IE Notepad Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well - choosing between setVisible and dispose depends on use case
to just hide something - setVisible is fine
if you want to get rid of something - and you will to terminate EDT - you have to use dispose

reason: if you hide a top-level container the gui EDT is kept alive so your application wont terminate - so you have to call dispose in the end to completely shutdown the grapgics subsystem so you can end your program

as a personal side-note: as your screenshot looks rather advanced - you seem to lack the basics
I would recommend to put your current project aside on hold and first learn the basics about GUIs in java to understand what's happen under the hood
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!