MenuButton.java 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. package model.objects;
  2. import java.awt.Color;
  3. import java.awt.Font;
  4. import java.awt.Graphics2D;
  5. import java.util.ArrayList;
  6. import audio.Song;
  7. public class MenuButton {
  8. private ArrayList<Color> colors;
  9. private int x, y;
  10. private int xx,yy;
  11. private boolean selected;
  12. private Song song;
  13. Color color;
  14. public MenuButton(int x, int y, Color color, Song song){
  15. this.x = x;
  16. this.y = y;
  17. this.color = color;
  18. setSong(song);
  19. }
  20. public MenuButton(int x, int y, int xx, int yy, Color color, Song song){
  21. this.x = x;
  22. this.y = y;
  23. this.color = color;
  24. this.yy = yy;
  25. this.xx = xx;
  26. setSong(song);
  27. }
  28. public void draw(Graphics2D g2d){
  29. if(selected){
  30. g2d.setColor(color.darker().darker().darker().darker());
  31. g2d.fillRect(x-10, y-10,xx+20,yy+20);
  32. g2d.setColor(color.darker().darker());
  33. g2d.fillRect(x-5, y-5,xx+10,yy+10);
  34. g2d.setColor(color);
  35. g2d.fillRect(x,y,xx,yy);
  36. g2d.setColor(Color.BLACK);
  37. g2d.drawRect(x-10, y-10, xx+20, yy+20);
  38. g2d.drawRect(x-5, y-5, xx+10, yy+10);
  39. g2d.drawRect(x, y, xx, yy);
  40. }
  41. else{
  42. g2d.setColor(color.darker().darker());
  43. g2d.fillRect(x-5, y-5,890,80);
  44. g2d.setColor(color);
  45. g2d.fillRect(x,y,880,70);
  46. }
  47. //draw text
  48. g2d.setColor(Color.BLACK);
  49. Font textFont = new Font("OCR A Extended", Font.BOLD,60);
  50. g2d.setFont(textFont);
  51. if(selected)
  52. g2d.drawString(song.getTitle(), x+50, y+63);
  53. else
  54. g2d.drawString(song.getTitle(), x+50, y+57);
  55. }
  56. public void setSelected(boolean selected) {
  57. this.selected = selected;
  58. }
  59. public boolean isSelected(){
  60. return selected;
  61. }
  62. public void setX(int x){
  63. this.x = x;
  64. }
  65. public int getX() {
  66. return x;
  67. }
  68. public Song getSong() {
  69. return song;
  70. }
  71. public void setSong(Song song) {
  72. this.song = song;
  73. }
  74. }