Problem with Full-screen mode

I've this code:

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

publicclass Main{

publicstaticvoid main(String[] args){

// Determine if full-screen mode is supported directly

GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();

GraphicsDevice gs = ge.getDefaultScreenDevice();

// Create a window for full-screen mode; add a button to leave full-screen mode

JFrame frame =new JFrame(gs.getDefaultConfiguration());

JWindow win =new JWindow(frame);

//creating panels

JPanel topPanel =new JPanel(new FlowLayout(FlowLayout.LEFT));

JPanel bottomPanel =new JPanel(new FlowLayout(FlowLayout.RIGHT));

//inserts into topPanel

JTextField textfield =new JTextField(20);

topPanel.add(textfield);

//inserts into bottomPanel

JButton exitButton =new JButton("Afslut");

bottomPanel.add(exitButton);

//inserts panels

win.add(topPanel, BorderLayout.NORTH);

win.add(bottomPanel, BorderLayout.SOUTH);

// Create a button that leaves full-screen mode

exitButton.addActionListener(new ActionListener(){

publicvoid actionPerformed(ActionEvent evt){

// Return to normal windowed mode

GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();

GraphicsDevice gs = ge.getDefaultScreenDevice();

gs.setFullScreenWindow(null);

System.exit(0);

}

});

try{

gs.setFullScreenWindow(win);

win.validate();

}catch (Exception ex){

System.out.println(ex);

}

}

}

It create a full-screen window with a JTextField and JButton to leave the program.

My problem is that I can't enter anything into my JTextField.

Hope somebody can help me.

[3151 byte] By [Dennis_Madsena] at [2007-10-3 10:47:29]
# 1
This is continued from this thread: http://forum.java.sun.com/thread.jspa?threadID=789248&tstart=0
CaptainMorgan08a at 2007-7-15 6:12:04 > top of Java-index,Desktop,Core GUI APIs...
# 2

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

public class Main

{

public static void main(String[] args)

{

// Determine if full-screen mode is supported directly

GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();

GraphicsDevice gs = ge.getDefaultScreenDevice();

// Create a window for full-screen mode; add a button to leave full-screen mode

JFrame frame = new JFrame(gs.getDefaultConfiguration());

//creating panels

JPanel topPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));

JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));

//inserts into topPanel

JTextField textfield = new JTextField(20);

topPanel.add(textfield);

//inserts into bottomPanel

JButton exitButton = new JButton("Afslut");

bottomPanel.add(exitButton);

//inserts panels

frame.add(topPanel, BorderLayout.NORTH);

frame.add(bottomPanel, BorderLayout.SOUTH);

// Create a button that leaves full-screen mode

exitButton.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent evt)

{

// Return to normal windowed mode

GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();

GraphicsDevice gs = ge.getDefaultScreenDevice();

gs.setFullScreenWindow(null);

System.exit(0);

}

});

gs.setFullScreenWindow(frame);

frame.setVisible(true);

}

}

sabre150a at 2007-7-15 6:12:04 > top of Java-index,Desktop,Core GUI APIs...
# 3
Well, when running your script, I don't get a full-screen window like my example-code. I just get a screen with maximum-size.
Dennis_Madsena at 2007-7-15 6:12:04 > top of Java-index,Desktop,Core GUI APIs...
# 4

> Well, when running your script, I don't get a

> full-screen window like my example-code. I just get a

> screen with maximum-size.

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

public class Main

{

public static void main(String[] args)

{

// Create a window for full-screen mode; add a button to leave full-screen mode

JFrame frame = new JFrame();

//creating panels

JPanel topPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));

JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));

//inserts into topPanel

JTextField textfield = new JTextField(20);

topPanel.add(textfield);

//inserts into bottomPanel

JButton exitButton = new JButton("Afslut");

bottomPanel.add(exitButton);

//inserts panels

frame.add(topPanel, BorderLayout.NORTH);

frame.add(bottomPanel, BorderLayout.SOUTH);

// Create a button that leaves full-screen mode

exitButton.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent evt)

{

// Return to normal windowed mode

GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();

GraphicsDevice gs = ge.getDefaultScreenDevice();

gs.setFullScreenWindow(null);

System.exit(0);

}

});

frame.pack();

frame.setExtendedState(Frame.MAXIMIZED_BOTH);

frame.setVisible(true);

}

}

sabre150a at 2007-7-15 6:12:04 > top of Java-index,Desktop,Core GUI APIs...
# 5
The frame must be visible before the window can accept any input. Check out this posting for a simple example: http://forum.java.sun.com/thread.jspa?forumID=57&threadID=675445
camickra at 2007-7-15 6:12:04 > top of Java-index,Desktop,Core GUI APIs...
# 6

Alternatively u can get the screen size and set Jframe size according to it--

import javax.swing.*;

import java.awt.*;

public class FullScreen extends JFrame {

public FullScreen() {

this.setTitle("FullScreen");

Dimension d=Toolkit.getDefaultToolkit().getScreenSize();

this.setSize(d.width,d.height);

this.setDefaultCloseOperation(EXIT_ON_CLOSE);

this.setVisible(true);

}

public static void main(String[] args) {

new FullScreen();

}

}

AmitavaDeya at 2007-7-15 6:12:04 > top of Java-index,Desktop,Core GUI APIs...
# 7
> Alternatively u can get the screen size and set> Jframe size according to it--But this does not set maximized, it just sets the frame to maximum size. Yes, there is a difference.
sabre150a at 2007-7-15 6:12:04 > top of Java-index,Desktop,Core GUI APIs...
# 8
Thanks..to do a setVisible at the frame was the solution :)
Dennis_Madsena at 2007-7-15 6:12:04 > top of Java-index,Desktop,Core GUI APIs...