如何让jframe最大化?

sunriselx 2001-07-01 03:57:04
要让窗口右上角的图标也成为最大化图标,不只是将jframe的大小设成最大。
...全文
251 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
sunriselx 2001-07-03
  • 打赏
  • 举报
回复
高,呵呵,多谢了
icesummit 2001-07-02
  • 打赏
  • 举报
回复
这是bootcool写的代码,我贴出来给你看看,呵呵,我就是看了bootcool的代码才实现的.
//看看这。
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class RobotDemo {
public static void main(String args[]) throws AWTException {

JFrame frame = new JFrame("RobotDemo");
frame.setSize(200, 150);
frame.setLocation(200, 200);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);

// create a robot to feed in GUI events
Robot rob = new Robot();

// move cursor to the top, left corner
Point p = frame.getLocationOnScreen();
rob.mouseMove(p.x + 5, p.y + 5);

// press and release left mouse button
rob.mousePress(InputEvent.BUTTON1_MASK);
rob.mouseRelease(InputEvent.BUTTON1_MASK);

// send an 'x' key press
rob.keyPress(KeyEvent.VK_X);
}
}


//在看看这
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class MaxFrame extends JFrame {
JButton button = new JButton("hit me");
public MaxFrame(){
getContentPane().add(button);
setVisible(true);
setSize(100,100);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
// create a robot to feed in GUI events
Robot rob = new Robot();
// move cursor to the top, left corner
Point p = getLocationOnScreen();
rob.mouseMove(p.x + 5, p.y + 5);
// press and release left mouse button
rob.mousePress(InputEvent.BUTTON1_MASK);
rob.mouseRelease(InputEvent.BUTTON1_MASK);
// send an 'x' key press
rob.keyPress(KeyEvent.VK_X);
}
catch (Exception exc) {
System.err.println(exc);
}
}
});

}


public static void main(String args[]){
MaxFrame f = new MaxFrame();
f.show();
}
}
icesummit 2001-07-02
  • 打赏
  • 举报
回复
如果你用的是jdk1.3以上版本,Robot能够实现.
sunriselx 2001-07-02
  • 打赏
  • 举报
回复
看来这里没什么高手呀
wolfsquare 2001-07-02
  • 打赏
  • 举报
回复
to icesummit:
如果不是Windows平台也可以实现吗?
sunriselx 2001-07-01
  • 打赏
  • 举报
回复
呵呵,JFrame就没什么办法了吗?
knight_qmh 2001-07-01
  • 打赏
  • 举报
回复
你可以用JInternalFrame,它有void setMaximum(boolean b);
sunriselx 2001-07-01
  • 打赏
  • 举报
回复
先谢了

62,615

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧