answersLogoWhite

0

/* <applet code=palette height=600 width=600>

</applet> */

import java.awt.*;

import java.awt.event.*;

import java.applet.*;

public class palette extends Applet implements ActionListener,ItemListener

{

Button[] colors;

Checkbox foreground,background;

TextArea workarea;

CheckboxGroup cbg;

Panel buttonpanel,checkpanel,palettepanel;

String colour;

public void init()

{

buttonpanel=new Panel();

buttonpanel.setLayout(new GridLayout(3,3));

colors=new Button[9];

colors[0]=new Button("RED");

colors[1]=new Button("GREEN");

colors[2]=new Button("BLUE");

colors[3]=new Button("CYAN");

colors[4]=new Button("ORANGE");

colors[5]=new Button("WHITE");

colors[6]=new Button("BLACK");

colors[7]=new Button("YELLOW");

colors[8]=new Button("PINK");

for(int i=0;i<9;i++)

{

colors[i].addActionListener(this);

buttonpanel.add(colors[i]);

}

checkpanel=new Panel();

checkpanel.setLayout(new FlowLayout());

cbg=new CheckboxGroup();

foreground=new Checkbox("ForeGround",cbg,true);

background=new Checkbox("BackGround",cbg,false);

foreground.addItemListener(this);

background.addItemListener(this);

checkpanel.add(foreground);

checkpanel.add(background);

workarea=new TextArea(8,40);

workarea.setFont(new Font("Garamond",Font.BOLD,20));

palettepanel=new Panel();

palettepanel.setLayout(new BorderLayout());

palettepanel.add(workarea,BorderLayout.CENTER);

palettepanel.add(checkpanel,BorderLayout.EAST);

palettepanel.add(buttonpanel,BorderLayout.SOUTH);

add(palettepanel);

}

public void itemStateChanged(ItemEvent ie)

{

}

public void actionPerformed(ActionEvent ae)

{

colour=ae.getActionCommand();

if(foreground.getState()==true)

workarea.setForeground(getColour());

if(background.getState()==true)

workarea.setBackground(getColour());

}

public Color getColour()

{

Color mycolor=null;

if(colour.equals("RED"))

mycolor=Color.red;

if(colour.equals("GREEN"))

mycolor=Color.green;

if(colour.equals("BLUE"))

mycolor=Color.blue;

if(colour.equals("CYAN"))

mycolor=Color.cyan;

if(colour.equals("ORANGE"))

mycolor=Color.orange;

if(colour.equals("WHITE"))

mycolor=Color.white;

if(colour.equals("BLACK"))

mycolor=Color.black;

if(colour.equals("YELLOW"))

mycolor=Color.yellow;

if(colour.equals("PINK"))

mycolor=Color.pink;

return mycolor;

}

}

User Avatar

Wiki User

11y ago

What else can I help you with?

Related Questions

Why swing used insted of applet?

Swing is used for desktop applications. Applets are used to create program which run in a browser.


What is applet in javahow it works?

Applets allow you to do frontend in java. You can draw things like rectangle,circle etc or create buttons and textboxes or you could even create a game! You can make use of the powerful api of java to design the applet and make use of awk(abstract window kit).


Do you need netbeans to create java applets for your website?

No, you just need to know how to type manually the code. Netbeans, instead, can type the code for your.


How to mix colors effectively to create a harmonious color palette?

To mix colors effectively for a harmonious color palette, start with a primary color scheme and then add complementary or analogous colors. Use color theory principles like the color wheel to guide your choices and experiment with different shades and tones to create balance and cohesion in your palette.


How do you create a e-passport website using java swing?

You really don't want to do that. Swing is for desktop applications. If you want to create a website, use Java Server Faces or Applets, not Swing.


Who is a person who uses a palette?

An artist is a person who commonly uses a palette. They mix and organize their paints on the palette to create different colors and textures for their artwork. This tool allows for greater control and experimentation in the painting process, whether in traditional painting or modern art forms.


How do you create a player on Poptropica?

Go to poptropica then there will be two buttons with one of them saying "create" or something


What are the essential artist paint tools needed to create a masterpiece?

The essential artist paint tools needed to create a masterpiece are high-quality paintbrushes, a variety of paint colors, a palette for mixing colors, a canvas or painting surface, and a palette knife for blending and applying paint.


How do you create monochromatic colors?

I am wearing monochromatic today. I am wearing red, pink, and deep red. Add white and add a shade to create that monochromatic palette.


What artistic techniques can be used to create a unique color palette, such as mixing burnt umber with other colors?

Artistic techniques such as color mixing, layering, and glazing can be used to create a unique color palette by combining burnt umber with other colors. Mixing burnt umber with different hues can create a range of warm, earthy tones, while layering and glazing can add depth and complexity to the colors. Experimenting with different combinations and techniques can result in a distinctive and personalized color palette.


What is a program that allows you to create written program?

word processing program


Where can someone find webpage buttons to download?

Buttons are found on the majority of large social media sites. Twitter and Facebook both have buttons that can be downloaded. If the ideas is to create buttons, then Button Maker and Da Button Factory are both websites that have this function.