{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Awtcolor class colors are made of red green and blue

Info icon This preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: lor Class You You can set colors for GUI components by using the java.awt.Color class. Colors are made of red, green, and blue components, each of which is represented by a byte value that describes its intensity, ranging from 0 (darkest shade) to 255 (lightest shade). This is known as the RGB model. RGB Color Color c = new Color(r, g, b); r, g, and b specify a color by its red, green, and blue components. Example: Color c = new Color(228, 100, 255); Color(228, 100, 255) EE3206/EE5805 Java Programming & Applications 17 Standard Standard Colors There There are thirteen standard color constants: BLACK BLACK, BLUE, CYAN, DARK_GRAY, GRAY, GREEN, LIGHT_GRAY, MAGENTA, ORANGE, PINK, RED, WHITE, and YELLOW. You You can use these two methods to set the component’s background and foreground colors: setBackground(Color setBackground(Color c) setForeground setForeground(Color c) Example: // jbt is an instance of JButton jbt jbt.setBackground(Color.YELLOW); jbt.setBackground(Color.YELLOW); jbt.setBackground(Color.LIGHT_GRAY); jbt.setBackground(Color.LIGHT_GRAY); EE3206/EE5805 Java Programming & Applications 18 The Font The Font Class Font Font Names Standard font names that are supported in all platforms are: SansSerif, Serif, Monospaced, Dialog, or DialogInput. Font Font Style Font.PLAIN, Font.BOLD, Font.ITALIC Font myFont = new Font(name, style, size); Example: Font myFont = new Font("SansSerif", Font.BOLD, 16); Font myFont = new Font("Serif", Font.BOLD|Font.ITALIC, 12); JButton jbtOK = new JButton("OK"); jbtOK.setFont(myFont); EE3206/EE5805 Java Programming & Applications a bitwise union 19 Using Using Pane...
View Full Document

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern