FullScreenDemo.java:
Java代码
1. package FullScreenDemo;
2.
3. import java.awt.*;
4.
5. import javax.swing.*;
6.
7. /**
8. * @author http://xp9802.iteye.com/
9. * 2011-11-19下午04:40:38
10. */
11. public class FullScreenDemo {
12.
13. public static void main(String[] args) {
14. final JFrame jframe = new JFrame();
15. new JButton("全屏显示");
16. new JButton("退出");
17. new java.awt.event.ActionListener() {
18. public void actionPerformed(java.awt.event.ActionEvent evt) {
19. 1);
20. }
21. });
22. new java.awt.event.ActionListener() {
23. public void actionPerformed(java.awt.event.ActionEvent evt) {
24. GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
25. //通过调用GraphicsEnvironment的getDefaultScreenDevice方法获得当前的屏幕设备了
26. GraphicsDevice gd = ge.getDefaultScreenDevice();
27. // 全屏设置
28. gd.setFullScreenWindow(jframe);
29. }
30. });
31. jframe.add(fullsButton);
32. jframe.add(exitButton);
33. new FlowLayout());
34. 400, 300);
35. true);
36. }
37. }
FullScreenDemo1.java:
Java代码
1. package FullScreenDemo;
2.
3. import java.awt.FlowLayout;
4.
5. import javax.swing.JButton;
6. import javax.swing.JFrame;
7. import javax.swing.UIManager;
8.
9. /**
10. * @author http://xp9802.iteye.com/
11. * 2011-11-19下午04:31:38
12. */
13. public class FullScreenDemo1 {
14.
15. public static void main(String[] args) {
16. new JFrame();
17. new JButton("退出");
18. new java.awt.event.ActionListener() {
19. public void actionPerformed(java.awt.event.ActionEvent evt) {
20. 1);
21. }
22. });
23. jframe.add(exitButton);
24. new FlowLayout());
25. false);
26. jframe.getGraphicsConfiguration().getDevice()
27. .setFullScreenWindow(jframe);
28. true);
29. }
30. }
FullScreenDemo2.java:
Java代码
1. package FullScreenDemo;
2.
3. import java.awt.Dimension;
4. import java.awt.FlowLayout;
5. import java.awt.Toolkit;
6.
7. import javax.swing.JButton;
8. import javax.swing.JFrame;
9.
10.
11. /**
12. * @author http://xp9802.iteye.com/
13. * 2011-11-19下午04:32:38
14. */
15. public class FullScreenDemo2 {
16. public static void main(String[] args) {
17. new JFrame();
18. new JButton("退出");
19. new java.awt.event.ActionListener() {
20. public void actionPerformed(java.awt.event.ActionEvent evt) {
21. 1);
22. }
23. });
24. jframe.add(exitButton);
25. new FlowLayout());
26. /**
27. * true无边框 全屏显示
28. * false有边框 全屏显示
29. */
30. false);
31. Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
32. jframe.setSize(d.width, d.height);
33. true);
34. }
35. }
FullScreenDemo3.java:
Java代码
1. package FullScreenDemo;
2.
3. import java.awt.Dimension;
4. import java.awt.FlowLayout;
5. import java.awt.Rectangle;
6. import java.awt.Toolkit;
7.
8. import javax.swing.JButton;
9. import javax.swing.JFrame;
10.
11. /**
12. * @author http://xp9802.iteye.com/
13. * 2011-11-19下午04:39:38
14. */
15. public class FullScreenDemo3 {
16.
17. public static void main(String[] args) {
18. new JFrame();
19. new JButton("退出");
20. new java.awt.event.ActionListener() {
21.
22. public void actionPerformed(java.awt.event.ActionEvent evt) {
23. 1);
24. }
25. });
26. jframe.add(exitButton);
27. new FlowLayout());
28. /**
29. * true无边框 全屏显示
30. * false有边框 全屏显示
31. */
32. false);
33. Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
34. new Rectangle(screenSize);
35. jframe.setBounds(bounds);
36. jframe.setExtendedState(JFrame.MAXIMIZED_BOTH);
37. true);
38. }
39. }