import javax.sound.sampled.AudioSystem; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.DataLine; import javax.sound.sampled.SourceDataLine;
import javax.sound.sampled.LineUnavailableException;
public class SoudPlayer extends Thread {
public void run() {
try {
line = (SourceDataLine) AudioSystem.getLine(info); line.open(streamInput.getFormat()); line.start();
private void newObject() { }
audioFormat = streamInput.getFormat();
info = new DataLine.Info(SourceDataLine.class, audioFormat, 2048); start();
public SoudPlayer(File file) { }
try { }
streamInput = AudioSystem.getAudioInputStream(file); newObject();
e.printStackTrace(); return;
public SoudPlayer(String path) { }
File file = new File(path); try { }
streamInput = AudioSystem.getAudioInputStream(file.toURL()); newObject();
e.printStackTrace(); return;
AudioFormat audioFormat; AudioInputStream streamInput; SourceDataLine line; DataLine.Info info;
} catch (Exception e) {
} catch (Exception e) {
- 21 -
}
}
}
int i = 0;
byte[] bytes = new byte[2048];
while ((i = streamInput.read(bytes)) != -1) { }
line.drain(); line.stop();
e.printStackTrace(); return;
e.printStackTrace(); return;
e.printStackTrace(); return; try { }
streamInput.close(); e.printStackTrace(); return;
} catch (IOException e) {
line.write(bytes, 0, i); sleep(5);
} catch (IOException e) {
} catch (LineUnavailableException e) {
} catch (InterruptedException e) {
} finally {
ToolButton.java
package eb.cstop.swing;
import javax.swing.JButton; import javax.swing.ImageIcon;
import java.awt.event.MouseListener; import java.awt.event.MouseEvent; import java.awt.Font; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Color;
public class ToolButton extends JButton implements MouseListener {
private boolean entered = false; private boolean pressed = false;
private Color topBorder = new Color(0xff, 0xff, 0xff);
- 22 -
private Color bottomBorder = new Color(0x87, 0x87, 0x87); private Color pressedTopBorder = new Color(0x87, 0x87, 0x87); private Color pressedBottomBorder = new Color(0xff, 0xff, 0xff); private Color pressedBG = new Color(0xa5, 0xa5, 0xa5); public ToolButton() { }
public ToolButton(String text) { }
public ToolButton(String text, ImageIcon icon) { }
public void paintBorder(Graphics g) { }
public void paintComponent(Graphics g) {
Graphics2D cs = (Graphics2D) g; if (entered && this.isEnabled()) {
if (pressed)
cs.setColor(pressedTopBorder); cs.setColor(topBorder); else
cs.drawLine(1, 1, this.getWidth() - 2, 1); cs.drawLine(1, 1, 1, this.getHeight() - 2); if (pressed)
cs.setColor(pressedBottomBorder); cs.setColor(bottomBorder);
.getHeight() - 2); .getHeight() - 2);
else
cs.drawLine(this.getWidth() - 2, 1, this.getWidth() - 2, this cs.drawLine(1, this.getHeight() - 2, this.getWidth() - 2, this this.addMouseListener(this); this.setText(text); if (icon != null)
this.setIcon(icon);
this.setContentAreaFilled(false); this.setFont(new Font(\宋体\, 0, 12)); this(text, null); this(\);
- 23 -
}
}
if (pressed) { }
cs.setColor(pressedBG);
cs.fillRect(2, 2, this.getWidth() - 4, this.getHeight() - 4);
super.paintComponent(g);
public void mouseClicked(MouseEvent e) { }
public void mousePressed(MouseEvent e) { }
public void mouseExited(MouseEvent e) { }
public void mouseEntered(MouseEvent e) { }
public void mouseReleased(MouseEvent e) { }
public Color getBottomBorderColor() { }
public void setBottomBorderColor(Color bottomBorder) { }
public Color getPressedBGColor() { }
public void setPressedBGColor(Color pressedBG) {
return pressedBG;
this.bottomBorder = bottomBorder; return bottomBorder; this.pressed = false; this.repaint(); this.entered = true; this.repaint(); this.entered = false; this.repaint(); this.pressed = true; this.repaint();
- 24 -
}
}
this.pressedBG = pressedBG;
public Color getPressedBottomBorderColor() { }
public void setPressedBottomBorderColor(Color pressedBottomBorder) { }
public Color getPressedTopBorderColor() { }
public void setPressedTopBorderColor(Color pressedTopBorder) { }
public Color getTopBorderColor() { }
public void setTopBorderColor(Color topBorder) { }
this.topBorder = topBorder; return topBorder;
this.pressedTopBorder = pressedTopBorder; return pressedTopBorder;
this.pressedBottomBorder = pressedBottomBorder; return pressedBottomBorder;
TrayIcon.java
package eb.cstop.swt;
import java.awt.image.ImageObserver; import java.awt.image.PixelGrabber; import java.util.ArrayList; import javax.swing.ImageIcon;
public class TrayIcon {
private static TrayIcon staticInstance = null; private String tooltip = \;
- 25 -