Solved

How to make the application fix on the desktop.

Posted on 2013-07-01
5
231 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now