public class Save extends JFrame { JTextField field1 = new JTextField(10); JComboBox box = new JComboBox(); ComboBoxText ct = new ComboBoxText(); JComboBox cb = new JComboBox(); JComboBox ca = new JComboBox(ct.a()); JTextField field5 = new JTextField(20); JTextField field6 = new JTextField(10); JButton button = new JButton("添加"); JButton canel = new JButton("退出"); JButton dispaly = new JButton("呵呵"); JLabel label = new JLabel("姓名:"); JLabel labe2 = new JLabel("性别:"); JLabel labe3 = new JLabel("所在系:"); JLabel labe4 = new JLabel("所在专业:"); JLabel labe5 = new JLabel("地址:"); JLabel labe6 = new JLabel("开始时间:"); p1 p = new p1(); Save() {
super("学生信息添加");
this.setSize(790, 140);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = new JPanel();
GridLayout gridLayout = new GridLayout();
GridBagLayout bagLayout = new GridBagLayout();
// /gridLayout.removeLayoutComponent(button);
gridLayout.removeLayoutComponent(canel);
panel.setLayout(gridLayout);
JFrame f = new JFrame();
Container contentPane = f.getContentPane();
contentPane.setLayout(bagLayout);
box.addItem("男");
box.addItem("女");
box.setSelectedIndex(-1);
// Toolkit kit=Toolkit.getDefaultToolkit();//设置顶层容器框架为居中
Dimension scr = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frm = this.getSize();
setLocation((scr.width - frm.width) / 2, (scr.height - frm.height) / 2);// 窗体居中 // public void paintComponent(Graphics g) {
// Graphics2D g2 = (Graphics2D)g;
// // super.paintComponent(g);
// Image img =
// Toolkit.getDefaultToolkit().getImage("D:\\images\\02.jpg");
// g2.drawImage(img, 0, 0, this.getWidth(), this.getHeight(), this);
// }
GridBagConstraints c2 = new GridBagConstraints();
c2.insets = new Insets(20, 20, 20, 20);
c2.gridx = 0;
c2.gridy = 0;
c2.gridwidth = 4;
c2.gridheight = 10;
c2.weightx = 0;
c2.weighty = 1.5;
c2.anchor = GridBagConstraints.WEST;
c2.fill = GridBagConstraints.NONE;
bagLayout.setConstraints(label, c2);
panel.add(label, c2); // panel.add(label);
c2.insets = new Insets(0, 0, 0, 0);
c2.gridx = 0;
c2.gridy = 0;
c2.gridwidth = 4;
c2.gridheight = 2;
c2.weightx = 10;
c2.weighty = 0.5;
c2.anchor = GridBagConstraints.WEST;
c2.fill = GridBagConstraints.NONE;
// bagLayout.setConstraints(field1, c2);
panel.add(field1, c2);
// panel.add(field1); c2.insets = new Insets(0, 0, 0, 0);
c2.gridx = 0;
c2.gridy = 0;
c2.gridwidth = 4;
c2.gridheight = 5;
c2.weightx = 20;
c2.weighty = 0.5;
c2.anchor = GridBagConstraints.WEST;
c2.fill = GridBagConstraints.NONE;
bagLayout.setConstraints(labe2, c2);
panel.add(labe2, c2);
// panel.add(labe2);
c2.insets = new Insets(0, 0, 0, 0);
c2.gridx = 0;
c2.gridy = 0;
c2.gridwidth = 4;
c2.gridheight = 10;
c2.weightx = 10;
c2.weighty = 0.5;
c2.anchor = GridBagConstraints.WEST;
c2.fill = GridBagConstraints.NONE;
bagLayout.setConstraints(box, c2);
panel.add(box, c2);
// panel.add(box); c2.insets = new Insets(0, 0, 0, 0);
c2.gridx = 0;
c2.gridy = 0;
c2.gridwidth = 4;
c2.gridheight = 5;
c2.weightx = 20;
c2.weighty = 0.5;
c2.anchor = GridBagConstraints.WEST;
c2.fill = GridBagConstraints.NONE;
// bagLayout.setConstraints(labe3, c2);
panel.add(labe3, c2);
// panel.add(labe3);
c2.insets = new Insets(0, 0, 0, 0);
c2.gridx = 0;
c2.gridy = 0;
c2.gridwidth = 4;
c2.gridheight =5;
c2.weightx = 20;
c2.weighty = 0.5;
c2.anchor = GridBagConstraints.WEST;
c2.fill = GridBagConstraints.NONE;
bagLayout.setConstraints(ca, c2);
panel.add(ca, c2);
// panel.add(ca);
c2.insets = new Insets(0, 0, 0, 0);
c2.gridx = 0;
c2.gridy = 0;
c2.gridwidth = 4;
c2.gridheight = 6;
c2.weightx = 20;
c2.weighty = 0.5;
c2.anchor = GridBagConstraints.WEST;
c2.fill = GridBagConstraints.NONE;
bagLayout.setConstraints(labe4, c2);
panel.add(labe4, c2);
// panel.add(labe4);
c2.insets = new Insets(0, 0, 0, 0);
c2.gridx = 0;
c2.gridy = 0;
c2.gridwidth = 20;
c2.gridheight = 5;
c2.weightx = 10;
c2.weighty = 0.5;
c2.anchor = GridBagConstraints.WEST;
c2.fill = GridBagConstraints.NONE;
bagLayout.setConstraints(cb, c2);
panel.add(cb, c2);
// panel.add(cb);
c2.insets = new Insets(0, 0, 0, 0);
c2.gridx = 0;
c2.gridy = 0;
c2.gridwidth = 20;
c2.gridheight = 5;
c2.weightx = 10;
c2.weighty = 0.5;
c2.anchor = GridBagConstraints.WEST;
c2.fill = GridBagConstraints.NONE;
bagLayout.setConstraints(labe5, c2);
panel.add(labe5, c2);
// panel.add(labe5);
c2.insets = new Insets(0, 0, 0, 0);
c2.gridx = 0;
c2.gridy = 0;
c2.gridwidth = 4;
c2.gridheight = 10;
c2.weightx = 10;
c2.weighty = 0.5;
c2.anchor = GridBagConstraints.WEST;
c2.fill = GridBagConstraints.NONE;
bagLayout.setConstraints(field5, c2);
panel.add(field5, c2);
// panel.add(field5);
c2.insets = new Insets(0, 0, 0, 0);
c2.gridx = 0;
c2.gridy = 0;
c2.gridwidth = 4;
c2.gridheight = 10;
c2.weightx = 10;
c2.weighty = 0.5;
c2.anchor = GridBagConstraints.WEST;
c2.fill = GridBagConstraints.NONE;
bagLayout.setConstraints(labe6, c2);
panel.add(labe6, c2);
// panel.add(labe6);
c2.insets = new Insets(0, 0, 0, 0);
c2.gridx = 0;
c2.gridy = 0;
c2.gridwidth = 4;
c2.gridheight = 10;
c2.weightx = 0;
c2.weighty = 0.5;
c2.anchor = GridBagConstraints.WEST;
c2.fill = GridBagConstraints.NONE;
bagLayout.setConstraints(field6, c2);
panel.add(field6, c2);
// panel.add(field6); // dispaly.setVisible(false);
// panel.add(dispaly);
// gridLayout.removeLayoutComponent(button);
// gridLayout.removeLayoutComponent(canel); // JPanel panel2 = new JPanel();
// GridBagConstraints c2 = new GridBagConstraints();
// c2.gridx = 50;
// c2.gridy =50;
// c2.gridwidth = 4;
// c2.gridheight = 10;
// c2.weightx = 20;
// c2.weighty = 0.5;
// c2.anchor = GridBagConstraints.SOUTH;
// c2.fill = GridBagConstraints.HORIZONTAL;
// panel2.add(canel,c2);
// panel2.add(button,c2);
// panel2.add(canel,c2);
// panel2.setVisible(true);
// GridBagLayout bagLayout = new GridBagLayout();
// bagLayout.getConstraints(button); button.setVisible(false);
// panel.add(dispaly);
// dispaly.setVisible(false);
panel.add(button);
// panel.add(canel);
panel.add(p);
c2.fill = GridBagConstraints.NONE;
this.setContentPane(panel);
Container c = new Container();
c.remove(button);
c.remove(canel); gridLayout.setColumns(8);
gridLayout.setRows(4); gridLayout.setHgap(2);
gridLayout.setVgap(2);
c.setLayout(gridLayout);我写的控制好像起不到作用。
super("学生信息添加");
this.setSize(790, 140);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = new JPanel();
GridLayout gridLayout = new GridLayout();
GridBagLayout bagLayout = new GridBagLayout();
// /gridLayout.removeLayoutComponent(button);
gridLayout.removeLayoutComponent(canel);
panel.setLayout(gridLayout);
JFrame f = new JFrame();
Container contentPane = f.getContentPane();
contentPane.setLayout(bagLayout);
box.addItem("男");
box.addItem("女");
box.setSelectedIndex(-1);
// Toolkit kit=Toolkit.getDefaultToolkit();//设置顶层容器框架为居中
Dimension scr = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frm = this.getSize();
setLocation((scr.width - frm.width) / 2, (scr.height - frm.height) / 2);// 窗体居中 // public void paintComponent(Graphics g) {
// Graphics2D g2 = (Graphics2D)g;
// // super.paintComponent(g);
// Image img =
// Toolkit.getDefaultToolkit().getImage("D:\\images\\02.jpg");
// g2.drawImage(img, 0, 0, this.getWidth(), this.getHeight(), this);
// }
GridBagConstraints c2 = new GridBagConstraints();
c2.insets = new Insets(20, 20, 20, 20);
c2.gridx = 0;
c2.gridy = 0;
c2.gridwidth = 4;
c2.gridheight = 10;
c2.weightx = 0;
c2.weighty = 1.5;
c2.anchor = GridBagConstraints.WEST;
c2.fill = GridBagConstraints.NONE;
bagLayout.setConstraints(label, c2);
panel.add(label, c2); // panel.add(label);
c2.insets = new Insets(0, 0, 0, 0);
c2.gridx = 0;
c2.gridy = 0;
c2.gridwidth = 4;
c2.gridheight = 2;
c2.weightx = 10;
c2.weighty = 0.5;
c2.anchor = GridBagConstraints.WEST;
c2.fill = GridBagConstraints.NONE;
// bagLayout.setConstraints(field1, c2);
panel.add(field1, c2);
// panel.add(field1); c2.insets = new Insets(0, 0, 0, 0);
c2.gridx = 0;
c2.gridy = 0;
c2.gridwidth = 4;
c2.gridheight = 5;
c2.weightx = 20;
c2.weighty = 0.5;
c2.anchor = GridBagConstraints.WEST;
c2.fill = GridBagConstraints.NONE;
bagLayout.setConstraints(labe2, c2);
panel.add(labe2, c2);
// panel.add(labe2);
c2.insets = new Insets(0, 0, 0, 0);
c2.gridx = 0;
c2.gridy = 0;
c2.gridwidth = 4;
c2.gridheight = 10;
c2.weightx = 10;
c2.weighty = 0.5;
c2.anchor = GridBagConstraints.WEST;
c2.fill = GridBagConstraints.NONE;
bagLayout.setConstraints(box, c2);
panel.add(box, c2);
// panel.add(box); c2.insets = new Insets(0, 0, 0, 0);
c2.gridx = 0;
c2.gridy = 0;
c2.gridwidth = 4;
c2.gridheight = 5;
c2.weightx = 20;
c2.weighty = 0.5;
c2.anchor = GridBagConstraints.WEST;
c2.fill = GridBagConstraints.NONE;
// bagLayout.setConstraints(labe3, c2);
panel.add(labe3, c2);
// panel.add(labe3);
c2.insets = new Insets(0, 0, 0, 0);
c2.gridx = 0;
c2.gridy = 0;
c2.gridwidth = 4;
c2.gridheight =5;
c2.weightx = 20;
c2.weighty = 0.5;
c2.anchor = GridBagConstraints.WEST;
c2.fill = GridBagConstraints.NONE;
bagLayout.setConstraints(ca, c2);
panel.add(ca, c2);
// panel.add(ca);
c2.insets = new Insets(0, 0, 0, 0);
c2.gridx = 0;
c2.gridy = 0;
c2.gridwidth = 4;
c2.gridheight = 6;
c2.weightx = 20;
c2.weighty = 0.5;
c2.anchor = GridBagConstraints.WEST;
c2.fill = GridBagConstraints.NONE;
bagLayout.setConstraints(labe4, c2);
panel.add(labe4, c2);
// panel.add(labe4);
c2.insets = new Insets(0, 0, 0, 0);
c2.gridx = 0;
c2.gridy = 0;
c2.gridwidth = 20;
c2.gridheight = 5;
c2.weightx = 10;
c2.weighty = 0.5;
c2.anchor = GridBagConstraints.WEST;
c2.fill = GridBagConstraints.NONE;
bagLayout.setConstraints(cb, c2);
panel.add(cb, c2);
// panel.add(cb);
c2.insets = new Insets(0, 0, 0, 0);
c2.gridx = 0;
c2.gridy = 0;
c2.gridwidth = 20;
c2.gridheight = 5;
c2.weightx = 10;
c2.weighty = 0.5;
c2.anchor = GridBagConstraints.WEST;
c2.fill = GridBagConstraints.NONE;
bagLayout.setConstraints(labe5, c2);
panel.add(labe5, c2);
// panel.add(labe5);
c2.insets = new Insets(0, 0, 0, 0);
c2.gridx = 0;
c2.gridy = 0;
c2.gridwidth = 4;
c2.gridheight = 10;
c2.weightx = 10;
c2.weighty = 0.5;
c2.anchor = GridBagConstraints.WEST;
c2.fill = GridBagConstraints.NONE;
bagLayout.setConstraints(field5, c2);
panel.add(field5, c2);
// panel.add(field5);
c2.insets = new Insets(0, 0, 0, 0);
c2.gridx = 0;
c2.gridy = 0;
c2.gridwidth = 4;
c2.gridheight = 10;
c2.weightx = 10;
c2.weighty = 0.5;
c2.anchor = GridBagConstraints.WEST;
c2.fill = GridBagConstraints.NONE;
bagLayout.setConstraints(labe6, c2);
panel.add(labe6, c2);
// panel.add(labe6);
c2.insets = new Insets(0, 0, 0, 0);
c2.gridx = 0;
c2.gridy = 0;
c2.gridwidth = 4;
c2.gridheight = 10;
c2.weightx = 0;
c2.weighty = 0.5;
c2.anchor = GridBagConstraints.WEST;
c2.fill = GridBagConstraints.NONE;
bagLayout.setConstraints(field6, c2);
panel.add(field6, c2);
// panel.add(field6); // dispaly.setVisible(false);
// panel.add(dispaly);
// gridLayout.removeLayoutComponent(button);
// gridLayout.removeLayoutComponent(canel); // JPanel panel2 = new JPanel();
// GridBagConstraints c2 = new GridBagConstraints();
// c2.gridx = 50;
// c2.gridy =50;
// c2.gridwidth = 4;
// c2.gridheight = 10;
// c2.weightx = 20;
// c2.weighty = 0.5;
// c2.anchor = GridBagConstraints.SOUTH;
// c2.fill = GridBagConstraints.HORIZONTAL;
// panel2.add(canel,c2);
// panel2.add(button,c2);
// panel2.add(canel,c2);
// panel2.setVisible(true);
// GridBagLayout bagLayout = new GridBagLayout();
// bagLayout.getConstraints(button); button.setVisible(false);
// panel.add(dispaly);
// dispaly.setVisible(false);
panel.add(button);
// panel.add(canel);
panel.add(p);
c2.fill = GridBagConstraints.NONE;
this.setContentPane(panel);
Container c = new Container();
c.remove(button);
c.remove(canel); gridLayout.setColumns(8);
gridLayout.setRows(4); gridLayout.setHgap(2);
gridLayout.setVgap(2);
c.setLayout(gridLayout);我写的控制好像起不到作用。
解决方案 »
- jdk1.6+tomcat6.0+myeclipse8.5(all-in-one)搭配的环境问题
- 100分 关于JTable 从数据库读取显示在表格问题 请大家帮我看看。
- JDK5.0的主要新特征(2)
- 在线等待:怎样实现根据数据得到统计图表(饼图,柱状图,曲线图)!
- 急向高手请教一个构造函数的问题!请帮小弟看看这段程序有什么错误?为什么?
- 各位朋友,如何修改JFrame标题栏中图标?
- Jtable更新问题.高手请进
- 头疼的问题
- 文本转换问题,在线等,UP有分!
- 问题是这样的,希望高手们热心参与!我给满100分!
- java string indexof out of range怎么办
- JNative的问题,返回值为void*,纠结一天了,请高手来帮忙
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.Insets;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Date;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;
import com.sessionFacrory.HibernateSessionFactory;public class Save extends JFrame { JTextField field1 = new JTextField(10); JComboBox box = new JComboBox(); ComboBoxText ct = new ComboBoxText(); JComboBox cb = new JComboBox(); JComboBox ca = new JComboBox(ct.a()); JTextField field5 = new JTextField(20); JTextField field6 = new JTextField(10); JButton button = new JButton("添加"); JButton canel = new JButton("退出"); JButton dispaly = new JButton("呵呵"); JLabel label = new JLabel("姓名:"); JLabel labe2 = new JLabel("性别:"); JLabel labe3 = new JLabel("所在系:"); JLabel labe4 = new JLabel("所在专业:"); JLabel labe5 = new JLabel("地址:"); JLabel labe6 = new JLabel("开始时间:"); p1 p = new p1(); Save() {
super("学生信息添加");
this.setSize(790, 140);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = new JPanel();
GridLayout gridLayout = new GridLayout();
GridBagLayout bagLayout = new GridBagLayout();
// /gridLayout.removeLayoutComponent(button);
gridLayout.removeLayoutComponent(canel);
panel.setLayout(gridLayout);
JFrame f = new JFrame();
Container contentPane = f.getContentPane();
contentPane.setLayout(bagLayout);
box.addItem("男");
box.addItem("女");
box.setSelectedIndex(-1);
// Toolkit kit=Toolkit.getDefaultToolkit();//设置顶层容器框架为居中
Dimension scr = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frm = this.getSize();
setLocation((scr.width - frm.width) / 2, (scr.height - frm.height) / 2);// 窗体居中
GridBagConstraints c2 = new GridBagConstraints();
c2.insets = new Insets(20, 20, 20, 20);
c2.gridx = 0;
c2.gridy = 0;
c2.gridwidth = 4;
c2.gridheight = 10;
c2.weightx = 0;
c2.weighty = 1.5;
c2.anchor = GridBagConstraints.WEST;
c2.fill = GridBagConstraints.NONE;
bagLayout.setConstraints(label, c2);
panel.add(label, c2); // panel.add(label);
c2.insets = new Insets(0, 0, 0, 0);
c2.gridx = 0;
c2.gridy = 0;
c2.gridwidth = 4;
c2.gridheight = 2;
c2.weightx = 10;
c2.weighty = 0.5;
c2.anchor = GridBagConstraints.WEST;
c2.fill = GridBagConstraints.NONE;
// bagLayout.setConstraints(field1, c2);
panel.add(field1, c2);
// panel.add(field1); c2.insets = new Insets(0, 0, 0, 0);
c2.gridx = 0;
c2.gridy = 0;
c2.gridwidth = 4;
c2.gridheight = 5;
c2.weightx = 20;
c2.weighty = 0.5;
c2.anchor = GridBagConstraints.WEST;
c2.fill = GridBagConstraints.NONE;
bagLayout.setConstraints(labe2, c2);
panel.add(labe2, c2);
// panel.add(labe2);
c2.insets = new Insets(0, 0, 0, 0);
c2.gridx = 0;
c2.gridy = 0;
c2.gridwidth = 4;
c2.gridheight = 10;
c2.weightx = 10;
c2.weighty = 0.5;
c2.anchor = GridBagConstraints.WEST;
c2.fill = GridBagConstraints.NONE;
bagLayout.setConstraints(box, c2);
panel.add(box, c2);
// panel.add(box); c2.insets = new Insets(0, 0, 0, 0);
c2.gridx = 0;
c2.gridy = 0;
c2.gridwidth = 4;
c2.gridheight = 5;
c2.weightx = 20;
c2.weighty = 0.5;
c2.anchor = GridBagConstraints.WEST;
c2.fill = GridBagConstraints.NONE;
// bagLayout.setConstraints(labe3, c2);
panel.add(labe3, c2);
// panel.add(labe3);
c2.insets = new Insets(0, 0, 0, 0);
c2.gridx = 0;
c2.gridy = 0;
c2.gridwidth = 4;
c2.gridheight =5;
c2.weightx = 20;
c2.weighty = 0.5;
c2.anchor = GridBagConstraints.WEST;
c2.fill = GridBagConstraints.NONE;
bagLayout.setConstraints(ca, c2);
panel.add(ca, c2);
// panel.add(ca);
c2.insets = new Insets(0, 0, 0, 0);
c2.gridx = 0;
c2.gridy = 0;
c2.gridwidth = 4;
c2.gridheight = 6;
c2.weightx = 20;
c2.weighty = 0.5;
c2.anchor = GridBagConstraints.WEST;
c2.fill = GridBagConstraints.NONE;
bagLayout.setConstraints(labe4, c2);
panel.add(labe4, c2);
// panel.add(labe4);
c2.insets = new Insets(0, 0, 0, 0);
c2.gridx = 0;
c2.gridy = 0;
c2.gridwidth = 20;
c2.gridheight = 5;
c2.weightx = 10;
c2.weighty = 0.5;
c2.anchor = GridBagConstraints.WEST;
c2.fill = GridBagConstraints.NONE;
bagLayout.setConstraints(cb, c2);
panel.add(cb, c2);
// panel.add(cb);
c2.insets = new Insets(0, 0, 0, 0);
c2.gridx = 0;
c2.gridy = 0;
c2.gridwidth = 20;
c2.gridheight = 5;
c2.weightx = 10;
c2.weighty = 0.5;
c2.anchor = GridBagConstraints.WEST;
c2.fill = GridBagConstraints.NONE;
bagLayout.setConstraints(labe5, c2);
panel.add(labe5, c2);
// panel.add(labe5);
c2.insets = new Insets(0, 0, 0, 0);
c2.gridx = 0;
c2.gridy = 0;
c2.gridwidth = 4;
c2.gridheight = 10;
c2.weightx = 10;
c2.weighty = 0.5;
c2.anchor = GridBagConstraints.WEST;
c2.fill = GridBagConstraints.NONE;
bagLayout.setConstraints(field5, c2);
panel.add(field5, c2);
// panel.add(field5);
c2.insets = new Insets(0, 0, 0, 0);
c2.gridx = 0;
c2.gridy = 0;
c2.gridwidth = 4;
c2.gridheight = 10;
c2.weightx = 10;
c2.weighty = 0.5;
c2.anchor = GridBagConstraints.WEST;
c2.fill = GridBagConstraints.NONE;
bagLayout.setConstraints(labe6, c2);
panel.add(labe6, c2);
// panel.add(labe6);
c2.insets = new Insets(0, 0, 0, 0);
c2.gridx = 0;
c2.gridy = 0;
c2.gridwidth = 4;
c2.gridheight = 10;
c2.weightx = 0;
c2.weighty = 0.5;
c2.anchor = GridBagConstraints.WEST;
c2.fill = GridBagConstraints.NONE;
bagLayout.setConstraints(field6, c2);
panel.add(field6, c2); button.setVisible(false);
// panel.add(dispaly);
// dispaly.setVisible(false);
panel.add(button);
// panel.add(canel);
panel.add(p);
c2.fill = GridBagConstraints.NONE;
this.setContentPane(panel);
Container c = new Container();
c.remove(button);
c.remove(canel);
gridLayout.setColumns(8);
gridLayout.setRows(4);
gridLayout.setHgap(2);
gridLayout.setVgap(2);
c.setLayout(gridLayout);
// 下拉框处理
ca.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// 清空选项框
cb.removeAllItems();
// 得到系的选项
Object selected = ca.getSelectedItem();
// 给专业赋值
Object[] newItems = ct.b(selected);
for (int i = 0; i < newItems.length; i++) {
cb.addItem(newItems[i]);
} } });
// 初始化系选项为-1
ca.setSelectedIndex(-1); } public class p1 extends JPanel {
p1() {
JButton das = new JButton("添加");
das.setSize(50, 50);
JButton das2 = new JButton("取消");
super.add(das);
super.add(das2);
}
} public static void main(String[] args) { Save save = new Save();
save.show();
}
}
ComboBoxText 它不是我建的。
我想把 姓名这个label这列 和 文本框的距离缩短。
就这个问题啊