嘿嘿,老兄,你问错地方了。
应该去J2SE版
应该去J2SE版
解决方案 »
- 求解
- J2EE 日程安排
- 关于Flash down组件下载文件的问题(HTTP协议与WebService协议混用),高分请教高手解决!在线等...
- eclipse和myeclipse,tomcat配置问题,
- struts+hibernate+spring配置报错,卡3天了,200分求
- Myeclipse+Hibernate时驱动JTDS问题和ODBC问题
- 最新eclipse下运行同一个包下的不同的java文件,有的没有问题,有的就直接报:错误: 找不到或无法加载主类
- 我为何总是汉化eclipse-SDK-3.1.1-win32老是不成功啊? 试了好多次了啊!谢谢!急啊!
- 样向另一台机发送信息 (无内容)
- 在java中怎么实现一个按钮对两个事件监听
- petstore中main.screen什么意思?
- 一个关于JSF的methodbinding的问题
//Frame1.java
public class Frame1 extends JFrame {
....
JButton jButton1 = new JButton();
JPanel jPanel2 = new JPanel();
.....
public Frame1() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
contentPane = (JPanel) this.getContentPane();
....
jPanel2.add(jButton1, null);
}
//Overridden so we can exit when window is closed
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
}
} void jButton1_mouseClicked(MouseEvent e) {
JFrame dFrame = new DrawFrame();
dFrame.setSize(new Dimension(600, 400));
dFrame.setTitle("绘图框");
dFrame.setLocation(100,100);
dFrame.show(); }
}
class Frame1_jButton1_mouseAdapter extends java.awt.event.MouseAdapter {
Frame1 adaptee; Frame1_jButton1_mouseAdapter(Frame1 adaptee) {
this.adaptee = adaptee;
}
public void mouseClicked(MouseEvent e) {
adaptee.jButton1_mouseClicked(e);
}
}
//DrawFrame.java 绘图框
public class DrawFrame extends JFrame {
BorderLayout borderLayout1 = new BorderLayout();
DrawPanel dp = new DrawPanel();
public DrawFrame() throws HeadlessException {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
} public static void main(String[] args) throws HeadlessException {
DrawFrame drawFrame1 = new DrawFrame(); }
private void jbInit() throws Exception {
this.getContentPane().setLayout(borderLayout1);
//this.getContentPane().repaint(); this.getContentPane().add(dp);
} public class DrawPanel extends JPanel {
public void paintComponent(Graphics g) {
super.paintComponents(g);
Graphics2D g2 = (Graphics2D)g; g2.setPaint(Color.black);
g2.draw(new Line2D.Double(40, 40, 40, 200));
g2.setPaint(Color.red);
g2.draw(new Line2D.Double(40,200,200,200));
}
}
}