1

I have a JFrame that sometimes I need it to act as a frame with it's own task-bar icon, but also I need to use it as a JDialog without task-bar icon and modal of a parent frame.

Is that possible? I don't know how to implement it, so I can't put any code.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Cako
  • 396
  • 3
  • 15
  • 4
    *"Is that possible?"* Sure. Design the GUI in a `JPanel`, then show the panel in a modal dialog or frame as required. But I really have to wonder what use-case calls for either showing it in a frame, or the choice between the two modes. See [The Use of Multiple JFrames, Good/Bad Practice?](http://stackoverflow.com/q/9554636/418556) – Andrew Thompson Apr 17 '15 at 21:21
  • @AndrewThompson so for this I am asking, this. The frame is a selector with buttons and I need to act is as a JFrame when the application starts and as a dialog when it works a as a selector with toggle buttons and I don't want to repeat code with a JDialog and a JFrame – Cako Apr 17 '15 at 21:29
  • *"The frame is a selector with buttons and I need to act is as a JFrame when the application starts and as a dialog when it works a as a selector with toggle buttons."* Hmm.. 'what' but not a 'why'.. I'm more interested in the 'why'. – Andrew Thompson Apr 17 '15 at 21:31
  • What do you mean with why? – Cako Apr 17 '15 at 21:34
  • .. I don't get it - are you saying you don't understand what '[why](http://dictionary.reference.com/browse/why)?' means? See also [What is the XY problem?](http://meta.stackexchange.com/q/66377) – Andrew Thompson Apr 17 '15 at 21:41
  • No I know the meaning of why, I will explain better, The frame is the main window when the user opens the application. In that context I want it working as a JFrame, with it's icon on task-bar. But I have other frame that opens this and I want to open it as JDialog, with the modality of a parent window. – Cako Apr 17 '15 at 21:48

1 Answers1

0

I finally solved it by making the main component a JPanel and then embedding it in a JFrame or in a JDialog.

Thanks for the idea Andrew Thompson

Cako
  • 396
  • 3
  • 15