简体   繁体   English

JFrame卡住了,我无法跨过屏幕

[英]JFrame stuck, i can't move across sreen

I made a frame with some labels and a button on it, created an executable ear and now when i start it i can't move the application on my screen. 我做了一个带有一些标签和一个按钮的框架,创建了一个可执行的耳朵,现在当我启动它时,我无法在屏幕上移动该应用程序。 Sometimes it works, sometimes it doesn't. 有时它起作用,有时却不起作用。 I just can't drag the thing.. 我就是不能拖东西。

  JFrame frame = new JFrame("Name"); frame.setPreferredSize(new Dimension(260, 160)); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JButton exitButton = new JButton("Exit"); exitButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { System.exit(0); } }); frame.add(exitButton, BorderLayout.SOUTH); frame.add(vertBox, BorderLayout.CENTER); frame.setVisible(true); frame.pack(); frame.setLocationRelativeTo(null); 

Any ideas what's wrong? 任何想法有什么问题吗? It's really annoying that i can't move it. 我不能动它真是令人讨厌。 PS There is a code part that i skipped, where i made the labels and added them PS:我跳过了一个代码部分,在其中做了标签并添加了标签

Perhaps (in the code you didn't show) you were disabling your frame through 也许(在您未显示的代码中)您正在禁用框架

frame.setEnabled(false); frame.setEnabled(false);

PS: I know it has been 2 years since you asked the question, but it might help someone else PS:我知道距您提出问题已有2年了,但这可能会对其他人有所帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM