关于JPanel的小问题!在JPanel里面放张图片! 本帖最后由 lanying2017 于 2011-04-11 14:28:38 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 import java.awt.Rectangle;import javax.swing.ImageIcon;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JPanel;public class Image extends JFrame { JPanel jpanel; JLabel label; ImageIcon icon; public Image(){ icon = new ImageIcon("pond.png"); label = new JLabel(icon); label.setLayout(null); label.setBounds(0,0,icon.getIconWidth(),icon.getIconHeight()); jpanel = new JPanel(); jpanel.setLayout(null); jpanel.setBackground(Color.GRAY); jpanel.add(label); jpanel.setBounds(0,0,icon.getIconWidth(),icon.getIconHeight()); this.setTitle("test"); this.add(jpanel); this.setVisible(true); this.pack(); this.setBounds(new Rectangle(10,10,icon.getIconWidth(),icon.getIconHeight())); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public static void main(String [] args){ new Image(); } }主要是紅色部份的設置 又要无满意结帖?? 关于接口问题....,请帮忙看下.... 编程问题 做过WebGIS的请进 突然迷惑了,关于ArrayList可以存放的数据类型,能存放自定义的对象类型吗? 如何得到键盘焦点,急!!!!! 不能出问题的问题???!!! 怎样获得文件的路径? 请问怎样把一个Jtextarea里面的文字,读到stringbuffer里面,谢谢 菜鸟问题!j2se的使用 送给火影迷-火影忍者漫画爬取 SWT/JFace 能开发出苹果的滑动效果吗?
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class Image extends JFrame {
JPanel jpanel;
JLabel label;
ImageIcon icon;
public Image(){
icon = new ImageIcon("pond.png");
label = new JLabel(icon);
label.setLayout(null);
label.setBounds(0,0,icon.getIconWidth(),icon.getIconHeight());
jpanel = new JPanel();
jpanel.setLayout(null);
jpanel.setBackground(Color.GRAY);
jpanel.add(label);
jpanel.setBounds(0,0,icon.getIconWidth(),icon.getIconHeight());
this.setTitle("test");
this.add(jpanel);
this.setVisible(true);
this.pack();
this.setBounds(new Rectangle(10,10,icon.getIconWidth(),icon.getIconHeight()));
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String [] args){
new Image();
}
}
主要是紅色部份的設置