我正在使用Netbeans在Java中开发一个小应用程序.我使用JFrame作为基本控件,并根据需要拖放所有必需的控件.
应用程序正如预期的那样正常工作.现在我只是希望当我的应用程序第一次运行时,我的应用程序窗口的大小应该等于我的屏幕大小.简单来说,我希望我的应用程序在打开时最大化.以下是我的主要方法的代码:
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
MyUI myframe = new MyUI();
myframe.setTitle("my tiltle");
myframe.setVisible(true);
//new GPrideUI().setVisible(true);
}
});
}
Run Code Online (Sandbox Code Playgroud) 我正在试图找到一种方法使Java应用程序对用户不可见.
基本上只是试图删除这个
< - 图像
如何才能做到这一点?
public class TransparentWindow extends JFrame {
public TransparentWindow() {
initComponents();
}
@SuppressWarnings("unchecked")
private void initComponents() {
setExtendedState(Frame.MAXIMIZED_BOTH);
setResizable(false);
setUndecorated(true);
setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
setAlwaysOnTop(true);
System.setProperty("sun.java2d.noddraw", "true");
WindowUtils.setWindowTransparent(this, true);
WindowUtils.setWindowAlpha(this, 0.6f);
}
public static void main(String[] args) {
new TransparentWindow().setVisible(true);
}
}
Run Code Online (Sandbox Code Playgroud) 我可以从JFrame中删除边框以及最小化和关闭按钮吗?我不能使用JWindow,因为它无法处理我理解的keyListener.(至少不容易).我怎样才能做到这一点?
我有一个框架延伸JWindow(因为我想处理我的X和 - 按钮)所以我不希望它装饰.我的问题是,当我运行应用程序时,我无法拖动窗口 - 它已固定在某个位置.我的代码如下(类我很大所以我选择了相关部分):
公共类StatisticsMainFrame扩展JWindow {
public StatisticsMainFrame()
{
bodyPane = new JPanel();
bodyPane.setLayout(new BoxLayout(bodyPane, BoxLayout.X_AXIS));
sideBannerPane = new JPanel(); // program banner
buttonsPane = new JPanel(); // contains buttons
contentPane = new JPanel();
contentPane.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
contentPane.setPreferredSize(new Dimension(500,500));
// contentPane contains some panel for display data
Container container = new Container();
container.setLayout(new BoxLayout(container, BoxLayout.X_AXIS));
container.add(Box.createVerticalGlue());
container.add(sideBannerPane);
container.add(buttonsPane);
container.add(contentPane);
Container cont = new Container();
cont.setLayout(new BoxLayout(cont, BoxLayout.Y_AXIS));
//cont.add(Box.createHorizontalGlue());
//cont.add(custDecorationPane);
cont.add(container);
add(cont);
// Adding Panes
setAlwaysOnTop(true);
//setUndecorated(true);
pack();
}
public …Run Code Online (Sandbox Code Playgroud)