• Post Reply Bookmark Topic Watch Topic
  • New Topic

Swing application without title bar  RSS feed

 
SteveThompson
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a swing application, and I would like it to run without the title bar, thus stopping the user from closing the window. I would like the user the only end the application using a button within the application.
Is this possible?
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Prior to JDK 1.4 you just use a JWindow. You can still use a JWindow with 1.4.x but if you want to use a JFrame there is a setDecorated(boolean) method. But then, it is a JWindow, so I don't know why Sun did that, but those are your options.
BTW - if you still want to be able to minimize and maximize and drag the frame around the screen (easily, can be done with JWindow, just have to use mouse listeners) then you can do a
frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
Then when the user clicks that X nothing will happen.
1 other thing, on a side note....
If this application is very every day Joe User, it is a good idea to stick with GUI conventions. Keep everything similar to how apps already function, otherwise the user can get confused and possibly think it is JAVA's fault?? It can happen. I know I considered doing what you want because there were things I needed to make sure got wrapped up with the app closed. But if you have a windowListener attached to your JFrame, you can catch the windowClosing() event, and handle all wrapping up in that method. I usually use it to make sure Databases are closed and the like. Just my opinion though.
[ April 05, 2003: Message edited by: Gregg Bolinger ]
 
SteveThompson
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Gregg.
Pity you're not based in the UK, I'd buy you a beer.
Another question will be coming soon.
This site is superb.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!