java.awt.GridBagLayout.preferredLayoutSize()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(1.3k)|赞(0)|评价(0)|浏览(105)

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

GridBagLayout.preferredLayoutSize介绍

[英]Determines the preferred size of the parent container using this grid bag layout.

Most applications do not call this method directly.
[中]

代码示例

代码示例来源:origin: io.ultreia.java4all.jaxx/jaxx-widgets-extra

@Override
public Dimension preferredLayoutSize(Container parent) {
  return layout.preferredLayoutSize(parent);
}

代码示例来源:origin: org.nuiton/nuiton-widgets

@Override
public Dimension preferredLayoutSize(Container parent) {
  return layout.preferredLayoutSize(parent);
}

代码示例来源:origin: com.stevesoft.pat/pat

public void packNShow() {
  int i;
  GridBagLayout gb = new GridBagLayout();
  setLayout(gb);
  GridBagConstraints gc = new GridBagConstraints();
  gc.gridx = 0;
  gc.fill = gc.HORIZONTAL;
  int xpos = 0,ypos = 0;
  Label lab;
  for(i=0;i<v.size();i++)
    if(v.elementAt(i) instanceof Label) {
    lab = (Label)v.elementAt(i);
    add(lab);
    gc.gridy = ypos++;
    gb.setConstraints(lab,gc);
  }
  gc.gridy = ypos;
  for(i=0;i<v.size();i++)
    if(v.elementAt(i) instanceof Button) {
    Button but = (Button)v.elementAt(i);
    add(but);
    gc.gridx = xpos++;
    gb.setConstraints(but,gc);
  }
  pack();
  resize(gb.preferredLayoutSize(this));
  show();
}
/** @serial */

相关文章