java界面中显示图片_java中怎样在界面中显示图片?
生活随笔
收集整理的這篇文章主要介紹了
java界面中显示图片_java中怎样在界面中显示图片?
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
方法一:
JLabel helloLabel = new JLabel("New label");
helloLabel.setIcon(new ImageIcon("E:\\javaSE\u4EE3\u7801\\TimeManager\\asset\\hello.gif"));
helloLabel.setBackground(Color.BLACK);
helloLabel.setBounds(0, 0, 105, 50);
contentPane.add(helloLabel);
方法二:
ImageIcon imagetoshow=new ImageIcon(urlofimagetoshow);
JLabel showimagelabel=new JLabel(imagetoshow);
this.getLayeredPane().add(showimagelabel,
new Integer(Integer.MIN_VALUE)); // 設置JLabel在最底層
showimagelabel.setBounds(0, 0, 500,150);
總結
以上是生活随笔為你收集整理的java界面中显示图片_java中怎样在界面中显示图片?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 亿赛通加密软件不显示小锁图标
- 下一篇: 数据结构 快速排序