MenuButton.java 1.8 KB

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