| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2293 人关注过本帖
标题:java中如何添加背景图片,是运行窗口有背景图片
只看楼主 加入收藏
gongcheng123
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2015-12-11
结帖率:0
收藏
已结贴  问题点数:20 回复次数:1 
java中如何添加背景图片,是运行窗口有背景图片
java中如何添加背景图片,是运行窗口有背景图片,下面是我的一部分代码,希望大神解救。[code]import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

import *;
/*
*author wyfssssss
*/
public class Student {
   
   public static void main(String[] args) {
        new Student();
        
    }
    public Student(){
        new MainFrame().setVisible(true);
    }
    public String xuesheng[][]=new String[100][7];   //存储学生基本信息
    public String score[][]=new String[100][4];     //存储学生成绩
    int count=0;                                  //标记录入几个成绩信息
    int cou=0;                                    //记录有多少学生信息记录
    class MainFrame extends JFrame implements ActionListener{   //主的窗口
        JButton button1,button2,button3,button4,button5,button6,button7;
        JPanel jp=new JPanel();
        JLabel label;
        public MainFrame(){
            super("主界面");
            jp.setLayout(null);
            add(jp);
            label=new JLabel("学生成绩管理系统");
            label.setFont(new Font("宋体_GB2312",Font.BOLD,24));
            label.setForeground(Color.blue);
            label.setBounds(190,20,250,30);
            jp.add(label);
            setVisible(true);
            setResizable(false);
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            setBounds(300,300,600,400);
            button1=new JButton("学生信息录入");
            button2=new JButton("查找or删除");
            button3=new JButton("录入学生成绩");
            button4=new JButton("成绩查询");
            button5=new JButton("指定课程平均值");
            button6=new JButton("等级人数");
            button7=new JButton("排序");
            button1.setBounds(100,100,170,20);
            button2.setBounds(100,140,170,20);
            button3.setBounds(100,180,170,20);
            button4.setBounds(300,100,170,20);
            button5.setBounds(300,140,170,20);
            button6.setBounds(300,180,170,20);
            button7.setBounds(300,220,170,20);
            jp.add(button1);
            jp.add(button2);
            jp.add(button3);
            jp.add(button4);
            jp.add(button5);
            jp.add(button6);
            jp.add(button7);
            button1.addActionListener(this);
            button2.addActionListener(this);
            button3.addActionListener(this);
            button4.addActionListener(this);
            button5.addActionListener(this);
            button6.addActionListener(this);
            button7.addActionListener(this);
           
        }
        
        public void actionPerformed(ActionEvent e){
            if(e.getSource()==button1){            
                new AddFrame().setVisible(true);
            }
            else if(e.getSource()==button2){
                new DeleteAndSerchFrame().setVisible(true);
            }
            else if(e.getSource()==button3){
                new AddScoreFrame().setVisible(true);
            }
            else if(e.getSource()==button4){
                new SerchScoreFrame().setVisible(true);
            }
            else if(e.getSource()==button5){
                new StatScoreFrame().setVisible(true);
            }
            else if(e.getSource()==button6){
                new DengjiFrame().setVisible(true);
            }
            else if(e.getSource()==button7){
                new PaixuFrame().setVisible(true);
            }
        }
    }
    class AddFrame extends JFrame implements ActionListener{   //实现学生对象插入的窗口
          JLabel label1 = new JLabel("添加基本信息",JLabel.CENTER);
        JLabel labxuehao=new JLabel("学号:",JLabel.CENTER);
        JLabel labyear=new JLabel("年龄:",JLabel.CENTER);
        JLabel labName=new JLabel("姓名:",JLabel.CENTER);
        JLabel labDate=new JLabel("出生日期:",JLabel.CENTER);
        JLabel labclass=new JLabel("班级:",JLabel.CENTER);
        JLabel labzy=new JLabel("专业:",JLabel.CENTER);
        JLabel labmz=new JLabel("民族:",JLabel.CENTER);
        JLabel labsex = new JLabel("性别:",JLabel.CENTER);
        JLabel labmima=new JLabel("登录密码:",JLabel.CENTER);
        JTextField txtName=new JTextField(20);
        JTextField txtSex=new JTextField(18);
        JTextField txtXueHao=new JTextField(20);
        JTextField txtYear=new JTextField(20);
        JTextField txtClass=new JTextField(20);
        JTextField txtZY=new JTextField(20);
        JTextField txtMZ=new JTextField(20);
        JTextField txtMM=new JTextField(20);
        JButton btnAdd=new JButton("添加");
        JButton btnCancel=new JButton("返回");
        JButton btnReset = new JButton("重置");
        JPanel jpl=new JPanel();
        File file=new File("D:\\myletter","letter.txt");
      
        public AddFrame(){
            super("添加学生信息");
            this.setResizable(false);
            this.setSize(550,450);
            this.setVisible(true);
            this.setLocation(300,300);
            this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
            this.add(jpl);
            jpl.setLayout(null);
            btnAdd.addActionListener(this);
            btnReset.addActionListener(this);
            btnCancel.addActionListener(this);
            jpl.setBackground(Color.cyan);
            label1.setBounds(100,20,300,20);
            jpl.add(label1);
            labxuehao.setBounds(100,50,70,20);
            jpl.add(labxuehao);
            txtXueHao.setBounds(190,50,140,20);
            jpl.add(txtXueHao);
            labName.setBounds(100,90,70,20);
            jpl.add(labName);
            txtName.setBounds(190,90,140,20);
            jpl.add(txtName);
            labsex.setBounds(110,130,60,20);
            jpl.add(labsex);
            txtSex.setBounds(190,130,140,20);
            jpl.add(txtSex);
            labyear.setBounds(100,170,70,20);
            jpl.add(labyear);
            txtYear.setBounds(190,170,140,20);
            jpl.add(txtYear);
            labclass.setBounds(100,210,70,20);
            jpl.add(labclass);
            txtClass.setBounds(190,210,140,20);
            jpl.add(txtClass);
            labzy.setBounds(100,250,70,20);
            jpl.add(labzy);
            txtZY.setBounds(190,250,140,20);
            jpl.add(txtZY);
            labmima.setBounds(100,290,70,20);
            jpl.add(labmima);
            txtMM.setBounds(190,290,140,20);
            jpl.add(txtMM);
            btnReset.setBounds(80,380,90,20);
            btnAdd.setBounds(200,380,90,20);
            btnCancel.setBounds(320,380,90,20);
            jpl.add(btnReset);
            jpl.add(btnAdd);
            jpl.add(btnCancel);
            try{
                file.createNewFile();
            }
            catch(Exception e){}
        }
    [code]   
        
搜索更多相关主题的帖子: 背景图片 public import java 如何 
2015-12-11 23:34
诸葛欧阳
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
来 自:流年
等 级:贵宾
威 望:82
帖 子:2790
专家分:14619
注 册:2014-10-16
收藏
得分:20 
frame.setIconImage(Image image)

一片落叶掉进了回忆的流年。
2015-12-11 23:48
快速回复:java中如何添加背景图片,是运行窗口有背景图片
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019368 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved