怎样设置才能去除这些按钮,找了很久了

解决方案 »

  1.   

    好像Frame不能消除那些按钮,建议改用Window
      

  2.   


    import java.awt.BorderLayout;
    import java.awt.event.MouseAdapter;
    import java.awt.event.MouseEvent;
    import javax.swing.JButton;
    import javax.swing.JLabel;
    import javax.swing.JWindow;public class WindowTest extends JWindow
    {
    /**
     * @param args
     */
    public static void main(String[] args)
    {
    WindowTest main = new WindowTest();
    main.setVisible(true);
    } public WindowTest()
    {
    super();
    setSize(400, 300);
    final JButton button = new JButton();
    button.addMouseListener(new MouseAdapter()
    {
    public void mousePressed(MouseEvent e)
    {
    WindowTest.this.setVisible(false);
    WindowTest.this.dispose();
    System.exit(0);
    }
    });
    button.setText("想关闭?Click me!!");
    getContentPane().add(button, BorderLayout.CENTER);
    }
    }
      

  3.   

    setIconified(false);
    setMaximum(false);
      

  4.   

    to allen830826($Java) : JFrame和Frame都不支持你的方法,是不是还有其他问题你没有弄清楚
      

  5.   

    bovy(蓝狐狸) 你的window没有边框,这也不是我想要的
      

  6.   

    import java.awt.*;
    import java.awt.event.*;public class FrameTest {
      static Point origin = new Point();
      public static void main (String args[]) {
        final Frame frame = new Frame();
        frame.setUndecorated(true);
        frame.addMouseListener(new MouseAdapter() {
          public void mousePressed(MouseEvent e) {
            origin.x = e.getX();
            origin.y = e.getY();
          }
        });
        frame.addMouseMotionListener(new MouseMotionAdapter() {
          public void mouseDragged(MouseEvent e) {
            Point p = frame.getLocation();
            frame.setLocation(
              p.x + e.getX() - origin.x,
              p.y + e.getY() - origin.y);
          }
        });
        frame.setSize(300, 300);
        Button b1 = new Button("Maximize");
        b1.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            frame.setExtendedState(Frame.MAXIMIZED_BOTH);
          }
        });
        Button b2 = new Button("Iconify");
        b2.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Preserve maximizing
            frame.setExtendedState(Frame.ICONIFIED
               | frame.getExtendedState());
          }
        });
        Button b3 = new Button("Normal");
        b3.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            frame.setExtendedState(Frame.NORMAL);
          }
        });
        Button b4 = new Button("Close");
        b4.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            System.exit(0);
          }
        });
        frame.setLayout(new GridLayout(5,1));
        frame.add(b1);
        frame.add(b2);
        frame.add(b3);
        frame.add(b4);
        frame.show();
      }
    }
      

  7.   

    swing的我也不会,swt的子窗体符合你的要求,下面是个子窗体的例子。import org.eclipse.swt.widgets.*;public class ChildShellExample {
        Display d = new Display( );
        
        
        ChildShellExample( )    {    
            Shell s = new Shell(d);
            s.setSize(500,500);
            s.open( );
            ChildShell cs = new ChildShell(s);
            while(!s.isDisposed( )){
                if(!d.readAndDispatch( ))
                    d.sleep( );
            }
            d.dispose( );
        }
    }