[英]How do I make it so that my MousePressed listener only respons when I click in a certain area?
[英]How do I make so when I click my checkbox, a separate and editable frame opens?
我目前正在使用Java。 我已经创建了复选框,我想知道如何制作它,因此当单击复选框时,它会打开一个单独的框架,可以根据我的需要进行修改和编辑。 我听说,一组框架/组件可以工作。 任何帮助/解决方案将不胜感激。
如果我理解您的问题,则必须为复选框实现一个侦听器。 在该侦听器的主体中,应该有以下内容:
//1. Create the frame.
JFrame frame = new JFrame("FrameDemo");
//2. Optional: What happens when the frame closes?
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//3. Create components and put them in the frame.
//...create emptyLabel...
frame.getContentPane().add(emptyLabel, BorderLayout.CENTER);
//4. Size the frame.
frame.pack();
//5. Show it.
frame.setVisible(true);
第一点和第五点是最重要的 。
如果您不知道如何创建和注册复选框的侦听器,请尝试访问以下站点: http : //examples.javacodegeeks.com/desktop-java/awt/event/checkbox-listener-example/ http://docs.oracle .com / javase / tutorial / uiswing / components / button.html
希望此建议对您有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.