我就是用新建的默认的窗体加了botton

解决方案 »

  1.   

    那不行的,JAVA所有的控件都应该放在容器控件中才行,你还是先看一下书,了解一下面板吧,要不就看看JBuilder9的help,最开始有一个很简单的应用,step by step,你就会明白了
      

  2.   

    我觉得你一开始还是不要先用JBuilder9这样可视化编程的工具,
    先用JCreator或者eclipse甚至UltraEdit这样地工具手写代码比较好,明白了肌理以后再用Jbuilder不迟,再说,现在好多人都再用eclipse,因为他免费吗!很多人都喜欢手写界面的。
      

  3.   

    快要做课程设计,哎!
    好像jbuiler方便一些,好像vb一样。
      

  4.   

    还是用VB吧,入门简单啊,JAVA要学的东西都这呢
      

  5.   

    package com.borland.samples.welcome;
    import java.awt.*;
    import java.awt.event.*;
    public class Frame2 extends Frame implements ActionListener
    {
       static Frame2 frm=new Frame2();
       static Dialog dlg=new Dialog(frm);
       static Button change_btn=new Button("Change Color");
       static Button ok_btn=new Button("Ok");
       static Button Cancel_btn=new Button("Cancel");
       static Checkbox ckb1=new Checkbox("Green");
       static Checkbox ckb2=new Checkbox("Yellow");
       static Checkbox ckb3=new Checkbox("White");
       static WinLis wlis=new WinLis();   public static void main(String args[])
       {
          CheckboxGroup grp=new CheckboxGroup();
          frm.setTitle("Frame");
          frm.setSize(200,150);
          dlg.setTitle("Dialog");
          dlg.setSize(150,100);
          frm.setLayout(null);
          dlg.setLayout(null);
          ckb1.setCheckboxGroup(grp);
          ckb2.setCheckboxGroup(grp);
          ckb3.setCheckboxGroup(grp);
          change_btn.setBounds(40,40,120,30);
          ckb1.setBounds(10,20,60,30);
          ckb2.setBounds(10,40,60,30);
          ckb3.setBounds(10,60,60,30);
          ok_btn.setBounds(80,40,50,20);
          Cancel_btn.setBounds(80,60,50,20);
          dlg.add(ckb1);
          dlg.add(ckb2);
          dlg.add(ckb3);
          dlg.add(ok_btn);
          dlg.add(Cancel_btn);
          frm.add(change_btn);
          Cancel_btn.addActionListener(frm);
          change_btn.addActionListener(wlis);
          ok_btn.addActionListener(frm);
          frm.setVisible(true);
       }   static class WinLis implements ActionListener
       {
          public void actionPerformed(ActionEvent e)
          {
             dlg.setLocation(80,30);
             dlg.show();
          }
       }   public void actionPerformed(ActionEvent c)
       {
          if(ckb1.getState()==true)
          {
             Button btn=(Button) c.getSource();
             if(btn==ok_btn)
             {
                dlg.dispose();
                frm.setBackground(Color.green);
             }
             else if (btn==Cancel_btn)
                dlg.hide();
          }
          else if(ckb2.getState()==true)
          {
             Button btn=(Button) c.getSource();
             if(btn==ok_btn)
             {
                dlg.dispose();
                frm.setBackground(Color.yellow);
             }
             else if (btn==Cancel_btn)
                dlg.hide();
          }
          else if(ckb3.getState()==true)
          {
             Button btn=(Button) c.getSource();
             if(btn==ok_btn)
             {
                dlg.dispose();
                frm.setBackground(Color.white);
             }
             else if (btn==Cancel_btn)
                dlg.hide();
          }
       }
    }上面程序在jbuilder编译成功,但botton等都显示不出来,为什么呢?