dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Displaying a JPanel as a dialog

  1. #1
    Join Date
    Jan 2003
    Posts
    9

    Angry Displaying a JPanel as a dialog

    OK, I realize this may seem a little strange but I really need some help on this. I have an application in which I would like to display a simple JPanel with a JTextField that allows the user to enter search text. I am also planning on adding a JList to the bottom of this Panel that displays the results. However, I can't seem to get a Panel to display when I call setVisible(true). Can a JPanel be used like a JDialog? If not, is there any way to remove the buttons like minimize, maximize and close?

    TIA,
    -=- Kevin

  2. #2
    Join Date
    Jan 2003
    Location
    Israel
    Posts
    137
    Hi Kevin,
    If I understand you correctly, you want to display an "undecorated" GUI window (like a "[J]Frame" or a "[J]Dialog"). If this is the case, and if you are using JDK 1.4, then you can use the "setDecorated()" method -- that is defined in both "java.awt.Frame" and "java.awt.Dialog". I suggest you check the javadocs for more details.

    There is also a relevant section in the latest version of "The Java Tutorial":

    http://java.sun.com/docs/books/tutor...usivemode.html

    If you are using an earlier version of the JDK, then you need to use "javax.swing.JWindow". Again, I suggest you peruse the javadocs for more details.

    By the way, this question is also an often asked one on the "comp.lang.java*" newsgroups. I think you would probably find more useful information if you searched the newsgroup archives. You can search them from here:

    http://groups.google.com

    Hope this helps you.

    Good Luck,
    Avi.

  3. #3
    Join Date
    Jan 2003
    Posts
    9
    Perfect!! I was actually planning on using the JWindow approach but I definitely like the undecorated JDialog idea better. As it turns out I am using the 1.4.1 SDK but I was unable to figure out what object has the setDefaultLookAndFeelDecorated method on it, so I ended up using the example from the javaDocs which works perfectly. Here's the code in case anyone else is interested:

    <code>
    JDialog dialog = new JDialog();
    dialog.setUndecorated(true);
    dialog.getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);
    </code>

    Thanks again,
    -=- Kevin

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)