fork download
  1. package topica.io;
  2.  
  3. import java.awt.BorderLayout;
  4. import java.awt.Container;
  5.  
  6. import javax.swing.JButton;
  7. import javax.swing.JFrame;
  8. import javax.swing.JPanel;
  9.  
  10. public class BorderLayoutDemo extends JFrame {
  11.  
  12.  
  13. private JPanel jpn;
  14. private JButton jbt1, jbt2 , jbt3 , jbt4, jbt5;
  15.  
  16.  
  17. public BorderLayoutDemo() {
  18. // TODO Auto-generated constructor stub
  19. this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  20. this.setSize(600,400);
  21. this.setVisible(true);
  22. this.setLocationRelativeTo(null);
  23. creatAndShow();
  24.  
  25. }
  26.  
  27.  
  28. private void creatAndShow() {
  29. // TODO Auto-generated method stub
  30. jpn = new JPanel();
  31. jpn.setLayout(new BorderLayout());
  32. jbt1 = new JButton("NORTH");
  33. jbt2 = new JButton("WEST");
  34. jbt3 = new JButton("CENTER");
  35. jbt4 = new JButton("EAST");
  36. jbt5 = new JButton("SOUTH");
  37.  
  38.  
  39.  
  40. jpn.add(jbt1,BorderLayout.NORTH);
  41. jpn.add(jbt2,BorderLayout.WEST);
  42. jpn.add(jbt3,BorderLayout.CENTER);
  43. jpn.add(jbt4,BorderLayout.EAST);
  44. jpn.add(jbt5,BorderLayout.SOUTH);
  45.  
  46. Container con = getContentPane();
  47. con.add(jpn);
  48.  
  49.  
  50. }
  51.  
  52.  
  53. public static void main(String[] args) {
  54. new BorderLayoutDemo();
  55.  
  56. }
  57.  
  58. }
  59.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:10: error: class BorderLayoutDemo is public, should be declared in a file named BorderLayoutDemo.java
public class BorderLayoutDemo extends JFrame {
       ^
1 error
stdout
Standard output is empty