Search:

Type: Posts; User: Vic45

Search: Search took 0.11 seconds.

  1. Replies
    29
    Views
    1,581

    Re: Making a universal RGB Color in Swing

    I know it's not good practice but I am trying this code out:


    import java.awt.Color;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;

    import javax.swing.ButtonGroup;...
  2. Replies
    29
    Views
    1,581

    Re: Making a universal RGB Color in Swing

    Could I do a setColors getter/setter and set them all that way? Or is it better individually like setRed??
  3. Replies
    29
    Views
    1,581

    Re: Making a universal RGB Color in Swing

    I am trying to change them individually (not all three values at once) because I actually need them to get values from a JTextField. The radio buttons were just training wheels and I have failed. :( ...
  4. Replies
    29
    Views
    1,581

    Re: Making a universal RGB Color in Swing

    I'm having trouble with that then.



    public int getRed() {
    return COLOR_RED;
    }

    public void setRed(int red) {
    this.COLOR_RED = red;
  5. Replies
    29
    Views
    1,581

    Re: Making a universal RGB Color in Swing

    Ok, I see what you are saying. Within the "user interface" (The code with the radio buttons) I can put this for the red radio button:
    paintPanel.myColor = new Color(200, 0, 0); So I am really...
  6. Replies
    29
    Views
    1,581

    Re: Making a universal RGB Color in Swing

    OK, sure. I am trying to use setRed, setGreen and setBlue to set the corresponding values of COLOR_RED, COLOR_BLUE, COLOR_GREEN which controls the statement that sets the color for the rectangle,...
  7. Replies
    29
    Views
    1,581

    Re: Making a universal RGB Color in Swing

    Are you confused with what the program is trying to do?
    So I am trying to set COLOR_RED, COLOR_GREEN or COLOR_BLUE to any user-set value between 0 and 255. No they are not getting changed. Basically...
  8. Replies
    29
    Views
    1,581

    Re: Making a universal RGB Color in Swing

    Ok, here is the rest of it:

    (I will change the variable name c in my code, thanks)




    import java.awt.Color;
    import java.awt.Graphics;
  9. Replies
    29
    Views
    1,581

    Re: Making a universal RGB Color in Swing

    Ok:




    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseMotionListener;
    import java.util.ArrayList;
  10. Replies
    29
    Views
    1,581

    Re: Making a universal RGB Color in Swing

    My idea is that whatever value (between 0 and 255) is input with either of the 3 categories of R,G, or B. So I need to set the RED to user defined, green and blue as well.

    When I try to use my...
  11. Replies
    29
    Views
    1,581

    Re: Making a universal RGB Color in Swing

    Ok, that makes more sense, thank you. What about changing the color? Am I calling the getters/setters or something incorrectly?
  12. Replies
    29
    Views
    1,581

    Re: Making a universal RGB Color in Swing

    I'm not getting errors now. I am trying to set the color from a different class than where this code is: (This situation confuses me often)

    I can set them manually, like below with green = 100 to...
  13. Replies
    29
    Views
    1,581

    Re: Making a universal RGB Color in Swing

    Ok, so your code verbatim worked. I was trying to use stuff like Color.c and getColor(c) It works fine with just c as the final argument. Thank you for that.

    One more problem - setting the...
  14. Replies
    29
    Views
    1,581

    Re: Making a universal RGB Color in Swing

    It was actually commented out. So I know I need something like this: Color c = new Color(255, 0, 0); for red, correct? But putting that into my code:
    drawingShape = new Rectangle(e.getX(),...
  15. Replies
    29
    Views
    1,581

    Making a universal RGB Color in Swing

    Hello. So I am making a small "paint" program in java as a GUI. I have most of it done but one thing is giving trouble. I need to be able to set an RGB value from one class to another. I have tried...
Results 1 to 15 of 15