我用了FlowLayout布局,.. 我用了FlowLayout布局,也用了JScrollPane,然后我想显示4副不同的图片,每行显示2个, 然后,我就用了FOR语句,但是却并不是我所希望的!换了GridLayout后,还是不行啊~ 请教 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 setLayout(new GridLayout(3,2));//3行两列 add(new Button("1")); add(new Button("2")); add(new Button("3")); add(new Button("4")); add(new Button("5")); add(new Button("6"));这是加按钮的,你换成图片就可以了 Java codeimport java.awt.*;import javax.swing.*;public class Jcsdn extends JFrame{ public Jcsdn() { this.setLayout(new GridLayout(2,2,5,5)); Container c=getContentPane(); JPanel jp= new JPanel(new GridLayout(2,2,5,5)); Icon icon1 =new ImageIcon("src/IMG_0531.jpg"); JLabel jl=new JLabel(icon1); Icon icon2 =new ImageIcon("src/IMG_0535.jpg"); JLabel j2=new JLabel(icon2); Icon icon3= new ImageIcon("src/IMG_0536.jpg"); JLabel j3=new JLabel(icon3); JLabel j4= new JLabel(new ImageIcon("src/IMG_0539.jpg")); jp.add(jl); jp.add(j2); jp.add(j3); jp.add(j4); JScrollPane js=new JScrollPane(jp); js.setBounds(10, 10, 500, 1000); this.getContentPane().add( js); this.setSize(1000,1000); this.setVisible(true); } public static void main(String a[]) { new Jcsdn(); }我写了个,可以显示4幅图片的,采用了布局管理器,也用了JScrollPane,看能给LZ些参考不?? new FlowLayout(行数,列数,行间距,列间距); new GridLayout(行数,列数,行间距,列间距); java 窗口 JDialog和JFrame对象如何让它不能最小化?续 怎么能立刻进行内存回收? JAVA的运行问题 菜鸟问题 notify无法唤醒wait的问题 问个mouseDragged问题 我如何知道一个类中有哪些属性和方法,又怎样在不知道的情况下调用呢? 如何实现自定义tcp报文的首部呢? 关于args[]?? ★★★通告:请各位网友关注一下★★★ 请大家指教?? 关于Eclipse3.2的Myeclipse 奇怪,求助
setLayout(new GridLayout(3,2));//3行两列
add(new Button("1"));
add(new Button("2"));
add(new Button("3"));
add(new Button("4"));
add(new Button("5"));
add(new Button("6"));
这是加按钮的,你换成图片就可以了
import javax.swing.*;
public class Jcsdn extends JFrame
{
public Jcsdn()
{
this.setLayout(new GridLayout(2,2,5,5));
Container c=getContentPane();
JPanel jp= new JPanel(new GridLayout(2,2,5,5));
Icon icon1 =new ImageIcon("src/IMG_0531.jpg");
JLabel jl=new JLabel(icon1);
Icon icon2 =new ImageIcon("src/IMG_0535.jpg");
JLabel j2=new JLabel(icon2);
Icon icon3= new ImageIcon("src/IMG_0536.jpg");
JLabel j3=new JLabel(icon3);
JLabel j4= new JLabel(new ImageIcon("src/IMG_0539.jpg"));
jp.add(jl);
jp.add(j2);
jp.add(j3);
jp.add(j4);
JScrollPane js=new JScrollPane(jp);
js.setBounds(10, 10, 500, 1000);
this.getContentPane().add( js);
this.setSize(1000,1000);
this.setVisible(true);
}
public static void main(String a[])
{
new Jcsdn();
}
我写了个,可以显示4幅图片的,采用了布局管理器,也用了JScrollPane,看能给LZ些参考不??