java中怎么调按钮的大小???
importjavax.swing.*;importjava.awt.FlowLayout;publicclassTest{publicstaticvoidmain(St...
import javax.swing.*;
import java.awt.FlowLayout;
public class Test {
public static void main(String[]args){
JFrame a = new JFrame();
a.setVisible(true);
a.setTitle("CC");
a.setSize(420,320);
a.setLocation(200,200);
a.setResizable(true);
a.setLayout(new FlowLayout());
//
JLabel b = new JLabel("账号:");
a.add(b);
JTextField b1 = new JTextField(12);
a.add(b1);
JLabel c = new JLabel("密码:");
a.add(c);
JPasswordField c1 = new JPasswordField(12);
a.add(c1);
//
JButton d = new JButton("登陆");
a.add(d);
d.setBounds(5,5,5,5);
JButton d1 = new JButton("注册");
a.add(d1);
d1.setBounds(10,10,10,10);
a.setVisible(true);
}
}
用了 d1.setBounds(10,10,10,10); d.setBounds(5,5,5,5);按钮怎么没有变??? 展开
import java.awt.FlowLayout;
public class Test {
public static void main(String[]args){
JFrame a = new JFrame();
a.setVisible(true);
a.setTitle("CC");
a.setSize(420,320);
a.setLocation(200,200);
a.setResizable(true);
a.setLayout(new FlowLayout());
//
JLabel b = new JLabel("账号:");
a.add(b);
JTextField b1 = new JTextField(12);
a.add(b1);
JLabel c = new JLabel("密码:");
a.add(c);
JPasswordField c1 = new JPasswordField(12);
a.add(c1);
//
JButton d = new JButton("登陆");
a.add(d);
d.setBounds(5,5,5,5);
JButton d1 = new JButton("注册");
a.add(d1);
d1.setBounds(10,10,10,10);
a.setVisible(true);
}
}
用了 d1.setBounds(10,10,10,10); d.setBounds(5,5,5,5);按钮怎么没有变??? 展开
展开全部
你设成 10 和5 也太小了 怎么可能显示
import java.awt.Dimension;
import java.awt.FlowLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
public class JButtonTest extends JFrame
{
private JButton button;
public JButtonTest(){
button = new JButton("登陆");
this.setLayout(new FlowLayout(FlowLayout.CENTER, 1, 1));
Dimension preferredSize = new Dimension(300, 100);
button.setPreferredSize(preferredSize );
this.setBounds(100, 100, 500, 500);
this.add(button);
this.setVisible(true);
}
public static void main(String [] args){
JButtonTest test = new JButtonTest();
}
}
完整解答测试过的
import java.awt.Dimension;
import java.awt.FlowLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
public class JButtonTest extends JFrame
{
private JButton button;
public JButtonTest(){
button = new JButton("登陆");
this.setLayout(new FlowLayout(FlowLayout.CENTER, 1, 1));
Dimension preferredSize = new Dimension(300, 100);
button.setPreferredSize(preferredSize );
this.setBounds(100, 100, 500, 500);
this.add(button);
this.setVisible(true);
}
public static void main(String [] args){
JButtonTest test = new JButtonTest();
}
}
完整解答测试过的
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询