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.Button;
  9. import java.awt.Color;
  10. import java.awt.Container;
  11. import java.awt.HeadlessException;
  12. import javax.swing.JFrame;
  13. import javax.swing.JPanel;
  14. import javax.swing.JTabbedPane;
  15.  
  16. /**
  17.  *
  18.  * @author ta
  19.  */
  20. public class JTabbedPaneDemo extends JFrame{
  21.  
  22. public JTabbedPaneDemo(String title) throws HeadlessException {
  23.  
  24. super(title);
  25. this.setSize(400,600);
  26. this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  27. this.setVisible(true);
  28. this.setLocationRelativeTo(null);
  29. creatAndShow();
  30.  
  31. }
  32.  
  33.  
  34. private void creatAndShow() {
  35.  
  36.  
  37. //Khai báo đoi tuong tab cua lop JTabbedPane
  38. JTabbedPane tab = new JTabbedPane();
  39.  
  40. //Tao panel jpn1
  41. JPanel jpn1 = new JPanel();
  42. jpn1.setBackground(Color.red);
  43. jpn1.add(new Button("SUBMIT 1"));
  44.  
  45. //Tao panel jpn2
  46. JPanel jpn2 = new JPanel();
  47. jpn2.setBackground(Color.ORANGE);
  48. jpn2.add(new Button("SUBMIT 2"));
  49.  
  50.  
  51. tab.add(jpn1,"TAB 1");
  52. tab.add(jpn2,"TAB 2");
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61. Container con = getContentPane();
  62. con.add(tab);
  63.  
  64.  
  65. }
  66.  
  67.  
  68. public static void main(String[] args) {
  69.  
  70. new JTabbedPaneDemo("MY WINDOW");
  71. }
  72.  
  73.  
  74.  
  75.  
  76.  
  77. }
  78.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:20: error: class JTabbedPaneDemo is public, should be declared in a file named JTabbedPaneDemo.java
public class JTabbedPaneDemo extends JFrame{
       ^
1 error
stdout
Standard output is empty