本文整理了Java中java.awt.Window.setMinimumSize()
方法的一些代码示例,展示了Window.setMinimumSize()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Window.setMinimumSize()
方法的具体详情如下:
包路径:java.awt.Window
类名称:Window
方法名:setMinimumSize
暂无
代码示例来源:origin: stackoverflow.com
import java.awt.Dimension;
import javax.swing.JFrame;
public class JFrameExample {
public static void main(String[] args) {
JFrame frame = new JFrame("Hello World");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setMinimumSize(new Dimension(100, 100));
frame.setVisible(true);
}
}
代码示例来源:origin: stackoverflow.com
public class JavaGui extends javax.swing.JFrame
{
public JavaGui()
{
setMinimumSize(1154, 753); // Make sure you do setMinimumSize() instead of setSize() when using pack() so that the JFrame does not shrink to 0 size
setLayout(null);
add(panelLeft);
add(panelRight);
pack();
}
// Next is main method
代码示例来源:origin: stackoverflow.com
setMinimumSize(new Dimension(400, 400));
setVisible(true);
代码示例来源:origin: stackoverflow.com
final JFrame frame = new JFrame("Nested Layout Example");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
plafComponents.add(plafChooser);
plafComponents.add(pack);
SwingUtilities.updateComponentTreeUI(frame);
if (pack.isSelected()) {
frame.pack();
frame.setMinimumSize(frame.getSize());
gui.add(plafComponents, BorderLayout.NORTH);
frame.pack();
frame.setMinimumSize(frame.getSize());
} catch(Throwable ignoreAndContinue) {
frame.setVisible(true);
代码示例来源:origin: stackoverflow.com
import java.awt.*;
import java.awt.Dialog.ModalityType;
import javax.swing.*;
public class SSCCE {
public static void main(String[] args) {
JDialog dlg = new JDialog(null, ModalityType.APPLICATION_MODAL);
dlg.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
JPanel pnl = new JPanel(new BorderLayout());
pnl.add(new JLabel("As big as needed"), BorderLayout.CENTER);
//pnl.setMinimumSize(new Dimension(300,300));
dlg.add(pnl);
System.out.println("Dialog minimum size: " + dlg.getMinimumSize());
dlg.pack(); // make the dialog as large as needed to display content
// Minimum size is not enforced by the OS without this call
dlg.setMinimumSize(dlg.getPreferredSize());
System.out.println("Dialog minimum size: " + dlg.getMinimumSize());
dlg.setVisible(true);
}
}
代码示例来源:origin: stackoverflow.com
JPanel fontNameCol = new JPanel(new GridLayout(0, 1, 2, 2));
JPanel fontExampleCol = new JPanel(new GridLayout(0, 1, 2, 2));
fontTable.add(fontNameCol, BorderLayout.WEST);
fontTable.add(fontExampleCol, BorderLayout.CENTER);
for (int ii = 0; ii < fonts.length; ii++) {
fontNameCol.add(new JLabel(fonts[ii]));
fontExampleCol.add(getExampleOfFont(fonts[ii]));
p.add(tabPane, BorderLayout.CENTER);
p.setPreferredSize(new Dimension(400, 400));
JFrame f = new JFrame("Properties");
f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
f.getContentPane().add(p, BorderLayout.CENTER);
f.pack();
f.setMinimumSize(f.getPreferredSize());
f.setSize(600, 500);
f.setLocationRelativeTo(null);
f.setVisible(true);
代码示例来源:origin: stackoverflow.com
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
p.add(f);
frame.add(p);
frame.pack();
frame.setVisible(true);
lastFocusableIndex = 0;
sl.setFocused(false);
autoSuggestionPopUpWindow.setVisible(false);
setFocusToTextField();
autoSuggestionPopUpWindow.setVisible(false);
setFocusToTextField();
suggestionsPanel.add(suggestionLabel);
autoSuggestionPopUpWindow.getContentPane().add(suggestionsPanel);
autoSuggestionPopUpWindow.setMinimumSize(new Dimension(textField.getWidth(), 30));
autoSuggestionPopUpWindow.setSize(tW, tH);
autoSuggestionPopUpWindow.setVisible(true);
autoSuggestionPopUpWindow.setMinimumSize(new Dimension(textField.getWidth(), 30));
autoSuggestionPopUpWindow.revalidate();
autoSuggestionPopUpWindow.repaint();
代码示例来源:origin: stackoverflow.com
JToolBar tools = new JToolBar();
tools.setFloatable(false);
gui.add(tools, BorderLayout.PAGE_START);
tools.add(new JButton("New")); // TODO - add functionality!
tools.add(new JButton("Save")); // TODO - add functionality!
tools.add(new JButton("Restore")); // TODO - add functionality!
tools.addSeparator();
new ChessBoardWithColumnsAndRows();
JFrame f = new JFrame("ChessChamp");
f.add(cb.getGui());
f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
f.setLocationByPlatform(true);
f.pack();
f.setMinimumSize(f.getSize());
f.setVisible(true);
代码示例来源:origin: stackoverflow.com
ui.add(text, BorderLayout.PAGE_START);
io = new JTextField(15);
Font font = io.getFont();
io.setHorizontalAlignment(SwingConstants.TRAILING);
io.setFocusable(false);
text.add(io);
ui.add(buttons, BorderLayout.CENTER);
String[] keyValues = {
"7", "8", "9", "/",
public void run() {
ScriptEngineCalculator sc = new ScriptEngineCalculator();
JFrame f = new JFrame("Calculet");
f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
f.setContentPane(sc.getUI());
f.pack();
f.setMinimumSize(f.getSize());
f.setLocationByPlatform(true);
f.setVisible(true);
代码示例来源:origin: stackoverflow.com
Box box = new Box(BoxLayout.Y_AXIS);
box.setAlignmentX(JComponent.CENTER_ALIGNMENT);
box.add(Box.createVerticalGlue());
box.add(new CustomComponents12());
box.add(Box.createVerticalGlue());
add(box);
pack();
setTitle("Custom Component Test / BoxLayout");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setMaximumSize(getMinimumSize());
setMinimumSize(getMinimumSize());
setPreferredSize(getPreferredSize());
setLocation(150, 150);
setVisible(true);
代码示例来源:origin: stackoverflow.com
getContentPane().add(bp);
validate();
SwingUtilities.invokeLater(new Runnable() {
public void run() {
JFrame f = new JFrame("Beeper");
f.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
BeeperPanel BeeperPanel = new BeeperPanel();
f.setContentPane(BeeperPanel);
f.pack();
f.setMinimumSize( f.getSize() );
f.setLocationByPlatform(true);
f.setVisible(true);
JPanel pSampleRate = new JPanel(new BorderLayout());
pSampleRate.setBorder(new TitledBorder("Sample Rate"));
pSampleRate.add( sampleRate );
sampleRate.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
options.add( pSampleRate );
代码示例来源:origin: stackoverflow.com
import javax.swing.JFrame;
import java.awt.Dimension;
public class Ex extends JFrame {
public static void main(String[] args) {
JFrame frame = new JFrame("YOU CAN'T SHRINK ME COMPLETELY!");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(400, 400);
frame.setMinimumSize(new Dimension(100, 100));
frame.setVisible(true);
}
}
代码示例来源:origin: stackoverflow.com
import java.awt.*;
import javax.swing.*;
public class Example {
public static void main(String args[]) {
JFrame frame = new JFrame();
JMenuBar menubar = new JMenuBar();
JLabel label = new JLabel("Hello World");
menubar.setLayout(new BorderLayout());
menubar.add(label, BorderLayout.EAST);
frame.setLayout(new BorderLayout());
frame.add(menubar, BorderLayout.PAGE_START);
frame.setMinimumSize(new Dimension(200, 100));
frame.setVisible(true);
}
}
代码示例来源:origin: stackoverflow.com
private JFrame frame = new JFrame();
panel.add(btn);
frame.add(tabbedPane, BorderLayout.CENTER);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setMinimumSize(new Dimension(300, 300));
frame.setVisible(true);
代码示例来源:origin: stackoverflow.com
import javax.swing.JFrame;
import java.awt.Insets;
public class JFrameInsets extends JFrame {
@Override
public Insets getInsets() {
return new Insets(10, 10, 10, 10);
}
private JFrameInsets() {
super("Insets of 10");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
pack();
setMinimumSize(getSize());
setVisible(true);
}
public static void main(String[] args) {
new JFrameInsets();
}
}
代码示例来源:origin: stackoverflow.com
Runnable r = new Runnable() {
public void run() {
JFrame jf=new JFrame("This is JFrame");
JPanel h=new JPanel();
h.add(new JButton("Button"));
h.add(new JLabel("this is JLabel"));
h.setBackground(Color.RED);
jf.add(h);
jf.getContentPane().setBackground(Color.BLACK);
jf.setLayout(new FlowLayout());
jf.setVisible(true);
jf.pack();
jf.setMinimumSize(jf.getSize());
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
代码示例来源:origin: stackoverflow.com
super(title);
JLabel lab = new JLabel("Label");
this.getContentPane().add(lab);
this.setMinimumSize(new Dimension(200, 200));
this.pack();
this.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
代码示例来源:origin: stackoverflow.com
@Override
public void run() {
JFrame f = new JFrame("Button GUI");
JButton b = new JButton("CLICK");
p.add(b);
f.add(p);
f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
f.setLocationByPlatform(true);
f.pack();
f.setMinimumSize(f.getSize());
f.setVisible(true);
代码示例来源:origin: stackoverflow.com
private JFrame frame = new JFrame();
frame.add(ui);
ui.setBorder(new LineBorder(Color.CYAN, 3));
toolPanel.setBorder(new LineBorder(Color.ORANGE, 3));
ui.add(toolPanel, BorderLayout.PAGE_START);
for (int i = 0; i < 3; i++) {
toolPanel.add(new JButton("Button " + i));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack(); // pack will make it as small as it can be.
frame.setMinimumSize(frame.getSize()); // nice tweak..
frame.setVisible(true);
代码示例来源:origin: stackoverflow.com
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(new MyPanel());
frame.pack();
frame.setMinimumSize(frame.getPreferredSize());
frame.setVisible(true);
gbc.weightx = 1;
gbc.insets = new Insets(10, 10, 10, 10);
north.add(labelD, gbc);
south.add(labelA, gbc);
gbc.gridy = 1;
south.add(labelB, gbc);
内容来源于网络,如有侵权,请联系作者删除!