
Java图形界面设计中为什么Button无法显示
importjava.awt.*;importjavax.swing.*;publicclassSetextendsJFrame{JLabeljl1,jl2,jl3,jl...
import java.awt.*;import javax.swing.*;public class Set extends JFrame { JLabel jl1,jl2,jl3,jl4,jl5; JButton jb1,jb2; JTextField jtf1,jtf2; JComboBox jcb; JPanel jp1,jp2,jp3,jp11,jp12,jp21; public static void main(String[]args){ Set t= new Set(); } public Set(){ jl1=new JLabel("参数设置"); jl2=new JLabel("最小支持度"); jl3=new JLabel("最小可信度"); jl4=new JLabel("选择关联规则"); jl5=new JLabel("关联规则"); jb1=new JButton("挖掘规则"); jb2=new JButton("取消"); jb1.setLocation(100,300); jb2.setLocation(150,300); jb1.setVisible(true); jb2.setVisible(true); String[]s={"HotSpot","Apriori"}; jcb=new JComboBox(s); jp1=new JPanel(new GridLayout(3,1)); jp11=new JPanel(); jp12=new JPanel(); jtf1=new JTextField(4); jtf2=new JTextField(4); jp11.add(jl2); jp11.add(jtf1); jp11.add(jtf2); jp12.add(jl3); jp12.add(jtf2); jp1.add(jl1); jp1.add(jp11); jp1.add(jp12); jp1.setBounds(50,50,150,100); jp2=new JPanel(new GridLayout(2,1,10,10)); jp21=new JPanel(); jp21.add(jl5); jp21.add(jcb); jp2.add(jl4); jp2.add(jp21); jp2.setBounds(250,40,150,100); this.setSize(500,500); this.setBackground(Color. pink); this.setLayout(null); this.add(jp1); this.add(jp2); this.add(jb1); this.add(jb2); this.setVisible(true); } }求指教,请修改。谢谢了
展开
1个回答
展开全部
jb1.setBounds(100, 300, 100, 20);
jb2.setBounds(200, 300, 100, 20);
// jb1.setLocation(100, 300);
// jb2.setLocation(150, 300);
setLocation 改为setBounds.
jb2.setBounds(200, 300, 100, 20);
// jb1.setLocation(100, 300);
// jb2.setLocation(150, 300);
setLocation 改为setBounds.
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询