![]() ("SOLUTION: " + randRed + " " + randGrn + " " + randBlu) // This is just to show what the RGB values are so you can easily solve Static Color userColor = new Color(userRed, userGrn, userBlu) ĭimension d = new Dimension(500, 500) //color panel sizeĭimension b = new Dimension(50,50) //button size Static int randBlu = (rand.nextInt(17)+1)*15 Ĭolor randColor = new Color(randRed, randGrn, randBlu) ![]() Static int randGrn = (rand.nextInt(17)+1)*15 Static int randRed = (rand.nextInt(17)+1)*15 //randomized red green and blue values, multiples of 15 Private static final long serialVersionUID = 1L įont font = new Font("Times New Roman", Font.BOLD, 30) I added some comments to help explain what's going on package guessColor The functionality is very similar because they all either increase or decrease the color by 15, so I was wondering if there was a way to condense them all into just one function. There are 6 buttons, one that adds red, one that subtracts red, one that adds green, one that subtracts green, one that adds blue, and one that subtracts blue. My biggest concern with this program is the repetitiveness of the JButtons and the functions which they run. This is my first java program in a few years so I may have broken some unwritten rules. Any other tips would be greatly appreciated. ![]() It's a pretty fun program, and I suggest you try it out! It's fully runnable as is.īut a lot of the code seems repetitive and I was wondering how it could be condensed and made any more efficient if possible. I've made this program here (~240 lines) in which the user has to match their RGB Panel(right) with a randomized color on the left. ![]()
0 Comments
Leave a Reply. |