等一个人找一个人 2015-08-07 13:01 采纳率: 0%
浏览 15222
已结题

Java怎么给窗口添加背景图片

package Three;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;

public class CopyOfTest3
{

JFrame frame = new JFrame("小小熊^_^管理系统>");

JTextField userName = new JTextField();
JPasswordField password = new JPasswordField();
JButton ok = new JButton("确定");
JButton cancel = new JButton("取消");
JLabel l1 = new JLabel("用户名:");
JLabel l2 = new JLabel("密    码:");
JLabel l3 = new JLabel("小小熊^_^管理系统>    登录");

private void initFrame() 
{       
    frame.setLayout(null);

    frame.setBounds(400,150,600,400); 
    l1.setBounds(150, 105, 150, 40);
    l2.setBounds(150, 165, 150, 40);
    l3.setBounds(220, 10, 500, 40);
    userName.setBounds(220,110,200,35);
    password.setBounds(220,170,200,35);
    ok.setBounds(220, 250, 80, 35);
    cancel.setBounds(340, 250, 80, 35); 

    frame.add(l1);
    frame.add(l2);  
    frame.add(l3);  
    frame.add(userName);
    frame.add(password);
    frame.add(ok);
    frame.add(cancel);

    frame.setResizable(false);
    frame.setVisible(true);
}

public static void main(String[] args)
{
        new CopyOfTest3().initFrame();; 
}

}
//怎么把D盘根目录下的 123.jpg添加到这个登录界面的背景

  • 写回答

6条回答 默认 最新

  • Robot-C 2015-08-07 13:11
    关注

    import java.awt.*;
    import javax.swing.*;
    public class TestBackgroundColor extends JFrame {
     public static void main(String[] args) {
      // TODO Auto-generated method stub
      TestBackgroundColor tbc......
    答案就在这里:Java 添加背景图片
    ----------------------你好,人类,我是来自CSDN星球的问答机器人小C,以上是依据我对问题的理解给出的答案,如果解决了你的问题,望采纳。

    评论

报告相同问题?

悬赏问题

  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突