src/main/java/swinghx/chapter12/hack96/ComponentGlassPane.java
private static void demo() {

        final JFrame frame = new JFrame("Component Boundary Glasspane");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        final Container root = frame.getContentPane();
        root.setLayout(new BoxLayout(root,BoxLayout.Y_AXIS));

        final JButton activate = new JButton("Show component boundaries");
        root.add(activate);
        root.add(new JLabel("Juice Settings"));

        final JPanel panel = new JPanel();
        panel.setLayout(new BoxLayout(panel,BoxLayout.X_AXIS));
        panel.add(new JLabel("Flavor"));
        panel.add(new JTextField("put some text here..."));
        root.add(panel);

        final ComponentGlassPane glass = new ComponentGlassPane(frame);
        // frame.setGlassPane(glass); // moved to ComponentGlassPane constructor

        activate.addActionListener(glass);
		// Moved to ComponentGlassPane::actionPerformed()
		//                new ActionListener() {
		//            @Override public void actionPerformed(ActionEvent evt) {
		//                glass.setVisible(true);
		//                glass.paintCount = 0;
		//            }
		//        });

        frame.pack();
        frame.setVisible(true);
    }
/**
     * The original Swing Hacks implementation.
     */
The original Swing Hacks implementation.
The original Swing Hacks implementation .
private static void demo() {
        final JFrame frame = new JFrame("Component Boundary Glasspane");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        final Container root = frame.getContentPane();
        root.setLayout(new BoxLayout(root,BoxLayout.Y_AXIS));
        final JButton activate = new JButton("Show component boundaries");
        root.add(activate);
        root.add(new JLabel("Juice Settings"));
        final JPanel panel = new JPanel();
        panel.setLayout(new BoxLayout(panel,BoxLayout.X_AXIS));
        panel.add(new JLabel("Flavor"));
        panel.add(new JTextField("put some text here..."));
        root.add(panel);
        final ComponentGlassPane glass = new ComponentGlassPane(frame);
        activate.addActionListener(glass);
        frame.pack();
        frame.setVisible(true);
    }
private static void demo ( ) { final JFrame frame = new JFrame ( "Component Boundary Glasspane" ) ; frame . setDefaultCloseOperation ( JFrame . EXIT_ON_CLOSE ) ; final Container root = frame . getContentPane ( ) ; root . setLayout ( new BoxLayout ( root , BoxLayout . Y_AXIS ) ) ; final JButton activate = new JButton ( "Show component boundaries" ) ; root . add ( activate ) ; root . add ( new JLabel ( "Juice Settings" ) ) ; final JPanel panel = new JPanel ( ) ; panel . setLayout ( new BoxLayout ( panel , BoxLayout . X_AXIS ) ) ; panel . add ( new JLabel ( "Flavor" ) ) ; panel . add ( new JTextField ( "put some text here..." ) ) ; root . add ( panel ) ; final ComponentGlassPane glass = new ComponentGlassPane ( frame ) ; activate . addActionListener ( glass ) ; frame . pack ( ) ; frame . setVisible ( true ) ; }
The original Swing Hacks implementation.
The original Swing Hacks implementation .
// frame.setGlassPane(glass); // moved to ComponentGlassPane constructor // Moved to ComponentGlassPane::actionPerformed() //                new ActionListener() { //            @Override public void actionPerformed(ActionEvent evt) { //                glass.setVisible(true); //                glass.paintCount = 0; //            } //        });