设置窗口斜边大小java
2个回答
展开全部
public class MaxSizeUI
{
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
new MaxSizeUI().makeUI();
}
});
}
public void makeUI() {
final JFrame frame = new JFrame("Sample Fram") {
@Override
public void paint(Graphics g) {
Dimension d = getSize();
Dimension m = getMaximumSize();
boolean resize = d.width > m.width || d.height > m.height;
d.width = Math.min(m.width, d.width);
d.height = Math.min(m.height, d.height);
if (resize) {
Point p = getLocation();
setVisible(false);
setSize(d);
setLocation(p);
setVisible(true);
}
super.paint(g);
}
};
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(300, 150);
frame.setMaximumSize(new Dimension(400, 200));//设置最大值
frame.setMinimumSize(new Dimension(200, 100));//设置最小值
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
}
{
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
new MaxSizeUI().makeUI();
}
});
}
public void makeUI() {
final JFrame frame = new JFrame("Sample Fram") {
@Override
public void paint(Graphics g) {
Dimension d = getSize();
Dimension m = getMaximumSize();
boolean resize = d.width > m.width || d.height > m.height;
d.width = Math.min(m.width, d.width);
d.height = Math.min(m.height, d.height);
if (resize) {
Point p = getLocation();
setVisible(false);
setSize(d);
setLocation(p);
setVisible(true);
}
super.paint(g);
}
};
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(300, 150);
frame.setMaximumSize(new Dimension(400, 200));//设置最大值
frame.setMinimumSize(new Dimension(200, 100));//设置最小值
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
}
2016-06-15
展开全部
窗口斜边,是哪的边呢 。。。。。。。。。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询