List of usage examples for java.awt.event HierarchyBoundsAdapter HierarchyBoundsAdapter
HierarchyBoundsAdapter
From source file:com.all.browser.impl.MozillaBrowser.java
private void registerListeners() { mozillaPanel.addHierarchyBoundsListener(new HierarchyBoundsAdapter() { @Override/*from ww w. ja v a 2 s .c o m*/ public void ancestorResized(HierarchyEvent e) { Container changedParent = e.getChangedParent(); if (changedParent != null) { mozillaPanel.setBounds(changedParent.getBounds()); } } }); mozillaPanel.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { int keyCode = e.getKeyCode(); if (keyCode == KeyEvent.VK_SPACE) { e.consume(); } } }); }
From source file:com.all.browser.impl.SwtBrowser.java
@PostConstruct public void initialize() { containerPanel.setSize(DEFAULT_SIZE); containerPanel.addHierarchyBoundsListener(new HierarchyBoundsAdapter() { @Override//from w w w . j av a 2 s . c o m public void ancestorResized(HierarchyEvent e) { browser.setBounds(containerPanel.getBounds()); } }); canvas.setSize(DEFAULT_SIZE); containerPanel.add(canvas, BorderLayout.CENTER); }
From source file:org.openmicroscopy.shoola.agents.imviewer.view.ImViewerUI.java
/** Builds and lays out the GUI. */ private void buildGUI() { Browser browser = model.getBrowser(); int sizeX = model.getTiledImageSizeX(); int sizeY = model.getTiledImageSizeY(); browser.setComponentsSize(sizeX, sizeY); tabs = new ClosableTabbedPane(JTabbedPane.TOP, JTabbedPane.WRAP_TAB_LAYOUT); tabs.setAlignmentX(LEFT_ALIGNMENT);// w ww. ja v a2s . c om viewPanel = new ClosableTabbedPaneComponent(ImViewer.VIEW_INDEX, browser.getTitle(), browser.getIcon(), ""); viewPanel.setClosable(false); double[][] tl = { { TableLayout.PREFERRED, TableLayout.FILL }, { TableLayout.FILL, TableLayout.PREFERRED, TableLayout.PREFERRED } }; viewPanel.setLayout(new TableLayout(tl)); viewPanel.add(controlPane, "0, 0"); viewPanel.add(browser.getUI(), "1, 0"); viewPanel.add(controlPane.getTimeSliderPane(ImViewer.VIEW_INDEX), "1, 1"); if (model.isLifetimeImage()) { viewPanel.add(controlPane.getLifetimeSliderPane(ImViewer.VIEW_INDEX), "1, 2"); } tabbedIconHeight = browser.getIcon().getIconHeight() + ICON_EXTRA; tabs.insertTab(browser.getTitle(), browser.getIcon(), viewPanel, "", ImViewer.VIEW_INDEX); gridViewPanel = new ClosableTabbedPaneComponent(ImViewer.GRID_INDEX, browser.getGridViewTitle(), browser.getGridViewIcon(), ""); gridViewPanel.setLayout(new TableLayout(tl)); gridViewPanel.add(controlPane.buildGridComponent(), "0, 0"); gridViewPanel.add(browser.getGridView(), "1, 0"); gridViewPanel.add(controlPane.getTimeSliderPane(ImViewer.GRID_INDEX), "1, 1"); if (model.isLifetimeImage()) { gridViewPanel.add(controlPane.getLifetimeSliderPane(ImViewer.GRID_INDEX), "1, 2"); } if (model.allowSplitView() && !model.isBigImage()) { tabs.insertTab(browser.getGridViewTitle(), browser.getGridViewIcon(), gridViewPanel, "", ImViewer.GRID_INDEX); } double[][] tl2 = { { TableLayout.PREFERRED, TableLayout.FILL }, { TableLayout.PREFERRED, TableLayout.FILL, TableLayout.PREFERRED } }; projectionViewPanel = new ClosableTabbedPaneComponent(ImViewer.PROJECTION_INDEX, browser.getProjectionViewTitle(), browser.getProjectionViewIcon(), ""); projectionViewPanel.setLayout(new TableLayout(tl2)); projectionViewPanel.add(controlPane.buildProjectionToolBar(), "0, 0, 1, 0"); projectionViewPanel.add(controlPane.buildProjectionComponent(), "0, 1"); projectionViewPanel.add(browser.getProjectionView(), "1, 1"); projectionViewPanel.add(controlPane.getTimeSliderPane(ImViewer.PROJECTION_INDEX), "1, 2"); if (model.getMaxZ() > 0 && !model.isBigImage()) { tabs.insertTab(browser.getProjectionViewTitle(), browser.getProjectionViewIcon(), projectionViewPanel, "", ImViewer.PROJECTION_INDEX); } tabs.addChangeListener(controller); //mainComponent = tabs; rendererSplit.setLeftComponent(tabs); mainComponent = rendererSplit; Container container = getContentPane(); container.setLayout(new BorderLayout(0, 0)); container.add(toolBar, BorderLayout.NORTH); container.add(mainComponent, BorderLayout.CENTER); container.add(statusBar, BorderLayout.SOUTH); //attach listener to the frame border boundsAdapter = new HierarchyBoundsAdapter() { /** * Stores the size of the tab pane when the frame is resized. * @see HierarchyBoundsListener#ancestorResized(HierarchyEvent) */ public void ancestorResized(HierarchyEvent e) { if (tabs != null) restoreSize = tabs.getSize(); } }; container.addHierarchyBoundsListener(boundsAdapter); //restoreSize = new Dimension(0, 0); //layoutComponents(false); }