• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Dialogs

 
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have a dialog that calls another one while pressing a button. I would like that the first dialog is blocked till the second one is opened. How to do?

i have a dialog made with netbean, i have some jLables and a jTextField that even if i change them the name, always have the old name, why??
 
Sheriff
Posts: 22821
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Antony Amicone wrote:i have a dialog that calls another one while pressing a button. I would like that the first dialog is blocked till the second one is opened. How to do?


Make it modal.
 
Antony Amicone
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
newbie sorry... can you tell me more?
 
Ranch Hand
Posts: 156
Python Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try looking here:
http://download.oracle.com/docs/cd/E17409_01/javase/tutorial/uiswing/components/dialog.html

Oracle has a lot of Java tutorials online, you should take a look at them sometimes, especially if you're a newbie.
 
Marshal
Posts: 80288
433
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to our GUIs forum, where we usually discuss that sort of question.
 
Antony Amicone
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ty i read that page, i know that i need to use .setvisible() but a lil problem :P when i calls the second window, i am into the first, so i do secondwindows.setVisible(true) but how can i call the method on the window i already am? i am in that class already
 
Jan Hoppmann
Ranch Hand
Posts: 156
Python Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
With this.setVisible();. this always references the current object.
 
Antony Amicone
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jan Hoppmann wrote:With this.setVisible();. this always references the current object.


was the same thing i tried, but when i call this. it only show me few things, not the setVisible, probably cause i call the other dialog in a button action

 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
in your first post
"i have a dialog that calls another one while pressing a button."
then in your 3rd post
"when i calls the second window, i am into the first, so i do secondwindows.setVisible(true) but how can i call the method on the window i already am? i am in that class already"

so, you state you are doing 'something', then you later ask how to do that same 'something'?

smells troll-ish to me.
 
Antony Amicone
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Michael Dunn wrote:in your first post
"i have a dialog that calls another one while pressing a button."
then in your 3rd post
"when i calls the second window, i am into the first, so i do secondwindows.setVisible(true) but how can i call the method on the window i already am? i am in that class already"

so, you state you are doing 'something', then you later ask how to do that same 'something'?

smells troll-ish to me.



you didnt got what i said :P

i have a dialog FIRSTDIALOG, when i press a button it launch another dialog SECONDDIALOG.
so in the Action of the button i have the call to SECONDDIALOG with mydialog x = new mydialog(); x.setVisible(true);
i need that till this SECONDDIALOG is opened, the FIRSTDIALOG is blocked or hidden, but i am already in the action of a button so if i call this, it doesnt take my FIRSTDIALOG
and doesnt show me this.setVisible(true) in the method options

how solve? i should get the instance of the parent window i think, but dunno how to do that


 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
> you didnt got what i said

and I probably still don't get what you said.

"i need that till this SECONDDIALOG is opened, the FIRSTDIALOG is blocked or hidden"

if you want it blocked, you were given the answer in the first reply to your post.

if your problem is hiding the dialog, then
this.setVisible(false);
won't work inside actionPerformed. Depends on how you've structured the listener

if it's an inner class of an extended JDialog e.g. 'class MyDialog extends JDialog'
this.setVisible(false);
would need to be
MyDialog.this.setVisible(false);

if a separate class, you'd need to pass a reference of the dialog to the listener class
 
Antony Amicone
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Michael Dunn wrote:
if a separate class, you'd need to pass a reference of the dialog to the listener class


this! thank you micheal i dunno why i didnt think bout that, lool was easy :)

aehm ok dunno how to do looool

the MAIN is in class mainClass, and it create a windows with class DesktWindows

in the DesktopWindows ( that is the one i should hide ) i call the class DeskEvent where i have the actionlistener to the button that open the SecondWindow

so DesktioWindows call a class with actionlistener, that open another window... so i should pass the instance of Desktopwindow to the listener, but how can i get it?

 
Antony Amicone
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
helppppppppppppppppp
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
without knowing the class structures, specifically where DeskEvent is created,
all we can do is guess/suggest what to do.

post a simpified version of your program:
MainClass - just a JFrame with a button
DesktopWindows - JDialog with button
SecondWindow = JDialog, doesn't need anything, just a size
DeskEvent - code that opens SecondWindow
include the listener code that opens DesktopWindows

without the above, we don't know how/where DeskEvent is created
i.e. where 'new DeskEvent()' is called
we don't know whether DesktopWindows is a JDialog, or uses a JDialog
etc etc.
 
Antony Amicone
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Main


FIRST WINDOW


EVENT HANDLER


SECOND WINDOW

 
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When Michael was asking you to post a simple version of your program he meant a compilable version. Given that your code as posted doesn't compile, there's no way we can run it, test it or modify it. All I can do is to reiterate what has been posted before: pass a reference of the original dialog or window to the listener which can be done via the listener's constructor or via a setter method -- this has nothing to do with GUI coding but rather is nothing but basic bread and butter Java and nothing more.

Much luck.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't have many of the classes you're using (org.desktop's etc),
so all I can do is modify your code to what I think they may be - dialog's etc

you can run this as one .java file, click the button to show second window,
and you'll see firstWindow disappear (hide) at the same time as secondWindow shows.

 
Antony Amicone
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator








is it ok now? lol hope i dont need to remove all button
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Michael's post shows the solution to your problem -- you can't go wrong following any suggestions he has to give. You may wish to have a look at this link as it will help you learn how to understand the underpinnings of Swing and thereby create better Swing code: Using Swing Components

Much luck!
 
Antony Amicone
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i know is confused that code, i usually write the code but this time i wanted to try netbeans to create a dialog.

i'm gonna reading the page you told me, but is there the answer i need? i dunno how to do that
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Antony Amicone wrote:i know is confused that code, i usually write the code but this time i wanted to try netbeans to create a dialog.


Your netbeans generated code though is too long for us to reasonably go through and modify. This is why we asked you for a simplified version. We don't want to see the whole program but rather just a small compilable program that demonstrates your problem and that we can easily understand and modify.


i'm gonna reading the page you told me, but is there the answer i need? i dunno how to do that


My link is to the Sun Swing tutorials. As I mention above, Michael's posts solve your immediate problem.
 
Antony Amicone
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

pete stein wrote:

Antony Amicone wrote:i know is confused that code, i usually write the code but this time i wanted to try netbeans to create a dialog.


Your netbeans generated code though is too long for us to reasonably go through and modify. This is why we asked you for a simplified version. We don't want to see the whole program but rather just a small compilable program that demonstrates your problem and that we can easily understand and modify.


i'm gonna reading the page you told me, but is there the answer i need? i dunno how to do that


My link is to the Sun Swing tutorials. As I mention above, Michael's posts solve your immediate problem.



i know, tell me, how should i write the code here? removing all buttons?

i know i have to simply pass the instance to the new dialog, but how??? from the starting dialog?
 
Antony Amicone
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok solved..... now another question, how can i set the dialog not resizable? i hate the way it resize
 
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


 
Rob Spoor
Sheriff
Posts: 22821
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check the Javadocs of JDialog and its super class, all the way up the chain until you find a method you like.
 
Antony Amicone
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i need the instance of the dialog i have there is not getInstance or similar?
 
Rob Spoor
Sheriff
Posts: 22821
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't you have a reference to it already?
 
She'll be back. I'm just gonna wait here. With this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic