Solaris 9 & JTable Scrolling

Hi,
I've got an application that runs fine on Windows and earlier Solaris versions, but has a problem on Solaris 9. The application has a JTable in a JScrollPane that displays dynamically captured data. In Solaris 9, the table is not repainting properly when scrolling up/down by a row or page. The old information is not erased before writing the new information, so it becomes a big garbled mess when scrolling. When the block is grabbed with the mouse and moved, the table is repainted properly.
Has anyone seen this? Any ideas for workarounds?

many thanks for your test!
I need to install it in the next couple of weeks so I will keep this issue in mind.
Perhaps you can let the BU to update the ReadMe with this information - otherwise it could result in some frustration when installing it on solaris 9...:-)

Similar Messages

  • JTable scrolling problem...

    I am having a problem with my JTable scrolling to show the newest added row. I have it working, but it jumps. Here is my problem.
    I have the enter key acting like the tab key. I can force the scroll to the active cell but it jumps to row 0 for just a split second.
    I know the problem is the way that I handle the Enter key. When I press enter I drop a cell down but then I force it back up.
    Does any one know how to fix this? Here is some of the code that I am using...
    if (event.getKeyChar() == '\n')
    int r = tblDetailEntry.getSelectedRow();
    int c = tblDetailEntry.getSelectedColumn();
    if(r == 0)
    r = curBill.billDetail.size();
    c--;
    if(r <= curBill.billDetail.size())
    r--;
    if(c == curBill.CODE)
    c = 0;
    if(r == curBill.billDetail.size() - 1)
    detailEntry.addLine();     
    r = curBill.billDetail.size() - 1;               
    else
    r++;
    Rectangle rect = tblDetailEntry.getCellRect(r, 0, true);
    tblDetailEntry.scrollRectToVisible(rect);
    tblDetailEntry.editCellAt(r,c + 1);
    tblDetailEntry.setRowSelectionInterval(r,r);
    tblDetailEntry.setColumnSelectionInterval(c + 1,c + 1);     
    }

    My app is a bit more complex. It includes search criteria (Textboxes) and a
    submit button which will write a dynamic SQL statment, execute and fill a table > thin an internal scrollpaneIt doesn't matter that you are using a "dynamic SQL statement". Whats important is how you build your TableModel and the TableModel you are using. I gave you an example that will use the DefaultTableModel and will work for a single row or 1,000 rows in the ResultSet.
    Your question didn't state whether you are using the the DefaultTableModel or a custom TableModel. If you are using a custom TableModel, then chances are you have an error in you TableModel.
    In no way am I asking for you or anyone else to supply me with code. Only a
    possible step in the right direction. This is exactly what my example did. It proved to you that it works. So you look at your code and see what the differences are between one that works and one that doesn't. The example has three basic lines of code to build a scrollable table:
    JTable table = new JTable(data, columnNames);
    JScrollPane scrollPane = new JScrollPane( table );
    getContentPane().add( scrollPane );
    I don't know how is can get any simpler than that, so I would have no idea what to suggest you are doing wrong. Are you mixing AWT and Swing components?

  • JTable Scrolling

    Hi,
    I have a problem in JTable scrolling of large data,I am getting a large data set from database, but I do not want to display all of the data at once (mainly because of OutOfMemory error).I want to display data in pages (say 50 records in each page) ,but I want to keep the vertical scrollbar position as though I have the entire data (Let's say 10,000 records) in JTable,But physically only 50 records are there in JTable. In another words,I want to give user an illusion of having 10,000 records, but in fact only 50 records are there at a time.It means if my scrollbar position is halfway,my jtable has displayed 5000 records.
    I will appreciate your help.
    Please email me directly at [email protected] or post your reply.
    Thanks

    hi Chuanhao,
    The reason I can't get the data directly from my table model using getValueAt is that,
    1) The data which I am getting from database is raw data, I have to do lot of processing,and format it in a certain way so that my JTable implementaion can understand it (My implementation of JTable takes the data as JTextArea and JButton,moreover, I have to convert the data into user readable format before I can send it to JTable for display)
    2) I want to do some caching of data, for example if user has scrolled down, and then again he wants to go back by scrolling up, I don't want to get the data from database,I would like to use the same data which is in cache,Or I want to keep several pages of data ready in another thread, so that when user scrolled down, he doesn't have to wait for database fetch.
    I don't think I can do all this thing if I get the data directly from table model using getValueAt.
    What I want to do at this point is find some way to override the scrolling behaviour of JTable,My problem here is this,When user scrolled down to 51st record, I am fetching another 50 records(or already cached page) and wants to display it in the table afresh,But as soon as I do it, scrollbar goes back to its starting position,but I want it to stay where it was,in this way I will have place to scroll up,and user will think that he has entire set of records at his disposal.
    Let me know what you think, any help will be greatly appreciated.
    Thanks

  • JTable Scroll Issue (not scrollRectToVisible)

    I have a JTable that the user adds rows to. This table has a totals row as well at the bottom.
    This table can get quite large and each new row they add is at the bottom (minus one for the totals row). Currently, I'm using scrollRectToVisible which works fine.
    My problem is that this table has more columns then there is room for on screen.
    scrollRectToVisible wants a column as well as it's scrolling to a cell, not an actual row. I've always used 0 as my column as it works but now I've had some users say that if they scroll the table to the right, then add a new row, it "jumps" back to the left. Which would be true as it's going to row x column 0. The reason this matters is because they are looking at the totals row to see what the new total will be once the row is added. Some are slightly annoyed that they have to scroll back to the right to see the new total.
    Is there anyway to scroll to a row but not worry about the column?
    Thanks for your help!
    --Ethan                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    could you recommend me a good book(s) on SwingSorry, I've never read a book on Swing. I learned by reading the [url http://java.sun.com/docs/books/tutorial/]Swing Tutotorial and by answering questions on the forum and by reading answers of other posters on the forum.

  • JTable scroll

    how can I programatically scroll a JTable?
    thanks.

    If you want to scroll to see a certain cell you can use
    jtable.scrollRectToVisible(jtable.getCellRect(row, column, true);
    I hope this helps you,
    Denis

  • JTable scrolling in Windows 7 very slow compared to Windows XP

    I am running the following test program on jdk-6u18. The program displays a simple 900 rows x 20 columns table with each cell being an integer 1. When I run this is Windows 7, the scrollbar handle cannot keep up with the mouse movement as I drag it up and down. But the scrolling is very smooth if I run it on a Windows XP virtual machine on the same PC. Is there any way to improve the JTable performance on Windows 7?
    Thanks.
    import java.awt.*;
    import javax.swing.table.*;
    import javax.swing.*;
    public class TableTestSimple extends AbstractTableModel {
        static final Integer tableValue = new Integer(1);
        static final String columnName = "Column";
        @Override public int getColumnCount() {
            return 20;
        @Override public int getRowCount() {
            return 900;
        @Override public Object getValueAt(int row, int column) {
            return tableValue;
        @Override public String getColumnName (int columnIndex) {
            return columnName;
        @Override public Class getColumnClass (int columnIndex) {
                return Integer.class;
        public static void main(String[] args) throws Exception{
            TableTestSimple t = new TableTestSimple();
            JFrame frame = new JFrame("Table Test");
            JPanel panel = new JPanel();
            panel.setLayout(new BorderLayout());
            JTable table = new JTable(t);
            JScrollPane scrollPane = new JScrollPane(table);
            panel.add(scrollPane, BorderLayout.CENTER);
            panel.setPreferredSize(new java.awt.Dimension(1000, 1000));
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setContentPane(panel);
            frame.pack();
            frame.setVisible(true);
    }

    I ran your code and didn't get the problem stated.Microsoft Windows [Version 6.1.7600]
    Copyright (c) 2009 Microsoft Corporation.  All rights reserved.
    C:\Users\Darryl>java -version
    java version "1.6.0_17"
    Java(TM) SE Runtime Environment (build 1.6.0_17-b04)
    Java HotSpot(TM) Client VM (build 14.3-b01, mixed mode, sharing)Possibly a defective video driver. You could try installing optional updates from Windows Update.
    db

  • How to auto scroll from top to bottom on JTable ?

    HI All.
    At the current, I use JTable is contained JScrollPane. Now, I want Jtable auto scroll from first item to bottom and when JTable scroll to bottom then Jtable will scroll bottom to top, It is loop. Who know how do this function, please help me.

    Thanks for reply
    Actually. I was code -> scroll from top to bottom on JTable. Code below But when JTable auto scroll then screen is not smooth.
    Please help How to workground for this problem
    private void scrollTopToBottom() {
                   try {
                        JViewport viewport = flexGrid.getViewport();
                        int heightViewport = viewport.getViewSize().height;
                        while(moveY < heightViewport) {
                             synchronized (this) {
                                  while (suspended)
                                       this.wait();
                                  if (stopped)
                                       break;
                             moveY += 10;
                             if(moveY > heightViewport) {
                                  moveY = heightViewport;
                             viewport.setViewPosition(new Point(0, moveY));
                             try {
                                  Thread.sleep(500);
                             } catch (InterruptedException e1) {
                                  e1.printStackTrace();
                             viewport.updateUI();
                   } catch (InterruptedException e) {
              }

  • How to write the JTables Content into the CSV File.

    Hi Friends
    I managed to write the Database records into the CSV Files. Now i would like to add the JTables contend into the CSV Files.
    I just add the Code which Used to write the Database records into the CSV Files.
    void exportApi()throws Exception
              try
                   PrintWriter writing= new PrintWriter(new FileWriter("Report.csv"));
                   System.out.println("Connected");
                   stexport=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
                   rsexport=stexport.executeQuery("Select * from IssuedBook ");
                   ResultSetMetaData md = rsexport.getMetaData();
                   int columns = md.getColumnCount();
                   String fieldNames[]={"No","Name","Author","Date","Id","Issued","Return"};
                   //write fields names
                   String rec = "";
                   for (int i=0; i < fieldNames.length; i++)
                        rec +='\"'+fieldNames[i]+'\"';
                        rec+=",";
                   if (rec.endsWith(",")) rec=rec.substring(0, (rec.length()-1));
                   writing.println(rec);
                   //write values from result set to file
                    rsexport.beforeFirst();
                   while(rsexport.next())
                        rec = "";
                         for (int i=1; i < (columns+1); i++)
                             try
                                    rec +="\""+rsexport.getString(i)+"\",";
                                    rec +="\""+rsexport.getInt(i)+"\",";
                             catch(SQLException sqle)
                                  // I would add this System.out.println("Exception in retrieval in for loop:\n"+sqle);
                         if (rec.endsWith(",")) rec=rec.substring(0,(rec.length()-1));
                        writing.println(rec);
                   writing.close();
         }With this Same code how to Write the JTable content into the CSV Files.
    Please tell me how to implement this.
    Thank you for your Service
    Jofin

    Hi Friends
    I just modified my code and tried according to your suggestion. But here it does not print the records inside CSV File. But when i use ResultSet it prints the Records inside the CSV. Now i want to Display only the JTable content.
    I am posting my code here. Please run this code and find the Report.csv file in your current Directory. and please help me to come out of this Problem.
    import javax.swing.*;
    import java.util.*;
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.table.*;
    public class Exporting extends JDialog implements ActionListener
         private JRadioButton rby,rbn,rbr,rbnore,rbnorest;
         private ButtonGroup bg;
         private JPanel exportpanel;
         private JButton btnExpots;
         FileReader reading=null;
         FileWriter writing=null;
         JTable table;
         JScrollPane scroll;
         public Exporting()throws Exception
              setSize(550,450);
              setTitle("Export Results");
              this.setLocation(100,100);
              String Heading[]={"BOOK ID","NAME","AUTHOR","PRICE"};
              String records[][]={{"B0201","JAVA PROGRAMING","JAMES","1234.00"},
                               {"B0202","SERVLET PROGRAMING","GOSLIN","1425.00"},
                               {"B0203","PHP DEVELOPMENT","SUNITHA","123"},
                               {"B0204","PRIAM","SELVI","1354"},
                               {"B0205","JAVA PROGRAMING","JAMES","1234.00"},
                               {"B0206","SERVLET PROGRAMING","GOSLIN","1425.00"},
                               {"B0207","PHP DEVELOPMENT","SUNITHA","123"},
                               {"B0208","PRIAM","SELVI","1354"}};
              btnExpots= new JButton("Export");
              btnExpots.addActionListener(this);
              btnExpots.setBounds(140,200,60,25);
              table = new JTable();
              scroll=new JScrollPane(table);
              ((DefaultTableModel)table.getModel()).setDataVector(records,Heading);
              System.out.println(table.getModel());
              exportpanel= new JPanel();
              exportpanel.add(btnExpots,BorderLayout.SOUTH);
              exportpanel.add(scroll);
              getContentPane().add(exportpanel);
              setVisible(true);
          public void actionPerformed(ActionEvent ae)
              Object obj=ae.getSource();
              try {
              PrintWriter writing= new PrintWriter(new FileWriter("Report.csv"));
              if(obj==btnExpots)
                   for(int row=0;row<table.getRowCount();++row)
                             for(int col=0;col<table.getColumnCount();++col)
                                  Object ob=table.getValueAt(row,col);
                                  //exportApi(ob);
                                  System.out.println(ob);
                                  System.out.println("Connected");
                                  String fieldNames[]={"BOOK ID","NAME","AUTHOR","PRICE"};
                                  String rec = "";
                                  for (int i=0; i <fieldNames.length; i++)
                                       rec +='\"'+fieldNames[i]+'\"';
                                       rec+=",";
                                  if (rec.endsWith(",")) rec=rec.substring(0, (rec.length()-1));
                                  writing.println(rec);
                                  //write values from result set to file
                                   rec +="\""+ob+"\",";     
                                   if (rec.endsWith(",")) rec=rec.substring(0,(rec.length()-1));
                                   writing.println(rec);
                                   writing.close();
         catch(Exception ex)
              ex.printStackTrace();
         public static void main(String arg[]) throws Exception
              Exporting ex= new Exporting();
    }Could anyone Please modify my code and help me out.
    Thank you for your service
    Cheers
    Jofin

  • JDialog/JTable sizing

    I have a JDialog with a JTable/scroll pane. The JTable has headers but no data initially.
    I want to set the min size samller than the initial size.
    When I try setSize/setPreferred size this is not working. It always inits to the min size.
        public TheDialog(Frame parent)
            super(parent);
            theModel = new TheTableModel();
            theTable      = new TheTable(thetableModel);
            Dimension size = new Dimension(100,400);
            setLayout(new BorderLayout());
            JScrollPane scrollPane = new JScrollPane(theTable,
                                                     JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                                                     JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
            scrollPane.setPreferredSize(size);
            scrollPane.setSize(size);
            add(scrollPane, BorderLayout.CENTER);  
            setPreferredSize(size);
            setSize(size);
           setMinimumSize(new Dimension(100,20));

    I am fairly new to the forum
    Didn't know that people cared about any feedbackWhat does being new to a forum have to do with anything?
    In other words you don't believe in saying "thank you" when someone gives you help, whether in a forum or in other apects of daily life?
    Maybe the following will work:
    table.setPreferredScrollableViewportSize(...);If you need further help then you need to create a [Short, Self Contained, Compilable and Executable, Example Program (SSCCE)|http://homepage1.nifty.com/algafield/sscce.html], that demonstrates the incorrect behaviour.
    Don't forget to use the Code Formatting Tags so the posted code retains its original formatting. That is done by selecting the code and then clicking on the "Code" button above the question input area.

  • JScrollPane not scrolling to the end of JTable

    Hello,
    I put a table in a scroll pane, and add the scroll pane to a panel. The problem is the scroll pane does not scroll to the end of the table, it always lets me view only the first 37 rows of the table, regardless of how many rows the table actually has. Basically, the scroll pane thinks the table has exactly the same height, no matter how many lines it has. Why is this happening?
    The code is something like
    model = new SearchResultTableModel(false, null, null);
    table = new ResultTable(model);
    scrollPane = new JScrollPane(table);
    mainBox.add(scrollPane);
    If this is important, the table is a bit more complicated, I subclass JTable, use a custom TableModel, several types of cell renderers / editors, so maybe this is why it behaves so strange. How could I tell the scroll pane the table is actually larger?
    Thank you very much, any ideas are highly appreciated,
    Regards from Romania,
    Adi

    Hi,
    fireTableDataChanged() is the easiest way to do it, but also that one, that forces JTable to rerender all visible cells, regardless the fact, that they are already displayed and would not need rerendering - if you add a row - for example row 7 - do fireTableRowsInserted(7,7); instead - so JTable will only render this single row if it is visible in the viewport. If you add a couple of rows, for example row 7 to 227, do fireTableRowsInserted(7,227); - always fire only the correct notifications accordingly to the changes you make, in order to keep the performance of JTable high.
    greetings Marsian

  • No horizontal scroll bar on the Jtable. In order to see long column.....

    No horizontal scroll bar on the tJable.
    In order to see long cell data we have to eliminate other columns of the table.
    I need an horizontal scroll bar on the JTable if the data in a cell is longer.
    Could somebody help me out?
    Thanks in advance.

    in the jtable use following method :
    myTable.setAutoResizeMode(this.AUTO_RESIZE_OFF);
    KR,
    Jan

  • Horizontal Scroll in JTable

    Hello!
    I have a JTable inside a JScrollPane when the table has horizontal scroll it looks strange. When the user clicks in arrows of horizontal scroll the headers of table don't follow the scroll.
    What am I doing wrong?
    Thanks,
    Pati

    That's my code
    import java.awt.Dimension;
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    public class Teste extends JFrame{
         public Teste()
         this.setSize(320,270);
         JTable table = new JTable(10,15);
         JScrollPane scroll = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_NEVER, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
         table.getColumnModel().getColumn(0).setPreferredWidth(150);
         table.getTableHeader().setPreferredSize(new Dimension(150,15));
         table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
         scroll.setBounds(10,10,300,250);
         this.getContentPane().add(scroll);
         this.setVisible(true);
         public static void main(String args[]){
              Teste obj = new Teste();          
    The problem is in line:
    table.getTableHeader().setPreferredSize(new Dimension(150,15));
    When I remove it, the table works well.

  • JTable can't display column names and scroll bar in JDialog !!

    Dear All ,
    My flow of program is JFrame call JDialog.
    dialogCopy = new dialogCopyBay(frame, "Bay Name Define", true, Integer.parseInt(txtSourceBay.getText()) ,proVsl ,300 ,300);
    dialogCopy.setBounds(0, 0, 300, 300);
    dialogCopy.setVisible(true);        Then,I set the datasource of JTable is from a TableModel.
    It's wild that JTable can diplay the data without column names and scroll bar.
    I have no idea what's going wrong.Cause I follow the Sun Tutorial to code.
    Here with the code of my JDialog.
    Thanks & Best Regards
    package com.whl.panel;
    import com.whl.vslEditor.vslDefine;
    import java.awt.Container;
    import java.awt.Dimension;
    import java.awt.Frame;
    import javax.swing.JDialog;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.table.AbstractTableModel;
    public class dialogCopyBay extends JDialog {
        vslDefine glbVslDefine;
        int lvCnt = -1;
        JTable tableCopyBay;
        int bgnX = 0;
        int bgnY = 30;
        int tableWidth = 100;
        int tableHeight = 100;
        public dialogCopyBay(Frame frame, String title, boolean modal, int sourceBay,
                vslDefine pVslDefine, int ttlWidth, int ttlHeight) {
            super(frame, title, true);
            Container contentPane = getContentPane();
            System.out.println("dialogCopyBay Constructor");
            glbVslDefine = null;
            glbVslDefine = pVslDefine;
            copyBayModel copyBay = new copyBayModel((glbVslDefine.getVslBayStructure().length - 1),sourceBay);
            tableCopyBay = new JTable(copyBay);
            tableCopyBay.setPreferredScrollableViewportSize(new Dimension(tableWidth, tableHeight));
            JScrollPane scrollPane = new JScrollPane(tableCopyBay);
            scrollPane.setViewportView(tableCopyBay) ;
            tableCopyBay.setFillsViewportHeight(true);
            tableCopyBay.setBounds(bgnX, bgnY, tableWidth, tableHeight);
            tableCopyBay.setBounds(10, 10, 100, 200) ;
            contentPane.setLayout(null);
            contentPane.add(scrollPane);
            contentPane.add(tableCopyBay);
        class copyBayModel extends AbstractTableModel {
            String[] columnNames;
            Object[][] dataTarget;
            public copyBayModel(int rowNum ,int pSourceBay) {
                columnNames = new String[]{"Choose", "Bay Name"};
                dataTarget = new Object[rowNum][2];
                for (int i = 0; i <= glbVslDefine.getVslBayStructure().length - 1; i++) {
                    if (pSourceBay != glbVslDefine.getVslBayStructure().getBayName() &&
    glbVslDefine.getVslBayStructure()[i].getIsSuperStructure() == 'N') {
    lvCnt = lvCnt + 1;
    dataTarget[lvCnt][0] = false;
    dataTarget[lvCnt][1] = glbVslDefine.getVslBayStructure()[i].getBayName();
    System.out.println("lvCnt=" + lvCnt + ",BayName=" + glbVslDefine.getVslBayStructure()[i].getBayName());
    public int getRowCount() {
    return dataTarget.length;
    public int getColumnCount() {
    return columnNames.length;
    public String getColumnName(int col) {
    return columnNames[col];
    public Object getValueAt(int rowIndex, int columnIndex) {
    return dataTarget[rowIndex][columnIndex];
    public Class getColumnClass(int c) {
    return getValueAt(0, c).getClass();
    public boolean isCellEditable(int row, int col) {
    if (col == 1) {
    // Bay Name Not Allow To modify
    return false;
    } else {
    return true;
    public void setValueAt(Object value, int row, int col) {
    dataTarget[row][col] = value;
    fireTableCellUpdated(row, col);

    Dear DB ,
    I am not sure what you mean.
    Currently,I don't undestand which code is error.
    And I also saw some example is add JTable and JScrollPane in JDialog.
    Like Below examle in Sun tutorial
    public class ListDialog extends JDialog implements MouseListener, MouseMotionListener{
        private static ListDialog dialog;
        private static String value = "";
        private JList list;
        public static void initialize(Component comp,
                String[] possibleValues,
                String title,
                String labelText) {
            Frame frame = JOptionPane.getFrameForComponent(comp);
            dialog = new ListDialog(frame, possibleValues,
                    title, labelText);
         * Show the initialized dialog. The first argument should
         * be null if you want the dialog to come up in the center
         * of the screen. Otherwise, the argument should be the
         * component on top of which the dialog should appear.
        public static String showDialog(Component comp, String initialValue) {
            if (dialog != null) {
                dialog.setValue(initialValue);
                dialog.setLocationRelativeTo(comp);
                dialog.setVisible(true);
            } else {
                System.err.println("ListDialog requires you to call initialize " + "before calling showDialog.");
            return value;
        private void setValue(String newValue) {
            value = newValue;
            list.setSelectedValue(value, true);
        private ListDialog(Frame frame, Object[] data, String title,
                String labelText) {
            super(frame, title, true);
    //buttons
            JButton cancelButton = new JButton("Cancel");
            final JButton setButton = new JButton("Set");
            cancelButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    ListDialog.dialog.setVisible(false);
            setButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    ListDialog.value = (String) (list.getSelectedValue());
                    ListDialog.dialog.setVisible(false);
            getRootPane().setDefaultButton(setButton);
    //main part of the dialog
            list = new JList(data);
            list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
            list.addMouseListener(new MouseAdapter() {
                public void mouseClicked(MouseEvent e) {
                    if (e.getClickCount() == 2) {
                        setButton.doClick();
            JScrollPane listScroller = new JScrollPane(list);
            listScroller.setPreferredSize(new Dimension(250, 80));
    //XXX: Must do the following, too, or else the scroller thinks
    //XXX: it's taller than it is:
            listScroller.setMinimumSize(new Dimension(250, 80));
            listScroller.setAlignmentX(LEFT_ALIGNMENT);
    //Create a container so that we can add a title around
    //the scroll pane. Can't add a title directly to the
    //scroll pane because its background would be white.
    //Lay out the label and scroll pane from top to button.
            JPanel listPane = new JPanel();
            listPane.setLayout(new BoxLayout(listPane, BoxLayout.Y_AXIS));
            JLabel label = new JLabel(labelText);
            label.setLabelFor(list);
            listPane.add(label);
            listPane.add(Box.createRigidArea(new Dimension(0, 5)));
            listPane.add(listScroller);
            listPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    //Lay out the buttons from left to right.
            JPanel buttonPane = new JPanel();
            buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.X_AXIS));
            buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
            buttonPane.add(Box.createHorizontalGlue());
            buttonPane.add(cancelButton);
            buttonPane.add(Box.createRigidArea(new Dimension(10, 0)));
            buttonPane.add(setButton);
    //Put everything together, using the content pane's BorderLayout.
            Container contentPane = getContentPane();
            contentPane.add(listPane, BorderLayout.CENTER);
            contentPane.add(buttonPane, BorderLayout.SOUTH);
            pack();
        public void mouseClicked(MouseEvent e) {
            System.out.println("Mouse Click");
        public void mousePressed(MouseEvent e) {
            throw new UnsupportedOperationException("Not supported yet.");
        public void mouseReleased(MouseEvent e) {
            throw new UnsupportedOperationException("Not supported yet.");
        public void mouseEntered(MouseEvent e) {
            throw new UnsupportedOperationException("Not supported yet.");
        public void mouseExited(MouseEvent e) {
            throw new UnsupportedOperationException("Not supported yet.");
        public void mouseDragged(MouseEvent e) {
            throw new UnsupportedOperationException("Not supported yet.");
        public void mouseMoved(MouseEvent e) {
            throw new UnsupportedOperationException("Not supported yet.");
         * This is here so that you can view ListDialog even if you
         * haven't written the code to include it in a program.
    }

  • JTable Horizontal Scroll WHEN NEEDED fix?

    Me again....
    JTable in a JScrollPane When the Jtable width exceeds the scrollpane I would like a horizontal scrollbar to appear. If the Jtable does not exceed the width Id like it to fill the ScrollPane.
    If I use the AUTO_RESIZE_OFF I get a horizontal scrollbar all the time. I dont want this if possible.
    I did try to overwrite getScrollableTracksViewportWidth() and getPreferredSize() as suggested by work around http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4127936
    However this bug is not exactly what I am having trouble with.
    Anyone know what I can do for this?
    Thanks
    B.

    You're welcome.
    Autoscrolling means that you can middle click on a web page and then get a scroll icon to indicate that you can move the mouse up or down to scroll the page automatically.

  • Automating scrolling of a JTable when model gets updated

    Hi,
    I have a JTable in a JScrollPane with a table model that updates in real time and I need to keep the currently selected row on the same place on screen (for example when a row is inserted before the selected row I'd like the scroll pane to automatically scroll one row down so the selected row remains at the same location on screen).
    the scrollpane before the row insertion:
    row A
    row B
    row C
    row D (selected)
    row E
    now 'row F' is inserted between B and C
    row B
    row F
    row C
    row D (selected)
    row E
    (row A is scrolled out of sigth and D remains (visually) the 4th row in the view)
    Is there any easy way how to achieve this ? I tried a number of approaches but all end up with an annoying scrollpane jitter.

    I'd try to call JViewPort's scrollRectToVisible(Rectangle contentRect) for the JScrollPane.getViewPort() and keep the parameter Rectangle's size the same (JViewPort.getViewRect()) but adjust the y-position by amount returned by JTable.getRowHeight() + JTable.getRowmargin(). This would be done after row wuold be added and only if vertical scrollbar is visible.
    Maybe this is what you have tried already. Anyway I hope this helps.

Maybe you are looking for