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

📄 structure.java

📁 自己制作的简单的歌词编辑器
💻 JAVA
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package lyric;import javax.swing.*;import javax.swing.event.*;import java.awt.*;import java.awt.event.*;import java.util.*;/** * * @author 徐新坤 */public class Structure extends JPanel implements MouseListener,ActionListener{    public void actionPerformed(ActionEvent e) {        System.out.println("action");        Time t  = new Time();        if(e.getActionCommand().equals("START")){                       t.start();            System.out.println("start");        }        if(e.getActionCommand().equals("END")){            try{                t.stop();                time=0;            }            catch(Exception ex){                System.err.print(ex);            }            System.gc();            System.out.println("end");        }                    //        throw new UnsupportedOperationException("Not supported yet.");    }    public void mouseClicked(MouseEvent e) {        int minute = time / 6000;        int second = time / 100 - minute * 60;        int min = time - second * 100 - minute * 6000;        String temp = "["+minute+":"+second+":"+min+"]";        int pos = GetPostion(e.getY());        InsertTime(temp,pos);        System.out.println(temp);//        throw new UnsupportedOperationException("Not supported yet.");    }    public void mouseEntered(MouseEvent e) {//        throw new UnsupportedOperationException("Not supported yet.");    }    public void mouseExited(MouseEvent e) {//        throw new UnsupportedOperationException("Not supported yet.");    }    public void mousePressed(MouseEvent e) {//                int minute = time / 6000;//        int second = time / 100 - minute * 60;//        int min = time - second * 100 - minute * 6000;//        String temp = "["+minute+":"+second+":"+min+"]";//        System.out.println(temp);//        throw new UnsupportedOperationException("Not supported yet.");    }    public void mouseReleased(MouseEvent e) {//        throw new UnsupportedOperationException("Not supported yet.");    }        JTextArea jta;    JButton jbs,jbe;    ScrollPane sp;    int time=0;    public Structure(){        jta=new JTextArea();        jbs =new JButton("START");        jbe = new JButton("END");        sp = new ScrollPane();        setLayout(new BorderLayout());        add("Center",sp);        sp.add(jta);        add("East",jbe);        add("West",jbs);        jbs.addActionListener(this);        jbe.addActionListener(this);        jta.addMouseListener(this);    }    	class Time	{		java.util.Timer ti=new java.util.Timer();		java.util.Date da=new java.util.Date();		public void start()		{			ti.scheduleAtFixedRate(new Task(),da,10);		}		public void stop()		{			ti.cancel();		}	}        class Task extends TimerTask	{		public void run(){			time++;		}	}            private void InsertTime(String time,int position){        jta.insert(time, position);    }        private int GetPostion (int y){        int height =18;//                jta.getRowHeight();        int line = y / height;        int pos =0;        try{            pos =jta.getLineStartOffset(line);            System.out.println("y="+y+"h="+height);        }        catch(Exception ex){            System.err.println(ex);        }        return pos;    }}

⌨️ 快捷键说明

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