Update JScrollPane at runtime

Hi, well my problem is that I have a few JTextFields and an empty JScrollPane, but when something happens (e.i. a JButton is pressed) the text in the JTextFields should be added to the JScrollPane, but instead of that only the text from the last JTextField (in the example JTextField2) is added one time, no matters how many times the button is pressed, so the problem is:
How to add all the elements (in this case JLabels with the text from the JTextFields)?
I guess that all the elements are added but the last one overlaps the others.
Example:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class ScrollUpdate extends JFrame{
     JTextField text1;
     JTextField text2;
     JScrollPane scroll;
     public ScrollUpdate(){
          text1 = new JTextField("Text 1");
          text1.setPreferredSize(new Dimension(100,22));
          text2 = new JTextField("Text 2");
          text2.setPreferredSize(new Dimension(100,22));
          JPanel panel = (JPanel)getContentPane();
          panel.add(text1, BorderLayout.LINE_START);
          scroll = new JScrollPane();
          scroll.setPreferredSize(new Dimension(100,100));
          panel.add(scroll, BorderLayout.LINE_END);
          panel.add(text2, BorderLayout.CENTER);
          JButton update = new JButton("Update");
          update.addActionListener(new ActionListener(){
               public void actionPerformed(ActionEvent e){
                    JLabel texto1 = new JLabel(text1.getText());
                    texto1.setAlignmentX(CENTER_ALIGNMENT);
                    scroll.getViewport().add(texto1);
                    JLabel texto2 = new JLabel(text2.getText());
                    texto2.setAlignmentX(CENTER_ALIGNMENT);
                    scroll.getViewport().add(texto2);
                    scroll.getViewport().revalidate();
                    scroll.repaint();
          panel.add(update, BorderLayout.PAGE_END);
          pack();
          setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
          setLocationRelativeTo(null);
     public static void main(String args[]){
          java.awt.EventQueue.invokeLater(new Runnable() {
               public void run() {
                    try {
                         // Set System L&F
                         JFrame.setDefaultLookAndFeelDecorated(true);
                         JDialog.setDefaultLookAndFeelDecorated(true);
                         UIManager.setLookAndFeel(UIManager
                                   .getSystemLookAndFeelClassName());
                    } catch (ClassNotFoundException e) {
                          //handle exception
                    } catch (Exception e) {
                         try {
                              UIManager
                                        .setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
                         } catch (Exception f) {
                    ScrollUpdate fenster = new ScrollUpdate();
                    fenster.setVisible(true);
}

I think that your problem is that you're adding things directly to the viewport rather than to a JPanel that is viewed in the viewport, say one that uses a GridLayout(0, 1). For e.g.,
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class ScrollUpdate extends JFrame {
  JTextField text1;
  JTextField text2;
  JScrollPane scroll;
  private JPanel innerScrolledPanel = new JPanel(new GridLayout(0, 1));
  public ScrollUpdate() {
    text1 = new JTextField("Text 1");
    text1.setPreferredSize(new Dimension(100, 22));
    text2 = new JTextField("Text 2");
    text2.setPreferredSize(new Dimension(100, 22));
    JPanel panel = (JPanel) getContentPane();
    panel.add(text1, BorderLayout.LINE_START);
    scroll = new JScrollPane(innerScrolledPanel);
    scroll.setPreferredSize(new Dimension(100, 100));
    panel.add(scroll, BorderLayout.LINE_END);
    panel.add(text2, BorderLayout.CENTER);
    JButton update = new JButton("Update");
    update.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        JLabel texto1 = new JLabel(text1.getText());
        texto1.setAlignmentX(CENTER_ALIGNMENT);
        innerScrolledPanel.add(texto1);
        JLabel texto2 = new JLabel(text2.getText());
        texto2.setAlignmentX(CENTER_ALIGNMENT);
        innerScrolledPanel.add(texto2);
        innerScrolledPanel.revalidate();
        scroll.repaint();
    panel.add(update, BorderLayout.PAGE_END);
    pack();
    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setLocationRelativeTo(null);
  public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {
      public void run() {
        ScrollUpdate fenster = new ScrollUpdate();
        fenster.setVisible(true);
}

Similar Messages

  • Recent update download upset my entire itunes program. Can't use to sync iphone, ipad, etc nor run any other updates.  Get runtime error message, etc...and contact app support team.  Says itunes not installed correctly, pls reinstall. tried to no avail.

    A recent update download upset my entire itunes program. Unable to use to sync iphone, ipad, etc nor run any other updates.  Get runtime error message, Error 7 (windows error 1114)  etc...and contact app support team.  Says itunes not installed correctly, pls reinstall. tried to no avail.

    First try updating to iTunes 11.1.5.5, using an installer downloaded from the Apple website:
    http://www.apple.com/itunes/download/
    If you still get the errors after that, try the following user tip:
    Troubleshooting issues with iTunes for Windows updates

  • HT1338 how do i update to java runtime environment? Sun JavaVM (Virtual Machine)

    I need to update/install Java Runtime in order to update my Brother Printer. How do I install this program?

    See Using Java in Mac OS X.

  • How to update stylesheets at runtime?

    Strangely the style does'nt change if i manually change the css class rules in one of the css document and switch between the 2 files.
      @Override
      public void initialize(URL url, ResourceBundle rb) {
        final String cssUrl1 = getClass().getResource("/tracker/view/fxmlgui1.css").toExternalForm();
        final String cssUrl2 = getClass().getResource("/tracker/view/fxmlgui2.css").toExternalForm();
        rootPane.getStylesheets().add(cssUrl1);
        rootPane.addEventHandler(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() {
          @Override
          public void handle(KeyEvent keyEvent) {
            if (keyEvent.getCode().equals(KeyCode.DIGIT1)) {
              rootPane.getStylesheets().clear();
              rootPane.getStylesheets().add(cssUrl1);
              msgLabel.setText("Css1 selected.");
            } else if (keyEvent.getCode().equals(KeyCode.DIGIT2)) {
              rootPane.getStylesheets().clear();
              rootPane.getStylesheets().add(cssUrl2);
              msgLabel.setText("Css2 selected.");
    The event occurs and the style change from css1 and css2 as they was at the time of stage rendering, but if then i change one of the rules in the sylesheets after the stage is layed out, the style does'nt change anymore.
    So wich is the general way to change the style of nodes changing the css document at runtime?
    It's as the initial stylesheets in the css documents are someway cached and does'nt update at any switch.

    The controller's initialize() method is invoked during the call to FXMLLoader.load(...). Your application almost certainly has a structure like this:
    Parent root = FXMLLoader.load(...);
    Scene scene = new Scene(root);
    stage.setScene(scene);
    So at the point the initialize(...) method is called the root pane hasn't actually been attached to a Scene; thus the call to getScene() returns null.
    However, when your handler methods are called, the root will have been attached to a Scene and the Scene placed in a Stage, so at that point it is safe to call getScene() and getWindow() on the result.
    I would actually manipulate the stylesheets on the Scene, rather than the Stage, so the call to getWindow() is probably not needed.
    So I would try:
      @Override
      public void initialize(URL url, ResourceBundle rb) {
        final String cssUrl1 = getClass().getResource("/tracker/view/fxmlgui1.css").toExternalForm();
        final String cssUrl2 = getClass().getResource("/tracker/view/fxmlgui2.css").toExternalForm();
        rootPane.addEventHandler(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() {
          @Override
          public void handle(KeyEvent keyEvent) {
            if (keyEvent.getCode().equals(KeyCode.DIGIT1)) {
              rootPane.getScene().getStylesheets().clear();
              rootPane.getScene().getStylesheets().add(cssUrl1);
              msgLabel.setText("Css1 selected.");
            } else if (keyEvent.getCode().equals(KeyCode.DIGIT2)) {
              rootPane.getScene().getStylesheets().clear();
              rootPane.getScene().getStylesheets().add(cssUrl2);
              msgLabel.setText("Css2 selected.");
    The only issue now is that the initial stylesheet isn't set on the Scene. If you really want to do this from the controller, you need to listen for changes to the sceneProperty on the root pane. This gets a little ugly, but you can do something like this in your initialize method:
    rootPane.sceneProperty().addListener(new ChangeListener<Scene>() {
         @Override
         public void changed(ObservableVale<? extends Scene> observable, Scene oldScene, Scene newScene) {
              if (newScene != null) {
                   newScene.getStylesheets().add(cssUrl1);
                   rootPane.sceneProperty().removeListener(this);
    If you wanted to hold a reference to the Scene in the controller, you could use this same ChangeListener to do so, but there's no real benefit to doing that and the code is less readable, imo.
    Do you think i can use jdk8 as a stable jvm or it's yet for testing only as it's an early release?
    It depends to a certain extent what you're doing, but generally I would recommend using it for testing only. I was just suggesting trying your code against it to see if the issues were caused by a bug that had been fixed, which would rule out the possibility that there was something still wrong in your code that we weren't seeing. I can see two use cases for using JavaFX 8 right now other than just for testing. One (which I'm actually doing in one project right now) is if you have a release date suitably far ahead (ours is summer 2014) that you can reasonably expect JDK8 to be in a stable public release at that time. (You'd also probably want either to be able to control the JRE version for your client machines or be planning on a "native bundle" release.) The other is if you had a non-critical application that was going to be deployed in-house for a very limited number of users, and you wanted to take advantage of some new JDK/JavaFX 8 features.

  • How to update ArrayCollection at runtime?

    Am facing some problem with arraycollection..
    am having an arraycolelction like this...
    var dpHierarchy:ArrayCollection = new ArrayCollection([
    {Region:"Demand1"},
    {Region:"Demand2"},
    {Region:"Demand3"},
    {Region:"Demand4"}]
    now what am looking for is.. how to update this
    arraycollection at runtime using actions script?
    i need to update this array colelction something like this...
    var dpHierarchy:ArrayCollection = new ArrayCollection([
    {Region:"Demand1", Year:"2008"},
    {Region:"Demand2", Year:"2008"},
    {Region:"Demand3", Year:"2008"},
    {Region:"Demand4", Year:"2008"}]
    How to add Year field in to existing arraycollection like
    shown in about example..
    thanks in advance
    Pratap

    There are two ways you can do this. One would be setting it
    straight like this.
    private function updateDP():void {
    dpHierarchy[0].Year = "2008";
    This will also make it so that every other item in your
    ArrayCollection has the Year identifier however nothing will be
    filled in for the values. The other way you could do this would be
    to user setItemAt which would look like this.
    dpHierarchy.setItemAt({Region:"Demand1", Year:"2008"}, 0);
    which essentially does the exact same thing except your
    setting all the properties of that item instead of just adding the
    identifier Year.

  • ITunes 11.1.4 update failure. Runtime Error 6034

    I have had a complete nightmare today following an attempt to update iTunes 11.1.38 to 11.1.4 on my PC running Windows 7 Home Premium.
    These are the errors I encountered
    During installation the following messages were displayed ..
    Service 'Apple Mobile Device' (Apple Mobile Device) failed to start. Verify you have sufficient provileges to start system services.
    Whether I clicked Retry or Ignore, this message still appeared. 
    Clicking Abort triggered a further message ...
    The Installer encountered errors before iTunes could be configured.  Errors occurred during the Installation.  Your system has not been modified.    Please run the installer again or click Finish to Exit
    Temporary relief, thinking that iTunes had been rolled back to the previous settings of version 11.1.38
    Running the installer again had exactly the same result.
    iTunes then failed to launch
    An attempt at launching the program triggered the following Error
    Runtime Error R6034    An application has made an attempt to load the C Runtime library incorrectly.  Please contact Application support team for more information.
    This is when I turned to this Forum for help and found the following advice in various posts which have solved the problem  Follow the steps in this article to completely remove iTunes from your PC   http://support.apple.com/kb/HT1923
    If, like me, you are unable to uninstall Apple Mobile Device Support  Check this thread and follow the advice given by b_noir in the 4th post down, which is to download and run this tool  http://support.microsoft.com/mats/Program_Install_and_Uninstall    It takes its time so be patient, it did fix it for me.
    Reboot.
    Re Install iTunes  I chose to stick with version 11.1.38, which I knew worked.  
    This worked for me, I hope it helps

    THE ABOVE or    http://support.apple.com/kb/TS5376    WORKS AND IT IS FROM APPLE
    Basically it instructs you with a link to get a MS (MicrosoftFixit) software tool that wipes the registry, so you can do a clean install.
    Follow the instructions and it should be fine.
    I don't know why Apple is not putting this on the front page of itunes.com.  Of course they should post a new itunes that does not muck your 'puter, but I think if you tried already it is too late unless you fix what they effed.

  • Deciding Column name in UPDATE statement at runtime?

    Hi,
    Assuming there are 5 columns COLUMN1 through COLUMN5 in TABLE1
    In any Update Statement, say:
    UPDATE TABLE1 SET COLUMN1='Hi' WHERE COLUMN2='Hello';
    Can we decide the COLUMN to bet set at runtime depending on some literal value?
    Here in this case, like i get some value in a variable x := 'COLUMN1';, then how can i use an UPDATE statement to following:
    UPDATE TABLE1 SET x='Hi' WHERE COLUMN2='Hello';
    here x is decided on some logic, i.e. which column is to be updated is decided at runtime.
    Please help.
    Many thanks in advance.

    Hi,
    I understood a bit of your code...a 60%..
    Better you can see this below example...small and simple example..from this you can understand....and you can solve your problem.. and use of EXECUTE IMMEDIATE...
    DECLARE
    sql_stmt VARCHAR2(200);
    plsql_block VARCHAR2(500);
    emp_id NUMBER(4) := 7566;
    salary NUMBER(7,2);
    dept_id NUMBER(2) := 50;
    dept_name VARCHAR2(14) := 'PERSONNEL';
    location VARCHAR2(13) := 'DALLAS';
    emp_rec emp%ROWTYPE;
    BEGIN
    EXECUTE IMMEDIATE 'CREATE TABLE bonus (id NUMBER, amt NUMBER)';
    sql_stmt := 'INSERT INTO dept VALUES (:1, :2, :3)';
    EXECUTE IMMEDIATE sql_stmt USING dept_id, dept_name, location;
    sql_stmt := 'SELECT * FROM emp WHERE empno = :id';
    EXECUTE IMMEDIATE sql_stmt INTO emp_rec USING emp_id;
    plsql_block := 'BEGIN emp_pkg.raise_salary(:id, :amt); END;';
    EXECUTE IMMEDIATE plsql_block USING 7788, 500;
    sql_stmt := 'UPDATE emp SET sal = 2000 WHERE empno = :1
    RETURNING sal INTO :2';
    EXECUTE IMMEDIATE sql_stmt USING emp_id RETURNING INTO salary;
    EXECUTE IMMEDIATE 'DELETE FROM dept WHERE deptno = :num'
    USING dept_id;
    EXECUTE IMMEDIATE 'ALTER SESSION SET SQL_TRACE TRUE';
    END;
    Thanks
    Pavan Kumar N

  • Something is Causing ReaderX Update to C++ Runtime Library Error AdobeARM.exe

    Anytime Adobe Reader tries to update, on login, periodically, or manually the error Visual C++ Runtime Library Error appears. I am using Adobe Reader 10.1.1. I have tried letting Adobe regenerate the Adobe.ARM.exe file located in C:\Program Files\Common Files\Adobe\ARM\1.0\AdobeARM.exe. I am using Windows XP Professional SP3.
    This started when after it ran an automatic update it started to defrag that took way too long so I forced shutdown that obviously corrupted some file somewhere which leads to this error. In a new Windows profile the error is not present but I am not willing just yet to move all of my files to a new user account because one third party application has a bug.

    Thanks for trying out the suggestion.
    Since, you mentioned that the issue is not reproducible when you switch to another account, could you try one more thing.
    1. Open Start > Run
    2. Type "%temp%"
    3. In the folder that appears, delete the following files: AdobeARM.log, AdobeARM_NotLocked.log, ARMUI.ini
    4. Try initiating an update transaction again from within Reader by clicking on Help > Check For Updates
    Hope this works.
    Ankit
    Message was edited by: Ankit_Jain

  • Help needed in creating a table that updates itself at runtime.

    I am working on creating a sniffer in java and need a GUI that will show the incoming packets as they are sniffed. How can I use tables such that they automatically update as and when the packets arrive.
    Any help on this matter would be appreciated thanks
    hasrar

    Hello, I am working in a Sniffer in java too, but I have not information about this.
    I want to tell you if you can send me some information or examples.

  • How to auto update JTable during runtime

    Can anyone tell me how to dynamically update a JTable during execution, what i mean isin the I want the table to automatically add new rows as i enter new data.
    if I pass the object array reference of the TableModel to a method, then add more objects to the array and the revalidate the JTable will it work, or how do I do it ? Thanks

    Your table model should extend AbstractTableModel. And when (for example) it adds a row to whatever data structure is supporting the model, it should call fireTableRowsInserted... you can find out more about those methods in the API documentation. You don't need to revalidate or invalidate or validate the JTable, at least I don't have that in my code anywhere.

  • Update jscrollpane / viewable area when click on JButton

    Hi all,
    I have a JTable inside a JScrollPane. I use some JButtons to do some row selections on the JTable.
    I would like the viewable area / scroll pane to increment when the row selections are changed using the JButtons. By doing this I wish to see, at the bottom of the scrollpane the row that was selected by the JButton. (i.e. I want the behaviour you get if you select a row then use the arrow keys to move up and down the rows).
    Below is a single class which sets up the table buttons etc. A lot of the length comes from the table's data so don't worry.
    If you run it and click on the "Next team member" button you will see what it currently does.
    package ui;
    import java.awt.BorderLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.util.Vector;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.ListSelectionModel;
    import javax.swing.event.ListSelectionEvent;
    import javax.swing.event.ListSelectionListener;
    import javax.swing.table.AbstractTableModel;
    * Class Window displays a frame in which there is a table and some buttons to
    * manipulate the table.  It is used as an example of manipulating table data.
    public class Window extends JFrame
         * Data members.
         * ========================================================================
         private JTable table;
         private JScrollPane scroller;
         private final static int noButtons= 4;
         private final static String[] buttonNames=
              "Pick for team", "Unpick", "Next team member", "Next non-team member"
         private JButton[] buttons= new JButton[noButtons];
          * End of Data members.
          * ========================================================================
          * Constructor.
          * ========================================================================
         public Window()
              setTitle("Testing table manipulation");
              setSize(1024,300);
              setDefaultCloseOperation(EXIT_ON_CLOSE);
              setLayout(new BorderLayout());
              // Make the table.
              table= makeTable();
              // Create the scroll pane.
              scroller= new JScrollPane(table);
              scroller.setSize(800,300);
              // Create buttons to manipulate the data.
              for (int i= 0; i < noButtons; i++)
                   buttons= new JButton(buttonNames[i]);
                   buttons[i].addActionListener(new ButtonHandler(buttonNames[i]));
              // A panel for the buttons.
              JPanel buttonPanel= new JPanel();
              buttonPanel.setSize(224,300);
              for (int i= 0; i < noButtons; i++)
                   buttonPanel.add(buttons[i]);
              // Add everything to the frame.
              JPanel contentPane= (JPanel)this.getContentPane();
              contentPane.add(scroller,BorderLayout.WEST);     
              contentPane.add(buttonPanel,BorderLayout.EAST);
              // Make visible.
              setVisible(true);
         * End of Constructor.
         * ========================================================================
         * Methods.
         * ========================================================================
         // Makes a table.
         private JTable makeTable()
              // The table model.     
              TableModel tm= new TableModel();
              // The actual table.
              JTable jt= new JTable(tm);
              // The table's selection model.
              jt.getSelectionModel().addListSelectionListener(new RowSelectionListener());
         return jt;
         * End of Methods.
         * ========================================================================
         * Inner classes
         * ========================================================================
         * Inner class TableModel manages the table model for the table in Window.
         * This class contains the real data and methods to manipulate that data.
         private class TableModel extends AbstractTableModel
              // Data.
              Vector<String> columns;
              Vector<Vector> rows;
              public TableModel()
                   columns= new Vector<String>();
                   rows= new Vector<Vector>();
                   columns.add("Surname");
                   columns.add("Firstname");
                   columns.add("SquadNo");
                   columns.add("Position");
                   columns.add("In team?");
                   Vector<Object> v= new Vector<Object>();
                   v.add("McGeady");
                   v.add("Aiden");
                   v.add(46);
                   v.add("AM RLC");
                   v.add(true);
                   rows.add(v);
                   v= new Vector<Object>();
                   v.add("McGovern");
                   v.add("Michael");
                   v.add(47);
                   v.add("GK");
                   v.add(false);
                   rows.add(v);
                   v= new Vector<Object>();
                   v.add("Zurawski");
                   v.add("Maciej");
                   v.add(7);
                   v.add("F C");
                   v.add(true);
                   rows.add(v);
                   v= new Vector<Object>();
                   v.add("McManus");
                   v.add("Stephen");
                   v.add(44);
                   v.add("D LC");
                   v.add(true);
                   rows.add(v);
                   v= new Vector<Object>();
                   v.add("Virgo");
                   v.add("Adam");
                   v.add(4);
                   v.add("D/F RC");
                   v.add(false);
                   rows.add(v);
                   v= new Vector<Object>();
                   v.add("Feguson");
                   v.add("Barry");
                   v.add(6);
                   v.add("DM C");
                   v.add(false);
                   rows.add(v);
                   v= new Vector<Object>();
                   v.add("Boyd");
                   v.add("Kris");
                   v.add(19);
                   v.add("S C");
                   v.add(false);
                   rows.add(v);
                   v= new Vector<Object>();
                   v.add("Prso");
                   v.add("Dado");
                   v.add(9);
                   v.add("S C");
                   v.add(false);
                   rows.add(v);
                   v= new Vector<Object>();
                   v.add("Gordon");
                   v.add("Craig");
                   v.add(1);
                   v.add("GK");
                   v.add(false);
                   rows.add(v);
                   v= new Vector<Object>();
                   v.add("Pressley");
                   v.add("Steven");
                   v.add(4);
                   v.add("D RC");
                   v.add(false);
                   rows.add(v);
                   v= new Vector<Object>();
                   v.add("Hartley");
                   v.add("Paul");
                   v.add(7);
                   v.add("AM RC");
                   v.add(false);
                   rows.add(v);
                   v= new Vector<Object>();
                   v.add("Smith");
                   v.add("John");
                   v.add(10);
                   v.add("AM L");
                   v.add(false);
                   rows.add(v);
                   v= new Vector<Object>();
                   v.add("Smith");
                   v.add("John");
                   v.add(10);
                   v.add("AM L");
                   v.add(false);
                   rows.add(v);
                   v= new Vector<Object>();
                   v.add("Smith");
                   v.add("John");
                   v.add(10);
                   v.add("AM L");
                   v.add(false);
                   rows.add(v);
                   v= new Vector<Object>();
                   v.add("Smith");
                   v.add("John");
                   v.add(10);
                   v.add("AM L");
                   v.add(false);
                   rows.add(v);
                   v= new Vector<Object>();
                   v.add("Smith");
                   v.add("John");
                   v.add(10);
                   v.add("AM L");
                   v.add(false);
                   rows.add(v);
                   v= new Vector<Object>();
                   v.add("Smith");
                   v.add("John");
                   v.add(10);
                   v.add("AM L");
                   v.add(false);
                   rows.add(v);
                   v= new Vector<Object>();
                   v.add("Smith");
                   v.add("John");
                   v.add(10);
                   v.add("AM L");
                   v.add(false);
                   rows.add(v);
                   v= new Vector<Object>();
                   v.add("Smith");
                   v.add("John");
                   v.add(10);
                   v.add("AM L");
                   v.add(false);
                   rows.add(v);
                   v= new Vector<Object>();
                   v.add("Smith");
                   v.add("John");
                   v.add(10);
                   v.add("AM L");
                   v.add(false);
              // AbstractTableModel methods.
              // The number of rows.
              public int getRowCount()
                   return rows.size();
              // The number of columns.
              public int getColumnCount()
                   return columns.size();
              // The value at row, column.
              public Object getValueAt(int row, int column)
                   return (rows.elementAt(row)).elementAt(column);
              // Allows the column names to be set.
              // Also obtains the column name at column.
              public String getColumnName(int column)
                   return columns.elementAt(column);
              // Allows boolean columns to be displayed as checkboxes.
              public Class getColumnClass(int columnIndex)
                   return getValueAt(0,columnIndex).getClass();
              // Is the cell at row, column editable?
              public boolean isCellEditable(int row, int column)
                   return true;
              // Allows the data to be changed.
              public void setValueAt(Object o, int row, int column)
              (rows.elementAt(row)).setElementAt(o, column);
              fireTableDataChanged(); // Very important.     
         * Inner class RowSelectionListener handles selection events on a Window
         * instance's table rows.
         private class RowSelectionListener implements ListSelectionListener
              public void valueChanged(ListSelectionEvent e)
                   //Ignore extra messages.
         if (e.getValueIsAdjusting())
         return;
         ListSelectionModel lsm = (ListSelectionModel)e.getSource();
         if (!lsm.isSelectionEmpty())
         int selectedRow = lsm.getMinSelectionIndex();
         String s= "";
         for (int i= 0; i < table.getColumnCount(); i++)
              s+= (table.getValueAt(selectedRow, i)).toString() + " ";
         System.out.println(s); // Would be appended to the textarea.
         * Inner class buttonHandler handles events from the buttons.
         private class ButtonHandler implements ActionListener
              // Data members.
              private String name;
              // Constructor.
              // Sets the name.
              public ButtonHandler(String nm)
                   name= nm;
              public void actionPerformed(ActionEvent ae)
                   if (name.equals(buttonNames[0])) // "Pick for team"
                        changeStatus(true);
                   else if (name.equals(buttonNames[1])) // "Unpick"
                        changeStatus(false);
                   else if (name.equals(buttonNames[2])) // "Next team member"
                        int row;
                        if (table.getSelectionModel().isSelectionEmpty())
                        row= -1;
                        else
                        row= table.getSelectedRow();
                        // From next row until end of rows, look for correct value.
                        while (true)
                        for (int i= (row+1); i < table.getRowCount(); i++)
                             // The in team? column is the last one.
                             int inTeamColumn= table.getColumnCount()-1;
                             if (((Boolean)table.getValueAt(i,inTeamColumn)).booleanValue() == true)
                                  table.getSelectionModel().setSelectionInterval(i, i);
                                  return;
                        // Go back to the start.
                        row= -1;
                   else if (name.equals(buttonNames[3])) // "Next non-team member"
                        int row;
                        if (table.getSelectionModel().isSelectionEmpty())
                        row= -1;
                        else
                        row= table.getSelectedRow();
                        // From next row until end of rows, look for correct value.
                        while (true)
                        for (int i= (row+1); i < table.getRowCount(); i++)
                             // The in team? column is the last one.
                             int inTeamColumn= table.getColumnCount()-1;
                             if (((Boolean)table.getValueAt(i,inTeamColumn)).booleanValue() == false)
                                  table.getSelectionModel().setSelectionInterval(i, i);
                                  return;
                        // Go back to the start.
                        row= -1;
              // Changes whether they were picked or unpicked.
              // picked = true means they were picked.
              private void changeStatus(boolean picked)
                   int row= table.getSelectedRow();
                   if (row < 0)
                        // Should be a dialogue (or do nothing?)
                        System.out.println("Error! No row was selected.");
                   else
                        for (int i= 0; i < table.getColumnCount(); i++)
                             if (table.getColumnName(i).equals("In team?"))
                                  boolean boolVal= (Boolean)table.getValueAt(row, i);
                                  if (boolVal == !picked)
                                  table.setValueAt(picked, row, i);
                        // Reselect the row.
                        table.getSelectionModel().setSelectionInterval(row, row);
              // Find the next one who has value picked.
              private void findNext(boolean picked)
         * End of Inner Classes.
         * ========================================================================
    * Test program.
    * ========================================================================
         public static void main(String[] args)
              new Window();
         * End of Test program.
         * ========================================================================

    why do you make lots of points that don't help before answering the question?They may not help with the immediate problem, but they may help with future problems, if you take the time to understand what I am saying.
    If I make the points after answering the question, then you probably won't read them.
    You should read about packages - they let you give classes the same name if they are in different packages.Just because you can do something doesn't mean you should
    A class name should be descriptive. Window is not very descriptive.
    Even for a simple text case I would use something like WindowTest.
    If I am just reading your source code and I see a line like the following:
    Window window = new Window();The first thing that comes to mind is that you are trying to create an AWT Window. How do I know that you've given your class a package name? I should not need to look at the package or import statments to know what class you are talking about. Any time you can reduce confusion the better.
    Created my own TableModel because this program is a mock up of a more complicated oneWhy go to all this trouble for a simple demo program? Your question is about scrolling, not the data in the table. I would use:
    JTable table = new JTable(30, 5);The less clutter you have in your demo program. The easier it is for us to see whats happening.
    I mention the DefaultTableModel, because the majority of people who post table related questions on the forum don't fully understand how TableModels work or the flexibility of the DefaultTableModel and end up getting themselves into trouble by trying to unnecessarily extend AbstractTableModel. Remember your last posting was about an incorrect implementation of a TableModel when you couldn't get the column names to work.
    Why don't you use JDK 1.5 - why not download it?JDK1.4 does everthing I want.
    I need generics in my app (booleans, strings and numbers in my vectors) so I use them.You don't need to use Generics. You just decided you wanted to use them. The TableModel still stores Integers and Booleans etc. The compiler just does the conversion for you.
    Another design is to create a class to hold your data and then create a TableModel based on this class. For example here is an example of a TableModel that holds Stock Securities:
    import java.util.*;
    import javax.swing.table.*;
    public class SecurityTableModel extends AbstractTableModel
         List list;
         private static String[] columnNames =
              "Security",
              "Symbol",
              "Exchange",
              "Type",
              "Asset Class",
              "Goal"
         public SecurityTableModel()
              SecurityManager manager = SecurityManager.getSharedInstance();
              list = manager.getList();
              Collections.sort( list );
         public int getColumnCount()
              return columnNames.length;
         public int getRowCount()
              return list.size();
         public String getColumnName(int col)
              return columnNames[col];
         public Object getValueAt(int row, int col)
              Security security = (Security)list.get( row );
              switch (col)
                   case 0: return security.getName();
                   case 1: return security.getSymbol();
                   case 2: return security.getExchange();
                   case 3: return security.getType();
                   case 4: return security.getAssetClass();
                   case 5: return security.getGoal();
              return null;
         public Class getColumnClass(int c)
              return String.class;
         public boolean isCellEditable(int row, int col)
              return false;
         public void xxxsetValueAt(Object value, int row, int col)
    } Your getter and setter of the Security class then convert the data as required.
    who is OP? Original Poster

  • ITunes Update Problem Causing Runtime Error R6034

    I have tried everything to fix this issue and read postings about it.  None worked.
    I uninstalled all apple applications, restarting in between, then started getting
    (APSDaemon.exe system error icudt49.dll is missing).
    Installed iTunes and back to Runtime error R6034.
    PC runs on Win 7, 64 bit.
    Any help is appreciated.
    Thanks

    I have the same Error
    I've tried uninstalling and reinstalling, even downloading older versions without any luck. When Apple resolves an issue can we simply redownload iTunes at that time. Or is this something we need to fix ourselves? Help please!
    iPod classic 160GB (Late 2009), Windows 7

  • Error updating...runtime error while application tried to access C   library

    Please fix.  itunes was working just fine for the last 100 updates.  Now BOOM!

    Hello 6The6Kid6,
    The following articles provide troubleshooting steps that can help get iTunes properly updated and stabilized.
    Issues installing iTunes or QuickTime for Windows
    http://support.apple.com/kb/HT1926
    iTunes for Windows XP: Troubleshooting unexpected quits, freezes, or launch issues
    http://support.apple.com/kb/TS1421
    iTunes for Windows Vista, Windows 7, or Windows 8: Fix unexpected quits or launch issues
    http://support.apple.com/kb/TS1717
    Cheers,
    Allen

  • Update enum at runtime

    I have a typedef enum that helps sequences each state in my testing process ( test1 point to test2 if pass or handle_results if fail, test2 point to test3 if pass or handle_results if fail, etc).  This works great for one product.  Now, management wants to modify product A into product B which doesn't need to do test3, and into product C which doesn't need to do test4, etc.  Is there anywhere to modify my typedef enum at runtime depending upon which product the operator selects to be tested?  It seems wasteful to create a VI for each product since they all use the essential state machine and only skip specific states within that state machine.  I thought about having a database which lists which tests are appropriate for each product.  Is this possible?
    CLD Certified

    I would go with the queued state machine.
    If a tester selects a specific product, just feed sequentially the several states to be performed.
    Ton
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!

  • How to update query at runtime

    I have one input page in which i display only some fields from a table (some are hide through to model -> attributes --> properties). i have a mandatory field in one of hidden fields and i need to set some default value to that field after user clicks on Commit button. How to do that. Can some body helps me.

    Hi,
    Thank you Duncan and Scott. I set it through entity object properties and it is working fine.
    One more help,
    I want to display two table fields in one insert form (JSP) and after the values are entered it has to be insert in to two tables. Do you have any document or help manual on that.
    Thanks,

Maybe you are looking for

  • JMStudio Error  "Can not create session manager"

    Hi, I'm trying to transmit an mpg file through a simple pc to pc network, using the transmission wizard in the JMStudio, and everytime it causes a "can not create session manager" error, even when I try to transmit .mp3 file I'm using an ip like 100.

  • How to export internal table and pass the internal table to another screen?

    Hi, I have a sql SELECT statement that select data from table into internal table. I would like to export out the internal table and pass to another screen and display the data in ALV list. How to export it out? I try but the error given was " The ty

  • Dreamweaver CS3 Design View messed up

    I'm not quite sure why, but the design view is all messed up when I am editing my webpage. Here is what it looks like. http://img257.imageshack.us/img257/4749/sammesseduphl2.jpg but as you can see by going here http://sdsusammys.com/rush.php that the

  • VAT ID missing for Europe

    Hi Gurus, Am trying to post the purchase invoice for country Poland in Europe through Idoc.Even though the Idoc  contains VAT registration id when I looked in MIR4,it's not showing the VAT ID or the reporting country field. But If I post an SD invoic

  • Between the Blackberry Curve 3G and the Bold 9700

    I am confused between the Blackberry Curve 3G and the Bold 9700. Please guide me with the difference in features,options,performance,display.... which one is advisable...