• Post Reply Bookmark Topic Watch Topic
  • New Topic

Panel inside dialog box  RSS feed

 
Seema Sharma
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am trying to place panel having button inside a dialog box. But the following code does execute. Let me know where did i go wrong.



Thanks in advance.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
perhaps you need to call
show();
at the end of init()
 
Seema Sharma
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Michael.

Its working. Now i am trying to setLayout as "null" for dialog box which is a parent frame and place few components on it. What i see is dialog box is empty and no components are seen. When i comment line (1) and line (2) as shown in code, it works fine but without layout. Please let me know how can i set layout.



Thanks in advance.
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you set a JPanel's layout to "null" and then add a component to the JPanel, you are fully responsible for setting the component's position and size (often done with a call to the component's setBounds() method).

I advise against your using null layouts unless you have a very good reason to do so.
 
Seema Sharma
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
The code mentioned in previous mail is not accepting any changes if i comment line (1) and (2) as mentioned in code.
1. I tried using Border layout but no changes are reflected.
2. I am trying to change the title bar color by using the following line of code but no changes are reflected:


what went wrong in the code in the previous mail.

Thanks in advance.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> UIManager.put("activeCaption", new javax.swing.plaf.ColorUIResource(Color.YELLOW));

where you copied that line from, also copy/include the line that follows
 
Seema Sharma
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
I have include the code for changing title bar color, i.e., lines (a) and (b), after my dialog box instance is created. Here my dialog box is a parent frame. Yet changes are not reflected in my code.



Please let me know.

Thanks in advance.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> I have include the code for changing title bar color, after my dialog box instance is created.

if you ordered a new car, would you wait until after it was built to tell them what color you wanted?

if you want this for a dialog
JFrame.setDefaultLookAndFeelDecorated(true);
change to
JDialog.setDefaultLookAndFeelDecorated(true);
 
Seema Sharma
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Michael,
I got it. The code is working now.

Regards,
Seema
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!