Advertisement
Guest User

Untitled

a guest
May 3rd, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. >>54351911
  2. FlowLayout doesn't support autofill stuff.
  3.  
  4. If you want the panel to fill out the entirety of the frame, you can use BorderLayout, and add it to center.
  5.  
  6. [code]
  7. public class DrawApp extends JPanel{
  8.  
  9. private JRadioButton redButton;
  10. private JRadioButton yellowButton;
  11. private JRadioButton blueButton;
  12. private JRadioButton eraserButton;
  13. private JButton clearButton;
  14. private JPanel control;
  15. private ArrayList<Point> pointList;
  16. private int clickCount;
  17. private Color penPaint;
  18.  
  19. public DrawApp() {
  20. setLayout(new BorderLayout());
  21. control = new JPanel();
  22. control.setBackground(Color.BLACK);
  23. add(control,BorderLayout.CENTER);
  24.  
  25. clickCount = 0;
  26. pointList = new ArrayList<>();
  27. redButton = new JRadioButton("Red");
  28. yellowButton = new JRadioButton("Yellow");
  29. blueButton = new JRadioButton("Blue");
  30. eraserButton = new JRadioButton("Eraser");
  31. clearButton = new JButton("Clear Drawing");
  32. control.add(redButton);
  33. control.add(yellowButton);
  34. control.add(blueButton);
  35. control.add(eraserButton);
  36. control.add(clearButton);
  37. }
  38. [/code]
  39.  
  40. Also, adding a panel using the BorderLayout.SOUTH parameter doesn't do anything in your example, because you've set the layout to FlowLayout.
  41.  
  42. pic related is how a basic BorderLayout is set up.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement