问题描述
我正在开发一个功能绘图仪,并希望绘制 2 条代表 x 和 y 轴的线条。你会这么友好并检查我的代码,并可能告诉我什么是错的!谢谢! :) 这个东西 funktionsschar 与我的问题无关。
public class AUSGABE_GUI extends JFrame {
// Anfang Attribute
public static final int WIDTH = 1024;
public static final int HEIGHT = 768;
Funktionsschar funktionsschar;
private JPanel jPanel1 = new JPanel(null);
// Ende Attribute
public AUSGABE_GUI(Funktionsschar pFunktionsschar) {
super ("Plotter");
setDefaultCloSEOperation(WindowConstants.EXIT_ON_CLOSE);
setSize(WIDTH,HEIGHT);
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
int x = (d.width - getSize().width) / 2;
int y = (d.height - getSize().height) / 2;
setLocation(x,y);
Container cp = getContentPane();
cp.setLayout(null);
jPanel1.setBounds(0,WIDTH,HEIGHT);
cp.add(jPanel1);
setVisible(true);
}
public void paintComponents(Graphics g) {
super.paintComponents(g);
Graphics2D g2d = (Graphics2D) g;
g2d.setColor(Color.blue);
g2d.drawLine(0,HEIGHT / 2,HEIGHT / 2);
g2d.drawLine(WIDTH / 2,WIDTH / 2,HEIGHT);
}
另外,如果我的代码看起来很糟糕,我真的很抱歉,我是编码新手!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)