本文整理了Java中net.miginfocom.swing.MigLayout
类的一些代码示例,展示了MigLayout
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MigLayout
类的具体详情如下:
包路径:net.miginfocom.swing.MigLayout
类名称:MigLayout
[英]A very flexible layout manager.
Read the documentation that came with this layout manager for information on usage.
[中]一个非常灵活的布局管理器。
有关用法的信息,请阅读此布局管理器随附的文档。
代码示例来源:origin: geotools/geotools
@Override
public JPanel createControlPanel() {
JPanel panel = new JPanel(new MigLayout());
panel.add(new JLabel(DECIMAL_DIALOG_LABEL), "gap related");
digitsFld = new JIntegerField(numDigits, false);
panel.add(digitsFld, "w 40!");
return panel;
}
代码示例来源:origin: stackoverflow.com
public static void main(String[] args)
{
JFrame frame = new JFrame();
JPanel panel = new JPanel(new MigLayout("debug"));
panel.add(new JLabel("Label Title"), "x2 min(b1.x - unrel, (container.w+pref)/2)");
panel.add(new JButton("Close Button"), "id b1, pushx, alignx right");
panel.add(new JButton("Main Menu Button"), "alignx right");
frame.add(panel);
frame.setSize(800, 200);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.setVisible(true);
}
代码示例来源:origin: geotools/geotools
public JComponent doLayout() {
final JPanel panel = new JPanel(new MigLayout("insets 0"));
panel.add(field = new JTextField(32), "width 200::700, growx");
// field.setActionCommand(FINISH); // pressing return will Finish wizard
panel.add(browse = new JButton("Browse"), "wrap");
browse.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
browse();
}
});
return panel;
}
代码示例来源:origin: Slowpoke101/FTBLaunch
private void setupGui () {
setIconImage(Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("/image/logo_ftb.png")));
setResizable(false);
Container panel = getContentPane();
panel.setLayout(new MigLayout());
messageLbl = new JLabel(message);
overwriteLbl = new JLabel(confirmMsg);
overwrite = new JButton(I18N.getLocaleString("MAIN_YES"));
abort = new JButton(I18N.getLocaleString("MAIN_NO"));
messageLbl.setHorizontalAlignment(SwingConstants.CENTER);
overwriteLbl.setHorizontalAlignment(SwingConstants.CENTER);
panel.add(messageLbl, GuiConstants.CENTER_SINGLE_LINE);
panel.add(overwriteLbl, GuiConstants.CENTER_SINGLE_LINE);
panel.add(overwrite, GuiConstants.FILL_TWO);
panel.add(abort, GuiConstants.GROW);
pack();
setLocationRelativeTo(getOwner());
}
}
代码示例来源:origin: stackoverflow.com
JFrame frame = new JFrame();
JPanel panel = new JPanel();
JLabel label = new JLabel("Centered text");
JButton button = new JButton("Button");
panel.setLayout(new MigLayout());
label.setHorizontalAlignment(JLabel.CENTER);
panel.add(label, "wrap, pushx, growx");
panel.add(button);
frame.add(panel);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.pack();
frame.setVisible(true);
代码示例来源:origin: GrammarViz2/grammarviz2_src
/** Creates the reusable dialog. */
public GrammarvizOptionsDialog(JFrame parentFrame, JPanel optionPanel, UserSession session) {
super(parentFrame, true);
if (parentFrame != null) {
Dimension parentSize = parentFrame.getSize();
Point p = parentFrame.getLocation();
setLocation(p.x + parentSize.width / 4, p.y + parentSize.height / 4);
}
this.session = session;
this.optionPane = (GrammarvizOptionsPane) optionPanel;
MigLayout mainFrameLayout = new MigLayout("fill", "[grow,center]", "[grow]5[]");
getContentPane().setLayout(mainFrameLayout);
getContentPane().add(this.optionPane, "h 200:300:,w 500:550:,growx,growy,wrap");
JPanel buttonPane = new JPanel();
JButton okButton = new JButton(OK_BUTTON_TEXT);
JButton cancelButton = new JButton(CANCEL_BUTTON_TEXT);
buttonPane.add(okButton);
buttonPane.add(cancelButton);
okButton.addActionListener(this);
cancelButton.addActionListener(this);
getContentPane().add(buttonPane, "wrap");
pack();
}
代码示例来源:origin: stackoverflow.com
frame = new JFrame("Test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLayout(new MigLayout());
nameLabel = new JLabel("Name:");
birthDateLabel = new JLabel("Birth Date:");
frame.add(nameLabel);
frame.add(nameTextField, "wrap");
frame.add(birthDateLabel);
frame.add(birthDateTextField);
frame.pack();
frame.setVisible(true);
代码示例来源:origin: geotools/geotools
MigLayout layout = new MigLayout();
JPanel panel = new JPanel(layout);
controls = new HashMap<Component, ControlCategory>();
JButton btn = null;
label = new JLabel("Feature type");
label.setForeground(Color.BLUE);
panel.add(label, "wrap");
typeLabel = new JLabel();
panel.add(typeLabel, "gapbefore indent, span, wrap");
panel.add(label, "wrap");
panel.add(label, "wrap");
btn = new JButton("Color...");
btn.addActionListener(
new ActionListener() {
panel.add(btn);
getContentPane().add(panel);
pack();
代码示例来源:origin: winder/Universal-G-Code-Sender
public static void main(String[] args) throws Exception {
BackendAPI backend = new GUIBackend();
backend.applySettings(SettingsFactory.loadSettings());
JPanel panel = new JPanel();
JFrame frame = new JFrame("Widget Previewer");
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(new BorderLayout());
frame.getContentPane().add(panel, BorderLayout.CENTER);
panel.setLayout(new MigLayout("wrap 1"));
panel.add(frameLauncherButton("ConnectionPanelGroup", new ConnectionPanelGroup(backend, new JogService(backend))));
panel.add(frameLauncherButton("CommandTextArea", new CommandTextArea(backend)));
代码示例来源:origin: stackoverflow.com
setSize(300, 250);
setTitle("Push constraint");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLocationRelativeTo(null);
JPanel pnl = new JPanel(new MigLayout("wrap"));
pnl.add(field, "pushx, growx");
pnl.add(new JScrollPane(area), "push, grow");
add(pnl);
public void run() {
MigLayoutPushEx ex = new MigLayoutPushEx();
ex.setVisible(true);
代码示例来源:origin: stackoverflow.com
import net.miginfocom.swing.MigLayout;
public class PanelLearning extends JPanel {
public PanelLearning() {
setLayout(new MigLayout("", "[grow, fill]", ""));
for (int i = 0; i < 3; i++) {
JPanel panel = new JPanel();
panel.add(new JLabel("label1"));
panel.add(new JLabel("label2"));
panel.add(new JLabel("label3"));
panel.setBorder(BorderFactory.createLineBorder(Color.red));
add(panel, "span, wrap");
}
}
public static void main(String[] args) {
JFrame frame = new JFrame("Login");
frame.setVisible(true);
frame.setContentPane(new PanelLearning());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
frame.pack();
}
}
代码示例来源:origin: geotools/geotools
MigLayout layout = new MigLayout();
JPanel panel = new JPanel(layout);
JLabel label = new JLabel("Family");
panel.add(label);
panel.add(familyCBox);
label = new JLabel("Style");
panel.add(label);
panel.add(styleCBox);
label = new JLabel("Weight");
panel.add(label);
JButton btn = new JButton("Apply");
btn.addActionListener(
new ActionListener() {
panel.add(btn, "span, split 2, align right");
panel.add(btn);
getContentPane().add(panel);
pack();
代码示例来源:origin: stackoverflow.com
migbug.pack();
migbug.setVisible(true);
JPanel content = new JPanel();
content.setLayout(new MigLayout("filly, debug", "[][grow][][grow]"));
content.add(new JLabel("Label 1"));
content.add(new JComboBox());
content.add(new JLabel("Label 2"));
content.add(new JTextField(25), "growx, wrap");
content.add(new JLabel("BIG"), "span, w :400:, h :200:, grow");
setContentPane(content);
代码示例来源:origin: geotools/geotools
public JPanel createPanel() {
final JPanel page = super.createPanel();
page.setLayout(new MigLayout());
JLabel title = new JLabel("Choose DataStore");
Font titleFont = new Font("Arial", Font.BOLD, 14);
title.setFont(titleFont);
page.add(title, "span");
JLabel description = new JLabel("Available DataStores on your classpath");
page.add(description, "grow, span");
代码示例来源:origin: winder/Universal-G-Code-Sender
JButton button;
if (customGcodeButtons.size() <= i) {
button = new JButton(i+"");
button.setEnabled(false);
customGcodeButtons.add(button);
button.addActionListener((ActionEvent evt) -> {
customGcodeButtonActionPerformed(index);
});
this.macroPanel.removeAll();
this.macroPanel.repaint();
for (int i = customGcodeButtons.size(); i > macros.size(); i--) {
JButton b = customGcodeButtons.remove(i-1);
MigLayout layout = new MigLayout("fillx, wrap " + columns + ", inset " + INSET, columnConstraint.toString());
macroPanel.setLayout(layout);
代码示例来源:origin: stackoverflow.com
setDefaultCloseOperation(EXIT_ON_CLOSE);
setSize(600, 400);
setContentPane(getTestPanel());
setVisible(true);
JPanel tempPanel = new JPanel(new MigLayout("debug", "0lp![grow,fill]0lp!", "[80:n:]"));
tempPanel.add(testBox);
JPanel testPanel = new JPanel(new MigLayout("", "[grow,fill]", "[grow,fill]"));
testPanel.add(tempPanel);
代码示例来源:origin: stackoverflow.com
JFrame frame = new JFrame();
frame.setBounds(100, 100, 784, 533);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
// Use whatever layout suits you but I prefer mig
frame.getContentPane().setLayout(new MigLayout("", "[344.00,grow,fill][-457.00]", "[grow]"));
frame.setTitle("Title");
frame.setAlwaysOnTop(true);
JPanel panel = new JPanel();
frame.getContentPane().add(panel, "cell 0 0,grow");
// Then add Text fields and labels so the user knows what to enter
JLabel lbl = new JLabel("Environment Name");
panel .add(lbl, "cell 0 0");
JTextField textField = new JTextField();
panel.add(textField , "cell 0 1,growx");
代码示例来源:origin: winder/Universal-G-Code-Sender
setLayout(new MigLayout(debug + "fillx, wrap 1, inset 5", "grow"));
activeStateValueLabel.setForeground(ThemeColors.VERY_DARK_GREY);
activeStateValueLabel.setText(OFFLINE);
activeStatePanel.setLayout(new MigLayout(debug + "fill, inset 0 5 0 5"));
if (backend.getSettings().isDisplayStateColor()) {
activeStatePanel.setBackground(Color.BLACK);
activeStateValueLabel.setBorder(BorderFactory.createEmptyBorder());
add(activeStatePanel, "growx");
addAxisPanel(Z, workPositionZValue, machinePositionZValue);
JPanel speedPanel = new JPanel(new MigLayout(debug + "fillx, wrap 2, inset 0", "[al right][]"));
speedPanel.setOpaque(false);
JLabel feedLabel = new JLabel(Localization.getString("gcode.setting.feed"));
speedPanel.add(feedLabel);
speedPanel.add(feedValue, "pad 2 0 0 0");
JLabel spindleSpeedLabel = new JLabel(Localization.getString("overrides.spindle.short"));
pinStatePanel.setLayout(new MigLayout("insets 0 5 0 5"));
pinStatePanel.setBackground(transparent);
resetStatePinComponents();
代码示例来源:origin: stackoverflow.com
JPanel panel = new JPanel(new MigLayout("flowy, fillx, filly", "[fill, grow]", "[fill, 0:100:300][fill, 0:100:max(100%,300)]"));
JPanel redPanel = new JPanel();
redPanel.setBackground(Color.RED);
JPanel bluePanel = new JPanel();
bluePanel.setBackground(Color.BLUE);
panel.add(redPanel);
panel.add(bluePanel);
JFrame frame = new JFrame();
frame.add(panel);
frame.pack();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
代码示例来源:origin: stackoverflow.com
public static void main(String[] args) {
JPanel panel1 = new JPanel(new MigLayout(new LC().fill()));
panel1.add(new JTextField("text1"), "span, growx");
panel1.add(new JTextField("another text field"), "span, growx");
panel1.add(new JTextField("text3"), "span, growx");
JPanel panel2 = new JPanel(new MigLayout());
JTextArea textArea = new JTextArea();
textArea.setColumns(15);
textArea.setRows(7);
JScrollPane jsp = new JScrollPane(textArea);
panel2.add(jsp, "span, grow");
JFrame frame = new JFrame();
frame.setLayout(new GridLayout(1, 2));
frame.add(panel1);
frame.add(panel2);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
内容来源于网络,如有侵权,请联系作者删除!