⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qq.java

📁 应用IDE开发工具设计有菜单等标准GUI组件的界面
💻 JAVA
字号:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import sun.audio.*;
import java.io.*;

public class QQ {
    public static void main(String[] args){
	    new mainFrame();
	}
}
class mainFrame extends JFrame implements ActionListener{
    File theFile = null;
	AudioData theData = null;
	InputStream nowPlaying = null;

    mainFrame(){
    	Container contentPane = f.getContentPane();
    	contentPane.setLayout(new BorderLayout());

    	JPanel p1 = new JPanel();
    	p1.setBackground(Color.black);

    	p1.setLayout(new GridBagLayout());
    	GridBagConstraints gbc = new GridBagConstraints();
    	gbc.anchor = GridBagConstraints.WEST; //设定Layout的位置
    	gbc.insets = new Insets(5,5,5,5); //设定与边界的距离(上,左,下,右)

    	p1.setBorder(BorderFactory.createTitledBorder("个人简历"));
    	
    	b1 = new JButton("曾获荣誉");
    	b2 = new JButton("健康状况");
    	b5 = new JButton("退出");
    	b3 = new JButton("音乐");
        b4 = new JButton("停止");
        
    	b1.addActionListener(this);
        b2.addActionListener(this);
        b3.addActionListener(this);
		b4.addActionListener(this);
		b5.addActionListener(this);
		
		b1.setBackground(Color.pink);
        b2.setBackground(Color.pink);

        p1.add(b1);
		p1.add(b2);
		p1.add(b3);
        p1.add(b4);
        p1.add(b5);

        contentPane.add(p1,BorderLayout.CENTER);
        
        Icon icon=new ImageIcon("g4.gif");
        Icon icon1=new ImageIcon("g5.gif");

    	JLabel l1 = new JLabel("         姓名:",icon,JLabel.CENTER);

    	JLabel l2 = new JLabel("   个人形象                                                               爱好:");
    	JLabel l3 = new JLabel("                                                                                   年龄:");
    	JLabel l4 = new JLabel("               个人说明:",icon1,JLabel.CENTER);

    	JTextArea t1 = new JTextArea(1,14);
    	JTextArea t2 = new JTextArea(2,14);
    	JTextArea t3 = new JTextArea("21                                               ");
    	JTextArea t4 = new JTextArea("现在华北电力大学,软件0601班上学!\n人生格言:\n快乐是人生的根本!(自创)",5,14);
        t1.setText("瞿强");
        t2.append("看书,打球,音乐、、、、");
        t4.setLineWrap(true);
        t1.setBackground(Color.pink);
        t2.setBackground(Color.pink);
        t3.setBackground(Color.pink);
        t4.setBackground(Color.pink);
    	gbc.gridy=1;
    	gbc.gridx=0;
    	p1.add(l1,gbc);
    	gbc.gridx=1;
    	p1.add(t1,gbc);
    	gbc.gridy=2;
    	gbc.gridx=0;
    	p1.add(l2,gbc);
    	gbc.gridx=1;
    	p1.add(t2,gbc);
    	gbc.gridy=3;
    	gbc.gridx=0;
   	    p1.add(l3,gbc);
   	    gbc.gridx=1;
    	p1.add(t3,gbc);
    	gbc.gridy=4;
    	gbc.gridx=0;
    	p1.add(l4,gbc);
    	gbc.gridx=1;
    	p1.add(t4,gbc);

    	contentPane.add(p1);
    	f.pack();
    	f.show();
    }
    
    public void open(){
	   FileDialog fd = new FileDialog(this,"please select a file");
       fd.show();
       try{
	      theFile = new File(fd.getDirectory()+"/"+fd.getFile());
	      if(theFile != null){
            FileInputStream fis = new FileInputStream(theFile);
	        AudioStream as = new AudioStream(fis);
	        theData = as.getData();
          }
	   }
       catch(IOException e){
           System.err.println(e);
       }
       catch(SecurityException e){
           System.out.println("security exception");
       }
	}
	
	public void play(){
       if(theData == null) 
         open();
	   if(theData != null){
         AudioDataStream ads = new AudioDataStream(theData);
         AudioPlayer.player.start(ads);
         nowPlaying = ads;
       }
	}
	
	public void stop(){
       if(nowPlaying != null){
         AudioPlayer.player.stop(nowPlaying);
         nowPlaying = null;
       }
    }
    
    JFrame f = new JFrame("个人简历");
    JButton b1,b2,b3,b4,b5;
   
    public void actionPerformed(ActionEvent e){
       if(e.getSource()==b1){
          JOptionPane.showMessageDialog(this, "小学一至六年级获三好学生及各种校竞赛奖!\n初中一至三年级获三好学生、演讲比赛金项奖、五四最佳文艺活动奖、\n优秀班干、团员等各种奖项!\n高中荣获数学、物理竞赛奖、优秀组织宣传奖等!");
       }
       else 
          if(e.getSource()==b2){
             JOptionPane.showMessageDialog(this, "无各种传染病史,无严重疾病史,健康状况良好!");
          }
          else 
             if(e.getSource()==b3){
             	open();play();
             }
		     else 
		        if(e.getSource()==b4){
		           stop();
		        }
		        else 
		           if(e.getSource()==b5){
		           	  System.exit(0);
		           }
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -