以下的文章主要是对Oracle Java的相关的实际应用程序添加漂亮的背景图片的实际操作的描述,其在整理之后可执行的相关实际应用代码如下:希望本文章会给你在其实际应用方面带来一些帮助在此方面。

汉源ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为创新互联公司的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:13518219792(备注:SSL证书合作)期待与您的合作!
- import java.awt.*;
 - import javax.swing.*;
 - public class TestBackgroundColor extends JFrame
 - {
 - public static void main(String[] args)
 - {
 - TODO Auto-generated method stub
 - TestBackgroundColor tbc = new TestBackgroundColor();
 - tbc.setVisible(true);
 - }
 - private JPanel imagePanel;
 - private ImageIcon background;
 - public TestBackgroundColor()
 - {
 - background = new ImageIcon("渐变背景14.png");
 
背景图片
- JLabel label = new JLabel(background);
 
把背景图片显示在一个标签里面
把标签的大小位置设置为图片刚好填充整个面板
- label.setBounds(0,0,background.getIconWidth(),background.getIconHeight());
 
把内容窗格转化为JPanel,否则不能用方法setOpaque()来使内容窗格透明
- imagePanel = (JPanel)this.getContentPane();
 - imagePanel.setOpaque(false);
 
内容窗格默认的布局管理器为BorderLayout
- imagePanel.setLayout(new FlowLayout());
 - imagePanel.add(new JButton("测试按钮"));
 - this.getLayeredPane().setLayout(null);
 
把背景图片添加到分层窗格的最底层作为背景
- this.getLayeredPane().add(label,new Integer(Integer.MIN_VALUE));
 - this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 - this.setSize(background.getIconWidth(),background.getIconHeight());
 - this.setVisible(true);
 - }
 - }
 
以上的相关内容就是对为Oracle Java程序添加漂亮背景图片的介绍,望你能有所收获。
【编辑推荐】
                新闻名称:OracleJava程序添加背景图片的操作方案
                
                地址分享:http://www.csdahua.cn/qtweb/news17/140717.html
            
网站建设、网络推广公司-快上网,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 快上网