首页上一页 1 下一页尾页 1 条记录 1/1页
如何让button 上的字显示出来
发表在Java图书答疑
2010-03-03
是否精华
是
否
版块置顶:
是
否
package swing_gaoji;
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class Test_a extends JFrame {
public Test_a() {
setSize(600, 75);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container con = getContentPane();
JPanel JPanel_1 = new JPanel();
JPanel_1.setLayout(new GridBagLayout());
GridBagConstraints GridBagConstraints_1 = new GridBagConstraints();
GridBagConstraints_1.gridx = 0;
GridBagConstraints_1.gridy = 0;
JLabel JLabel_1 = new JLabel("进货单编号:");
JPanel_1.add(JLabel_1, GridBagConstraints_1);
GridBagConstraints GridBagConstraints_2 = new GridBagConstraints();
GridBagConstraints_2.gridx = 1;
GridBagConstraints_2.gridy = 0;
JTextField JTextField_1 = new JTextField(10);
JPanel_1.add(JTextField_1, GridBagConstraints_2);
GridBagConstraints GridBagConstraints_3 = new GridBagConstraints();
GridBagConstraints_3.gridx = 2;
GridBagConstraints_3.gridy = 0;
GridBagConstraints_3.anchor = GridBagConstraints.EAST;
JLabel JLabel_2 = new JLabel("供应商:");
JPanel_1.add(JLabel_2, GridBagConstraints_3);
GridBagConstraints GridBagConstraints_4 = new GridBagConstraints();
GridBagConstraints_4.gridx = 3;
GridBagConstraints_4.gridy = 0;
JTextField JTextField_2 = new JTextField(10);
JPanel_1.add(JTextField_2, GridBagConstraints_4);
GridBagConstraints GridBagConstraints_a = new GridBagConstraints();
GridBagConstraints_a.gridx = 4;
GridBagConstraints_a.gridy = 0;
JLabel JLabel_a = new JLabel("进货单编号:");
GridBagConstraints_a.anchor = GridBagConstraints.NORTH;
GridBagConstraints_a.gridheight = 2;
JPanel_1.add(JLabel_a, GridBagConstraints_a);
GridBagConstraints GridBagConstraints_b = new GridBagConstraints();
GridBagConstraints_b.gridx = 5;
GridBagConstraints_b.gridy = 0;
JTextField JTextField_b = new JTextField(10);
GridBagConstraints_b.gridwidth = 2;
JPanel_1.add(JTextField_b, GridBagConstraints_b);
GridBagConstraints GridBagConstraints_A = new GridBagConstraints();
GridBagConstraints_A.gridx = 0;
GridBagConstraints_A.gridy = 1;
GridBagConstraints_A.anchor = GridBagConstraints.EAST;
JLabel JLabel_A = new JLabel("供应商:");
JPanel_1.add(JLabel_A, GridBagConstraints_A);
GridBagConstraints GridBagConstraints_d = new GridBagConstraints();
GridBagConstraints_A.gridx = 1;
GridBagConstraints_A.gridy = 1;
JTextField JTextField_A = new JTextField(10);
JPanel_1.add(JTextField_A, GridBagConstraints_A);
GridBagConstraints GridBagConstraints_B = new GridBagConstraints();
GridBagConstraints_B.gridx = 2;
GridBagConstraints_B.gridy = 1;
JLabel JLabel_B = new JLabel("进货单编号:");
GridBagConstraints_B.gridheight = 2;
JPanel_1.add(JLabel_B, GridBagConstraints_B);
GridBagConstraints GridBagConstraints_C = new GridBagConstraints();
GridBagConstraints_C.gridx = 3;
GridBagConstraints_C.gridy = 1;
JTextField JTextField_C = new JTextField(10);
JPanel_1.add(JTextField_C, GridBagConstraints_C);
GridBagConstraints GridBagConstraints_D = new GridBagConstraints();
GridBagConstraints_D.gridx = 5;
GridBagConstraints_D.gridy = 1;
GridBagConstraints_D.ipadx = -5;
GridBagConstraints_D.ipady = -5;
JButton JB_1 = new JButton("no");
JPanel_1.add(JB_1, GridBagConstraints_D);
GridBagConstraints GridBagConstraints_E = new GridBagConstraints();
GridBagConstraints_E.gridx = 6;
GridBagConstraints_E.gridy = 1;
GridBagConstraints_E.ipadx = -5;
GridBagConstraints_E.ipady = -5;
JButton JB_E = new JButton("ok");
JPanel_1.add(JB_E, GridBagConstraints_E);
con.add(JPanel_1, BorderLayout.NORTH);
}
public static void main(String[] args) {
new Test_a().setVisible(true);
}
}
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class Test_a extends JFrame {
public Test_a() {
setSize(600, 75);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container con = getContentPane();
JPanel JPanel_1 = new JPanel();
JPanel_1.setLayout(new GridBagLayout());
GridBagConstraints GridBagConstraints_1 = new GridBagConstraints();
GridBagConstraints_1.gridx = 0;
GridBagConstraints_1.gridy = 0;
JLabel JLabel_1 = new JLabel("进货单编号:");
JPanel_1.add(JLabel_1, GridBagConstraints_1);
GridBagConstraints GridBagConstraints_2 = new GridBagConstraints();
GridBagConstraints_2.gridx = 1;
GridBagConstraints_2.gridy = 0;
JTextField JTextField_1 = new JTextField(10);
JPanel_1.add(JTextField_1, GridBagConstraints_2);
GridBagConstraints GridBagConstraints_3 = new GridBagConstraints();
GridBagConstraints_3.gridx = 2;
GridBagConstraints_3.gridy = 0;
GridBagConstraints_3.anchor = GridBagConstraints.EAST;
JLabel JLabel_2 = new JLabel("供应商:");
JPanel_1.add(JLabel_2, GridBagConstraints_3);
GridBagConstraints GridBagConstraints_4 = new GridBagConstraints();
GridBagConstraints_4.gridx = 3;
GridBagConstraints_4.gridy = 0;
JTextField JTextField_2 = new JTextField(10);
JPanel_1.add(JTextField_2, GridBagConstraints_4);
GridBagConstraints GridBagConstraints_a = new GridBagConstraints();
GridBagConstraints_a.gridx = 4;
GridBagConstraints_a.gridy = 0;
JLabel JLabel_a = new JLabel("进货单编号:");
GridBagConstraints_a.anchor = GridBagConstraints.NORTH;
GridBagConstraints_a.gridheight = 2;
JPanel_1.add(JLabel_a, GridBagConstraints_a);
GridBagConstraints GridBagConstraints_b = new GridBagConstraints();
GridBagConstraints_b.gridx = 5;
GridBagConstraints_b.gridy = 0;
JTextField JTextField_b = new JTextField(10);
GridBagConstraints_b.gridwidth = 2;
JPanel_1.add(JTextField_b, GridBagConstraints_b);
GridBagConstraints GridBagConstraints_A = new GridBagConstraints();
GridBagConstraints_A.gridx = 0;
GridBagConstraints_A.gridy = 1;
GridBagConstraints_A.anchor = GridBagConstraints.EAST;
JLabel JLabel_A = new JLabel("供应商:");
JPanel_1.add(JLabel_A, GridBagConstraints_A);
GridBagConstraints GridBagConstraints_d = new GridBagConstraints();
GridBagConstraints_A.gridx = 1;
GridBagConstraints_A.gridy = 1;
JTextField JTextField_A = new JTextField(10);
JPanel_1.add(JTextField_A, GridBagConstraints_A);
GridBagConstraints GridBagConstraints_B = new GridBagConstraints();
GridBagConstraints_B.gridx = 2;
GridBagConstraints_B.gridy = 1;
JLabel JLabel_B = new JLabel("进货单编号:");
GridBagConstraints_B.gridheight = 2;
JPanel_1.add(JLabel_B, GridBagConstraints_B);
GridBagConstraints GridBagConstraints_C = new GridBagConstraints();
GridBagConstraints_C.gridx = 3;
GridBagConstraints_C.gridy = 1;
JTextField JTextField_C = new JTextField(10);
JPanel_1.add(JTextField_C, GridBagConstraints_C);
GridBagConstraints GridBagConstraints_D = new GridBagConstraints();
GridBagConstraints_D.gridx = 5;
GridBagConstraints_D.gridy = 1;
GridBagConstraints_D.ipadx = -5;
GridBagConstraints_D.ipady = -5;
JButton JB_1 = new JButton("no");
JPanel_1.add(JB_1, GridBagConstraints_D);
GridBagConstraints GridBagConstraints_E = new GridBagConstraints();
GridBagConstraints_E.gridx = 6;
GridBagConstraints_E.gridy = 1;
GridBagConstraints_E.ipadx = -5;
GridBagConstraints_E.ipady = -5;
JButton JB_E = new JButton("ok");
JPanel_1.add(JB_E, GridBagConstraints_E);
con.add(JPanel_1, BorderLayout.NORTH);
}
public static void main(String[] args) {
new Test_a().setVisible(true);
}
}