我是按照写Frame的方式写JFrame
不能这么写么 让他消除窗口装饰
import javax.swing.JFrame;
public class camera
{
JFrame j=new JFrame();
public camera()
{
init();
}
public void init()
{
j=new JFrame();
j.setVisible(true);
j.setUndecorated(true); //去掉窗口装饰
j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
j.setVisible(true);
j.setExtendedState(JFrame.MAXIMIZED_BOTH);
}
public static void main(String args[])
{
new camera();
}
}
不能这么写么 让他消除窗口装饰
import javax.swing.JFrame;
public class camera
{
JFrame j=new JFrame();
public camera()
{
init();
}
public void init()
{
j=new JFrame();
j.setVisible(true);
j.setUndecorated(true); //去掉窗口装饰
j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
j.setVisible(true);
j.setExtendedState(JFrame.MAXIMIZED_BOTH);
}
public static void main(String args[])
{
new camera();
}
}
public class DecoratedFrame extends JFrame {
public DecoratedFrame() {
this.getContentPane().add(new JLabel("Just a test."));
this.setUndecorated(true); // 去掉窗口的装饰
this.getRootPane().setWindowDecorationStyle(JRootPane.NONE);//采用指定的窗口装饰风格
this.setSize(300,150);
}
public static void main(String[] args) {
JFrame frame = new DecoratedFrame();
frame.setVisible(true);
}
} 试试 这个
没看懂啊, 我的类名不是窗口名,JFrame 是在类里面定义的不想用this 直接用JFrame 的名字setUndecorated(true)不行吗
public class camera
{
JFrame j=new JFrame();
public camera()
{
j.setVisible(true);
// j.setUndecorated(true); //去掉窗口装饰
JFrame.setDefaultLookAndFeelDecorated(false);
j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
j.setVisible(true);
j.setExtendedState(JFrame.MAXIMIZED_BOTH); }
public static void main(String args[])
{
new camera();
}
}
所以 后面调用 j.setUndecorated(true); //去掉窗口装饰
就去不掉的。将j.setUndecorated(true); 放在setVisible(true); 前在就好了。
你要把 j.getRootPane().setWindowDecorationStyle(JRootPane.NONE);//采用指定的窗口装饰风格
j.setSize(300,150); 这两句添加上