Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

disable alt+tab

  Asked By: Jayden    Date: May 18    Category: Java    Views: 2666
  

I need to know is it possible to disable the alt+tab while
running an application?for those people who had helped me with my
previous problem,thanks.i had disable buttons on the jframe.i used
setUndecorated(true); in fact it works like jwindow.now my
application with a mouse click or keypress,the black frame will be
dispose.but i need to disable the alt+tab so that user cannot switch
program using this.the only way they can end the application is by
disposing the frame.anyone have any idea on this

Share: 

 

3 Answers Found

 
Answer #1    Answered By: Nagina Mian     Answered On: May 18

have you try the lastest solution that I ever give you ?
that solution also could solve your alt tab problem.
(by using focuslistener)

 
Answer #2    Answered By: Whitney Cruz     Answered On: May 18

ya i tried but i think i miss out something somewhere,it cant seems
to work.

 
Answer #3    Answered By: Asir Hashmi     Answered On: May 18

ok..here is the example I made ...

--- code ----

import java.awt.* ;
import java.awt.event.* ;

import javax.swing.* ;


public class RadioButton {
public static void main(String[] args) {
RadioButtonFrame frame  = new RadioButtonFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.show();
}
}

class RadioButtonFrame extends JFrame
{
public RadioButtonFrame()
{
setTitle("Radio Button Test");
setSize(400,200);

Container contentPane = getContentPane();
label = new JLabel("The quick brown fox jumps over the lazy dog");
label.setFont(new Font("Serif",Font.PLAIN,12));
contentPane.add(label, BorderLayout.CENTER);

buttonPanel = new JPanel();

group = new ButtonGroup();
addRadioButton("Small", 8);
addRadioButton("Medium", 12);
addRadioButton("Large", 18);
addRadioButton("Extra Large", 36);

contentPane.add(buttonPanel, BorderLayout.SOUTH);

WindowFocusListener listen = new WindowFocusListener()
{
public void windowLostFocus(WindowEvent e) {
System.out.println("Window FOcus Listener : focus lost");
// requestFocus();
setLocation(200,300);
show();
}

public void windowGainedFocus(WindowEvent e) {
System.out.println("window focus listener : gain focus ");
}
};

addWindowFocusListener(listen);
}

public void addRadioButton(String name, final int size)
{
boolean selected = size == 12 ;
JRadioButton button = new JRadioButton(name,selected);
group.add(button);
buttonPanel.add(button);

ActionListener listener =
new ActionListener(){
public void actionPerformed(ActionEvent e) {
label.setFont(new Font("Serif",Font.PLAIN,size));
}
};
button.addActionListener(listener);


}

private JLabel label ;
private JPanel buttonPanel ;
private ButtonGroup group ;
}

-- end  of code --

 
Didn't find what you were looking for? Find more on disable alt+tab Or get search suggestion and latest updates.




Tagged: