java graphics display help
- by java
I know that i am not calling the graphics paint command in the mainframe in order to display it. but i'm not sure how.
thanks in advance
import java.awt.*;
import javax.swing.*;
public class MainFrame extends JFrame {
private static Panel panel = new Panel();
public MainFrame() {
panel.setBackground(Color.white);
Container c = getContentPane();
c.add(panel);
}
public void paint(Graphics g) {
g.drawString("abc", 20, 20);
}
public static void main(String[] args) {
MainFrame frame = new MainFrame();
frame.setVisible(true);
frame.setSize(600, 400);
frame.setResizable(false);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}