swing jframe全屏顯示無邊框

import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Toolkit;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;

/**
 * swing jframe全屏顯示無邊框
 * @author ZFang
 */
public class FullScreenDemo {
	private static final JLabel label = new JLabel(new ImageIcon("C:\\ZFang.jpg"));

	public static void main(String[] args) {
		JFrame jframe = new JFrame();
		// jframe.getContentPane().setLayout(new FlowLayout());
		jframe.getContentPane().add(label);
		//卸掉窗口裝飾 title欄 最小化最大化關閉按鈕等
		jframe.setUndecorated(false);
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		Rectangle bounds = new Rectangle(screenSize);
		jframe.setBounds(bounds);
		jframe.setUndecorated(true);
		//一直在最上層顯示
		jframe.setAlwaysOnTop(true);
		jframe.setVisible(true);
	}
}
相關文章
相關標籤/搜索