![](/img/trans.png)
[英]why ActionListener is not implemented when creating GUI using window builder in eclipse?
[英]Is their a way to make your java GUI (using Window Builder) possible to work with Graphics in eclipse?
我正在尝试使用 2D 图形并使其与 eclipse 中的 Window Builder 一起工作,我尝试了很多如何使用它的组合,但我一直收到错误,它不会让我运行它,因为它会给我语法错误或其他东西甚至不会工作。
我尝试制作一种方法并尝试制作 Rectangle 形状但没有用。 我喜欢解决这个问题,但我不确定这将如何解决。
代码示例是,
该代码将是基础。
package com.cookie.clicker;
import java.awt.EventQueue;
import javax.swing.JFrame;
public class GraphicsTest {
private JFrame frame;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
GraphicsTest window = new GraphicsTest();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the application.
*/
public GraphicsTest() {
initialize();
}
/**
* Initialize the contents of the frame.
*/
private void initialize() {
frame = new JFrame();
frame.setBounds(100, 100, 450, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
如果您设法在此添加一个矩形,将不胜感激!
您的 class 必须扩展 JFrame。 以后应该使用WindowBuilder提供的向导。 Select 你的 java package 然后按 CTRL+N。 这将打开“新建”向导,您可以在其中 select WB JFrame class。
入门页面在这里:
https://help.eclipse.org/latest/topic/org.eclipse.wb.doc.user/html/index.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.