Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to add JTable in JPanel

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 5.46k
    Comment on it

    Hello Guys

    I writing blog to add JTable in Jpanel. JTable is an component of the swing package in java technology and also it's a class, so we need to create instance and using add() method add the JTable in JPanel.


    Here, add() method used for adding the components in swing container.

    For better understanding see below example :

    JPanel panel = new JPanel();// creating instance of JPanel
    
    this.setContentPane(panel);// add panel in ContentPane
    
    panel.setLayout(null);// Set null layout
    
    String data[][] = {{"1.", "ABC"}, {"2.", "DEF"}, {"3.", "GHI" }};
    
    // filling row and column data in JTable 
    
    String col[] = {"Sr. No", "Name"};
    
    JTable table = new Jtable(data,col);
    
    table.setBounds(100, 100, 100, 80);
    
    panel.add(table);// add table in panel using add() method
    
    setVisible(true);
    
    setSize(300,300);
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: