Hi Stefan,

The behavior is as per Swing. Please see the snippet below.

Please see: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4202002

Thanks and regards,

Janak

>-----Original Message-----
>From: [EMAIL PROTECTED]
>[mailto:[EMAIL PROTECTED] Behalf Of
>[EMAIL PROTECTED]
>Sent: Thursday, August 16, 2007 2:48 PM
>To: [email protected]
>Subject: [ULC-developer] Scrolling problem with RowHeaders on
>ULCScrollPane
>
>
>
>Hello
>
>I have an ULCScrollPane with viewPort and rowHeader.
>Each of them contains some TextFields.
>On the TextFiels I set scrollToVisible() when gettingFocus.
>
>Now when I scroll with the scrollbar, the rowHeader and viewPort are both
>scrolling.
>--> OK
>
>When I tab through the Fields in the viw Port, the row Header and viewPort
>are both scrolling, to make the focus-field visible
>--> OK.
>
>When I tab through the Fields in the rowHeader, only the rowHeader scrolls
>to make the focus-field visible, but the viewPort does not scroll.
>--> not OK, because rowHeader and viewPort are not synchronous
>
>The same Problem is with columnHeaders on the ULCScrollPane.
>
>
>Please see the example below.
>Thanks for any help.
>
>Regards
>Stefan
>
>
>/**
> * TestApplication for ScrollPane with RowHeader
> */
>public class ScrollPaneApplication extends AbstractApplication {
>
>      public void start() {
>
>            ULCFrame frame = new ULCFrame("ScrollPane mit RowHeader");
>            frame.setDefaultCloseOperation(ULCFrame.TERMINATE_ON_CLOSE);
>
>            ULCScrollPane scrollPane = new ULCScrollPane();
>            scrollPane.setRowHeaderView(createFieldsPane("Row Header"));
>            scrollPane.setViewPortView(createFieldsPane("View Port"));
>
>            frame.setSize(new Dimension(400, 300));
>            frame.add(scrollPane);
>            frame.setVisible(true);
>      }
>
>      private ULCComponent createFieldsPane(String titel) {
>
>            ULCBoxPane pane = new ULCBoxPane(true);
>
>            for (int i = 1; i <= 20; i++) {
>                  pane.add(createText(String.valueOf(i)));
>            }
>
>            pane.setBorder(BorderFactory.createTitledBorder(titel));
>            return pane;
>      }
>
>      private ULCTextField createText(String inhalt) {
>
>            final ULCTextField text = new ULCTextField(inhalt, 10);
>
>            text.addFocusListener(new IFocusListener() {
>
>                  public void focusGained(FocusEvent event) {
>
>                        text.scrollToVisible();
>                  }
>
>                  public void focusLost(FocusEvent event) {
>
>                  }
>            });
>
>            return text;
>      }
>
>      public static void main(String[] args) {
>
>
>DevelopmentRunner.setApplicationClass(ScrollPaneApplication.class);
>            DevelopmentRunner.main(args);
>      }
>
>}
>
-----------------

import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;

public class ScrollPaneApplicationSwing extends JFrame {

    private JScrollPane fScrollPane;

    public ScrollPaneApplicationSwing() {
        super("ScrollPaneApplicationSwing");
        setSize(400, 150);

        GridLayout gl = new GridLayout(20, 1);
        JPanel fixedPanel = new JPanel(gl);
        addFields(fixedPanel);

        JPanel nonfixedPanel = new JPanel(gl);
        addFields(nonfixedPanel);

        fScrollPane = new JScrollPane();

        fScrollPane.setRowHeaderView(fixedPanel);
        fScrollPane.setViewportView(nonfixedPanel);

        getContentPane().add(fScrollPane, BorderLayout.CENTER);
    }

    public static void main(String[] args) {
        ScrollPaneApplicationSwing frame = new ScrollPaneApplicationSwing();
        frame.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });
        frame.setVisible(true);
    }

    private void addFields(JPanel p) {
        JTextField previous = null;
        for (int i = 0; i < 20; i++) {
            final JTextField text = new JTextField(10);
            text.setText(Integer.toString(i));
            text.addFocusListener(new FocusListener() {
                public void focusGained(FocusEvent e) {
                    SwingUtilities.invokeLater(new Runnable() {
                        public void run() {
                            ((JPanel)text.getParent()).scrollRectToVisible(t
ext.getBounds());
                        }
                    });
                }

                public void focusLost(FocusEvent e) {

                }
            });
            p.add(text);
            if (previous != null) {
                previous.setNextFocusableComponent(text);
            }
            previous = text;
        }
    }
}

_______________________________________________
ULC-developer mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/ulc-developer

Reply via email to