Results 1 to 8 of 8
- 10-14-2009, 03:34 PM #1
JTextArea in Full-Screen Exclusive Mode
Can we put a JTextArea in a frame to display in Fullscreen Exlcusive mode. I tried and the result is depressed.
If I put these lines of code in my program, the full-screen exclusive mode is not showed up :
But then I removed it and the full-screen mode is showed up properly. Is there any idea about this problem?Java Code:JTextArea textArea = new JTextArea(20, 30); textArea.setLineWrap(true); textArea.setEditable(false); JScrollPane scrollPane = new JScrollPane(textArea); JPanel panel = new JPanel(); panel.add(scrollPane);
If JTextArea is the problem then is there a way to put multiple lines text on a JFrame in Fullscreen Exclusive mode?
Thanks in advance!Write a program to achieve anything you want in your life!
-
Perhaps I'm missing something (which happens too often), but I don't see anything in that code that would prevent full-screen mode from working. You may wish to create and post a small workable program that compiles, runs, requires no external resources, and which demonstrates your problem (an SSCCE), and let us play with it. Much luck.
- 10-14-2009, 05:12 PM #3
Thanks for replying. Here is the code, I hope you can spend a little time to look through. The program is long, but it's straightforward :
Java Code:import java.awt.*; import java.awt.event.*; import javax.swing.*; public class FullScreenTest { public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { GraphicsEnvironment en = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] devices = en.getScreenDevices(); for (int i = 0; i < devices.length ; i++) { FullScreenFrame frame = new FullScreenFrame(devices[i]); frame.enterFullScreen(); } } }); } } class FullScreenFrame extends JFrame { private GraphicsDevice graphicsDevice; private DisplayMode originalMode; private JPanel northPanel; private JPanel southPanel; private JTextArea textArea; private JButton exitButton; public FullScreenFrame(final GraphicsDevice graphicsDevice) { this.graphicsDevice = graphicsDevice; // save the original display mode for restoring to original mode purpose originalMode = graphicsDevice.getDisplayMode(); // this panel is used to hold the JTextArea northPanel = new JPanel(); // create a text area to hold text textArea = new JTextArea(20, 30); textArea.setLineWrap(true); textArea.setEditable(false); JScrollPane scrollPane = new JScrollPane(textArea); northPanel.add(scrollPane); // a JButton to exit the fullscreen exclusive mode exitButton = new JButton("Exit"); southPanel = new JPanel(); southPanel.add(exitButton); add(northPanel, BorderLayout.NORTH); add(southPanel, BorderLayout.SOUTH); // Register an ActionListener for the exitButton exitButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { // Restore the original display mode graphicsDevice.setDisplayMode(originalMode); graphicsDevice.setFullScreenWindow(null); // Exit the application System.exit(0); } }); } // Method to enter the fullscreen exclusive mode public void enterFullScreen() { // Check whether the full-screen exclusive mode is supported on this system if(graphicsDevice.isFullScreenSupported()) { setUndecorated(true); setResizable(false); setIgnoreRepaint(true); graphicsDevice.setFullScreenWindow(this); validate(); } else { // If the full-screen exclusive mode is not supported, show a dialog box to prompt a message JOptionPane.showMessageDialog(null, "Full-Screen Exclusive Mode is not supported!"); } } }Write a program to achieve anything you want in your life!
-
I compiled your code, and on my computer (windows xp, java 1.6), full-screen mode appeared to work just fine with or without adding the JTextArea / JScrollPane. So I have no idea what is the cause of your problem. Could it be an OS or hardware dependent issue? Have you searched the Java bug database?
Much luck
- 10-14-2009, 06:57 PM #5
Senior Member
- Join Date
- Jul 2009
- Posts
- 1,143
- Rep Power
- 5
I use the same configuration. (build 1.6.0_07-b06) and I also have problems. When I run the code with the following line comment out I get full screen mode:and on my computer (windows xp, java 1.6),
// northPanel.add(scrollPane);
When the line is uncommented, I don't get full screen mode (nothing is displayed) and my computer freezes up.
I have this old code I found on the web lying around. I can display a text area using this code, however, the text area cannot accept input. Seems to me its like the problem of using a JWindow, that can't accept focus unless it was created specifying a parent JFrame.
I have no idea what the solution is, but here is the other code which seems to work a little better (for me anyway):
Java Code:import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; public class FullScreen01 extends JFrame implements ActionListener{ private GraphicsDevice graphicsDevice; private DisplayMode origDisplayMode; private JButton exitButton = new JButton( "Exit Full-Screen Mode"); public static void main(String[] args){ //Get and display a list of graphics devices solely for // information purposes. GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] devices = graphicsEnvironment.getScreenDevices(); for(int cnt = 0;cnt < 1;cnt++){ System.out.println(devices[cnt]); }//end for loop //Construct a full-screen object using // graphicsDevice 0. new FullScreen01(devices[0]); }//end main //Constructor public FullScreen01(GraphicsDevice graphicsDevice){ //Save a reference to the graphics device as an // instance variable so that it can be used later to // exit the full-screen mode. this.graphicsDevice = graphicsDevice; setTitle("This title will be hidden (undecorated)"); //Get and save a reference to the original display // mode as an instance variable so that it can be // restored later. origDisplayMode = graphicsDevice.getDisplayMode(); //Register an action listener on the exitButton. exitButton.addActionListener(this); //Place the exitButton in the JFrame getContentPane().add(exitButton, BorderLayout.NORTH); //Place four labels in the JFrame solely for the // purpose of showing that it is a full-screen // undecorated JFrame. JLabel eastLabel = new JLabel(" East "); eastLabel.setOpaque(true); eastLabel.setBackground(Color.RED); getContentPane().add(eastLabel,BorderLayout.EAST); JLabel southLabel = new JLabel("South",SwingConstants.CENTER); southLabel.setOpaque(true); southLabel.setBackground(Color.GREEN); getContentPane().add(southLabel,BorderLayout.SOUTH); JLabel westLabel = new JLabel(" West "); westLabel.setOpaque(true); westLabel.setBackground(Color.RED); getContentPane().add(westLabel,BorderLayout.WEST); // JLabel centerLabel = new JLabel("Center",SwingConstants.CENTER); // centerLabel.setOpaque(true); // centerLabel.setBackground(Color.WHITE); // getContentPane().add(centerLabel,BorderLayout.CENTER); JTextArea textArea = new JTextArea(20, 30); textArea.setText("I'm a JTextArea"); textArea.setLineWrap(true); textArea.setEditable(false); JScrollPane scrollPane = new JScrollPane(textArea); getContentPane().add(scrollPane,BorderLayout.CENTER); if (graphicsDevice.isFullScreenSupported()){ // Enter full-screen mode witn an undecorated, // non-resizable JFrame object. setUndecorated(true); setResizable(false); //Make it happen! graphicsDevice.setFullScreenWindow(this); validate(); }else{ System.out.println("Full-screen mode not supported"); }//end else }//end constructor //The following method is invoked when the used clicks // the exitButton public void actionPerformed(ActionEvent evt){ //Restore the original display mode graphicsDevice.setDisplayMode(origDisplayMode); //Terminate the program System.exit(0); }//end actionPerformed }//end classListing 26
- 10-14-2009, 07:46 PM #6
People said the world is small, and I think that internet made it smaller :D. This program is one of more than 600 tutorials of Richard G Baldwin and @camickr : I read so many tutorials in this series but I don't even touch them to find a solution for this problem. Such a shame! :(. Thank you!
You can not enter text in the JTextArea because the setEditable() method has been disabled :
@Fubarable : where can I find the Java's bug database? Thank you!Java Code:textArea.setEditable(false);
Anyone who interested in the useful series of Richard G Baldwin can take a look at this : dickbaldwin.com (2 more posts to be able to post hyperlink :D)Write a program to achieve anything you want in your life!
- 10-14-2009, 08:02 PM #7
In my program, I add some text inside the JTextArea and I got Full-Screen Exclusive Mode.
For the first thought, I thought this was the solution. But then for sure in camickr example, I cleared the line :Java Code:textArea.setText("haha");
and the program still works!Java Code:textArea.setText(""I am a JTextArea!);
Uncomprehensible! The solution is still in the dark =))Write a program to achieve anything you want in your life!
- 10-14-2009, 08:10 PM #8
Similar Threads
-
How can I implement this in Full-Screen Exclusive Mode
By Willi in forum AWT / SwingReplies: 4Last Post: 10-13-2009, 02:10 PM -
Open a shell maximized (full screen)
By Java Tip in forum SWTReplies: 0Last Post: 07-25-2008, 02:27 PM -
Full screen test
By Java Tip in forum java.awtReplies: 0Last Post: 06-23-2008, 11:24 PM -
how to set full screen dimensions
By valery in forum New To JavaReplies: 1Last Post: 08-03-2007, 06:08 PM -
Full screen
By Jack in forum Advanced JavaReplies: 2Last Post: 07-02-2007, 05:49 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks