三国武将查询系统//Java访问数据库(九)

2015-07-24 10:44:43 · 作者: · 浏览: 27
stener()); JLabel label = new JLabel("\u6B66\u5C06\u540D"); label.setFont(new Font("长城行楷体", Font.ITALIC, 30)); label.setBounds(10, 55, 105, 63); contentPane.add(label); } class deletelistener implements ActionListener { public void actionPerformed(ActionEvent e) { try{ String s=new String(); s=textField.getText(); String temps=new String(); temps="delete from hero where hname='"+s+"'"; System.out.println(temps); ResultSet res=start.statement.executeQuery(temps); tt=new JFrame(); tt.setBounds(100, 100, 500, 80); JButton ta = new JButton("恭喜!武将"+s+"删除成功! 点击返回"); tt.add(ta); tt.setVisible(true); ta.addActionListener(new backlistener()); }catch(SQLException ss ) { textField.setText("error!"); } } } class backlistener implements ActionListener { public void actionPerformed(ActionEvent e) { deletehero.this.setVisible(false); tt.setVisible(false); dba f8=new dba(); f8.setVisible(true); } } }
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.SourceDataLine;
import java.io.File;

public class music{
  private AudioInputStream stream = null;
  private AudioFormat format = null;
  private SourceDataLine m_line;
  public void play(File fileName)
  {
    try {  
        stream = AudioSystem.getAudioInputStream(fileName);
        // At present, ALAW and ULAW encodings must be converted
        // to PCM_SIGNED before it can be played
        format = stream.getFormat();
        if (format.getEncoding() != AudioFormat.Encoding.PCM_SIGNED) {
            format = new AudioFormat(
              AudioFormat.Encoding.PCM_SIGNED,
              format.getSampleRate(),
              16,
              format.getChannels(),
              format.getChannels() * 2,
              format.getSampleRate(),
               false);        // big endian
            stream = AudioSystem.getAudioInputStream(format, stream);
        }
        // Create the clip
        DataLine.Info info = new DataLine.Info(SourceDataLine.class, stream.getFormat(), AudioSystem.NOT_SPECIFIED);
        m_line = (SourceDataLine) AudioSystem.getLine(info);
        m_line.open(stream.getFormat(),m_line.getBufferSize());
        m_line.start();
        int numRead = 0;
        byte[] buf = new byte[m_line.getBufferSize()];
        while ((numRead = stream.read(buf, 0, buf.length)) >
= 0) { int offset = 0; while (offset < numRead) { offset += m_line.write(buf, offset, numRead-offset); } } m_line.drain(); m_line.stop(); m_line.close(); stream.close(); } catch (Exception e) { e.printStackTrace(); } } public double getDuration() { return m_line.getBufferSize() / (m_line.getFormat().getFrameSize() * m_line.getFormat().getFrameRate()); } public double getDecision() { return m_line.getMicrosecondPosition()/1000.0; } }