本文整理了Java中javax.swing.JFrame.getPreferredSize()
方法的一些代码示例,展示了JFrame.getPreferredSize()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JFrame.getPreferredSize()
方法的具体详情如下:
包路径:javax.swing.JFrame
类名称:JFrame
方法名:getPreferredSize
暂无
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
public void actionPerformed(ActionEvent e){
Dimension preferred = frame.getPreferredSize();
frame.setPreferredSize(new Dimension(0, 0));
frame.pack();
frame.setPreferredSize(preferred);
}
});
代码示例来源:origin: RipMeApp/ripme
private void pack() {
SwingUtilities.invokeLater(() -> {
Dimension preferredSize = mainFrame.getPreferredSize();
mainFrame.setMinimumSize(preferredSize);
if (isCollapsed()) {
mainFrame.setSize(preferredSize);
}
});
}
代码示例来源:origin: gocd/gocd
frame.setSize(frame.getPreferredSize());
frame.setVisible(true);
progressPane.label.setText(errormsg + " Please see /var/log/system.log for more info.");
frame.pack();
frame.setSize(frame.getPreferredSize());
Thread.sleep(15000);
System.exit(1);
代码示例来源:origin: RaiMan/SikuliX2
introPane.add(introText);
intro.pack();
Dimension introSize = intro.getPreferredSize();
Element centered = new Element(introSize).getCentered(Do.onMain());
intro.setLocation(centered.x, centered.y);
代码示例来源:origin: RaiMan/SikuliX2
Dimension size = frame.getPreferredSize();
Element centered = new Element(size).getCentered(Do.onMain());
frame.setLocation(centered.x, centered.y);
代码示例来源:origin: igniterealtime/Spark
public Dimension getPreferredSize() {
final Dimension dim = super.getPreferredSize();
dim.width = 400;
return dim;
}
};
代码示例来源:origin: AliView/AliView
public void centerLocationToCenterOfScreen() {
Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
int x = (int) ((dimension.getWidth() - frame.getPreferredSize().getWidth()) / 2);
int y = (int) ((dimension.getHeight() - frame.getPreferredSize().getHeight()) / 2);
logger.info(frame.getPreferredSize());
setLocation(x, y);
}
代码示例来源:origin: triplea-game/triplea
@Override
public void onServerMessengerCreated(final ServerModel serverModel) {
SwingUtilities.invokeLater(() -> {
setGameTypePanel(new ServerSetupPanel(serverModel, gameSelectorModel));
// for whatever reason, the server window is showing very very small, causing the nation info to be cut and
// requiring scroll bars
final int x = (ui.getPreferredSize().width > 800 ? ui.getPreferredSize().width : 800);
final int y = (ui.getPreferredSize().height > 660 ? ui.getPreferredSize().height : 660);
ui.setPreferredSize(new Dimension(x, y));
ui.setSize(new Dimension(x, y));
});
}
代码示例来源:origin: antlr/antlrworks
public Dimension getPreferredSize() {
if(useDesktop) {
return jInternalFrame.getPreferredSize();
} else {
return jFrame.getPreferredSize();
}
}
代码示例来源:origin: robo-code/robocode
private void optionsFitWindowActionPerformed() {
JFrame robocodeFrame = windowManager.getRobocodeFrame();
robocodeFrame.setSize(robocodeFrame.getPreferredSize());
WindowUtil.fitWindow(robocodeFrame);
}
代码示例来源:origin: stackoverflow.com
JFrame frame = new JFrame("Test");
JPanel panel = new JPanel(new GridLayout(2, 2));
frame.setContentPane(panel);
frame.setVisible(true);
JLabel label1 = new JLabel();
panel.add(label1);
JLabel label2 = new JLabel();
panel.add(label2);
JLabel label3 = new JLabel();
panel.add(label3);
JLabel label4 = new JLabel();
panel.add(label4);
try {
BufferedImage myPicture = ImageIO.read(new File("test.jpg"));
label1.setIcon(new ImageIcon(myPicture));
label2.setIcon(new ImageIcon(myPicture));
label3.setIcon(new ImageIcon(myPicture));
label4.setIcon(new ImageIcon(myPicture));
} catch (Exception e) {
e.printStackTrace();
}
frame.pack();
frame.setMinimumSize(frame.getPreferredSize());
代码示例来源:origin: hyperion-project/hypercon
@Override
@Transient
public Dimension getMaximumSize() {
Dimension maxSize = super.getMaximumSize();
Dimension prefSize = super.getPreferredSize();
return new Dimension(maxSize.width, prefSize.height);
}
代码示例来源:origin: AliView/AliView
public void centerLocationToThisComponentOrScreen(Component parent){
// align to middle of parent window
if(parent != null){
int newX = parent.getX() + parent.getWidth()/2 - frame.getPreferredSize().width/2;
int newY = parent.getY() + parent.getHeight()/2 - frame.getPreferredSize().height/2;
logger.info(parent.getX());
logger.info(parent.getWidth());
logger.info(frame.getWidth());
setLocation(newX, newY);
}
else{
centerLocationToCenterOfScreen();
}
}
代码示例来源:origin: AliView/AliView
public void setBottomRightRelativeThisComponent(Component parent) {
// align to middle of parent window
if(parent != null){
int newX = parent.getX() + parent.getWidth() - frame.getPreferredSize().width - 50;
int newY = parent.getY() + parent.getHeight() - frame.getPreferredSize().height - 50;
logger.info(parent.getX());
logger.info(parent.getWidth());
logger.info(frame.getWidth());
setLocation(newX, newY);
}
else{
centerLocationToCenterOfScreen();
}
}
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
@Override
public void actionPerformed(ActionEvent e) {
final MemoryUsagePanel panel = new MemoryUsagePanel();
final JFrame frame = Utils.getWekaJFrame("Memory usage", m_Self);
frame.getContentPane().setLayout(new BorderLayout());
frame.getContentPane().add(panel, BorderLayout.CENTER);
frame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent w) {
panel.stopMonitoring();
frame.dispose();
m_Frames.remove(frame);
checkExit();
}
});
frame.pack();
frame.setSize(400, 50);
Point l = panel.getFrameLocation();
if ((l.x != -1) && (l.y != -1)) {
frame.setLocation(l);
}
frame.setLocationRelativeTo(m_Self);
frame.setVisible(true);
Dimension size = frame.getPreferredSize();
frame.setSize(new Dimension((int) size.getWidth(),
(int) size.getHeight()));
m_Frames.add(frame);
}
});
代码示例来源:origin: org.codehaus.jtstand/jtstand-ui
public static void maxItWidth(JFrame jFrame) {
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
Rectangle r = env.getMaximumWindowBounds();
Dimension d = r.getSize();
d.setSize(d.width, Math.min(d.height, jFrame.getPreferredSize().height));
jFrame.setSize(d);
jFrame.setPreferredSize(d);
}
代码示例来源:origin: net.sourceforge.owlapi/org.semanticweb.hermit
m_mainFrame.pack();
Dimension screenSize=Toolkit.getDefaultToolkit().getScreenSize();
Dimension preferredSize=m_mainFrame.getPreferredSize();
m_mainFrame.setLocation((screenSize.width-preferredSize.width)/2,screenSize.height-100-preferredSize.height);
m_forwardingOn=historyOn;
代码示例来源:origin: com.hermit-reasoner/org.semanticweb.hermit
public Debugger(Prefixes prefixes,boolean historyOn) {
super(new DerivationHistory());
m_commandsByName=new TreeMap<String,DebuggerCommand>();
registerCommands();
m_prefixes=prefixes;
m_derivationHistory=(DerivationHistory)m_forwardingTargetMonitor;
m_consoleTextArea=new ConsoleTextArea();
m_consoleTextArea.setFont(s_monospacedFont);
m_output=new PrintWriter(m_consoleTextArea.getWriter());
m_input=new BufferedReader(m_consoleTextArea.getReader());
JScrollPane scrollPane=new JScrollPane(m_consoleTextArea);
scrollPane.setPreferredSize(new Dimension(800,300));
m_mainFrame=new JFrame("HermiT Debugger");
m_mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
m_mainFrame.setContentPane(scrollPane);
m_mainFrame.pack();
Dimension screenSize=Toolkit.getDefaultToolkit().getScreenSize();
Dimension preferredSize=m_mainFrame.getPreferredSize();
m_mainFrame.setLocation((screenSize.width-preferredSize.width)/2,screenSize.height-100-preferredSize.height);
m_forwardingOn=historyOn;
m_waitOptions=new HashSet<WaitOption>();
m_nodeCreationInfos=new HashMap<Node,NodeCreationInfo>();
m_forever=false;
m_singlestep=false;
m_breakpointTime=30000;
m_mainFrame.setVisible(true);
m_output.println("Good morning Dr. Chandra. This is HAL. I'm ready for my first lesson.");
m_output.println("Derivation history is "+(m_forwardingOn ? "on" : "off")+".");
}
protected void registerCommands() {
代码示例来源:origin: AliView/AliView
public void setTopRightRelativeThisComponent(Component parent) {
// align to middle of parent window
if(parent != null){
int newX = parent.getX() + parent.getWidth() - frame.getPreferredSize().width - 20;
int newY = parent.getY() + 150;
logger.info(parent.getX());
logger.info(parent.getWidth());
logger.info(frame.getWidth());
setLocation(newX, newY);
}
else{
centerLocationToCenterOfScreen();
}
}
代码示例来源:origin: ribomation/DroidAtScreen1
@Override
public Dimension getPreferredSize() {
Dimension frame = super.getPreferredSize();
Insets fb = super.getInsets();
Dimension screen = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().getSize();
内容来源于网络,如有侵权,请联系作者删除!