LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 11-27-2006, 02:51 PM   #1
Veteq
Member
 
Registered: Feb 2004
Posts: 155

Rep: Reputation: 30
Java swing problem


I have been tying to get a vertical scrollbar to display but no luck,
any help would be greatly appreciated

Code:
package test;


import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.JTableHeader;
import javax.swing.table.TableColumn; 


public class OverduePanel  extends JPanel {
    //final static boolean shouldfile = true;
    public final static Color cust_pink = new Color(241,221,196);//define a new color "Salmon"
    
    public String dataValues[][];
    public JTable tbl_overDue; 
    public TableColumn col;
    public JScrollPane scrollPane;
    public JTableHeader header;
    
    public void overduePanel(){      
                this.setBorder(BorderFactory.createEtchedBorder());
                this.setLayout(new GridBagLayout());
                GridBagConstraints c = new GridBagConstraints();   
               
                dataValues  = new String[20][7];
                String[] columnNames = {"Field1","Field2","Field3","Field4","Field5","Field6","Field7"}; 
                            
                tbl_overDue = new JTable(dataValues,columnNames );
                scrollPane = new JScrollPane(tbl_overDue);
                tbl_overDue.setEnabled(false);
                tbl_overDue.setGridColor(cust_pink);
                tbl_overDue.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
                
                                               
                header = tbl_overDue.getTableHeader();
                    c.gridx=0;c.gridy=0;
                    c.insets = new Insets(0,15,5,5);
                this.add(header,c);    
                    c.gridx=0;c.gridy=1;
                this.add(tbl_overDue,c);    
                    c.gridx=0;c.gridy=2;
                this.add(scrollPane,c);
    }

 
 }
 
Old 11-28-2006, 07:56 AM   #2
Veteq
Member
 
Registered: Feb 2004
Posts: 155

Original Poster
Rep: Reputation: 30
anyone?
it would be greatly appreciated...or is there another site that I can post this at?
 
Old 11-28-2006, 08:04 AM   #3
revof11
Member
 
Registered: Nov 2003
Location: Macungie, PA
Distribution: Fedora Core 9, Gentoo 2008.0
Posts: 108

Rep: Reputation: 15
Swing will automatically take care of displaying the scroll bar if and when it is ever actually needed. Are you trying to display it regardless of the need for scrolling?
 
Old 11-28-2006, 08:10 AM   #4
revof11
Member
 
Registered: Nov 2003
Location: Macungie, PA
Distribution: Fedora Core 9, Gentoo 2008.0
Posts: 108

Rep: Reputation: 15
If that's the case, all you need to do is this:
Code:
scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
 
Old 11-28-2006, 03:06 PM   #5
Veteq
Member
 
Registered: Feb 2004
Posts: 155

Original Poster
Rep: Reputation: 30
that was exactly it,

thank you
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
a java-swing problem... shosh Programming 2 06-26-2009 05:38 AM
Java - Swing cannot update components Veteq Programming 4 09-21-2006 12:45 AM
java swing JTextArea gauravbagga Programming 1 05-23-2005 04:34 AM
Java help! Using Swing and Layouts Mega Man X Programming 7 02-05-2004 05:02 PM
missing java swing libraries? a1ghagh05t Programming 5 01-26-2004 06:04 AM


All times are GMT -5. The time now is 08:13 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration