JScrollPane Properties ???

Dear Friends,
Kindly let me know how to remove the Table Headers, which is set by default when a JTable is added to a JScrollPane.

hi Friend!
would doing table.setTableHeader(null) do it?
http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JTable.html#setTableHeader(javax.swing.table.JTableHeader)
asjf

Similar Messages

  • Use of JScrollPane

    I try to use the JScrollPane class with a JPanel, which at the time contains a class compounded of several textboxes and other JComponent subclasses.
    I am not using any layout manager (setting every layout manager to null), and though displaying the components properly inside the JFrame, I don't get the JScrollPane (or the JViewPort in it) to recognize the underlying size of the JPanel, therefore not displaying any scrollbars, horizontal or vertical, when setting the JScrollPane horizontal and vertical scrollbar policies to "as needed". First guess, is that I should set some of the JScrollPane properties manually, such as extent, min, max and so on. Perhaps the problem lies on the LayoutManager.
    The strange point, is that whenever you provide as JViewPort component any root class (such as a texarea), everything works as desired.
    Can anybody help? Hope the explanation is clear.
    Thanks in advance.
    Carlos.

    Carlo,
    try setting the preferred size of the JScrollPane. If that doesn't work, You'll probably have to put your JScrollPane on another JPanel and set the size of THAT JPanel (the one that holds the scrollpane).
    If you just add the JScrollPane onto the JFrame, it will normally take up the whole size of the JFrame.
    If you paste up your code, it may help us understand the problem better.

  • Changing Arrows and Color of a JScrollBar inside of a JScrollPane

    Hi. I can't believe this hasn't been asked and answered before but I can't find it in these forums if it has.
    I am trying to create a JScrollPane in a touchscreen based application - no mouse... The default scrollbar
    in my JScrollPane is too small for large fingers. I have successfully increased the size of the scrollbar
    to a usable size using: UIManager.put("scrollbar.width", 75).
    My next problem is two-fold.
    1) The arrows at top and bottom of the scrollbar are now heavily pixelated (i.e. jagged and blocky) and
    look like we zoomed in too much on a bitmap. How can I change these arrows to a graphic that is
    more related to the current size of my scrollbar?
    2) The color of the scrollbar is shades of 'baby blue'. My color scheme for my application is shades of
    beige or brown. This makes the scrollbar stand out like a sore thumb. How can I change the color
    of the scrollbar?
    Note: This is being coded in NetBeans 6.7.1 but I can't find any property in the visual editor that covers
    my problems.
    Also, I came across the UIManager.put("scrollbar.width", xx) from googling. Is there an official (complete)
    list of the properties available to the UIManager?
    Thanks

    To help out anyone who has been struggling with this as I have, here is the final solution we were able to use. We only needed to work with the vertical scroll bar, but it should be easy to work with now that a better part of the work is done. I do hope this is helpful.
         public ReportDisplayFrame()
              UIManager.put( "ScrollBar.width", 75);
              RDFScrollBarUI rdfScrlBarUI = new RDFScrollBarUI();
              rdfScrlBarUI.setButtonImageIcon( new ImageIcon( "C:/company/images/upArrow.jpg") , rdfScrlBarUI.NORTH);
              rdfScrlBarUI.setButtonImageIcon( new ImageIcon( "C:/company/images/downArrow.jpg") , rdfScrlBarUI.SOUTH);
              tempScrlBar = new JScrollBar();
              tempScrlBar.setBlockIncrement( 100);
              tempScrlBar.setUnitIncrement( 12);
              tempScrlBar.setUI( rdfScrlBarUI);
    // other constructor code //
              rdfScreenRedraw();
         private void rdfScreenRedraw()
              String methodName = "rdfScreenRedraw()";
              logger.log(Level.INFO, methodName + ": Revalidating: mainPanel Thread = ["+Thread.currentThread().getName()+"]");
              jPanelRpt.revalidate();
              jPanelRpt.repaint();
         class RDFScrollBarUI extends BasicScrollBarUI {
              private ImageIcon decImage = null;
              private ImageIcon incImage = null;
              public void setThumbColor(Color thumbColor) {
                   this.thumbColor = thumbColor;
              public void setThumbDarkShadowColor(Color thumbDarkShadowColor) {
                   this.thumbDarkShadowColor = thumbDarkShadowColor;
              public void setThumbHighlightColor(Color thumbHighlightColor) {
                   this.thumbHighlightColor = thumbHighlightColor;
              public void setThumbLightShadowColor(Color thumbLightShadowColor) {
                   this.thumbLightShadowColor = thumbLightShadowColor;
              public void setTrackColor(Color trackColor) {
                   this.trackColor = trackColor;
              public void setTrackHighlightColor(Color trackHighlightColor) {
                   this.trackHighlightColor = trackHighlightColor;
              public void setButtonImageIcon( ImageIcon theIcon, int orientation)
                   switch( orientation)
                        case NORTH:
                             decImage = theIcon;
                             break;
                        case SOUTH:
                             incImage = theIcon;
                             break;
                        case EAST:
              if (scrollbar.getComponentOrientation().isLeftToRight())
                                  decImage = theIcon;
                             else
                                  incImage = theIcon;
                             break;
                        case WEST:
              if (scrollbar.getComponentOrientation().isLeftToRight())
                                  incImage = theIcon;
                             else
                                  decImage = theIcon;
                             break;
              @Override
              protected JButton createDecreaseButton(int orientation) {
                   JButton button = null;
                   if ( decImage != null)
                        button = new JButton( decImage);
                   else
                        button = new BasicArrowButton(orientation);
                   button.setBackground( new Color( 180,180,130));
                   button.setForeground( new Color( 236,233,216));
                   return button;
              @Override
              protected JButton createIncreaseButton(int orientation) {
                   JButton button = null;
                   if ( incImage != null)
                        button = new JButton( incImage);
                   else
                        button = new BasicArrowButton(orientation);
                   button.setBackground( new Color( 180,180,130));
                   button.setForeground( new Color( 236,233,216));
                   return button;
         }

  • How to list all properties in the default Toolkit

    I would like to know what kinds of properties are stored in the default Toolkit (Toolkit.getDefaultToolkit()). I don't know how to list all of them. Toolkit class has a method getProperty(String key, String defaultValue), but without knowing a list of valid keys, this method is useless.
    Any idea would be appreciated.

    Here is a little utility that I wrote to display all the UIDefaults that are returned from UIManager.getDefaults(). Perhaps this is what you are looking for?
    import javax.swing.*;
    import java.util.*;
    public class DefaultsTable extends JTable {
        public static void main(String args[]) {
            JTable t = new DefaultsTable();
        public DefaultsTable() {
            super();
            setModel(new MyTableModel());
            JFrame jf = new JFrame("UI Defaults");
            jf.addWindowListener(new WindowCloser());
            jf.getContentPane().add(new JScrollPane(this));
            jf.pack();
            jf.show();
        class MyTableModel extends javax.swing.table.AbstractTableModel {
            UIDefaults uid;
            Vector keys;
            public MyTableModel() {
                uid = UIManager.getDefaults();
                keys = new Vector();
                for (Enumeration e=uid.keys() ; e.hasMoreElements(); ) {
                    Object o = e.nextElement();
                    if (o instanceof String) {
                        keys.add(o);
                Collections.sort(keys);
            public int getRowCount() {
                return keys.size();
            public int getColumnCount() {
                return 2;
            public String getColumnName(int column) {
                if (column == 0) {
                    return "KEY";
                } else {
                    return "VALUE";
            public Object getValueAt(int row, int column) {
                Object key = keys.get(row);
                if (column == 0) {
                    return key;
                } else {
                    return uid.get(key);
        class WindowCloser extends java.awt.event.WindowAdapter {
            public void windowClosing(java.awt.event.WindowEvent we) {
                System.exit(0);
    }

  • Problem in refreshing JTree inside Jscrollpane on Button click

    hi sir,
    i have problem in refreshing JTree on Button click inside JscrollPane
    Actually I am removing scrollPane from panel and then again creating tree inside scrollpane and adding it to Jpanel but the tree is not shown inside scrollpane. here is the dummy code.
    please help me.
    import javax.swing.*;
    import java.awt.*;
    import javax.swing.tree.*;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    import java.awt.event.WindowListener;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    public class Test
    public static void main(String[] args)
         JFrame jf=new TestTreeRefresh();
         jf.addWindowListener( new
         WindowAdapter()
         public void windowClosing(WindowEvent e )
         System.exit(0);
         jf.setVisible(true);
    class TestTreeRefresh extends JFrame
         DefaultMutableTreeNode top;
    JTree tree;
         JScrollPane treeView;
         JPanel jp=new JPanel();
         JButton jb= new JButton("Refresh");
    TestTreeRefresh()
    setTitle("TestTree");
    setSize(500,500);
    getContentPane().setLayout(null);
    jp.setBounds(new Rectangle(1,1,490,490));
    jp.setLayout(null);
    top =new DefaultMutableTreeNode("The Java Series");
    createNodes(top);
    tree = new JTree(top);
    treeView = new JScrollPane(tree);
    treeView.setBounds(new Rectangle(50,50,200,200));
    jb.setBounds(new Rectangle(50,300,100,50));
    jb.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent ae)
              jp.remove(treeView);
              top =new DefaultMutableTreeNode("The Java ");
    createNodes(top);
              tree = new JTree(top);
                   treeView = new JScrollPane(tree);
                   treeView.setBounds(new Rectangle(50,50,200,200));
                   jp.add(treeView);     
                   jp.repaint();     
    jp.add(jb);     
    jp.add(treeView);
    getContentPane().add(jp);
    private void createNodes(DefaultMutableTreeNode top) {
    DefaultMutableTreeNode category = null;
    DefaultMutableTreeNode book = null;
    category = new DefaultMutableTreeNode("Books for Java Programmers");
    top.add(category);
    book = new DefaultMutableTreeNode("The Java Tutorial: A Short Course on the Basics");
    category.add(book);
    book = new DefaultMutableTreeNode("The Java Tutorial Continued: The Rest of the JDK");
    category.add(book);
    book = new DefaultMutableTreeNode("The JFC Swing Tutorial: A Guide to Constructing GUIs");
    category.add(book);
    book = new DefaultMutableTreeNode("Effective Java Programming Language Guide");
    category.add(book);
    book = new DefaultMutableTreeNode("The Java Programming Language");
    category.add(book);
    book = new DefaultMutableTreeNode("The Java Developers Almanac");
    category.add(book);
    category = new DefaultMutableTreeNode("Books for Java Implementers");
    top.add(category);
    book = new DefaultMutableTreeNode("The Java Virtual Machine Specification");
    category.add(book);
    book = new DefaultMutableTreeNode("The Java Language Specification");
    category.add(book);
    }

    hi sir ,
    thaks for u'r suggession.Its working fine but the
    properties of the previous tree were not working
    after setModel() property .like action at leaf node
    is not working,I'm sorry but I don't understand. I think you are saying that the problem is solved but I can read it to mean that you still have a problem.
    If you still have a problem then please post some code (using the [code] tags of course).

  • JScrollpane

    Hello, since my last post i seem to have got a handle on the gridbaglayout, the problem is, the listScrollPane inside of smokerPanel keeps overlapping the next column. I have no idea why it is doing this. the gridx is always 0 and there is an actual panel in the next column over.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Iq3GUI extends JFrame implements ActionListener{
    // main window
    protected JFrame frame;
    // content panel for main window
    private JPanel panel;
    private JPanel outpanel;
    * constructor
    * @param title Main window title
    public Iq3GUI(String title){
    //initialization of main window and declarations
    // initializes main window
    frame = new JFrame(title);
    // window listener -> closes program on window close
    frame.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {System.exit(0);}
    // inner content panel
    panel = new JPanel();
    // outter content panel
    outpanel = new JPanel();
    // creates a new layout object
    GridBagLayout gridbag = new GridBagLayout();
    // sets the content panel to a gridbag layout
    panel.setLayout(gridbag);
    // gridbag constraint object
    GridBagConstraints c;
    // sets the window to resemble the windows api
    setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
    // menu bar
    JMenuBar menuBar = new JMenuBar();
    frame.setJMenuBar(menuBar);
    JMenu menu = new JMenu("File");
    menu.setMnemonic(KeyEvent.VK_F);
    menu.getAccessibleContext().setAccessibleDescription("File menu");
    menuBar.add(menu);
    //creates JObjects and groups them into panels based on input categories
    c = new GridBagConstraints(); // constraints
    //**name text boxes
    JTextField firstName = new JTextField(20);
    JLabel firstNameLabel = new JLabel("First: ");
    JTextField lastName = new JTextField(20);
    JLabel lastNameLabel = new JLabel("Last: ");
    JPanel nameTextBoxPanel = new JPanel();
    nameTextBoxPanel.setBorder(BorderFactory.createTitledBorder("Name:"));
    nameTextBoxPanel.setLayout(gridbag);
    c.insets = new Insets(-2,5,0,0);
    c.gridx = 0;
    c.gridy = 0;
    nameTextBoxPanel.add(firstNameLabel,c);
    c.insets = new Insets(-2,0,0,5);
    c.gridx = 1;
    c.gridy = 0;
    nameTextBoxPanel.add(firstName,c);
    c.insets = new Insets(10,5,11,0);
    c.gridx = 0;
    c.gridy = 1;
    nameTextBoxPanel.add(lastNameLabel,c);
    c.insets = new Insets(10,0,11,5);
    c.gridx = 1;
    c.gridy = 1;
    nameTextBoxPanel.add(lastName,c);
    c=null;
    //**query type radio buttons
    c = new GridBagConstraints();
    JComboBox insuranceTypeComboBox = new JComboBox();
    insuranceTypeComboBox.setPreferredSize(new Dimension(115,20));
    JPanel typeComboBox = new JPanel();
    typeComboBox.setBorder(BorderFactory.createTitledBorder("Insurance Type:"));
    typeComboBox.setLayout(gridbag);
    c.insets = new Insets(-2,5,2,5);
    typeComboBox.add(insuranceTypeComboBox,c);
    //**plan type combo box
    c = new GridBagConstraints();
    JComboBox planTypeComboBox = new JComboBox();
    JPanel planTypeComboBoxPanel = new JPanel();
    planTypeComboBox.setPreferredSize(new Dimension(300,20));
    planTypeComboBoxPanel.setBorder(BorderFactory.createTitledBorder("Plan Type:"));
    planTypeComboBoxPanel.setLayout(gridbag);
    c.insets = new Insets(-2,5,2,5);
    gridbag.setConstraints(planTypeComboBox,c);
    planTypeComboBoxPanel.add(planTypeComboBox);
    c=null;
    //**is your client combo box
    c = new GridBagConstraints();
    JComboBox isYourClientComboBox = new JComboBox();
    JPanel isYourClientComboBoxPanel = new JPanel();
    isYourClientComboBox.setPreferredSize(new Dimension(300,20));
    isYourClientComboBoxPanel.setBorder(BorderFactory.createTitledBorder("Is Your Client:"));
    isYourClientComboBoxPanel.setLayout(gridbag);
    c.insets = new Insets(-2,5,2,5);
    gridbag.setConstraints(isYourClientComboBox, c);
    isYourClientComboBoxPanel.add(isYourClientComboBox);
    c=null;
    //**province client combo box
    c = new GridBagConstraints();
    JComboBox provinceComboBox = new JComboBox();
    JPanel provinceComboBoxPanel = new JPanel();
    provinceComboBox.setPreferredSize(new Dimension(300,20));
    provinceComboBoxPanel.setBorder(BorderFactory.createTitledBorder("Province:"));
    provinceComboBoxPanel.setLayout(gridbag);
    c.insets = new Insets(-2,5,2,5);
    gridbag.setConstraints(provinceComboBox, c);
    provinceComboBoxPanel.add(provinceComboBox);
    c=null;
    //**sex radio buttons
    c = new GridBagConstraints();
    JRadioButton[] sexRButton = new JRadioButton[2];
    sexRButton[0]=new JRadioButton("Male");
    sexRButton[1]=new JRadioButton("Female");
    JPanel sexRButtonPanel = new JPanel();
    sexRButtonPanel.setBorder(BorderFactory.createTitledBorder("Sex:"));
    sexRButtonPanel.setLayout(gridbag);
    ButtonGroup sexGroup = new ButtonGroup();
    for(int x=0;x<sexRButton.length;x++)
    sexGroup.add(sexRButton[x]);
    c.gridx=0;
    c.gridy=0;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(-2,5,0,0);
    sexRButtonPanel.add(sexRButton[0],c);
    c.gridx=1;
    c.gridy=0;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(-2,2,0,0);
    sexRButtonPanel.add(sexRButton[1],c);
    c=null;
    //** smoker list
    c = new GridBagConstraints();
    JList smokerList = new JList();
    JComboBox smokerHowLong = new JComboBox();
    JComboBox smokerMonths = new JComboBox();
    JScrollPane listScrollPane = new JScrollPane(smokerList);
    listScrollPane.setPreferredSize(new Dimension(115,30));
    JPanel smokerPanel = new JPanel();
    smokerPanel.setBorder(BorderFactory.createTitledBorder("Smoking Habits:"));
    smokerPanel.setLayout(gridbag);
    c.anchor = GridBagConstraints.WEST;
    c.gridy=0;
    c.gridx=0;
    smokerPanel.add(listScrollPane, c);
    c.gridy=1;
    c.gridx=0;
    smokerPanel.add(smokerHowLong, c);
    c.gridy=2;
    c.gridx=0;
    smokerPanel.add(smokerMonths, c);
    c=null;
    //** date of birth
    JPanel dobPanel = new JPanel();
    dobPanel.setLayout(gridbag);
    c = new GridBagConstraints();
    JTextField year = new JTextField(4);
    c.gridx=0;
    c.gridy=0;
    c.insets = new Insets(-2,2,0,2);
    dobPanel.add(year,c);
    JComboBox month = new JComboBox();
    c.gridx=1;
    c.gridy=0;
    c.insets = new Insets(-2,0,0,2);
    dobPanel.add(month,c);
    JComboBox day = new JComboBox();
    c.gridx=2;
    c.gridy=0;
    c.insets = new Insets(-2,0,0,2);
    dobPanel.add(day,c);
    dobPanel.setBorder(BorderFactory.createTitledBorder(
    "Date of Birth (YYYY/MM/DD):"));
    c=null;
    //**age text boxes
    c = new GridBagConstraints();
    JTextField actualAge = new JTextField(4);
    JLabel actualAgeLabel = new JLabel("Actual: ");
    JTextField nearestAge = new JTextField(4);
    JLabel nearestAgeLabel = new JLabel("Nearest: ");
    JPanel agePanel = new JPanel();
    agePanel.setBorder(BorderFactory.createTitledBorder("Age:"));
    agePanel.setLayout(gridbag);
    c.gridx = 0;
    c.gridy = 0;
    c.insets = new Insets(-2,5,0,1);
    agePanel.add(actualAgeLabel,c);
    c.gridx = 1;
    c.gridy = 0;
    c.insets = new Insets(-2,0,0,0);
    agePanel.add(actualAge,c);
    c.gridx = 2;
    c.gridy = 0;
    c.insets = new Insets(-2,5,0,1);
    agePanel.add(nearestAgeLabel,c);
    c.gridx = 3;
    c.gridy = 0;
    c.insets = new Insets(-2,0,0,5);
    agePanel.add(nearestAge,c);
    c=null;
    //**face amount text box
    c = new GridBagConstraints();
    JTextField faceTextBox = new JTextField(20);
    JPanel facePanel = new JPanel();
    facePanel.setBorder(BorderFactory.createTitledBorder
    ("Face Amount:"));
    facePanel.setLayout(gridbag);
    c.insets = new Insets(-2,5,2,5);
    gridbag.setConstraints(faceTextBox, c);
    facePanel.add(faceTextBox);
    c=null;
    //set constraints for each panel and add them to the content panel:
    c = new GridBagConstraints();
    //nameTextBoxPanel
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.NORTH;
    c.gridx = 0;
    c.gridy = 1;
    c.ipadx = 0;
    c.ipady = 0;
    c.gridwidth = 1;
    c.gridheight = 2;
    c.insets = new Insets(-2,0,0,0);
    panel.add(nameTextBoxPanel,c);
    //typeComboBox
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.NORTH;
    c.gridx = 0;
    c.gridy = 0;
    c.ipadx = 0;
    c.ipady = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.insets = new Insets(0,0,0,0);
    panel.add(typeComboBox,c);
    //planTypeComboBoxPanel
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.NORTH;
    c.gridx = 1;
    c.gridy = 0;
    c.ipadx = 0;
    c.ipady = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.insets = new Insets(0,0,0,0);
    panel.add(planTypeComboBoxPanel,c); /*
    //isYourClientComboBoxPanel
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.NORTH;
    c.gridx = ;
    c.gridy = ;
    c.ipadx = ;
    c.ipady = ;
    c.gridwidth = ;
    c.gridheight = ;
    c.insets = new Insets();
    panel.add(isYourClientComboBoxPanel,c);
    //provinceComboBoxPanel
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.NORTH;
    c.gridx = ;
    c.gridy = ;
    c.ipadx = ;
    c.ipady = ;
    c.gridwidth = ;
    c.gridheight = ;
    c.insets = new Insets();
    panel.add(provinceComboBoxPanel,c); */
    //sexRButtonPanel
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.NORTH;
    c.gridx = 1;
    c.gridy = 3;
    c.ipadx = 0;
    c.ipady = 0;
    c.gridwidth = 1;
    c.gridheight = 3;
    c.insets = new Insets(0,0,0,0);
    panel.add(sexRButtonPanel,c);
    //smokerPanel
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.NORTH;
    c.gridx = 0;
    c.gridy = 3;
    c.ipadx = 0;
    c.ipady = 0;
    c.gridwidth = 0;
    c.gridheight = 0;
    c.insets = new Insets(0,0,0,0);
    panel.add(smokerPanel,c);
    //dobPanel
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.NORTH;
    c.gridx = 1;
    c.gridy = 1;
    c.ipadx = 0;
    c.ipady = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.insets = new Insets(-2,0,0,0);
    panel.add(dobPanel,c);
    //agePanel
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.NORTH;
    c.gridx = 1;
    c.gridy = 2;
    c.ipadx = 0;
    c.ipady = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.insets = new Insets(-5,0,0,0);
    panel.add(agePanel,c); /*
    //facePanel
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.NORTH;
    c.gridx = ;
    c.gridy = ;
    c.ipadx = ;
    c.ipady = ;
    c.gridwidth = ;
    c.gridheight = ;
    c.insets = new Insets();
    panel.add(facePanel,c); */
    c=null;
    // set panel colors
    Color backgroundColor = SystemColor.inactiveCaptionBorder;
    panel.setBackground(backgroundColor);
    outpanel.setBackground(backgroundColor);
    nameTextBoxPanel.setBackground(backgroundColor);
    typeComboBox.setBackground(backgroundColor);
    planTypeComboBoxPanel.setBackground(backgroundColor);
    isYourClientComboBoxPanel.setBackground(backgroundColor);
    provinceComboBoxPanel.setBackground(backgroundColor);
    sexRButtonPanel.setBackground(backgroundColor);
    smokerPanel.setBackground(backgroundColor);
    dobPanel.setBackground(backgroundColor);
    agePanel.setBackground(backgroundColor);
    facePanel.setBackground(backgroundColor);
    // final properties for aesthetical purposes
    //screen dimensions
    // Dimension screenDim = Toolkit.getDefaultToolkit().getScreenSize();
    // frame boundries
    // Rectangle frameDim = frame.getBounds();
    //sets frame's location to center screen
    // frame.setSize(600,100);
    // frame.setLocation(
    // (screenDim.width - frameDim.width) / 4,(screenDim.height - frameDim.height) / 4);
    int border = 10;
    c = new GridBagConstraints();
    c.insets = new Insets(border,border,border,border);
    outpanel.add(panel,c);
    frame.setContentPane(outpanel);
    frame.pack();
    frame.setVisible(true);
    * setLookAndFeel
    * Sets the look and feel of the application, if it cannot be set to the
    * user defined one, sets the default java
    * @param feel Stores the look and feel string
    public void setLookAndFeel(String feel){
    //sets the GUI style to the parameter type
    try {
    UIManager.setLookAndFeel(feel);
    } catch (Exception e) {
    try{
    UIManager.setLookAndFeel(
    UIManager.getCrossPlatformLookAndFeelClassName());
    catch (Exception e2){
    System.err.println(e2.getMessage());
    System.exit(0);
    * errorBox
    * Displays a JDialog box with an ok button, programmer defined message
    * and a warning icon
    * @param message Programmer defined message
    public void errorBox(String message){
    //displays an error dialog
    JOptionPane.showMessageDialog(
    frame,message,"Error",JOptionPane.ERROR_MESSAGE);
    System.exit(0);
    * actionPerformed
    * Performs action sent to by action listener
    * @param e Action object
    public void actionPerformed(ActionEvent e){
    System.out.println("Click");
    * Main
    * Test method
    * @param args Does nothing
    public static void main(String[] args){
    Iq3GUI heh = new Iq3GUI("IQ3");
    /****END Iq3GUI.class****/

    David:
    Carefully look at this code (it starts at line 309 of your source) and tell me what you see wrong:
    //smokerPanel
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.NORTH;
    c.gridx = 0;
    c.gridy = 3;
    c.ipadx = 0;
    c.ipady = 0;
    c.gridwidth = 0;
    c.gridheight = 0;
    c.insets = new Insets(0,0,0,0);
    panel.add(smokerPanel,c);Aren't there too many constraints set to zero?

  • Setting JTextArea text within a JScrollPane

    Hey all. I'm attempting to use the setText() method of JTextArea to set the text of various areas located in various scroll panes. The general procedure I'm following is to initialize a new JTextArea and JScrollPane within an initializeGui function, set the properties of the JTextArea, then add it to the scroll pane using .getViewport().add(). After that, a separate function goes through all my form fields loading them with whatever data type is appropriate, in the case of the text areas I'm trying to use setText() to set a string. However, after using setText() the text area is displaying nothing. Here's some code for example (workerPane is using a layout manager exclusive to the environment I'm working in, but I don't believe it's the problem).
    workerLabel = new JLabel("Customer Address:");
              JScrollPane sp = new JScrollPane();          
              JTextArea ta = new JTextArea();          
              //set ta's properties to whatever is needed
              ta.addKeyListener(new java.awt.event.KeyAdapter(){
                   public void keyTyped(KeyEvent e){
                        JTextArea text = (JTextArea)e.getSource();                    
                        String txt = text.getText();                    
                        int nameLength = 240;
                        if ( txt.length() >= nameLength ){
                             text.setText ( txt.substring( 0, nameLength-1 ) );                         
                             Toolkit.getDefaultToolkit().beep();                    
              sp.getViewport().add(ta);          
              workerPane.add("3.1.right.top",workerLabel);
              workerPane.add("3.2.left.center",custAddScrollPane);After each area has been initialized, another function is called to load the data into it. Here are some methods I've tried that haven't worked.
    //basic, but leaves an empty field.
    ta.setText(formProperties[2].getStringValue());
    //this results in two NullPointerException warning windows popping
    ta=(JTextArea)sp.getViewport().getView();
    if(formProperties[2].getStringValue() != null)         ta.setText(formProperties[2].getStringValue());
    sp.getViewport().removeAll();
    sp.getViewport().add(ta);Can anyone point me in the right direction as to how to set my textarea's text?

    I usually use the approach given above. The other option is:
    scrollPane.setViewportView( textArea );

  • Changing properties in JTable

    Hi
    New to Java but with extensive Borland Delphi/C++ experience.
    Using NetBeans I've added a form to my project and added a JTable to the form. However I cannot seem to be able to alter the rowCount or the columnCount in a JTable's properties....why is that?
    And how do change their values?

    in netbeans just right-click on one of the created rows in jtable
    not on the empty space in jtable because that would take you to the
    properties of jscrollpane(netbeans automatically put jtable on jscrollpane). After doing that just reduce the number of rows and
    columns.

  • JEditorPane inside JScrollPane flickers somethin awful

    I'm working on an instant messenger/chat application, and I've noticed that when there is 'heavy' traffic, the JEditorPane flickers quite badly. The following code demonstrates the problem:
    import javax.swing.*;
    import java.awt.*;
    public class Test extends JFrame {
      public Test() {
        JEditorPane jep = new JEditorPane("text/html", "");
        StringBuffer sb = new StringBuffer();
        JScrollPane jsp = new JScrollPane(jep);
        this.setSize(640,480);
        this.getContentPane().setLayout(new BorderLayout());
        this.getContentPane().add(jsp, BorderLayout.CENTER);
        this.setVisible(true);
        for(int i = 0; i < 200; i++) {
          sb.insert(0, i+"<br>");
          jep.setText(sb.toString());
      public static void main(String[] args) { new Test(); }
    }I'm using JEditorPane because it's easy to change I can use html tags to alter the font color/size/properties/etc.... As well, users can embed links which will then open in a browser. Is there a better way of doing this? I've tried setDoubleBuffered(true/false) on various combinations of components, using String concatenations, and setting the StringBuffer's initial length to a largish number (~5000). Nothing seems to alter the results. This problem occurs on linux and NT4 with jdks 1.3.0_002, 1.3.1, 1.4. If someone can help I'd be really grateful. I want the target jdk to be 1.3.1, so anything that came in with 1.4 isn't really an option.
    Thanks in advance,
    m

    Kurt,
    Thanks, I think that did the trick. I still have to put it into the chat app, but it works great with the test app. One thing, I do want the new text to be inserted at the top, not appended, so I changed the read statement to:
    jep.getEditorKit().read(new java.io.StringReader(i+"<br>"), doc, 0);and that throws an exception:java.lang.RuntimeException: Must insert new content into body element-
         at javax.swing.text.html.HTMLDocument$HTMLReader.generateEndsSpecsForMidInsert(HTMLDocument.java:1716)
         at javax.swing.text.html.HTMLDocument$HTMLReader.<init>(HTMLDocument.java:1692)
         at javax.swing.text.html.HTMLDocument$HTMLReader.<init>(HTMLDocument.java:1564)
         at javax.swing.text.html.HTMLDocument$HTMLReader.<init>(HTMLDocument.java:1559)
         at javax.swing.text.html.HTMLDocument.getReader(HTMLDocument.java:118)
         at javax.swing.text.html.HTMLEditorKit.read(HTMLEditorKit.java:237)
         at Test.<init>(Test.java:25)
         at Test.main(Test.java:38)but if I change position to 1 it works fine. Any explanation? The source for EditorKit says:
         * @param pos The location in the document to place the
         *   content >= 0.m

  • JScrollPane : save positions

    I am working on file browser. I have a table in JScrollPane. I want to save position of JScrollPane vertical bar when I select a folder. I realized a class that save value when I select a folder. When I move up it loads these values and sets these properties back. But I have a problem. If I move from a folder with big number of files (maximum is big) to a folder with a few files all works fine.
    JScrollPane s =...
    s.getVerticalScrollBar().setValue (400);
    assert s.getVerticalScrollBar().getValue() == 400;
    But if I move from a folder with a few files (maximum is small) t oa folder with a lot of files it doesn't work.
    JScrollPane s =...
    s.getVerticalScrollBar().setValue (400);
    assert s.getVerticalScrollBar().getValue() != 400; //s.getVerticalScrollBar().getValue() == 152 for example
    What should I do?

    Try something like this:
    SELECT substring(I.ItemCode+'XXXXXXXXXXXXXXXXXXXXX',1,18) from OITM I

  • JScrollPane Visibility

    Hey,
    I'm having some issues with setVisible on JScrollPanes.
    Basically I'm writing a little class that's storing settings using java.util.Properties.
    These settings are checked on load to see if it should display some certain buttons, and a JScrollPane.
    I've also included a JMenu with checkbox items to toggle visibility of these buttons/JScrollPane during runtime.
    Now to the problem, when I launch the class with the JScrollPane disabled in configuration I can't seem to make it visible again.
    The setVisible(true); line is being run, as I've printlned the object on change. But it's just not appearing on screen.
    When the class is run with the JScrollPane enabled in configuration it runs fine, and changes visibility on demand.
    Heres a small example snippet:
    Properties config = new Properties();
    config.load(new FileInputStream("configfile.cfg));
    if (config.get("showScroll")!=null) {
        if (config.get("showScroll").equals("0") {
            scrollPane.setVisible(false);
        } else {
            scrollPane.setVisible(true);
    } else {
        config.setProperty("showScroll","1");
        scrollPane.setVisible(true);
    }Then the toggle button changes setVisible(); between true/false and config.setProperty("showScroll","1/0");.
    So basically if at runtime "showScroll" = "0" the scrollPane won't be visible, and the toggle button won't make it visible even though it is changing the state.
    If "showScroll" = "1" the scrollPane will be visible, and the toggle button will toggle it between visible and invisible without any hassles.
    Sorry if this post is mumbled, 3am here and I'm a bit tired.
    Thanks in advance.

    Ahh great, thanks heaps.
    I came so close as well, I had actually tried repaint() with no luck.
    validate(); worked a treat :)

  • Layout Problem in a JScrollPane

    Hi Friends. I have the following problem.
    Fact 1:
    When I add components to a JPanel with a FlowLayout, the components rearrange themself to the next line when the length exceeds the viewable area(horizontally).
    Goal:
    I want to add the JPanel to a scrollPane and I dont want the horizontal scrolling. I want that when I add the components to the JPanel, components are added to the new line, when the horizontal viewable area is used up.(Something like the "fact" mentioned above ... but the difference here is, I want the JPanel inside a JScrollPane)
    Problem :
    When i add the JPanel to the scrollPane and adds components to JPanel... all components come into one line and don't wraps up themself.
    I have also tried with various properties.. telling no horizontal scrollbar etc... but it doesnt helps..... the components are laid off in one single long line.
    Please help me with this problem.
    Thanks a lot in advance.
    Warm Regards,
    Nishant

    hi friends,
    yeah now after a lot of RnD , I am able to implement a solution to the problem... it might not be a good one, but for me it is decent enuf.
    I tried everything , extending a custom JPanel from Scrollable and all sorts of things, but nothing was very helpful.
    One single thing which is most important is the preferredSize of the JPanel, which if you can set properly with the addition/deletion or resizing ,..... the problem is solved.
    so the problem remains only to set the appropiate preferredSize of the Jpanel. unfortunately, the JPanel's respective preferredSize, maximumSize, minimumSize etc are not of much help.
    so I decided to look for the components inside the JPanel and look for the last component position and the height.... but unfortunately (I dont know the reason), I get the position of all components, except the last one correct. So my choice of component now is last but one. I calculated the position of last but one component and added the (height of this component + height of last component + some buffer ), to get the height of the panel.
    and set the preferredSize of the Jpanel appropiately, for ex. in the action, adding components to the panel.. etc .. etc...
    the code snippet is as follows..and it works absolutely fantastic for my requirements, atleast...
    Component[] tmpC = _oLeftPanel.getComponents();
    if(tmpC.length >1)
         double kbuffer = 25D;
         //doing for last but one comp.
         Component kcomp1 = tmpC[tmpC.length - 2];
         double kh1 = kcomp1.getY();
         kh1 += kcomp1.getHeight();
         kh1 += kbuffer;
         //doing it for the last component
         kcomp1 = tmpC[tmpC.length - 1];
         kh1 += kcomp1.getHeight();
         kh1 += kbuffer;
         Dimension kdim = new Dimension((int)_oLeftScrollPane.getViewport().getViewSize().getWidth(), (int)kh1);
         _oLeftPanel.setPreferredSize(kdim);

  • Image NOT refreshing in jscrollpane/jpanel [source code included]

    Hello All,
    I am simply trying to show a large image inside a JScrollPane. I put several panels inside the main frame with a scrollpane and buttons in separate panels. On load, the image shows fine, but when I click Hide, the image doesn't refresh unless i drag another window (whether it is the command prompt window or a browser window or ANY window) over the main frame. The same thing happens when I click Show. After the image is hidden (or removed) and Show is clicked, the image doesn't refresh unless you roll another window over the image window.
    Why does this happen??? Can someone please help? Your help is greatly appreciated! ...I am using Textpad by the way.
    You may try running this by pasting my code, but the line where it says "tempScreenCaptureTest = imageLoad "ScreenCapture/data/ScreenCapture.jpg");" needs a real jpg image file (i used a screenshot of my own desktop) for you to see an image.
    // import classes
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.datatransfer.*;
    import javax.swing.*;
    public class ScreenCaptureTest extends JFrame implements ActionListener
         private static void main(String[] args)
              // Create an instance of the application
              ScreenCaptureTest mainFrame = new ScreenCaptureTest();
              mainFrame.setVisible(true);
         } // end of main
         // create window objects
         private JPanel panelCenter = new JPanel();
         private JPanel panelSouth = new JPanel();
         private JScrollPane scrollPane;
         private JButton buttonShow = new JButton("Show");
         private JButton buttonHide = new JButton("Hide");
         private JLabel tempScreenCaptureTest;
         public ScreenCaptureTest()
              // font properties
              Font mainFont = new Font(("Verdana"), Font.PLAIN, 16);
              // set window properties
              setTitle("Screen Capture");
              setSize(700, 700);
              setBackground(Color.white);
              setResizable(false);
              getContentPane().setLayout(new BorderLayout());
              // load the ScreenCaptureTest image into the scrollPane object
              tempScreenCaptureTest = imageLoad("ScreenCapture/data/ScreenCapture.jpg");
              // set Cancel properties
              buttonShow.setFont(mainFont);
              buttonShow.setForeground(Color.black);
              buttonShow.setBackground(Color.gray);
              buttonShow.setBounds(50, 260, 200, 50);
              buttonShow.addActionListener(this);
              panelSouth.add(buttonShow, BorderLayout.WEST);
              // set Clear properties
              buttonHide.setFont(mainFont);
              buttonHide.setForeground(Color.black);
              buttonHide.setBackground(Color.gray);
              buttonHide.setBounds(50, 260, 200, 50);
              buttonHide.addActionListener(this);
              panelSouth.add(buttonHide, BorderLayout.EAST);
              // set panel properties
              getContentPane().add(panelSouth, BorderLayout.SOUTH);
         } // end of constructor
         // loads an image into the JScrollPane
         private JLabel imageLoad(String filepath)
              // create a label
              Icon image = new ImageIcon(filepath);
              JLabel labelScreenCaptureTest = new JLabel(image);
              panelCenter.setLayout(new BorderLayout());
              // create a tabbed pane
              scrollPane = new JScrollPane();
              scrollPane.getViewport().add(labelScreenCaptureTest);
              panelCenter.add(scrollPane, BorderLayout.CENTER);
              // set panel properties
              getContentPane().add(panelCenter, BorderLayout.CENTER);
              return labelScreenCaptureTest;
         // ActionListener method()
         public void actionPerformed(ActionEvent event)
              if (event.getSource() == buttonShow) {
                   scrollPane.getViewport().add(tempScreenCaptureTest);
                   panelCenter.add(scrollPane, BorderLayout.CENTER);
                   getContentPane().add(panelCenter, BorderLayout.CENTER);
              } else if (event.getSource() == buttonHide) {
                   System.out.print(tempScreenCaptureTest);
                   scrollPane.getViewport().remove(tempScreenCaptureTest);
                   panelCenter.remove(scrollPane);
                   getContentPane().add(panelCenter);
    }

    I might as well add my problem while I'm here. I'm using a JPanel with an overridden paint() method to draw my image. I'm holding the image in a JScrollPane and setting the preferred size to the image's dimensions. The trouble is, the image takes time to load. I've used an ImageObserver but I'm having trouble making it repaint the image. I can make the scroll pane update it's scrollbar width and height by telling it to updateUI() but I can't make it redraw the image. I've tried everything but from debugging I can see that it always calls my getPreferredSize() method last then after resizing, it doesn't redraw the image. Even if I tell it to repaint after updating UI. I'm at a loss :/ Is there a special component for managing images as I haven't done much work with them?

  • JList performance in JScrollPane

    Hi!
    I've got a really odd problem with JList handling inside a JScrollPane.
    What happens is that I populate the JList with elements from a vector, and it displays them allright, but when I add or remove any element after creating the jList for first time, the CPU usage goes crazy until I move the scrollbar knob of the ScrollPane it's in. After moving the knob, the elements display ok, and cpu usage goes down to normality.. I can reproduce this phenomenon every time.
    At first I thought it was a performance issue, but after implementing a custom minimal cell renderer (which I actually don't use anymore) and adjusting the prototypecell and fixed size properties, this kept happening... Any ideas are welcome!
    Thanks!
    P.S:The code is a little large, but I'll post it if it helps!

    Seems to work for meimport java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.*;
    public class Test2 extends JFrame {
      Vector data = new Vector(10000);
      DefaultListModel dlm = new DefaultListModel();
      JList jl = new JList();
      public Test2() {
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Container content = getContentPane();
        for (int i=0; i<10000; i++) dlm.addElement("Stuff-"+i);
        jl.setModel(dlm);
        JButton jb = new JButton("Remove");
        content.add(jb, BorderLayout.SOUTH);
        jb.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            int index = jl.getSelectedIndex();
            if (index>=0) dlm.remove(index);
        content.add(new JScrollPane(jl), BorderLayout.CENTER);
        setSize(300,300);
      public static void main(String[] args) { new Test2().setVisible(true); }
    }

  • Jscrollpane, jlist and forte

    hi, i putted a jlist into a jscrollpane into my form, but i can see all the elements into the jlist because scrollbars don't appear.
    i already saw some code into this forum, but i neet to know how to do it managing the properties of FORTE, not writing any code.
    can anyone help me?
    thanks
    sandro

    Follow this snippet
    JList list = new JList(model);
    list.setVisibleRowCount(4);
    The rowcount value should be less than the number of items in the list.
    For example,
    the number of items be 10 and visible row count is 4, then the scroll bar will automatically appear.
    Hope this will help you a lot

Maybe you are looking for

  • [SOLVED] USB Devices No Longer Designated by UUID

    My USB devices (external disks, flashdrives, etc) have always been mounted using  their UUID.  I have grsync processes set up using this method which I have used for years. Suddenly, my devices are being shown by label (/dev/sdb1, etc), and now no pr

  • Problem with Zen Micro

    I am having a problem with my ZEN Micro. Whenever I plug it in the computer it locks up. I have tried the disk cleanup. I have formated the device. I have removed the firmware. If it isn't pluged it, it will startup to the recovery menu, but as soon

  • The allow cookies option is missing  in safari preferences.

    The table relating to the cookies option is missing from the security tab in safari preferences,can't seem to find anywhere. Can anybody advise me on this. Thanks

  • Interactive Booklet purchased wont work under iTune 7

    Interactive Booklet purchased won't work under iTune 7.... I have two albums that I bought with iTune previously that contains interactive booklet, when I click on them, nothing happen. -T

  • ALTER TABLESPACE tbs READ ONLY; --hangs

    Hi all, The command to put the tablespace on READ ONLY mode is hang and i can´t do that. There is no backup runing at this time. There is no users changing objects on this tablespace. What could be the reason for this problem??? Tks, Paulo.