fork download
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package SwingControl;
  7.  
  8. import java.awt.Color;
  9. import java.awt.Container;
  10. import java.awt.HeadlessException;
  11. import javax.swing.JButton;
  12. import javax.swing.JFrame;
  13. import javax.swing.JPanel;
  14.  
  15. /**
  16.  *
  17.  * @author ta
  18.  */
  19. public class FlowLayout extends JFrame{
  20.  
  21. public FlowLayout(String title) throws HeadlessException {
  22. super(title);
  23. creatAndShow();
  24. }
  25.  
  26. private JPanel jpn;
  27. private JButton jbt1,jbt2,jbt3,jbt4,jbt5;
  28.  
  29.  
  30. public void creatAndShow()
  31. {
  32. jpn= new JPanel();
  33. jbt1 = new JButton("FLOW LAYOUT");
  34. jbt2 = new JButton("Add các dòng");
  35. jbt3 = new JButton("Trên 1 dòng");
  36. jbt4 = new JButton("Het cho chua");
  37. jbt5 = new JButton("Thi xuong dong");
  38.  
  39. // jpn.add(jbt1);
  40. // jpn.add(jbt2);
  41. // jpn.add(jbt3);
  42. // jpn.add(jbt4);
  43. // jpn.add(jbt5);
  44. //
  45. // Container con = getContentPane();
  46. // con.add(jpn);
  47. //
  48. this.getContentPane().add(jbt1);
  49. this.getContentPane().add(jbt2);
  50. this.getContentPane().add(jbt3);
  51. this.getContentPane().add(jbt4);
  52. this.getContentPane().add(jbt5);
  53.  
  54. this.getContentPane().setBackground(Color.red);
  55. this.getContentPane().setLayout(new java.awt.FlowLayout());
  56.  
  57.  
  58.  
  59. }
  60.  
  61. public static void main(String[] args) {
  62. FlowLayout layout = new FlowLayout("MY WINDOW");
  63. layout.setSize(600,100);
  64. layout.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  65. layout.setLocationRelativeTo(null);
  66. layout.setVisible(true);
  67. }
  68.  
  69.  
  70. }
  71.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:19: error: class FlowLayout is public, should be declared in a file named FlowLayout.java
public class FlowLayout extends  JFrame{
       ^
1 error
stdout
Standard output is empty