bug-classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug-classpath] [Bug swing/23204] New: JTable should compact columns to


From: abalkiss at redhat dot com
Subject: [bug-classpath] [Bug swing/23204] New: JTable should compact columns to avoid horizontal scrolling
Date: 2 Aug 2005 18:40:47 -0000

Reference implementation makes the columns in a JTable small enough that there
is no need for horizontal scrolling (even if this compacts the columns to an
unreadable size).

We should also shrink the columns to avoid horizontal scrolling.  The testcase
below should the difference.

==TESTCASE==
import java.awt.*;
import javax.swing.*;
import java.io.*;

class TestBig extends JFrame
{
   // Instance attributes used in this example
  private       JPanel          topPanel;
   public       JTable          table;
  public        JScrollPane scrollPane;
   public BufferedReader console = new BufferedReader(new
InputStreamReader(System.in));
  
  // Constructor of main frame
  public TestBig()
  {
    // Set the frame characteristics
    setTitle( "Simple Table Application" );
    setSize( 300, 200 );
    setBackground( Color.gray );
    
    // Create a panel to hold all other components
    topPanel = new JPanel();
    topPanel.setLayout( new BorderLayout() );
    getContentPane().add( topPanel );
    
    // Create columns names
    String columnNames[] = { "Column 1", "Column 2", "Column 3", "Column 4",
"Column 5", "Column 6","Column 1", "Column 2", "Column 3", "Column 4", "Column
5", "Column 6" };
    
    // Create some data
    String dataValues[][] =
      {
        { "12", "234", "67","12", "234", "67","12", "234", "67","12", "234", 
"67" },
        { "-123", "43", "853","12", "234", "67","12", "234", "67","12", "234",
"67" },
        { "93", "89.2", "109","12", "234", "67","12", "234", "67","12", "234",
"67" },
        { "279", "9033", "3092","12", "234", "67","12", "234", "67","12", "234",
"67" },
        { "2", "234", "67","12", "234", "67","12", "234", "67","12", "234", 
"67" },
        { "-23", "43", "853","12", "234", "67","12", "234", "67","12", "234",
"67" },
        { "9", "89.2", "109","12", "234", "67","12", "234", "67","12", "234",
"67" },
        { "29", "9033", "3092","12", "234", "67","12", "234", "67","12", "234",
"67" },
        { "11", "234", "67","12", "234", "67","12", "234", "67","12", "234", 
"67" },
        { "-1", "43", "853","12", "234", "67","12", "234", "67","12", "234", 
"67" },
        { "33", "89.2", "109","12", "234", "67","12", "234", "67","12", "234",
"67" },
        { "49", "9033", "3092","12", "234", "67","12", "234", "67","12", "234",
"67" },
        { "1", "234", "67","12", "234", "67","12", "234", "67","12", "234", 
"67" },
        { "3", "43", "853","12", "234", "67","12", "234", "67","12", "234", 
"67" },
        { "0", "89.2", "109","12", "234", "67","12", "234", "67","12", "234",
"67" },
        { "1279", "9033", "3092","12", "234", "67","12", "234", "67","12",
"234", "67" },
        { "32", "234", "67","12", "234", "67","12", "234", "67","12", "234", 
"67" },
        { "-2", "43", "853","12", "234", "67","12", "234", "67","12", "234", 
"67" },
        { "932", "89.2", "109","12", "234", "67","12", "234", "67","12", "234",
"67" },
        { "270", "9033", "3092","12", "234", "67","12", "234", "67","12", "234",
"67" },
        { "102", "234", "67","12", "234", "67","12", "234", "67","12", "234",
"67" },
        { "23", "43", "853","12", "234", "67","12", "234", "67","12", "234", 
"67" },
        { "193", "89.2", "109","12", "234", "67","12", "234", "67","12", "234",
"67" },
        { "2279", "9033", "3092","12", "234", "67","12", "234", "67","12",
"234", "67" }
      };
    
    // Create a new table instance
    table = new JTable( dataValues, columnNames );
    table.setColumnSelectionAllowed(true);
    table.setRowSelectionAllowed(true);
   
table.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
   
table.getColumnModel().getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
        //        table.setCellSelectionEnabled(false);


    
    // Add the table to a scrolling pane
    scrollPane = new JScrollPane( table );
    topPanel.add( scrollPane, BorderLayout.CENTER );
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }
  
  // Main entry point for this example
  public static void main( String args[] ) throws IOException
  {
    // Create an instance of the test application
    TestBig mainFrame   = new TestBig();
    mainFrame.setVisible( true );
  }
}

-- 
           Summary: JTable should compact columns to avoid horizontal
                    scrolling
           Product: classpath
           Version: unspecified
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: swing
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: abalkiss at redhat dot com
                CC: bug-classpath at gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23204




reply via email to

[Prev in Thread] Current Thread [Next in Thread]