| 网站首页 | 业界新闻 | 群组 | 人才 | 下载频道 | 博客 | 代码贴 | 编程论坛
雷速体育发帖软件开发QQ118000023C语言培训|一对一辅导|零基础学编程LightningChart 快速先进的.Net图表控件
共有 412 人关注过本帖
标题:关于界面设计的问题
只看楼主 收藏
温酒斩化腾
Rank: 1
等 级:新手上路
帖 子:32
专家分:0
注 册:2017-3-28
结帖率:72.73%
  问题点数:0  回复次数:2   
关于界面设计的问题
请问怎么把下拉表放到第一行的后面?

 import java.awt.*;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
public class num1 extends JFrame{
    Box b1,b2,b3,b4,b5,b6,b;
    JTextField t1,t2,t3,t4,t5,t6;
    num1(){
        b = Box.createVerticalBox();
        
        JPanel pane = new JPanel();
        pane.setBorder(new EmptyBorder(5, 5, 5, 5));
        setContentPane(pane);
        JLabel abe = new JLabel("@");
        pane.add(abe);
        JComboBox q1 = new JComboBox();
        q1.addItem("sina.com");
        q1.addItem("qq.com");
        q1.addItem("123.com");
        pane.add(q1);
        this.setLayout(new  GridLayout(1, 1));
        pane.setBounds(100, 10, 400, 40);
        
        t1 = new JTextField();
        t1.setPreferredSize(new Dimension(100,10));
        b1 = Box.createHorizontalBox();
        b1.add(new JLabel("*邮件地址"));
        b1.add(Box.createHorizontalStrut(10));
        b1.add(t1);
        
        
        
        t2 = new JTextField();
        t2.setPreferredSize(new Dimension(100,10));
        b2 = Box.createHorizontalBox();
        b2.add(new JLabel("*密码"));
        b2.add(Box.createHorizontalStrut(10));
        b2.add(t2);
        
        
        t3 = new JTextField();
        t3.setPreferredSize(new Dimension(200,10));
        b3 = Box.createHorizontalBox();
        b3.add(new JLabel("*确认密码"));
        b3.add(Box.createHorizontalStrut(10));
        b3.add(t3);
        
        t4 = new JTextField();
        t4.setPreferredSize(new Dimension(150,10));
        b4 = Box.createHorizontalBox();
        b4.add(new JLabel("手机号码"));
        b4.add(Box.createHorizontalStrut(10));
        b4.add(t4);
        
        t5 = new JTextField();
        t5.setPreferredSize(new Dimension(100,10));
        b5 = Box.createHorizontalBox();
        b5.add(new JLabel("验证码"));
        b5.add(Box.createHorizontalStrut(10));
        b5.add(t5);
        
        t6 = new JTextField();
        t6.setPreferredSize(new Dimension(140,10));
        b6 = Box.createHorizontalBox();
        b6.add(new JLabel("短信验证码"));
        b6.add(Box.createHorizontalStrut(10));
        b6.add(t6);
        
        setLayout(new FlowLayout(1));
        b.add(b1);
        b.add(Box.createVerticalStrut(10));
        b.add(b2);
        b.add(Box.createVerticalStrut(10));
        b.add(b3);
        b.add(Box.createVerticalStrut(10));
        b.add(b4);
        b.add(Box.createVerticalStrut(10));
        b.add(b5);
        b.add(Box.createVerticalStrut(10));
        b.add(b6);
        
        add(b);
        
        setLayout(new FlowLayout(0));
        setBounds(200, 200, 800, 800);
        setVisible(true);
        setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        validate();
    }
}
附件: 您没有浏览附件的权限,请 登录注册
2017-11-29 13:57
林月儿
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:湖南
等 级:版主
威 望:94
帖 子:1556
专家分:6808
注 册:2015-3-19
  得分:0 
程序代码:
package test;

import java.util.Arrays;
import java.util.List;

import javax.swing.Box;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;

public class Demo2 extends JFrame{
    /**
     *
     
*/
    private static final long serialVersionUID = 1L;
    List<String> labs = Arrays.asList("*邮件地址","*密码","*确认密码","手机号码","验证码","短信验证码");
    public Demo2() {
        Box bv = Box.createVerticalBox();
        for(String lab : labs) {
            Box bh = Box.createHorizontalBox();
            bh.add(new JLabel(lab));
            bh.add(new JTextField());
            bv.add(bh);
        }
        JComboBox<String> jcb = new JComboBox<String>();
        jcb.addItem("@sina.com");
        jcb.addItem("@qq.com");
        jcb.addItem("@123.com");
        bv.add(jcb);
        add(bv);
        setSize(240, 240);
        setVisible(true);
        setResizable(false);
        setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    }
    public static void main(String[] args) {
        new Demo2();
    }
}

不过是爱情,可以走很久
2017-12-02 23:09
object2
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2018-1-5
  得分:0 
2018-01-05 12:06







关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.067907 second(s), 9 queries.
Copyright©2004-2018, BCCN.NET, All Rights Reserved