Guest User

setting JTable size on JTab

a guest
Sep 26th, 2014
634
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.76 KB | None | 0 0
  1. package wan.dev.sample.tabbedpanejtable;
  2.  
  3. import java.awt.EventQueue;
  4.  
  5. import javax.swing.JFrame;
  6. import javax.swing.JScrollPane;
  7. import javax.swing.JTabbedPane;
  8. import javax.swing.JPanel;
  9. import javax.swing.JTable;
  10.  
  11. public class d {
  12.  
  13.     private JFrame frame;
  14.  
  15.     /**
  16.      * Launch the application.
  17.      */
  18.     public static void main(String[] args) {
  19.         EventQueue.invokeLater(new Runnable() {
  20.             public void run() {
  21.                 try {
  22.                     d window = new d();
  23.                     window.frame.setVisible(true);
  24.                 } catch (Exception e) {
  25.                     e.printStackTrace();
  26.                 }
  27.             }
  28.         });
  29.     }
  30.  
  31.     /**
  32.      * Create the application.
  33.      */
  34.     public d() {
  35.         initialize();
  36.     }
  37.  
  38.     /**
  39.      * Initialize the contents of the frame.
  40.      */
  41.     private void initialize() {
  42.         frame = new JFrame();
  43.         frame.setBounds(100, 100, 450, 300);
  44.         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  45.         frame.getContentPane().setLayout(null);
  46.  
  47.         JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
  48.         tabbedPane.setBounds(0, 0, 434, 262);
  49.         frame.getContentPane().add(tabbedPane);
  50.  
  51.         JPanel panel = new JPanel();
  52.         panel.setLayout(null);
  53.  
  54.         Object rowData[][] = {
  55.                 { "Row1-Column1", "Row1-Column2", "", "", "", "", "" },
  56.                 { "Row1-Column1", "Row1-Column2", "", "", "", "", "" },
  57.                 { "Row1-Column1", "Row1-Column2", "", "", "", "", "" },
  58.                 { "Row1-Column1", "Row1-Column2", "", "", "", "", "" },
  59.                 { "Row1-Column1", "Row1-Column2", "", "", "", "", "" },
  60.                 { "Row2-Column1", "Row2-Column2", "Row2-Column3", "", "", "",
  61.                         "", "" } };
  62.         Object columnNames[] = { "Column One", "Column Two", "Column Three",
  63.                 "", "", "", "" };
  64.         JTable table = new JTable(rowData, columnNames);
  65.         JScrollPane scrollPane = new JScrollPane(table);
  66.        
  67.         tabbedPane.addTab("table", null, scrollPane, null);
  68.     }
  69.  
  70. }
Advertisement
Add Comment
Please, Sign In to add comment