//设置个背景图 就是显示不了。。package com.name.view;import java.awt.Container;
import java.awt.Graphics;
import java.awt.Image;
import java.io.File;
import java.io.IOException;import javax.imageio.ImageIO;
import javax.swing.JDialog;
import javax.swing.JPanel;public class IndexView extends JDialog { /**
* @param args
*/
public static void main(String[] args) {
IndexView index = new IndexView();
}
public IndexView()
{
this.setLayout(null);
BackImage bi = new BackImage(); this.add(bi);
bi.setBounds(0, 0, 360, 293);
Container ct = this.getContentPane();
ct.add(bi);
this.setUndecorated(true);
this.setSize(360,293);
this.setVisible(true);
}
//图片的内部类
class BackImage extends JPanel
{
Image img;
public BackImage()
{
try
{
img = ImageIO.read(new File("image//login.gif"));
//img = ImageIO.read(new File("d:/login_bg2.gif"));
} catch (IOException e){
e.printStackTrace();
}
}
public void paintcomponent(Graphics g)
{
g.drawImage(img, 0, 0, 360, 293,this );
}
}}
import java.awt.Graphics;
import java.awt.Image;
import java.io.File;
import java.io.IOException;import javax.imageio.ImageIO;
import javax.swing.JDialog;
import javax.swing.JPanel;public class IndexView extends JDialog { /**
* @param args
*/
public static void main(String[] args) {
IndexView index = new IndexView();
}
public IndexView()
{
this.setLayout(null);
BackImage bi = new BackImage(); this.add(bi);
bi.setBounds(0, 0, 360, 293);
Container ct = this.getContentPane();
ct.add(bi);
this.setUndecorated(true);
this.setSize(360,293);
this.setVisible(true);
}
//图片的内部类
class BackImage extends JPanel
{
Image img;
public BackImage()
{
try
{
img = ImageIO.read(new File("image//login.gif"));
//img = ImageIO.read(new File("d:/login_bg2.gif"));
} catch (IOException e){
e.printStackTrace();
}
}
public void paintcomponent(Graphics g)
{
g.drawImage(img, 0, 0, 360, 293,this );
}
}}
解决方案 »
- main函数问题
- 求助java.sql.SQLException
- Vector类中查找是否存在某一元素(contains方法)是怎么个原理呢
- 用GeoRasterLoader在Oracle中上传图像,怎么用Java实现(分不够,可加)
- 跪求. java编译是无法使用汉字.
- 过年了,sourceforge却上不了,特来散分。大家说,中国XX是不是有病啊,这些东西都限制了!!
- 小问题!!帮助!!
- JAVA读取文件中的单项名,再进行单个名字排序的问题
- 下面这个小程序为什么执行COPY这个字符串不对,而执行net send确正确呢
- applet中drawString("中文字符串")显示中文失败,why?
- java 控制打印机实现打印 String【】aa 字符串的数据
- swing 刷新问题
{
g.drawImage(img, 0, 0, 360, 293,this );
}
paintcomponent 大写 paintComponent