javax.swing.JComponent.getLayout()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(107)

本文整理了Java中javax.swing.JComponent.getLayout()方法的一些代码示例,展示了JComponent.getLayout()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JComponent.getLayout()方法的具体详情如下:
包路径:javax.swing.JComponent
类名称:JComponent
方法名:getLayout

JComponent.getLayout介绍

暂无

代码示例

代码示例来源:origin: JetBrains/ideavim

/**
 * 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);
}

代码示例来源:origin: JetBrains/ideavim

JRootPane root = SwingUtilities.getRootPane(parent);
oldGlass = (JComponent)root.getGlassPane();
oldLayout = oldGlass.getLayout();
wasOpaque = oldGlass.isOpaque();
oldGlass.setLayout(null);

代码示例来源:origin: runelite/runelite

LayoutManager delegate = titleBar.getLayout();
titleBar.setLayout(new LayoutManager()

代码示例来源:origin: tinyMediaManager/tinyMediaManager

@Override
 public Dimension getPreferredSize(JComponent c) {
  Dimension preferred = c.getLayout().preferredLayoutSize(c);
  return preferred;
 }
}

代码示例来源:origin: org.metawidget.modules/metawidget-all

/**
 * 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();
}

代码示例来源:origin: org.metawidget.modules.swing/metawidget-swing

/**
 * 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();
}

代码示例来源:origin: stackoverflow.com

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();

代码示例来源:origin: stackoverflow.com

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());
}

代码示例来源:origin: org.metawidget.modules/metawidget-all

@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 ) );
  }
}

代码示例来源:origin: org.swinglabs.swingx/swingx-all

/**
   * 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;
  }
}

代码示例来源:origin: org.bidib.jbidib.swinglabs.swingx/swingx-core

/**
   * 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;
  }
}

代码示例来源:origin: org.swinglabs.swingx/swingx-core

/**
   * 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;
  }
}

代码示例来源:origin: org.jspresso.framework/jspresso-swing-application

/**
 * {@inheritDoc}
 */
@Override
protected void showCardInPanel(JComponent cardsPeer, String cardName) {
 JComponent cardPanel = findFirstCardPanel(cardsPeer);
 if (cardPanel != null) {
  ((CardLayout) cardPanel.getLayout()).show(cardPanel, cardName);
 }
}

代码示例来源:origin: stackoverflow.com

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);

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-bugtracking

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);
}

代码示例来源:origin: freeplane/freeplane

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();
    }
  }
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-bugtracking

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();
  }
}

代码示例来源:origin: org.netbeans.api/org-openide-explorer

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());
  }
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide

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());
  }
}

代码示例来源:origin: khuxtable/seaglass

/**
 * @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;
}

相关文章

JComponent类方法