免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1151 | 回复: 0
打印 上一主题 下一主题

高手,有程序乞求帮我LAYOUT一下 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2005-07-05 09:27 |只看该作者 |倒序浏览
我搞不定呀。谢谢!!


import java.util.*;
import java.lang.*;
import java.io.*;


import javax.swing.*;
import java.awt.event.*;

public class CupHost
{
    public CupHost()
    {
        GuiVariable.frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        GuiVariable.frame1.getContentPane().setLayout(new java.awt.FlowLayout());
        
        
        
        WhetherStart();
        WhetherSelecte();
        AddFieldToFrame();
//                                GuiVariable.frame1.setSize(600, 800);
GuiVariable.frame1.pack();
        GuiVariable.frame1.show();
        
    }
   
   
   
    public void WhetherSelecte()
                {
                        ActionListener a = new ActionListener()
                        {
            public void actionPerformed(ActionEvent ae)
            {
                   for(int i=0; i<64; i++)
                    {
                            if(ae.getSource() == GuiVariable.fx)
                            {
                        GuiVariable.isfx = GuiVariable.fx.isSelected();
                        System.out.println("true ...";
                }
                    }
            }
        };
        for(int j=0; j<64; j++)
                GuiVariable.fx[j].addActionListener(a);
        return;
                }
   
    public void AddFieldToFrame()
    {
           
            GuiVariable.MsgIDLabel.setLabelFor(GuiVariable.MsgIDText);
           
            for(int i=0; i<64; i++)
            {
                    GuiVariable.frame1.getContentPane().add(GuiVariable.fx);
                    GuiVariable.frame1.getContentPane().add(GuiVariable.textFieldx);
            }
      GuiVariable.frame1.getContentPane().add(GuiVariable.toggle);
      GuiVariable.frame1.getContentPane().add(GuiVariable.MsgIDLabel);
      
      GuiVariable.frame1.getContentPane().add(GuiVariable.MsgIDText);
      
      return;
    }
   
   
    public void WhetherStart()
    {
            GuiVariable.toggle.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent ae) {
                JToggleButton toggle1 = (JToggleButton) ae.getSource();
               
                if (toggle1.isSelected())
                {
                    System.out.println("Starting.......";
                    
                                    

                }
                else
                {
                    System.out.println("Starting.......";
                    
                }
               
               
            }
        });
        
//        GuiVariable.frame1.getContentPane().add(GuiVariable.toggle);
        
    }
   
   
    public static void main(String[] args)
    {
        
        new CupHost();
       }

}


import java.util.*;
import java.lang.*;
import java.io.*;

import javax.swing.*;
import java.awt.event.*;

public class GuiVariable
{
        public static JFrame frame1 = new JFrame("CUP         HOST";
        public static JToggleButton toggle = new JToggleButton("BASIC/EXPERT";
       
        public static boolean isfx[] = new boolean[64];
        static
  {
          for(int i=0; i<64; i++)
          {
                  isfx = false;
          }
        }

        public static JLabel MsgIDLabel = new JLabel("Msg ID";
        public static JTextField MsgIDText = new JTextField(10);
        public static JCheckBox fx[] = new JCheckBox[64];
        static
  {
          String aa = null;
          for(int i=0; i<64; i++)
          {
                          aa = "f"+(i+1);
//                          System.out.println(aa);
                          fx = new JCheckBox(aa);
//                          fx.setText(aa);
          }
        }
       
        public static JTextField textFieldx[] = new JTextField[64];
        static
        {
                for(int i=0; i<64; i++)
                {
                        textFieldx = new JTextField(15);
                }
        }

}
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP