0

Is there anyway I can add a JPanel in a Modal-less JDialog that also has Max/Min/Close buttons? Even when I do something like this, it does not show max/min button.

JFrame f1 = new JFrame("Book 1 (parent frame)");
            JDialog myDialog = new JDialog(f1);
            myDialog.setVisible(true);

I am looking to have a window like this which is modalless and have max/min buttons

enter image description here

Update: In these examples I can see modalless dialogs with max/min button but can't figure out why are they not working for me

Volatil3
  • 14,253
  • 38
  • 134
  • 263
  • @mKorbel What do you mean? – Volatil3 Jul 11 '14 at 12:25
  • @mKorbel Actually I want to add `JPanel` in Dialog and show max/min button. I tried this but it did not work either. MY main motive is to show JPanel based stuff in a Modalless Dialog – Volatil3 Jul 11 '14 at 12:28
  • JFrame has 3buttons(can be visible in TaskBar), JDialog only one, JWindow is without button, this is standard for windowing conceptand valid for most of Native OS's – mKorbel Jul 11 '14 at 12:28
  • for better help sooner post an SSCCE/MCVE, short, runnable, compilable – mKorbel Jul 11 '14 at 12:29
  • @Volatil3, why don't you use [JInternalFrame](http://docs.oracle.com/javase/7/docs/api/javax/swing/JInternalFrame.html) ? Also see how to [use it](http://docs.oracle.com/javase/tutorial/uiswing/components/internalframe.html) –  Jul 11 '14 at 12:36
  • @Arvind I need a window like this: http://www.docear.org/wp-content/uploads/2012/08/Docear4Word-Add-BibTeX-reference-in-Microsoft-Word.png – Volatil3 Jul 11 '14 at 12:41
  • @mKorbel Refer to this image(http://www.docear.org/wp-content/uploads/2012/08/Docear4Word-Add-BibTeX-reference-in-Microsoft-Word.png) I tried to achieve by adding `JPanel` in `JDialog`, it did not work for me. – Volatil3 Jul 11 '14 at 12:42
  • @mKorbel So are you saying that I don't need to put `JFrame` in a `JDialog` and can show it modalless? – Volatil3 Jul 11 '14 at 13:14
  • 1
    A complete example is shown [here](http://stackoverflow.com/a/11832979/230513); @mKorbel is [correct](http://stackoverflow.com/a/13718147/230513): `JDialog` should not be minimized. – trashgod Jul 11 '14 at 15:04

2 Answers2

0

The way I understand your question, you're trying to give a JPanel (which is inside a nonmodal window) windowing options.

A JPanel probably wouldn't work for this; instead, you should use a JInternalFrame, which allows you to accomplish this. It's a component which goes inside a window and which itself can be minimized, maximized, and dragged around.

APerson
  • 8,140
  • 8
  • 35
  • 49
0

Ok Finally this worked for me. It might be helpful for other readers.

JFrame.setDefaultLookAndFeelDecorated(true);
            JFrame f = new JFrame();
            f.setResizable(false);
            JPanel p = new JPanel(new GridBagLayout());
            JButton btn = new JButton("Exit");
            p.add(btn,new GridBagConstraints());
            f.getContentPane().add(p);
            f.setSize(400,300);
            f.setLocationRelativeTo(null);
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.setVisible(true);

I got impression that I need to put things in JDialog anyway while same could be achieved by using JFrame

Volatil3
  • 14,253
  • 38
  • 134
  • 263