Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Swing-AWT urgent please, help!

Have Programming Question? Ask it here!
 
 
 


genesisortega
urgent please, help!
1 Answer(s)      2 years and 5 months ago
Posted in : Swing AWT


how to make jTable unclickable and have unmovable columns, thanks in advance


Advertisement
View Answers

March 15, 2012 at 1:24 PM


import javax.swing.*;
import java.awt.*;

public class SimpleJTableExample{
  public static void main(String[] args) 
{
  new SimpleJTableExample();
  }

  public SimpleJTableExample(){
  JFrame frame = new JFrame("Creating JTable Component Example!");
  JPanel panel = new JPanel();
  String data[][] = {{"A","Delhi","1111"},{"B","Mumbai","2222"},
   {"C","Kolkata","3333"},{"D","Chennai","4444"}};

    String col[] = {"Name","Address","Contact No"};

  JTable table = new JTable(data,col);
table.getTableHeader().setReorderingAllowed(false) ;
table.getTableHeader().setResizingAllowed(false);

 panel.add(table.getTableHeader() , BorderLayout.NORTH);
panel.add(table, BorderLayout.CENTER);


frame.add(panel);
  frame.setSize(300,200);
  frame.setVisible(true);
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }
}


Related Tutorials/Questions & Answers:
 

 

 

DMCA.com