All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.pagosoft.plaf.PgsScrollPaneUI Maven / Gradle / Ivy

Go to download

The PgsLookAndFeel is a modern, cross platform LookAndFeel for Java/Swing. It’s goal is to provide a single look and feel for applications on Windows, Gnome and KDE. It is free and OpenSource, licensed under terms of the Apache Software License 2.

There is a newer version: 1.1.4
Show newest version
/*
 * PgsScrollPaneUI.java
 *
 * Created on 15. Mai 2005, 14:21
 */

package com.pagosoft.plaf;

import javax.swing.*;
import javax.swing.border.*;
import javax.swing.plaf.*;
import javax.swing.plaf.metal.*;
import java.awt.*;
import java.awt.event.*;

/**
 * @author pago
 */
public class PgsScrollPaneUI extends MetalScrollPaneUI {
	public static ComponentUI createUI(JComponent x) {
		return new PgsScrollPaneUI();
	}

	public void installUI(JComponent c) {
		super.installUI(c);
		//maybeRemoveBorder(scrollpane.getViewport().getView());
	}

	private ScrollPaneContainerListener scrollPaneContainerListener;

	public void installListeners(JScrollPane c) {
		super.installListeners(c);
		/*if (scrollPaneContainerListener == null) {
			scrollPaneContainerListener = new ScrollPaneContainerListener();
		}
		c.getViewport().addContainerListener(scrollPaneContainerListener);*/
	}

	public void uninstallListeners(JScrollPane c) {
		super.uninstallListeners(c);
		//c.getViewport().removeContainerListener(scrollPaneContainerListener);
	}

	private Border lastChildBorder;

	public void maybeRemoveBorder(Component c) {
		if (c instanceof JComponent) {
			JComponent child = (JComponent) c;
			lastChildBorder = child.getBorder();
			child.setBorder(null);
		}
	}

	public void maybeAddBorder(Component c) {
		if (c instanceof JComponent && lastChildBorder != null) {
			JComponent child = (JComponent) c;
			child.setBorder(lastChildBorder);
			lastChildBorder = null;
		}
	}

	protected class ScrollPaneContainerListener implements ContainerListener {
		public void componentAdded(ContainerEvent e) {
			maybeRemoveBorder(e.getChild());
		}

		public void componentRemoved(ContainerEvent e) {
			maybeAddBorder(e.getChild());
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy