下面的代码是在JBuilder产生的。请教各位大侠怎么在改成在eclipse 能运行的代码??谢谢大侠!
import com.borland.jbcl.layout.*;
import java.awt.*;
import javax.swing.*;public class MainFrame extends JFrame {
XYLayout xYLayout1 = new XYLayout();
JPanel jPanel1 = new JPanel();
JPanel jPanel2 = new JPanel();
JButton jButton1 = new JButton();
JTextField jTextField1 = new JTextField();
JPanel jPanel3 = new JPanel();
JPanel jPanel4 = new JPanel();
JPanel jPanel5 = new JPanel();
JButton jButton2 = new JButton();
JButton jButton3 = new JButton();
JButton jButton4 = new JButton();
public MainFrame() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception {
this.getContentPane().setLayout(xYLayout1);
jButton1.setBounds(new Rectangle(42, 54, 71, 23));
jButton1.setText("jButton1");
jPanel1.setLayout(null);
jPanel2.setLayout(null);
jTextField1.setText("jTextField1");
jTextField1.setBounds(new Rectangle(45, 86, 62, 20));
jPanel3.setLayout(null);
jPanel4.setLayout(null);
jPanel5.setLayout(null);
jButton2.setBounds(new Rectangle(42, 26, 71, 23));
jButton2.setText("jButton2");
jButton3.setBounds(new Rectangle(59, 36, 71, 23));
jButton3.setText("jButton3");
jButton4.setBounds(new Rectangle(63, 28, 71, 23));
jButton4.setText("jButton4");
xYLayout1.setWidth(480);
xYLayout1.setHeight(339);
this.getContentPane().add(jPanel1, new XYConstraints(5, 2, 153, 128));
jPanel1.add(jButton1, null);
this.getContentPane().add(jPanel2, new XYConstraints(7, 141, 187, 147));
jPanel2.add(jTextField1, null);
this.getContentPane().add(jPanel3, new XYConstraints(243, 22, 147, 72));
jPanel3.add(jButton2, null);
this.getContentPane().add(jPanel4, new XYConstraints(238, 108, 159, 84));
jPanel4.add(jButton3, null);
this.getContentPane().add(jPanel5, new XYConstraints(234, 203, 165, 87));
jPanel5.add(jButton4, null);
}
}
import com.borland.jbcl.layout.*;
import java.awt.*;
import javax.swing.*;public class MainFrame extends JFrame {
XYLayout xYLayout1 = new XYLayout();
JPanel jPanel1 = new JPanel();
JPanel jPanel2 = new JPanel();
JButton jButton1 = new JButton();
JTextField jTextField1 = new JTextField();
JPanel jPanel3 = new JPanel();
JPanel jPanel4 = new JPanel();
JPanel jPanel5 = new JPanel();
JButton jButton2 = new JButton();
JButton jButton3 = new JButton();
JButton jButton4 = new JButton();
public MainFrame() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception {
this.getContentPane().setLayout(xYLayout1);
jButton1.setBounds(new Rectangle(42, 54, 71, 23));
jButton1.setText("jButton1");
jPanel1.setLayout(null);
jPanel2.setLayout(null);
jTextField1.setText("jTextField1");
jTextField1.setBounds(new Rectangle(45, 86, 62, 20));
jPanel3.setLayout(null);
jPanel4.setLayout(null);
jPanel5.setLayout(null);
jButton2.setBounds(new Rectangle(42, 26, 71, 23));
jButton2.setText("jButton2");
jButton3.setBounds(new Rectangle(59, 36, 71, 23));
jButton3.setText("jButton3");
jButton4.setBounds(new Rectangle(63, 28, 71, 23));
jButton4.setText("jButton4");
xYLayout1.setWidth(480);
xYLayout1.setHeight(339);
this.getContentPane().add(jPanel1, new XYConstraints(5, 2, 153, 128));
jPanel1.add(jButton1, null);
this.getContentPane().add(jPanel2, new XYConstraints(7, 141, 187, 147));
jPanel2.add(jTextField1, null);
this.getContentPane().add(jPanel3, new XYConstraints(243, 22, 147, 72));
jPanel3.add(jButton2, null);
this.getContentPane().add(jPanel4, new XYConstraints(238, 108, 159, 84));
jPanel4.add(jButton3, null);
this.getContentPane().add(jPanel5, new XYConstraints(234, 203, 165, 87));
jPanel5.add(jButton4, null);
}
}
你把jbuilder/lib 下面的 jbcl.jar 导入到 eclipse的build path里面就可以了!如果不知道怎么添加自己的类库,请参考这个
http://www.java2000.net/viewthread.jsp?tid=463
http://cougaar.org/cgi-bin/viewcvs.cgi/CougaarUnit/lib/jbcl.jar?cvsroot=cougaarunit
XYLayout()是JB自带的,也就是控件按坐标布局在面板上,不管你分辨率是什么,位置都会一样。
你换一个布局吧