【Java精品源码栏目提醒】:网学会员为需要Java精品源码的朋友们搜集整理了【精品】Java仿千千静听音乐播放器源代码 - 其它资料相关资料,希望对各位网友有所帮助!
JAVA 仿千千静听音乐播放器源代码CrystalButton.javapackage eb.cstop.swingimport java.awt.import java.awt.event.import javax.swing.ImageIconimport javax.swing.JButtonpublic class CrystalButton extends JButton implements MouseListener private float alpha 1.0f private Color borderColor new Color0x00 0x00 0x00 private Color exitedBorderColor new Color0x33 0x33 0x33private boolean exited falseprivate boolean pressed falsepublic CrystalButton thisquotquotpublic CrystalButtonString text thistext nullpublic CrystalButtonString text ImageIcon icon thistext icon quotquotpublic CrystalButtonString text ImageIcon icon String toolTip this.addMouseListenerthis this.setTexttext if icon null this.setIconicon this.setContentAreaFilledfalse this.setFontnew Fontquot宋体quot 0 12 this.setForegroundColor.white this.setToolTipTexttoolTippublic void setAlphafloat alpha this.alpha alpha this.repaintpublic float getAlpha return alphapublic void paintBorderGraphics g public void paintComponentGraphics g Graphics2D cs Graphics2D g int width this.getSize.width int height this.getSize.height cs.setCompositeAlphaComposite.getInstanceAlphaComposite.SRC_OVER alphaint i 1int comparison 0if exited ampamp pressed cs.setColorexitedBorderColorelse cs.setColorborderColorcs.drawRect0 0 width - 1 height - 1while i lt height - 1 comparison i - 1 100 / height - 3 if comparison lt 36 if exited ampamp pressed cs.setColornew Color255 - comparison comparison 2 255 - comparison comparison 2 255 - comparison comparison 2 else cs.setColornew Color235 - comparison comparison 2 235 - comparison comparison 2 235 - comparison comparison 2 cs.drawLine1 i width - 2 i if i 1 if exited ampamp pressed cs.setColornew Color204 - comparison 2 204 - comparison 2 204 - comparison 2 else cs.setColornew Color184 - comparison 2 184 - comparison 2 184 - comparison 2 cs.drawLine2 i width - 3 i else if exited ampamp pressed cs.setColornew Colorcomparison - 16 comparison - 16 comparison - 16 else cs.setColornew Colorcomparison - 36 comparison - 36 comparison - 36 cs.drawLine1 i width - 2 i ics.setCompositeAlphaComposite.getInstanceAlphaComposite.SRC_OVER 0.8fsuper.paintComponentgcs.setCompositeAlphaComposite.getInstanceAlphaComposite.SRC_OVER alpha public void mouseClickedMouseEvent e public void mousePressedMouseEvent e pressed true this.repaint public void mouseExitedMouseEvent e exited false this.repaint public void mouseEnteredMouseEvent e exited true this.repaint public void mouseReleasedMouseEvent e pressed false this.repaint LButton.javapackage eb.cstop.swingimport java.awt.import java.awt.event.import javax.swing.public class LButton extends JButton implements MouseListener private final Font font new Fontquot宋体quot 0 12 private boolean mouseOn false private boolean mouseDown false public LButton this.setButton public LButtonString text supertext this.setButtonpublic LButtonImageIcon icon this.setIconicon this.setButtonpublic LButtonString text ImageIcon icon supertext this.setIconicon this.setButtonprivate void setButton this.setFontfont this.addMouseListenerthis this.setForegroundnew Color0 70 150public void paintBorderGraphics g this.setContentAreaFilledfalse g.setColornew Color255 255 255 g.fillRect3 3 this.getSize.width - 5 this.getSize.height - 5 if this.mouseDown if this.mouseOn g.setColornew Color160 160 160 else g.setColornew Color180 180 180 g.drawLine3 2 this.getSize.width - 3 2// TopLine g.drawLine3 this.getSize.height - 3 this.getSize.width - 3 this.getSize.height - 3// BottomLine g.drawLine2 3 2 this.getSize.height - 4// LeftLine g.drawLinethis.getSize.width - 2 3 this.getSize.width - 2 this.getSize.height - 4// RightLine int height this.getSize.height - 5 int row 3 while row lt height int now row 100 / height if now lt 35 if mouseOn g.setColornew Color245 - now 245 - now 245 - now else g.setColornew Color255 - now 255 - now 255 - now g.drawLine4 row this.getSize.width - 4 row else if mouseOn g.setColornew Color140 now 140 now 140 now else g.setColornew Color150 now 150 now 150 now g.drawLine4 row this.getSize.width - 4 row row else g.setColornew Color140 140 140 g.drawLine3 2 this.getSize.width - 3 2 g.drawLine3 this.getSize.height - 3 this.getSize.width - 3 this.getSize.height - 3 g.drawLine2 3 2 this.getSize.height - 4 g.drawLinethis.getSize.width - 2 3 this.getSize.width - 2 this.getSize.height - 4 int height this.getSize.height - 5 int row 3 while row lt height int now row 100 / height if now lt 35 g.setColornew Color210 - now 210 - now 210 - now g.drawLine4 row this.getSize.width - 4 row else g.setColornew Color110 now 110 now 110 now g.drawLine4 row this.getSize.width - 4 row row super.paintComponentgpublic void paintComponentGraphics g super.paintComponentgpublic void mouseClickedMouseEvent e public void mouseEnteredMouseEvent e this.mouseOn true this.setForegroundnew Color50 130 210 this.repaint public void mouseExitedMouseEvent e this.mouseOn false this.setForegroundnew Color0 70 150 this.repaint public void mousePressedMouseEvent e this.mouseDown true this.repaint public void mouseReleasedMouseEvent e this.mouseDown false this.repaint LPasswordField.javapackage eb.cstop.swingimport javax.swing.JPasswordFieldimport java.awt.event.FocusListenerimport java.awt.event.FocusEventimport java.awt.event.KeyListenerimport java.awt.event.KeyEventimport java.awt.Colorimport java.awt.event.MouseListenerimport javax.swing.JPopupMenuimport javax.swing.JMenuItemimport java.awt.Fontimport java.awt.event.ActionListenerimport java.awt.event.MouseEventimport java.awt.event.ActionEventpublic class LPasswordField extends JPasswordField implements ActionListener FocusListener KeyListener MouseListener private JPopupMenu popup new JPopupMenuprivate JMenuItem paste new JMenuItemquot 粘贴 quotprivate JMenuItem selectAll new JMenuItemquot 全选 quotprivate JMenuItem delete new JMenuItemquot 删除 quotprivate Font font new Fontquot宋体quot 0 12/ 构造函数ltbrgt/public LPasswordField thisquotquot/ 构造函数ltbrgt column - 占用列长度ltbrgt/public LPasswordFieldint column thiscolumn quotquot/ 构造函数ltbrgt column - 占用列长度ltbrgt text - 初始本文/public LPasswordFieldint column String text thistext this.setColumnscolumn/ 构造函数ltbrgt text - 初始本文/public LPasswordFieldString text this.setTexttext this.addFocusListenerthis this.addKeyListenerthis this.addMouseListenerthis paste.setFontfont selectAll.setFontfont delete.setFontfont paste.addActionListenerthis selectAll.addActionListenerthis delete.addActionListenerthis popup.addpaste popup.adddelete popup.addSeparator popup.addselectAll this.setSelectionColornew Color0 80 140 this.setSelectedTextColorColor.whitepublic void focusGainedFocusEvent e this.selectAllpublic void focusLostFocusEvent e public void keyPressedKeyEvent e if e.getKeyCode KeyEvent.VK_ENTER this.transferFocus public void keyReleasedKeyEvent e public void keyTypedKeyEvent e public void actionPerformedActionEvent e Object source e.getSource if source paste this.paste else if source selectAll this.selectAll else if source delete this.replaceSelectionquotquotpublic void mouseClickedMouseEvent e if e.getButton MouseEvent.BUTTON3 this.requestFocus if this.getPassword.length lt 1 selectAll.setEnabledfalse delete.setEnabledfalse else selectAll.setEnabledtrue if this.getSelectedText null delete.setEnabledtrue else delete.setEnabledfalse popup.showthis e.getX e.getY public void mouseEnteredMouseEvent e public void mouseExitedMouseEvent e public void mousePressedMouseEvent e public void mouseReleasedMouseEvent e LTextField.javapackage eb.cstop.swingimport javax.swing.JTextFieldimport java.awt.event.FocusListenerimport java.awt.event.FocusEventimport java.awt.event.KeyListenerimport java.awt.event.KeyEventimport java.awt.Colorimport javax.swing.JMenuItemimport javax.swing.JPopupMenuimport java.awt.event.ActionListenerimport java.awt.event.ActionEventimport java.awt.event.MouseListenerimport java.awt.event.MouseEventimport java.awt.Fontpublic class LTextField extends JTextField implements MouseListener FocusListener KeyListener ActionListener private JPopupMenu popup new JPopupMenu private JMenuItem copy new JMenuItemquot 复制 quotprivate JMenuItem cut new JMenuItemquot 剪切 quotprivate JMenuItem paste new JMenuItemquot 粘贴 quotprivate JMenuItem selectAll new JMenuItemquot 全选 quotprivate JMenuItem delete new JMenuItemquot 删除 quotprivate Font font new Fontquot宋体quot 0 12public LTextField thisquotquotpublic LTextFieldint column thiscolumn quotquotpublic LTextFieldint column String text thistext this.setColumnscolumnpublic LTextFieldString text this.setTexttext this.addFocusListenerthis this.addKeyListenerthis this.setSelectionColornew Color0 80 140 this.setSelectedTextColorColor.white this.addMouseListenerthis copy.setFontfont cut.setFontfont paste.setFontfont selectAll.setFontfont delete.setFontfont copy.addActionListenerthis cut.addActionListenerthis paste.addActionListenerthis selectAll.addActionListenerthis delete.addActionListenerthis popup.addcut popup.addcopy popup.addpaste popup.adddelete popup.addSeparator popup.addselectAllpublic void focusGainedFocusEvent e this.selectAllpublic void focusLostFocusEvent e public void keyPressedKeyEvent e if e.getKeyCode KeyEvent.VK_ENTER this.transferFocus public void keyReleasedKeyEvent e public void keyTypedKeyEvent e public void actionPerformedActionEvent e Object source e.getSource if source cut this.cut else if source copy this.copy else if source paste this.paste else if source selectAll this.selectAll else if source delete this.replaceSelectionquotquotpublic void mouseClickedMouseEvent e if e.getButton MouseEvent.BUTTON3 this.requestFocus if this.getText.length lt 1 copy.setEnabledfalse cut.setEnabledfalse selectAll.setEnabledfalse delete.setEnabledfalse else copy.setEnabledtrue cut.setEnabledtrue selectAll.setEnabledtrue if this.getSelectedText null delete.setEnabledtrue else delete.setEnabledfalse popup.showthis e.getX e.getY public void mouseEnteredMouseEvent e public void mouseExitedMouseEvent e public void mousePressedMouseEvent e public void mouseReleasedMouseEvent e ProgressBar.javapackage eb.cstop.swingimport javax.swing.JLabelimport java.awt.import java.awt.event.MouseListenerimport java.awt.event.MouseEventimport java.awt.event.MouseMotionListenerimport java.util.ArrayListimport java.awt.event.MouseWheelListenerimport java.awt.event.MouseWheelEventpublic class ProgressBar extends JLabel implements MouseListener MouseMotionListener MouseWheelListener private int value 0 private int minLimit 0 private int maxLimit 100 private float alpha 0.7f private Color border new Color0 0 0 private Color color new Color250 160 0 private ArrayList changeListener new ArrayList private ProgressBarEvent event new ProgressBarEventpublic ProgressBar this.setPreferredSizenew Dimension-1 5 this.addMouseListenerthis this.addMouseMotionListenerthis this.addMouseWheelListenerthispublic void setAlphafloat alpha this.alpha alpha this.repaintpublic float getAlpha return alphapublic void addProgressBarListenerProgressBarListener listener changeListener.addlistenerpublic boolean removeProgressBarListenerProgressBarListener listener return changeListener.removelistenerpublic void setMinLimtint value if value gt 0 minLimit value else minLimit 0public int getMinLimt return minLimitpublic void setMaxLimitint value if value gt 0 maxLimit value else maxLimit 100public int getMaxLimit return maxLimitpublic void setValueForChangeint value if value this.value return if value lt minLimit return else if value gt maxLimit return if value gt minLimit this.value value else value 0 this.repaintpublic void setValueint value if value this.value return if value lt minLimit return else if value gt maxLimit return if value gt minLimit this.value value else value 0 this.repaint ProgressBarListener listener null event.setValuevalue event.setComparisonint float value / maxLimit 100.0f f.