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

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

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

GridBagLayout.<init>介绍

[英]Creates a grid bag layout manager.
[中]创建网格袋布局管理器。

代码示例

代码示例来源:origin: skylot/jadx

public SettingsGroup(String title) {
  setBorder(BorderFactory.createTitledBorder(title));
  setLayout(new GridBagLayout());
  c = new GridBagConstraints();
  c.insets = new Insets(5, 5, 5, 5);
  c.weighty = 1.0;
}

代码示例来源:origin: stanfordnlp/CoreNLP

private JPanel makeFoundStatsBox() {
 JPanel foundStatsBox = new JPanel();
 foundStatsBox.setLayout(new GridBagLayout());
 Box labelBox = Box.createHorizontalBox();
 foundStats = new JLabel(" ");
 labelBox.add(foundStats);
 historyButton = new JButton("Statistics");
 historyButton.setEnabled(false);
 historyButton.addActionListener(this);
 GridBagConstraints c = new GridBagConstraints();
 c.fill = GridBagConstraints.BOTH;
 c.weightx = 1.7;
 foundStatsBox.add(labelBox,c);
 c.weightx = .3;
 c.gridwidth = 1;
 foundStatsBox.add(historyButton);
 return foundStatsBox;
}

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

public static void main(String[] args) {
  JFrame frame = new JFrame();
  frame.setLayout(new GridBagLayout());
  JPanel panel = new JPanel();
  panel.add(new JLabel("This is a label"));
  panel.setBorder(new LineBorder(Color.BLACK)); // make it easy to see
  frame.add(panel, new GridBagConstraints());
  frame.setSize(400, 400);
  frame.setLocationRelativeTo(null);
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.setVisible(true);
}

代码示例来源:origin: RipMeApp/ripme

public MainWindow() {
  mainFrame = new JFrame("RipMe v" + UpdateUtils.getThisJarVersion());
  mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  mainFrame.setLayout(new GridBagLayout());
  createUI(mainFrame.getContentPane());
  pack();
  loadHistory();
  setupHandlers();
  Thread shutdownThread = new Thread(this::shutdownCleanup);
  Runtime.getRuntime().addShutdownHook(shutdownThread);
  if (Utils.getConfigBoolean("auto.update", true)) {
    upgradeProgram();
  }
  boolean autoripEnabled = Utils.getConfigBoolean("clipboard.autorip", false);
  ClipboardUtils.setClipboardAutoRip(autoripEnabled);
  trayMenuAutorip.setState(autoripEnabled);
}

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

final GridBagLayout gridbag = new GridBagLayout();
final GridBagConstraints c = new GridBagConstraints();
setLayout(gridbag);
JLabel label = new JLabel("Filter Level:");
gridbag.setConstraints(label, c);
add(label);
label = new JLabel("Filter Thread:");
gridbag.setConstraints(label, c);
add(label);
label = new JLabel("Filter Logger:");
gridbag.setConstraints(label, c);
add(label);

代码示例来源:origin: alibaba/jstorm

String[] prompt,
                   boolean[] echo) {
panel = new JPanel();
panel.setLayout(new GridBagLayout());
panel.add(new JLabel(instruction), gbc);
gbc.gridy++;
  gbc.gridx = 0;
  gbc.weightx = 1;
  panel.add(new JLabel(prompt[i]), gbc);
    texts[i] = new JPasswordField(20);
  panel.add(texts[i], gbc);
  gbc.gridy++;

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

JPanel panel = new JPanel(new GridBagLayout());
EditorPanel.addContent(panel, i, 0, new JLabel("Shape"), false, GridBagConstraints.WEST, GridBagConstraints.NONE, 0,0);
EditorPanel.addContent(panel, i++,1, shapeCombo = new JComboBox(new DefaultComboBoxModel(spawnShapes)), false, GridBagConstraints.WEST, GridBagConstraints.NONE, 1,0);
EditorPanel.addContent(panel, i, 0, edgesLabel = new JLabel("Edges"), false, GridBagConstraints.WEST, GridBagConstraints.NONE, 0,0);	
EditorPanel.addContent(panel, i++, 1, edgesCheckbox = new JCheckBox(), false, GridBagConstraints.WEST, GridBagConstraints.NONE, 0,0);		
EditorPanel.addContent(panel, i, 0, sideLabel = new JLabel("Side"), false, GridBagConstraints.WEST, GridBagConstraints.NONE, 0,0);		
EditorPanel.addContent(panel, i++, 1, sideCombo = new JComboBox(new DefaultComboBoxModel(SpawnSide.values())), false, GridBagConstraints.WEST, GridBagConstraints.NONE, 1, 0);				
edgesCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);

代码示例来源:origin: chewiebug/GCViewer

/**
 * Constructor taking a "parent" frame as parameter.
 * @param parent parent frame for this dialog
 */
public OpenUrlView(JFrame parent) {
  super();
  
  this.parent = parent;
  autoCompletionComboBox = new AutoCompletionComboBox();
  
  panel = new JPanel(new GridBagLayout());
  GridBagConstraints gridBagConstraints = new GridBagConstraints();
  gridBagConstraints.anchor = GridBagConstraints.WEST;
  panel.add(autoCompletionComboBox, gridBagConstraints);
  gridBagConstraints.gridy = 1;
  addUrlCheckBox = new JCheckBox(LocalisationHelper.getString("urlopen_dialog_add_checkbox"), false);
  addUrlCheckBox.setToolTipText(LocalisationHelper.getString("urlopen_dialog_hint_add_checkbox"));
  panel.add(addUrlCheckBox, gridBagConstraints);
}

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

public LogFactor5LoadingDialog(JFrame jframe, String message) {
 super(jframe, "LogFactor5", false);
 JPanel bottom = new JPanel();
 bottom.setLayout(new FlowLayout());
 JPanel main = new JPanel();
 main.setLayout(new GridBagLayout());
 wrapStringOnPanel(message, main);
 getContentPane().add(main, BorderLayout.CENTER);
 getContentPane().add(bottom, BorderLayout.SOUTH);
 show();
}
//--------------------------------------------------------------------------

代码示例来源:origin: apache/ignite

/**
 * @return Panel with controls to display license.
 */
private JPanel createLicensePanel() {
  JPanel licPanel = new JPanel(new GridBagLayout());
  licPanel.add(Box.createVerticalGlue(), gbcStrut());
  addAboutItem(licPanel, "Version:", ver);
  addAboutItem(licPanel, "Release Date:", new SimpleDateFormat("dd MMM yyyy").format(release));
  addAboutItem(licPanel, "Copyright:", copyright);
  return licPanel;
}

代码示例来源:origin: deathmarine/Luyten

public Tab(String t) {
  super(new GridBagLayout());
  this.setOpaque(false);
  this.title = t;
  this.tabTitle = new JLabel(title);
  this.createTab();
}

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

tabPane.addTab(title, tabBody);
int index = tabPane.indexOfTab(title);
JPanel pnlTab = new JPanel(new GridBagLayout());
pnlTab.setOpaque(false);
JLabel lblTitle = new JLabel(title);
JButton btnClose = new JButton("x");

GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.weightx = 1;

pnlTab.add(lblTitle, gbc);

gbc.gridx++;
gbc.weightx = 0;
pnlTab.add(btnClose, gbc);

tabPane.setTabComponentAt(index, pnlTab);

btnClose.addActionListener(myCloseActionHandler);

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

private JFrame frame = new JFrame("Test");
private JPanel panel = new JPanel();
private JLabel label = new JLabel("CenteredJLabel");
  panel.setLayout(new GridBagLayout());
  panel.add(label);
  panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
  frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
  frame.add(panel);
  frame.setSize(400, 300);
  frame.setLocationRelativeTo(null);
  frame.setVisible(true);

代码示例来源:origin: stanfordnlp/CoreNLP

private JPanel makeBrowseButtonBox() {
 JPanel buttonBox = new JPanel();
 buttonBox.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
 buttonBox.setLayout(new GridBagLayout());
 browseButton = new JButton("Browse Trees");
 browseButton.addActionListener(this);
 JLabel sizeLabel = new JLabel("Tree size:");
 JSlider fontSlider = new JSlider(2, 64, 12);
 fontSlider.addChangeListener(this);
 GridBagConstraints buttonConstraints = new GridBagConstraints();
 buttonConstraints.fill = GridBagConstraints.HORIZONTAL;
 buttonConstraints.weightx = 0.2;
 buttonConstraints.weighty = 0.2;
 buttonBox.add(browseButton,buttonConstraints);
 buttonConstraints.weightx = 0.6;
 buttonBox.add(fontSlider, buttonConstraints);
 buttonConstraints.weightx = 0.2;
 buttonBox.add(sizeLabel, buttonConstraints);
 return buttonBox;
}

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

public class Class4 {

  private JFrame f;

  public Class4() {
    f = new JFrame("Love Test");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setSize(500,200);     
    f.setLayout(new GridBagLayout());
  }

  // ...
}

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

private ExEntryPanel() {
 setBorder(BorderFactory.createEtchedBorder());
 label = new JLabel(" ");
 entry = new ExTextField();
 entry.setBorder(null);
 setFontForElements();
 setForeground(entry.getForeground());
 setBackground(entry.getBackground());
 label.setForeground(entry.getForeground());
 label.setBackground(entry.getBackground());
 GridBagLayout layout = new GridBagLayout();
 GridBagConstraints gbc = new GridBagConstraints();
 setLayout(layout);
 gbc.gridx = 0;
 layout.setConstraints(this.label, gbc);
 add(this.label);
 gbc.gridx = 1;
 gbc.weightx = 1.0;
 gbc.fill = GridBagConstraints.HORIZONTAL;
 layout.setConstraints(entry, gbc);
 add(entry);
 setBorder(BorderFactory.createEtchedBorder());
 adapter = new ComponentAdapter() {
  public void componentResized(ComponentEvent e) {
   positionPanel();
  }
 };
}

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

public GridBagHelper(Container container, double[] weights) {
  this.container = container;
  this.weights = weights;
  gridbag = new GridBagLayout();
  container.setLayout(gridbag);
  c = new GridBagConstraints();
  c.insets = new Insets(2, 2, 2, 2);
  c.anchor = GridBagConstraints.EAST;
  c.fill = GridBagConstraints.HORIZONTAL;
}

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

JPanel panel = new JPanel(new GridBagLayout());
EditorPanel.addContent(panel, i, 0, new JLabel("Shape"), false, GridBagConstraints.WEST, GridBagConstraints.NONE, 0,0);
EditorPanel.addContent(panel, i++,1, shapeCombo = new JComboBox(new DefaultComboBoxModel(spawnShapes)), false, GridBagConstraints.WEST, GridBagConstraints.NONE, 1,0);
EditorPanel.addContent(panel, i, 0, edgesLabel = new JLabel("Edges"), false, GridBagConstraints.WEST, GridBagConstraints.NONE, 0,0);	
EditorPanel.addContent(panel, i++, 1, edgesCheckbox = new JCheckBox(), false, GridBagConstraints.WEST, GridBagConstraints.NONE, 0,0);		
EditorPanel.addContent(panel, i, 0, sideLabel = new JLabel("Side"), false, GridBagConstraints.WEST, GridBagConstraints.NONE, 0,0);		
EditorPanel.addContent(panel, i++, 1, sideCombo = new JComboBox(new DefaultComboBoxModel(SpawnSide.values())), false, GridBagConstraints.WEST, GridBagConstraints.NONE, 1, 0);				
edgesCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);

代码示例来源:origin: stanfordnlp/CoreNLP

JPanel buttonPanel = new JPanel();
buttonPanel.setBackground(Color.WHITE);
buttonPanel.applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
this.setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.gridwidth = GridBagConstraints.REMAINDER;

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

public LogFactor5ErrorDialog(JFrame jframe, String message) {
 super(jframe, "Error", true);
 JButton ok = new JButton("Ok");
 ok.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent e) {
   hide();
  }
 });
 JPanel bottom = new JPanel();
 bottom.setLayout(new FlowLayout());
 bottom.add(ok);
 JPanel main = new JPanel();
 main.setLayout(new GridBagLayout());
 wrapStringOnPanel(message, main);
 getContentPane().add(main, BorderLayout.CENTER);
 getContentPane().add(bottom, BorderLayout.SOUTH);
 show();
}
//--------------------------------------------------------------------------

相关文章