Solved

How to make the application fix on the desktop.

Posted on 2013-07-01
5
235 Views
Last Modified: 2013-07-18
I want to make my java based window form to appear in such a way so that it occupies whole window, and user is not able to minimize or close the application unless he enters his username and password.
0
Comment
Question by:searchsanjaysharma
  • 2
  • 2
5 Comments
 
LVL 35

Expert Comment

by:girionis
ID: 39292892
I am not sure if you can do this with Java, you can have a full screen application but the user would still be able to close the windows by pressing control + F4 for instance.

For a full screen windows you can use the full screen exclusive mode API, or set the preferred size to the size of the screen.

You can also set the default close operation (setDefaultCloseOperation) on the jframe to do nothing on close, so the user won't be able to close the windows on pressing the x button.
0
 
LVL 16

Accepted Solution

by:
Valeri earned 500 total points
ID: 39297379
As I told you in my previous answer the only way to do this with JFrame is to remove the three buttons
frame.setUndecorated(true);
that's the only way to avoid minimize and close! The app will be maximized by default.
So:
1. You can prevent "close" by Alt+F4 and by right click and select close with setDefaultCloseOperation and cancelation of close.
2. Switch to other applications by using "Alt+Tab" could be prevented with
frame.setAlwaysOnTop(true);
3. Maximaizing of the undecorated frame could be done by :
frame.setExtendedState(JFrame.MAXIMIZED_BOTH);

So, when the user enters username and password corectly you can close or iconify the app.
Hope it will help you, but you never listen to my comments. All of them are writen having in mind that you are writing app responsible to lock the PS's in Internet club or something like that...?! If it's not the case ignore my comment!

Here is the class:

import javax.swing.JFrame;
public class RemoveJFrameTitleBar {
      public static void main(String[]args){
            //Create a JFrame
            JFrame frame=new JFrame();
            //Method setUndecorated(true) will eliminate JFrame title bar
            frame.setUndecorated(true);
            frame.setAlwaysOnTop(true);
            frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
            frame.setVisible(true);            
      }
}
0
 
LVL 35

Expert Comment

by:girionis
ID: 39299675
I still believe you cannot do this with Java. The user will still be able to close it if (s)he starts the task manager. The closest you can get is what Valeri suggested.
0
 
LVL 16

Expert Comment

by:Valeri
ID: 39299821
ah, yes! girionis is right!
task manager also must be disabled before that, with administrator account.
see how:

http://www.windowsnetworking.com/kbase/WindowsTips/WindowsXP/UserTips/Customization/EnableDisableTaskManagerinWindowsXPHomePro.html

also valid for windows 7
0
 

Author Closing Comment

by:searchsanjaysharma
ID: 39336606
tx
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question