javax.swing.GroupLayout类的使用及代码示例

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

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

GroupLayout介绍

暂无

代码示例

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

GroupLayout layout = new GroupLayout(this);          
this.setLayout(layout);
layout.setAutoCreateGaps(true);
layout.setAutoCreateContainerGaps(true);
layout.setHorizontalGroup(layout.createSequentialGroup()
  .addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
    .addComponent(label1)
    .addComponent(label2)
    .addComponent(label3))
  .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
layout.setVerticalGroup(layout.createSequentialGroup()
  .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
  .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
  .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
JFrame f = new JFrame("GroupPanel");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setLayout(new BoxLayout(f.getContentPane(), BoxLayout.Y_AXIS));
f.add(new GroupPanel(1));
f.add(new GroupPanel(2));
f.add(Box.createVerticalGlue());
f.pack();
f.setLocationRelativeTo(null);
f.setVisible(true);

代码示例来源:origin: kiegroup/optaplanner

public MachineReassignmentPanel() {
  GroupLayout layout = new GroupLayout(this);
  setLayout(layout);
  createMachineListPanel();
  JPanel headerPanel = new JPanel();
  layout.setHorizontalGroup(layout.createParallelGroup()
      .addComponent(headerPanel).addComponent(machineListPanel));
  layout.setVerticalGroup(layout.createSequentialGroup()
      .addComponent(headerPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
          GroupLayout.PREFERRED_SIZE)
      .addComponent(machineListPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
          GroupLayout.PREFERRED_SIZE));
}

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

GroupLayout layout = new GroupLayout(getRootPane());
getRootPane().setLayout(layout);
layout.setAutoCreateGaps(true);
layout.setAutoCreateContainerGaps(true);
layout.setHorizontalGroup(
    layout.createSequentialGroup().addComponent(label)
        .addGroup(
            layout.createParallelGroup(Alignment.LEADING).addComponent(statusLabel)
                .addComponent(textField)
                .addGroup(layout.createSequentialGroup()
                    .addGroup(layout.createParallelGroup(Alignment.LEADING)
                        .addComponent(mcase))
                .addGroup(layout.createParallelGroup(Alignment.LEADING).addComponent(wholew))
                .addGroup(layout.createParallelGroup(Alignment.LEADING).addComponent(regex))
                .addGroup(layout.createParallelGroup(Alignment.LEADING).addComponent(classname)))
    .addGroup(layout.createSequentialGroup()
        .addGroup(layout.createParallelGroup(Alignment.LEADING).addComponent(listScroller)
            .addComponent(progressBar))))
    .addGroup(layout.createParallelGroup(Alignment.LEADING).addComponent(findButton))
layout.linkSize(SwingConstants.HORIZONTAL, findButton);
layout.setVerticalGroup(layout.createSequentialGroup()
    .addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(label).addComponent(textField)
        .addComponent(findButton))
    .addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(mcase).addComponent(wholew)
        .addComponent(regex).addComponent(classname))
    .addGroup(layout.createParallelGroup(Alignment.LEADING)
        .addGroup(layout.createSequentialGroup()

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

GroupLayout layout = new GroupLayout(this);
setLayout(layout);
layout.setHorizontalGroup(layout.createSequentialGroup()
    .addComponent(lblTitle)
    .addGap(20)
    .addComponent(lblContent));
layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
    .addComponent(lblTitle)
    .addComponent(lblContent));
JFrame frame = new JFrame();
frame.setContentPane(new TestPanel());
frame.pack();
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

代码示例来源:origin: GoldenGnu/jeveassets

jFrame = new JFrame();
updateTitle();
setSizeAndLocation(Settings.get().getWindowSize(),  Settings.get().getWindowLocation(), Settings.get().isWindowMaximized());
jFrame.setAlwaysOnTop(Settings.get().isWindowAlwaysOnTop());
List<Image> icons = new ArrayList<Image>();
icons.add(Images.TOOL_ASSETS.getImage());
icons.add(Images.MISC_ASSETS_32.getImage());
icons.add(Images.MISC_ASSETS_64.getImage());
jFrame.setIconImages(icons);
jFrame.addWindowListener(listener);
jFrame.addComponentListener(listener);
GroupLayout layout = new GroupLayout(jPanel);
jPanel.setLayout(layout);
layout.setAutoCreateGaps(false);
layout.setAutoCreateContainerGaps(false);
jFrame.getContentPane().add(jPanel);
layout.setHorizontalGroup(
  layout.createParallelGroup()
    .addComponent(jTabbedPane, 0, 0, Short.MAX_VALUE)
    .addComponent(statusPanel.getPanel(), 0, 0, Short.MAX_VALUE)
);
layout.setVerticalGroup(
  layout.createSequentialGroup()
    .addComponent(jTabbedPane, 0, 0, Short.MAX_VALUE)
    .addComponent(statusPanel.getPanel(), 25, 25, 25)
);

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

import java.awt.BorderLayout;import java.awt.Dimension;import java.awt.FlowLayout;import java.awt.Point;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.io.File;import javax.swing.GroupLayout;import javax.swing.GroupLayout.Alignment;import javax.swing.JButton;import javax.swing.JDialog;import javax.swing.JFileChooser;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JPanel;import javax.swing.JTextField;import javax.swing.LayoutStyle.ComponentPlacement;import javax.swing.border.EmptyBorder;import javax.swing.filechooser.FileFilter;import javax.swing.filechooser.FileNameExtensionFilter;public class ConfigureDialog extends JDialog implements ActionListener{private static final long serialVersionUID=1L;private final JPanel contentPanel=new JPanel();private JTextField driverPathTextField;private JLabel lblDriverPath;private JButton btnBrowse;public static void main(String[]args){try{ConfigureDialog dialog=new ConfigureDialog(new JFrame());dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);dialog.setVisible(true);}catch(Exception e){e.printStackTrace();}}
public ConfigureDialog(JFrame parent){super(parent,"",true);if(parent!=null){Dimension parentSize=parent.getSize();Point p=parent.getLocation();setLocation(p.x+parentSize.width+100,p.y+parentSize.height/1);}
setBounds(100,100,479,141);getContentPane().setLayout(new BorderLayout());contentPanel.setBorder(new EmptyBorder(5,5,5,5));getContentPane().add(contentPanel,BorderLayout.CENTER);{lblDriverPath=new JLabel("Driver Path : ");}
{driverPathTextField=new JTextField(System.getProperty("web.ie.driver"));driverPathTextField.setColumns(10);}
btnBrowse=new JButton("Browse");GroupLayout gl_contentPanel=new GroupLayout(contentPanel);gl_contentPanel.setHorizontalGroup(gl_contentPanel.createParallelGroup(Alignment.LEADING).addGroup(gl_contentPanel.createSequentialGroup().addContainerGap().addComponent(lblDriverPath).addPreferredGap(ComponentPlacement.RELATED).addGroup(gl_contentPanel.createParallelGroup(Alignment.LEADING).addComponent(btnBrowse).addComponent(driverPathTextField,GroupLayout.DEFAULT_SIZE,207,Short.MAX_VALUE)).addContainerGap()));gl_contentPanel.setVerticalGroup(gl_contentPanel.createParallelGroup(Alignment.LEADING).addGroup(gl_contentPanel.createSequentialGroup().addGap(5).addGroup(gl_contentPanel.createParallelGroup(Alignment.BASELINE).addComponent(driverPathTextField,GroupLayout.PREFERRED_SIZE,GroupLayout.DEFAULT_SIZE,GroupLayout.PREFERRED_SIZE).addComponent(lblDriverPath)).addPreferredGap(ComponentPlacement.UNRELATED).addComponent(btnBrowse).addContainerGap(21,Short.MAX_VALUE)));contentPanel.setLayout(gl_contentPanel);{JPanel buttonPane=new JPanel();buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));getContentPane().add(buttonPane,BorderLayout.SOUTH);{JButton okButton=new JButton("OK");okButton.setActionCommand("OK");okButton.addActionListener(this);buttonPane.add(okButton);getRootPane().setDefaultButton(okButton);}
{JButton cancelButton=new JButton("Cancel");cancelButton.setActionCommand("Cancel");cancelButton.addActionListener(this);buttonPane.add(cancelButton);}}
btnBrowse.addActionListener(this);}@Override
public void actionPerformed(ActionEvent e){if("Cancel".contains(e.getActionCommand())){dispose();}else if("Browse".contains(e.getActionCommand())){JFileChooser fileopen=new JFileChooser();FileFilter filter=new FileNameExtensionFilter("exe file","exe");fileopen.addChoosableFileFilter(filter);fileopen.setAcceptAllFileFilterUsed(false);fileopen.setFileFilter(filter);fileopen.setFileSelectionMode(JFileChooser.FILES_ONLY);int ret=fileopen.showOpenDialog(this);if(ret==JFileChooser.APPROVE_OPTION){File file=fileopen.getSelectedFile();System.out.println(file);driverPathTextField.setText(file.getPath());}}else if("OK".contains(e.getActionCommand())){System.setProperty("web.ie.driver",driverPathTextField.getText());dispose();}}}

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

setDefaultCloseOperation(EXIT_ON_CLOSE);
setJMenuBar(menuBar);
setSize(500, 500);
GroupLayout layout = new GroupLayout(contentPane);
contentPane.setLayout(layout);
setContentPane(contentPane);
layout.setAutoCreateGaps(true);
layout.setAutoCreateContainerGaps(true);
GroupLayout.SequentialGroup hGroup = layout.createSequentialGroup();
hGroup.addComponent(leftPanel);
hGroup.addGroup(layout.createParallelGroup().
     addComponent(topRightPanel).addComponent(bottomRightPanel));
layout.setHorizontalGroup(hGroup);
GroupLayout.ParallelGroup vGroup = layout.createParallelGroup();
vGroup.addComponent(leftPanel);
vGroup.addGroup(layout.createSequentialGroup().
     addComponent(topRightPanel).addComponent(bottomRightPanel));
layout.setVerticalGroup(vGroup);
 @Override
 public void run() {
  frame.setVisible(true);

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

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
setupButton(B);
GroupLayout gl_contentPane = new GroupLayout(contentPane);
gl_contentPane.setHorizontalGroup(gl_contentPane.createParallelGroup(Alignment.LEADING).addGroup(
    gl_contentPane.createSequentialGroup().addComponent(A, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE).addPreferredGap(ComponentPlacement.RELATED)
        .addComponent(B, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addContainerGap(237, Short.MAX_VALUE)));
gl_contentPane.setVerticalGroup(gl_contentPane.createParallelGroup(Alignment.LEADING).addGroup(
    gl_contentPane
        .createSequentialGroup()
        .addGroup(
            gl_contentPane.createParallelGroup(Alignment.BASELINE).addComponent(A, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                .addComponent(B, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)).addContainerGap(227, Short.MAX_VALUE)));
contentPane.setLayout(gl_contentPane);

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

panel = new JPanel();
Container pane = mainWindow.getContentPane();
GroupLayout gl = new GroupLayout(pane);
pane.setLayout(gl);
gl.setAutoCreateContainerGaps(false);
gl.setHorizontalGroup(gl.createSequentialGroup().addComponent(panel));
gl.setVerticalGroup(gl.createSequentialGroup().addComponent(panel));
// ++++++++++++  editing start
// force do layout subcomponents and rendering
mainWindow.pack();
// ++++++++++++  editing end
System.out.println("w:" + panel.getWidth() + " h:" + panel.getHeight());

代码示例来源:origin: kiegroup/optaplanner

public MrProcessAssignmentListDialog() {
  setModal(true);
  setTitle(getMachineLabel());
  JPanel contentPanel = new JPanel();
  GroupLayout layout = new GroupLayout(contentPanel);
  contentPanel.setLayout(layout);
  JPanel assignmentsPanel = createAssignmentsPanel();
  JScrollPane contentScrollPane = new JScrollPane(assignmentsPanel);
  contentScrollPane.setPreferredSize(new Dimension(800, 200));
  contentScrollPane.getVerticalScrollBar().setUnitIncrement(20);
  setContentPane(contentScrollPane);
  pack();
}

代码示例来源:origin: kiegroup/optaplanner

public NurseRosteringPanel() {
  employeeIcon = new ImageIcon(getClass().getResource("employee.png"));
  deleteEmployeeIcon = new ImageIcon(getClass().getResource("deleteEmployee.png"));
  GroupLayout layout = new GroupLayout(this);
  setLayout(layout);
  createEmployeeListPanel();
  JPanel headerPanel = createHeaderPanel();
  layout.setHorizontalGroup(layout.createParallelGroup()
      .addComponent(headerPanel).addComponent(employeeListPanel));
  layout.setVerticalGroup(layout.createSequentialGroup()
      .addComponent(headerPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
          GroupLayout.PREFERRED_SIZE)
      .addComponent(employeeListPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
          GroupLayout.PREFERRED_SIZE));
}

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

GroupLayout layout = new GroupLayout(panel);
panel.setLayout(layout);
layout.setAutoCreateContainerGaps(true);
layout.setAutoCreateGaps(true);
layout.setHorizontalGroup(layout.createSequentialGroup()
    .addGroup(layout.createParallelGroup()
      .addComponent(lblCardHolder)
      .addComponent(lblCardNumber)
      .addComponent(lblExpirationDate))
    .addGroup(layout.createParallelGroup()
      .addGroup(layout.createSequentialGroup()
        .addComponent(tfExpirationDate)
layout.setVerticalGroup(layout.createSequentialGroup()
    .addGroup(layout.createParallelGroup(BASELINE)
    .addGroup(layout.createParallelGroup(BASELINE)
    .addGroup(layout.createParallelGroup(BASELINE)
JFrame f = new JFrame();
f.setContentPane(panel);
f.pack();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);

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

this.setResizable(false);
GroupLayout layout = new GroupLayout(getRootPane());
getRootPane().setLayout(layout);
layout.setAutoCreateGaps(true);
layout.setAutoCreateContainerGaps(true);
layout.setHorizontalGroup(layout.createSequentialGroup().addComponent(label)
    .addGroup(layout.createParallelGroup(Alignment.LEADING).addComponent(textField)
        .addGroup(layout.createSequentialGroup()
            .addGroup(layout.createParallelGroup(Alignment.LEADING).addComponent(mcase)
                .addComponent(wholew).addComponent(wrap))
        .addGroup(layout.createParallelGroup(Alignment.LEADING).addComponent(regex)
            .addComponent(reverse))))
    .addGroup(layout.createParallelGroup(Alignment.LEADING).addComponent(findButton)));
layout.linkSize(SwingConstants.HORIZONTAL, findButton);
layout.setVerticalGroup(layout.createSequentialGroup()
    .addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(label).addComponent(textField)
        .addComponent(findButton))
    .addGroup(layout.createParallelGroup(Alignment.LEADING)
        .addGroup(layout.createSequentialGroup()
            .addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(mcase)
                .addComponent(regex))
            .addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(wholew)
                .addComponent(reverse))
            .addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(wrap)))));

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

JTextField searchTF = new JTextField(10);
GroupLayout layout = new GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setAutoCreateGaps(true);
layout.setAutoCreateContainerGaps(true);
layout.setHorizontalGroup(layout.createSequentialGroup().addGroup(
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(label)
    .addComponent(searchTF)));
layout.setVerticalGroup(layout.createSequentialGroup().addGroup(
    layout.createParallelGroup(BASELINE).addComponent(label)
    .addComponent(searchTF)));
pack();
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(400, 500);
setTitle("fdf");
new MyDictionaryFrame().setVisible(true);

代码示例来源:origin: kiegroup/optaplanner

public CloudBalancingPanel() {
  cloudComputerIcon = new ImageIcon(getClass().getResource("cloudComputer.png"));
  addCloudComputerIcon = new ImageIcon(getClass().getResource("addCloudComputer.png"));
  deleteCloudComputerIcon = new ImageIcon(getClass().getResource("deleteCloudComputer.png"));
  cloudProcessIcon = new ImageIcon(getClass().getResource("cloudProcess.png"));
  addCloudProcessIcon = new ImageIcon(getClass().getResource("addCloudProcess.png"));
  deleteCloudProcessIcon = new ImageIcon(getClass().getResource("deleteCloudProcess.png"));
  GroupLayout layout = new GroupLayout(this);
  setLayout(layout);
  JPanel headerPanel = createHeaderPanel();
  JPanel computersPanel = createComputersPanel();
  layout.setHorizontalGroup(layout.createParallelGroup()
      .addComponent(headerPanel).addComponent(computersPanel));
  layout.setVerticalGroup(layout.createSequentialGroup()
      .addComponent(headerPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
          GroupLayout.PREFERRED_SIZE)
      .addComponent(computersPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
          GroupLayout.PREFERRED_SIZE));
}

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

GroupLayout layout = new GroupLayout(panel);
layout.setAutoCreateContainerGaps(true);
layout.setAutoCreateGaps(true);
panel.setLayout(layout);
layout.setHorizontalGroup(layout.createSequentialGroup()
    .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
        .addComponent(progressBar, GroupLayout.DEFAULT_SIZE, 500, GroupLayout.DEFAULT_SIZE)
        .addComponent(startTimeLabel, GroupLayout.Alignment.LEADING)
        .addComponent(fileProgLabel, GroupLayout.Alignment.LEADING)
        .addComponent(sizeProgLabel, GroupLayout.Alignment.CENTER)
        .addComponent(lastUpdatedLabel, GroupLayout.Alignment.TRAILING)
        .addComponent(etcLabel, GroupLayout.Alignment.TRAILING))
    .addComponent(clearBtn));
layout.setVerticalGroup(layout.createSequentialGroup()
    .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
        .addComponent(startTimeLabel)
        .addComponent(lastUpdatedLabel))
    .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
        .addComponent(progressBar)
        .addComponent(clearBtn))
    .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
        .addComponent(fileProgLabel)
        .addComponent(sizeProgLabel)
        .addComponent(etcLabel)));

代码示例来源:origin: martin-lizner/trezor-ssh-agent

private void createLayout() {
  upPanel = new JPanel(new BorderLayout());
  bottomPanel = new JPanel();
  bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.Y_AXIS));
  upPanel.add(jScrollPane1, BorderLayout.CENTER);
  bottomPanel.add(copyButton);
  GroupLayout layout = new GroupLayout(this.getContentPane());
  this.getContentPane().setLayout(layout);
  layout.setAutoCreateGaps(true);
  layout.setAutoCreateContainerGaps(true);
  layout.setHorizontalGroup(layout.createParallelGroup(CENTER)
      .addComponent(upPanel)
      .addComponent(bottomPanel)
  );
  layout.linkSize(SwingConstants.CENTER, bottomPanel);
  layout.setVerticalGroup(layout.createSequentialGroup()
      .addGroup(layout.createParallelGroup(BASELINE)
          .addComponent(upPanel)
      )
      .addGroup(layout.createParallelGroup(TRAILING)
          .addComponent(bottomPanel)
      ));
}

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

setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setPreferredSize(new java.awt.Dimension(640, 480));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  .addComponent(superPane, javax.swing.GroupLayout.DEFAULT_SIZE, 640, Short.MAX_VALUE)
);
layout.setVerticalGroup(
  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  .addComponent(superPane, javax.swing.GroupLayout.DEFAULT_SIZE, 480, Short.MAX_VALUE)
);
pack();

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

BookPanel(Book b)
{
  setBorder(new EmptyBorder(3, 3, 3, 3));
  setBackground(ColorScheme.DARK_GRAY_COLOR);
  GroupLayout layout = new GroupLayout(this);
  this.setLayout(layout);
  JLabel image = new JLabel();
  b.getIcon().addTo(image);
  JLabel name = new JLabel(b.getShortName());
  location.setFont(FontManager.getRunescapeSmallFont());
  layout.setVerticalGroup(layout.createParallelGroup()
    .addComponent(image)
    .addGroup(layout.createSequentialGroup()
      .addComponent(name)
      .addComponent(location)
    )
  );
  layout.setHorizontalGroup(layout.createSequentialGroup()
    .addComponent(image)
    .addGap(8)
    .addGroup(layout.createParallelGroup()
      .addComponent(name)
      .addComponent(location)
    )
  );
  // AWT's Z order is weird. This put image at the back of the stack
  setComponentZOrder(image, getComponentCount() - 1);
}

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

JTextField searchTF = new JTextField(10);
GroupLayout layout = new GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  .addGroup(layout.createSequentialGroup()
    .addContainerGap()
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(layout.createSequentialGroup()
        .addComponent(label)
        .addGap(0, 0, Short.MAX_VALUE))
      .addComponent(searchTF, javax.swing.GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE))
    .addContainerGap())
);
layout.setVerticalGroup(
  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  .addGroup(layout.createSequentialGroup()
    .addContainerGap()
    .addComponent(label)
new MyDictionaryFrame().setVisible(true);

相关文章