Skip to content
This repository has been archived by the owner on Feb 15, 2022. It is now read-only.

Mouse Over JSplitPane Triggers Full Repaint Of Child Components #116

Open
mochaman opened this issue Mar 28, 2013 · 0 comments
Open

Mouse Over JSplitPane Triggers Full Repaint Of Child Components #116

mochaman opened this issue Mar 28, 2013 · 0 comments

Comments

@mochaman
Copy link

When the mouse cursor moves over a JSplitPane divider, paintComponent() is called many times for both child components. This only happens in Substance and is somewhat problematic if your components have expensive paint methods.

Example:

package test;

import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.Graphics;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JSplitPane;
import javax.swing.UIManager;
import org.pushingpixels.substance.api.skin.SubstanceGraphiteGlassLookAndFeel;

public class Test {

    public static void main(String[] args) {

        Runnable r = new Runnable() {
            public void run() {
                try {
                    UIManager.setLookAndFeel(new SubstanceGraphiteGlassLookAndFeel());
                } catch (Exception e) {
                    e.printStackTrace();
                }

                JFrame jf = new JFrame("JSplitPane");
                jf.getContentPane().setLayout(new BorderLayout());
                jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

                JPanel panel1 = new JPanel() {
                    @Override
                    protected void paintComponent(Graphics g) {
                        System.out.println("paintComponent 1");
                        super.paintComponent(g); 
                    }
                };

                JPanel panel2 = new JPanel() {
                    @Override
                    protected void paintComponent(Graphics g) {
                        System.out.println("paintComponent 2");
                        super.paintComponent(g);
                    }
                };

                JSplitPane jsp = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, panel1, panel2);
                jsp.setResizeWeight(.5);
                jsp.setOneTouchExpandable(true);

                jf.getContentPane().add(jsp, BorderLayout.CENTER);

                jf.setSize(400, 350);
                jf.setVisible(true);
            }
        };
        EventQueue.invokeLater(r);
    }
}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant