Search in sources :

Example 1 with ContainerAdapter

use of java.awt.event.ContainerAdapter in project com.revolsys.open by revolsys.

the class ProjectFrame method initUi.

@Override
protected void initUi() {
    setMinimumSize(new Dimension(600, 500));
    final JRootPane rootPane = getRootPane();
    addSaveActions(rootPane, this.project);
    final BoundingBox defaultBoundingBox = getDefaultBoundingBox();
    this.project.setViewBoundingBoxAndGeometryFactory(defaultBoundingBox);
    Project.set(this.project);
    this.project.setPropertyWeak(PROJECT_FRAME, this);
    setConnectionRegistries();
    newMapPanel();
    this.leftTabs.setMinimumSize(new Dimension(100, 300));
    this.leftTabs.setPreferredSize(new Dimension(300, 700));
    this.mapPanel.setMinimumSize(new Dimension(300, 300));
    this.mapPanel.setPreferredSize(new Dimension(700, 700));
    this.leftRightSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, this.leftTabs, this.mapPanel);
    this.leftRightSplit.setBorder(BorderFactory.createEmptyBorder());
    this.bottomTabs.setBorder(BorderFactory.createEmptyBorder());
    this.bottomTabs.setPreferredSize(new Dimension(700, 200));
    final ContainerListener listener = new ContainerAdapter() {

        @Override
        public void componentRemoved(final ContainerEvent e) {
            final Component eventComponent = e.getChild();
            if (eventComponent instanceof ProjectFramePanel) {
                final ProjectFramePanel panel = (ProjectFramePanel) eventComponent;
                panel.setProperty(BOTTOM_TAB, null);
            }
        }
    };
    this.bottomTabs.addContainerListener(listener);
    this.topBottomSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT, this.leftRightSplit, this.bottomTabs);
    this.bottomTabs.setMinimumSize(new Dimension(600, 100));
    this.topBottomSplit.setResizeWeight(1);
    add(this.topBottomSplit, BorderLayout.CENTER);
    newTabLeftTableOfContents();
    newTabLeftCatalogPanel();
    addBottomTabs(this.bottomTabs);
    setBounds((Object) null, false);
    super.initUi();
}
Also used : ContainerEvent(java.awt.event.ContainerEvent) BoundingBox(com.revolsys.geometry.model.BoundingBox) ContainerListener(java.awt.event.ContainerListener) JRootPane(javax.swing.JRootPane) Dimension(java.awt.Dimension) JSplitPane(javax.swing.JSplitPane) ContainerAdapter(java.awt.event.ContainerAdapter) Component(java.awt.Component) JComponent(javax.swing.JComponent)

Example 2 with ContainerAdapter

use of java.awt.event.ContainerAdapter in project adempiere by adempiere.

the class SwingTool method addOpaque.

public static void addOpaque(JComponent c, final boolean opaque) {
    ContainerAdapter ca = new ContainerAdapter() {

        public void componentAdded(ContainerEvent e) {
            setOpaque(e.getChild());
        }

        private void setOpaque(Component c) {
            //ignores all selectable items, like buttons
            if (c instanceof ItemSelectable) {
                return;
            } else // sets transparent
            if (c instanceof JComponent) {
                ((JComponent) c).setOpaque(opaque);
            } else // recursively calls this method for all container components
            if (c instanceof Container) {
                for (int i = 0; i > ((Container) c).getComponentCount(); i++) {
                    setOpaque(((Container) c).getComponent(i));
                }
            }
        }
    };
    c.addContainerListener(ca);
}
Also used : ContainerEvent(java.awt.event.ContainerEvent) Container(java.awt.Container) JComponent(javax.swing.JComponent) ContainerAdapter(java.awt.event.ContainerAdapter) JComponent(javax.swing.JComponent) Component(java.awt.Component) JTextComponent(javax.swing.text.JTextComponent) ItemSelectable(java.awt.ItemSelectable)

Aggregations

Component (java.awt.Component)2 ContainerAdapter (java.awt.event.ContainerAdapter)2 ContainerEvent (java.awt.event.ContainerEvent)2 JComponent (javax.swing.JComponent)2 BoundingBox (com.revolsys.geometry.model.BoundingBox)1 Container (java.awt.Container)1 Dimension (java.awt.Dimension)1 ItemSelectable (java.awt.ItemSelectable)1 ContainerListener (java.awt.event.ContainerListener)1 JRootPane (javax.swing.JRootPane)1 JSplitPane (javax.swing.JSplitPane)1 JTextComponent (javax.swing.text.JTextComponent)1