A
asdASF12
Gast
Hi,
zeichnen auf nem JPanel klappt nicht.
Main:
MainFrame:
CoordinateSystem:
zeichnen auf nem JPanel klappt nicht.
Main:
Java:
public class Main {
MainFrame mainFrame = new MainFrame("LOL");
mainFrame.setVisible(true);
}
}
MainFrame:
Java:
public class MainFrame extends JFrame {
private JPanel contentPane = null;
private CoordinateSystem cs = null;
public MainFrame(String title) {
super(title);
init();
}
private void init() {
setSize(520, 520);
int screenSizeX = (int) Toolkit.getDefaultToolkit().getScreenSize().getWidth();
int screenSizeY = (int) Toolkit.getDefaultToolkit().getScreenSize().getHeight();
setLocation((screenSizeX - (int) getWidth()) / 2, (screenSizeY - (int) getHeight()) / 2);
}
@Override
public JPanel getContentPane() {
if (contentPane == null) {
setContentPane(new JPanel());
getContentPane().setLayout(null);
getContentPane().setVisible(true);
}
return contentPane;
}
public void setContentPane(JPanel contentPane) {
this.contentPane = contentPane;
}
public CoordinateSystem getCoordinateSystem() {
if (cs == null) {
Range range = new Range(-10, 10, -10, 10);
cs = new CoordinateSystem(500, 500, range);
cs.setLocation(10, 10);
cs.setVisible(true);
getContentPane().add(cs);
}
return cs;
}
}
CoordinateSystem:
Java:
public class CoordinateSystem extends JPanel {
private ArrayList polynoms = null;
public CoordinateSystem(int height, int width, Range range) {
super();
setSize(height, width);
}
@Override
protected void paintComponent(Graphics g) {
super.paint(g);
g.drawString("lol", 10, 10);
System.out.println("painted");
}
}