领导要让我用java写一个界面,我又是一个搞c、c++的,java其他的都会,就是不会界面编程,郁闷死了,
    所以跪求一段 左右2边分别有1个文本域,中间有2个竖着排列的button,好心的人帮帮我呀,不然我就马上要下岗了

解决方案 »

  1.   

    用netbeans,有可视化编辑器,拖一个看看代码吧,
      

  2.   

    import info.clearthought.layout.TableLayout;import javax.swing.*;
    import java.awt.*;public class SwingDemo extends JFrame {
        public SwingDemo() {
            double f = TableLayout.FILL;
            double p = TableLayout.PREFERRED;
            double[][] size = {
                {f, p, f},
                {f}
            };
            Container container = getContentPane();
            container.setLayout(new TableLayout(size));        container.add(new JScrollPane(new JTextArea()), "0, 0");
            container.add(new JScrollPane(new JTextArea()), "2, 0");        Box vBox = Box.createVerticalBox();
            vBox.add(new JButton("Button One"));
            vBox.add(new JButton("Button Two"));
            container.add(vBox, "1, 0");        setDefaultCloseOperation(EXIT_ON_CLOSE);
            setSize(600, 600);
            setLocationRelativeTo(null);
            setVisible(true);
        }    public static void main(String[] args) {
            new SwingDemo();
        }
    }
      

  3.   

    需要下载一个TableLayout的jar包,我使用的是Maven来管理jar包,非常方便
    也可以到这里下载http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22TableLayout%22
      

  4.   

    大哥你终于救了我一命呀,非常3Q,能不能把我把那个button移到中间呀,那么的话我就更是感激加感激在加感激了呀,java界面编写我是从来都没有接触过呀
      

  5.   

    import info.clearthought.layout.TableLayout;import javax.swing.*;
    import java.awt.*;public class SwingDemo extends JFrame {
        public SwingDemo() {
            double f = TableLayout.FILL;
            double p = TableLayout.PREFERRED;
            double[][] size = {
                    {f, p, f},
                    {f}
            };
            Container container = getContentPane();
            container.setLayout(new TableLayout(size));        container.add(new JScrollPane(new JTextArea()), "0, 0");
            container.add(new JScrollPane(new JTextArea()), "2, 0");        double[][] size2 = {
                    {p},
                    {f, p, p, f}
            };        JPanel panel = new JPanel(new TableLayout(size2));
            panel.add(new JButton("Button One"), "0, 1");
            panel.add(new JButton("Button Two"), "0, 2");
            container.add(panel, "1, 0");        setDefaultCloseOperation(EXIT_ON_CLOSE);
            setSize(600, 600);
            setLocationRelativeTo(null);
            setVisible(true);
        }    public static void main(String[] args) {
            new SwingDemo();
        }
    }
      

  6.   

    大神,panel.add(new JButton("Button One"), "0, 1");
            panel.add(new JButton("Button Two"), "0, 2");
    这最后的参数我在改,也是不能移动到中间去呀,依然还是最上面呀,求大神赐教!!