i looked up the validate method but i dont understand it at all.
anyways for michael here is my code:
code:
import javax.swing.*;
import java.awt.*;
class RobinHood
{
public static void main(
String[] args)
{
JFrame frame = new JFrame();
JPanel drawing = new DrawingPanel();
JButton button = new JButton("Click me");
frame.setSize(300,300);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(drawing);
frame.getContentPane().add(button);
}
}
class DrawingPanel extends JPanel
{
public void pantComponent(Graphics g)
{
g.setColor(Color.red);
g.fillRect(0,0,300,300);
}
}
again this results in a small frame of the correct size displaying nothing, but then when i expand the box the Click Me button is in the direct center of the screen. thanks for reading once again