/** * Turns on the more window for the given editor */ private void activate() { JRootPane root = SwingUtilities.getRootPane(myEditor.getContentComponent()); myOldGlass = (JComponent)root.getGlassPane(); if (myOldGlass != null) { myOldLayout = myOldGlass.getLayout(); myWasOpaque = myOldGlass.isOpaque(); myOldGlass.setLayout(null); myOldGlass.setOpaque(false); myOldGlass.add(this); myOldGlass.addComponentListener(myAdapter); } setFontForElements(); positionPanel(); if (myOldGlass != null) { myOldGlass.setVisible(true); } myActive = true; UiHelper.requestFocus(myText); }
JRootPane root = SwingUtilities.getRootPane(parent); oldGlass = (JComponent)root.getGlassPane(); oldLayout = oldGlass.getLayout(); wasOpaque = oldGlass.isOpaque(); oldGlass.setLayout(null);
LayoutManager delegate = titleBar.getLayout(); titleBar.setLayout(new LayoutManager()
@Override public Dimension getPreferredSize(JComponent c) { Dimension preferred = c.getLayout().preferredLayoutSize(c); return preferred; } }
/** * Overridden to build widgets just-in-time. * <p> * This method may be called by developers who wish to test the SwingMetawidget's active * LayoutManager. */ @Override public LayoutManager getLayout() { buildWidgets(); return super.getLayout(); }
/** * Overridden to build widgets just-in-time. * <p> * This method may be called by developers who wish to test the SwingMetawidget's active * LayoutManager. */ @Override public LayoutManager getLayout() { buildWidgets(); return super.getLayout(); }
final JComponent comp = new JPanel(new MyBorderLayout()); comp.add(new JTable(10, 3)); comp.add(new JLabel("east"), BorderLayout.EAST); comp.add(new JLabel("west"), BorderLayout.WEST); comp.add(new JLabel("north"), BorderLayout.NORTH); comp.add(new JLabel("south"), BorderLayout.SOUTH); ActionListener l = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ((MyBorderLayout) comp.getLayout()).paintDebug(comp); } }; showInFrame(comp, "debug"); new Timer(400, l).start();
public static void main(String[] args) { JComponent component = new JComponent() {}; System.out.println("JComponent = " + component.getLayout()); JPanel panel = new JPanel(); System.out.println("JPanel = " + panel.getLayout()); }
@Override public void endContainerLayout( JComponent container, SwingMetawidget metawidget ) { // Make all labels the same width State state = getState( container ); javax.swing.GroupLayout groupLayout = (javax.swing.GroupLayout) container.getLayout(); if ( !state.labels.isEmpty() ) { groupLayout.linkSize( SwingConstants.HORIZONTAL, state.labels.toArray( EMPTY_COMPONENTS_ARRAY ) ); } }
/** * TODO: comment * * @see javax.swing.plaf.ComponentUI#getPreferredSize(javax.swing.JComponent) */ @Override public Dimension getPreferredSize(JComponent c) { Dimension d = new Dimension(); Dimension cd = super.getPreferredSize(c); Dimension ld = c.getLayout().preferredLayoutSize(c); d.height = Math.max(cd.height, ld.height); d.width = Math.max(cd.width, ld.width); return d; } }
/** * TODO: comment * * @see javax.swing.plaf.ComponentUI#getPreferredSize(javax.swing.JComponent) */ @Override public Dimension getPreferredSize(JComponent c) { Dimension d = new Dimension(); Dimension cd = super.getPreferredSize(c); Dimension ld = c.getLayout().preferredLayoutSize(c); d.height = Math.max(cd.height, ld.height); d.width = Math.max(cd.width, ld.width); return d; } }
/** * TODO: comment * * @see javax.swing.plaf.ComponentUI#getPreferredSize(javax.swing.JComponent) */ @Override public Dimension getPreferredSize(JComponent c) { Dimension d = new Dimension(); Dimension cd = super.getPreferredSize(c); Dimension ld = c.getLayout().preferredLayoutSize(c); d.height = Math.max(cd.height, ld.height); d.width = Math.max(cd.width, ld.width); return d; } }
/** * {@inheritDoc} */ @Override protected void showCardInPanel(JComponent cardsPeer, String cardName) { JComponent cardPanel = findFirstCardPanel(cardsPeer); if (cardPanel != null) { ((CardLayout) cardPanel.getLayout()).show(cardPanel, cardName); } }
JFileChooser fc = new JFileChooser(); //get the center component BorderLayout layout = (BorderLayout) fc.getLayout(); JComponent comp = (JComponent) layout.getLayoutComponent(BorderLayout.CENTER); layout = (BorderLayout) comp.getLayout(); comp = (JComponent) layout.getLayoutComponent(BorderLayout.CENTER); //add my panel at the bottom comp.add(panel, BorderLayout.SOUTH);
private void displayEmptyPanel() { if (!emptyPanelInitialized) { cardsPanel.add(new JPanel(), EMPTY_PANEL); emptyPanelInitialized = true; } ((CardLayout) cardsPanel.getLayout()).show(cardsPanel, EMPTY_PANEL); if (repositoryFormVisible) { repositoryFormsPanel.removeChangeListener(repositoryFormPanelListener); repositoryFormVisible = false; } setDataValid(true); }
public void setZoom(final float r) { zoom = r; for (final NodeView nodeView : viewers) { final JComponent viewer = nodeView.getContent(ViewerController.VIEWER_POSITION); final ViewerLayoutManager layoutManager = (ViewerLayoutManager)viewer.getLayout(); if(layoutManager != null) { final Dimension preferredSize = layoutManager.calculatePreferredSize(); ((ScalableComponent) viewer).setFinalViewerSize(preferredSize); viewer.revalidate(); } } }
public void displayRepositoryForm(RepositoryImpl repository, String initialErrMsg) { makeSureRepositoryFormsPanelExists(); boolean wasRepositoryFormVisible = repositoryFormVisible; boolean firstUsed = repositoryFormsPanel.displayForm(repository, initialErrMsg); ((CardLayout) cardsPanel.getLayout()).show(cardsPanel, NEW_REPO_PANEL); if (!wasRepositoryFormVisible) { repositoryFormsPanel.addChangeListener(repositoryFormPanelListener); setDataValid(repositoryFormsPanel.isValidData()); repositoryFormVisible = true; } if (firstUsed) { notifyResizeListeners(); } }
protected void prepareRenderer(JComponent comp) { comp.setBackground(getBackground()); comp.setForeground(getForeground()); comp.setBounds(0, 0, getWidth(), getHeight()); JComponent innermost; if ((innermost = findInnermostRenderer(comp)) instanceof JComboBox) { if (comp.getLayout() != null) { comp.getLayout().layoutContainer(comp); } } if (!isTableUI() && ((InplaceEditor) comp).supportsTextEntry()) { innermost.setBackground(PropUtils.getTextFieldBackground()); innermost.setForeground(PropUtils.getTextFieldForeground()); } }
protected void prepareRenderer(JComponent comp) { comp.setBackground(getBackground()); comp.setForeground(getForeground()); comp.setBounds(0,0,getWidth(),getHeight()); JComponent innermost; if ((innermost = findInnermostRenderer(comp)) instanceof JComboBox) { if (comp.getLayout() != null) { comp.getLayout().layoutContainer(comp); } } if (!isTableUI() && ((InplaceEditor) comp).supportsTextEntry()) { innermost.setBackground(PropUtils.getTextFieldBackground()); innermost.setForeground(PropUtils.getTextFieldForeground()); } }
/** * @see javax.swing.plaf.basic.BasicButtonUI#getMinimumSize(javax.swing.JComponent) */ public Dimension getMinimumSize(JComponent c) { if (c.getComponentCount() > 0 && c.getLayout() != null) { return null; } AbstractButton b = (AbstractButton) c; SeaGlassContext ss = getContext(c); final SynthStyle style2 = ss.getStyle(); Dimension size = style2.getGraphicsUtils(ss).getMinimumSize(ss, style2.getFont(ss), b.getText(), getSizingIcon(b), b.getHorizontalAlignment(), b.getVerticalAlignment(), b.getHorizontalTextPosition(), b.getVerticalTextPosition(), b.getIconTextGap(), b.getDisplayedMnemonicIndex()); ss.dispose(); return size; }