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添加到这个登录界面的背景
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,以上是依据我对问题的理解给出的答案,如果解决了你的问题,望采纳。
background = new ImageIcon("003.jpg");// 背景图片
JLabel label = new JLabel(background);// 把背景图片显示在一个标签里面
OK,找到一个简单实例以供参考。祝好!
http://blog.csdn.net/jdsjlzx/article/details/16831815
可以使用Eclipse可视化编程,直接在属性里方便设计背景等
可以新建个面板,在面板里放入带图片的JLabel,填满面板即可。
JPanel jp = new JPanel(); //新建面板
jp.setLayout(new FlowLayout()); //设置面板布局
ImageIcon ii=new ImageIcon(getClass().getResource("/Picture/i.jpg"));
JLabel uppicture=new JLabel(ii); //往面板里加入JLabel
this.setVisible(true);
给你个文章看一下,有两种方式:http://www.linuxidc.com/Linux/2011-08/41689.htm