File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dialogs

 
Antony Amicone
Ranch Hand
Posts: 125
  • 0
  • Mark post as helpful
  • send pies
  • 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??
 
Rob Spoor
Sheriff
Pie
Posts: 20369
44
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
newbie sorry... can you tell me more?
 
Jan Hoppmann
Ranch Hand
Posts: 147
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Campbell Ritchie
Sheriff
Pie
Posts: 47228
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to our GUIs forum, where we usually discuss that sort of question.
 
Antony Amicone
Ranch Hand
Posts: 125
  • 0
  • Mark post as helpful
  • send pies
  • 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: 147
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With this.setVisible();. this always references the current object.
 
Antony Amicone
Ranch Hand
Posts: 125
  • 0
  • Mark post as helpful
  • send pies
  • 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

 
Michael Dunn
Ranch Hand
Posts: 4632
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
helppppppppppppppppp
 
Michael Dunn
Ranch Hand
Posts: 4632
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Main


FIRST WINDOW


EVENT HANDLER


SECOND WINDOW

 
pete stein
Bartender
Posts: 1561
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator








is it ok now? lol hope i dont need to remove all button
 
pete stein
Bartender
Posts: 1561
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok solved..... now another question, how can i set the dialog not resizable? i hate the way it resize
 
Petar Thomas
Ranch Hand
Posts: 234
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


 
Rob Spoor
Sheriff
Pie
Posts: 20369
44
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i need the instance of the dialog i have there is not getInstance or similar?
 
Rob Spoor
Sheriff
Pie
Posts: 20369
44
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't you have a reference to it already?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic