Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- >>54351911
- FlowLayout doesn't support autofill stuff.
- If you want the panel to fill out the entirety of the frame, you can use BorderLayout, and add it to center.
- [code]
- public class DrawApp extends JPanel{
- private JRadioButton redButton;
- private JRadioButton yellowButton;
- private JRadioButton blueButton;
- private JRadioButton eraserButton;
- private JButton clearButton;
- private JPanel control;
- private ArrayList<Point> pointList;
- private int clickCount;
- private Color penPaint;
- public DrawApp() {
- setLayout(new BorderLayout());
- control = new JPanel();
- control.setBackground(Color.BLACK);
- add(control,BorderLayout.CENTER);
- clickCount = 0;
- pointList = new ArrayList<>();
- redButton = new JRadioButton("Red");
- yellowButton = new JRadioButton("Yellow");
- blueButton = new JRadioButton("Blue");
- eraserButton = new JRadioButton("Eraser");
- clearButton = new JButton("Clear Drawing");
- control.add(redButton);
- control.add(yellowButton);
- control.add(blueButton);
- control.add(eraserButton);
- control.add(clearButton);
- }
- [/code]
- Also, adding a panel using the BorderLayout.SOUTH parameter doesn't do anything in your example, because you've set the layout to FlowLayout.
- pic related is how a basic BorderLayout is set up.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement