Results 1 to 2 of 2
  1. #1
    OllyHal is offline Member
    Join Date
    Feb 2012
    Posts
    25
    Rep Power
    0

    Default Jtable size of JPane

    I am trying to make the jtable the size of the jpane with a maximum number of rows. Any help on this?

    Java Code:
    public void createMainGUI () { 
    	   
    	double screenheight = screenSize.height * 0.95;
    	double screenwidth = screenSize.width * 0.98;
    	
    	//Menu
    	menubar.add(File);
            File.add(NewTransaction);
    	File.add(Exit);
    	
    	//Table
    
    
    
    	Object[] columnNames = {"Date",
                "Last Name",
                "Sport",
                "# of Years",
                "Vegetarian"};
    	Object[][] data = {
    		    {"Kathy", "Smith",
    		     "Snowboarding", new Integer(5), new Boolean(false)},
    		    {"John", "Doe",
    		     "Rowing", new Integer(3), new Boolean(true)},
    		    {"Sue", "Black",
    		     "Knitting", new Integer(2), new Boolean(false)},
    		    {"Jane", "White",
    		     "Speed reading", new Integer(20), new Boolean(true)},
    		    {"Joe", "Brown",
    		     "Pool", new Integer(10), new Boolean(false)}
    		};
    			
    	JTable Transaction = new JTable(data, columnNames);
            
           
    	
    	JScrollPane scrollPane = new JScrollPane(Transaction);
    	
    	Transaction.setBorder(BorderFactory.createLineBorder(Color.BLACK,1));
    	
    	//Panel  settings 
    	Mainpane.addTab("Transactions", jp1);
    	Mainpane.addTab("Settings", jp2);
    	
    	//TabPane	
    	
    	jp1.add(scrollPane);
    	
    	
    	//Bottom Panel
    	Bottompanel.add(BLbl);
    	Bottompanel.add(XLbl);
    	
    	//MainFrame
    	mainframe.setJMenuBar(menubar);
    	
    	
    	mainframe.getContentPane().add(Mainpane, BorderLayout.NORTH);
    	mainframe.add(Bottompanel,BorderLayout.PAGE_END);	
    	mainframe.setVisible(true);
    	mainframe.setSize((int) screenwidth, (int) screenheight );
    }
    
    }

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,193
    Rep Power
    19

    Default Re: Jtable size of JPane

    Quote Originally Posted by OllyHal View Post
    I am trying to make the jtable the size of the jpane with a maximum number of rows. Any help on this?
    What's a jtable? What's a jpane? Java is case sensitive; and there's no class jpane with any combination of lower and upper case.

    And in your code, follow Java coding conventions. Variable names should not start with a capital letter.
    Code Conventions for the Java Programming Language: Contents

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. How to set the size of a JComboBox?
    By nickburris in forum New To Java
    Replies: 1
    Last Post: 01-02-2012, 01:21 AM
  2. Adding New JTable in JTable
    By anilkumar_vist in forum New To Java
    Replies: 0
    Last Post: 01-27-2010, 08:27 AM
  3. Setting frame size to the size of an image
    By Yoruichi in forum AWT / Swing
    Replies: 5
    Last Post: 04-22-2009, 04:37 PM
  4. Size of JTable
    By andre1011 in forum Advanced Java
    Replies: 3
    Last Post: 04-15-2009, 04:55 AM
  5. Replies: 2
    Last Post: 05-15-2008, 10:15 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •