为什么按钮不显示,图片会缩成一小块?怎样让图片跟随窗体自动变化?

 

其实前几天问过一个图片不显示的问题,现在解决了,但是新问题出来了,这个界面很简单,一张图片和3个按钮

问题一:刚开始的时候有按钮,但图片缩成了一点,不过也不知道怎么改的图片就出来了

问题二:图片大了,可是按钮没了,下面有截图

问题三:有没有哪个属性是让图片自动调整大小的?

 

截图和代码如下:

 

 

 

这个是出来的效果,但是3个按钮没显示出来

 

 

 

 

 

 

 

 

public JFrame_Main_Program(String str) {
        super(str);
        
        this.setLayout(new FlowLayout());
        
        setTitle("ImageTest");
        setSize(DEFAULT_WIDTH,DEFAULT_HEIGHT);
        ImagePanel imagePanel = new ImagePanel();
        imagePanel.setSize(1500, 200);
        this.add(imagePanel,BorderLayout.NORTH);
    
        
        Jbutton_G = new JButton("移动excel");
        Jbutton_W = new JButton("联通excel");
        Jbutton_C = new JButton("电信excel");

        Jbutton_G.addActionListener(this);
        Jbutton_W.addActionListener(this);
        Jbutton_C.addActionListener(this);

        Jbutton_G.setSize(50, 100);
                
        buttonPanel.add(Jbutton_G,BorderLayout.SOUTH);
        buttonPanel.add(Jbutton_W,BorderLayout.SOUTH);
        buttonPanel.add(Jbutton_C,BorderLayout.SOUTH);
        this.add(buttonPanel,BorderLayout.CENTER);      

        this.setLayout(null);
//      this.setResizable(false);       //设置窗口无法改变大小
        this.setLocation(300,300);      //用于定位窗体初始位置
        this.setVisible(true);
//      this.pack();
    }

 

 

        private JButton Jbutton_G = null;
private JButton Jbutton_W = null;
private JButton Jbutton_C = null;
private JPanel buttonPanel = new JPanel();

private static final int DEFAULT_WIDTH = 300;
private static final int DEFAULT_HEIGHT = 500;</pre><br /><strong>问题补充:</strong><br />如果图片看不到的话我把他上传到附件里,各位可以下到本地去看<br /><strong>问题补充:</strong><br />我把那FlowLayout注释掉了也一样啊。

简单点的办法还是楼上的说法,换成BorderLayout好了.图片放一个区域,按钮放一个区域.
[quote]布局设计-Borderlayout
http://210.34.148.101:8488/java/Chapt12.htm[/quote]
上面的地址貌似连接到人家的内部资料里面了,不过内容还可以,LZ快点看 呵呵

图片看不到

你的布局本身就有问题,不要用FlowLayout