import java.awt.event.*;
import java.awt.*;
import java.applet.*;
import javax.swing.*;
import java.util.*;
public class DrawTest extends Applet implements ActionListener{
Panel PN;
s PS;
myfram mf=new myfram();
Color color;
Panel a;
Panel side1;
Panel side2;
JButton bj;
DrawPanel panel;
Panel ppp;
Button showColor;
DrawControls controls;
JButton b1,b2,b3,b4,b5,b6,b7,f1,f2,f3;
JButton ColorRed,ColorWhite,Colorblue,ColorGreen,ColorBlack,ColorCyan,ColorYellow,ColorGray ,ColorDarkGray;
public void init() {
PS=new s();
setLayout(new BorderLayout());
panel = new DrawPanel();
controls = new DrawControls(panel);
a=new Panel();
a.setLayout(new FlowLayout());
ppp=new Panel();
side1=new Panel();
side2=new Panel();
side1.setBackground(Color.LIGHT_GRAY);
side2.setBackground(Color.LIGHT_GRAY);
showColor=new Button(" ");
showColor.setBackground(Color.black);
a.setBackground(Color.GRAY);
ppp.setBackground(Color.LIGHT_GRAY);
b1 = new JButton("Draw");
b2 = new JButton("Lines");
b3 = new JButton("Clear");
b4=new JButton("Box");
b5=new JButton("Circle");
b6=new JButton("Oval");
b7=new JButton("Eraser");
f1=new JButton("Fill Box");
f1.addActionListener(this);
f2=new JButton("Fill Circle");
f2.addActionListener(this);
f3=new JButton("Fill Oval");
f3.addActionListener(this);
a.add(b1);
a.add(b2);
a.add(b4);
a.add(b5);
a.add(b6);
a.add(f1);
a.add(f2);
a.add(f3);
a.add(b7);
a.add(b3);
ColorRed = new JButton(" ");
ColorRed.setSize(50,30);
ColorRed.setBackground(Color.RED);
ppp.add(ColorRed);
ColorRed.addActionListener(this);
ColorWhite = new JButton(" ");
ColorWhite.setSize(30,30);
ColorWhite.setBackground(Color.white);
ppp.add(ColorWhite);
ColorWhite.addActionListener(this);
ColorBlack = new JButton(" ");
ColorBlack.setSize(30,30);
ColorBlack.setBackground(Color.black);
ppp.add(ColorBlack);
ColorBlack.addActionListener(this);
ColorGray = new JButton(" ");
ColorGray.setSize(30,30);
ColorGray.setBackground(Color.gray);
ppp.add(ColorGray);
ColorGray.addActionListener(this);
Colorblue = new JButton(" ");
Colorblue.setSize(30,30);
Colorblue.setBackground(Color.blue);
ppp.add(Colorblue);
Colorblue.addActionListener(this);
ColorGreen = new JButton(" ");
ColorGreen.setSize(30,30);
ColorGreen.setBackground(Color.GREEN);
ppp.add(ColorGreen);
ColorGreen.addActionListener(this);
ColorCyan = new JButton(" ");
ColorCyan.setSize(30,30);
ColorCyan.setBackground(Color.cyan);
ppp.add(ColorCyan);
ColorCyan.addActionListener(this);
ColorYellow = new JButton(" ");
ColorYellow.setSize(30,30);
ColorYellow.setBackground(Color.yellow);
ppp.add(ColorYellow);
ColorYellow.addActionListener(this);
ColorDarkGray = new JButton(" ");
ColorDarkGray.setSize(30,30);
ColorDarkGray.setBackground(Color.DARK_GRAY);
ppp.add(ColorDarkGray);
ColorDarkGray.addActionListener(this);
add("West",PS);
add("East",PS);
add("Center", panel);
ppp.add(controls);
add("North",a);
add("South",ppp);
ppp.add(showColor);
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);
b5.addActionListener(this);
b6.addActionListener(this);
b7.addActionListener(this);
bj = new JButton( "Change Other Color" );
ppp.add( bj);
bj.addActionListener(this);
}
public void actionPerformed(ActionEvent e) {
Object source = e.getSource();
if (source==b2) {
panel.setDrawMode(DrawPanel.LINES);
}
else if (source==b1) {
panel.setDrawMode(DrawPanel.POINTS);
}
else if (source==b3) {
panel.destroy(1);
}
else if (source==b4) {
panel.setDrawMode(DrawPanel.BOX);
}
else if (source==b5) {
panel.setDrawMode(DrawPanel.CIRCLE);
}
else if (source==b6) {
panel.setDrawMode(DrawPanel.OVAL);
}
else if (source==b7) {
panel.setDrawMode(DrawPanel.ERASER);
}
else if (source==f1) {
panel.setDrawMode(DrawPanel.fillBOX);
}
else if (source==f2) {
panel.setDrawMode(DrawPanel.fillCIRCLE);
}
else if (source==f3) {
panel.setDrawMode(DrawPanel.fillOVAL);
}
else if(source==ColorRed){
controls.ch(Color.red);
showColor.setBackground(Color.red);
//////////////////////////////
}
else if(source==ColorBlack){
controls.ch(Color.BLACK);
showColor.setBackground(Color.black);
////////////////////////////
}
else if(source==ColorYellow){
controls.ch(Color.yellow);
showColor.setBackground(Color.yellow);
////////////////////////////
}
else if(source==ColorDarkGray){
controls.ch(Color.DARK_GRAY);
showColor.setBackground(Color.DARK_GRAY);
////////////////////////////
}
else if(source==ColorGray){
controls.ch(Color.gray);
showColor.setBackground(Color.gray);
////////////////////////////
}
else if(source==ColorGreen){
controls.ch(Color.green);
showColor.setBackground(Color.GREEN);
////////////////////////////
}
else if(source==ColorCyan){
controls.ch(Color.cyan);
showColor.setBackground(Color.cyan);
////////////////////////////
}
else if(source==Colorblue){
controls.ch(Color.blue);
showColor.setBackground(Color.blue);
////////////////////////////
}
else if(source==ColorWhite){
controls.ch(Color.white);
showColor.setBackground(Color.white);
////////////////////////////
}
else if (source==bj){
color = JColorChooser.showDialog(
DrawTest.this, "Choose a color", color );
if ( color == null )
{}
//*********
controls.ch(color);
showColor.setBackground(color);
}
}
//*****************************
//*****************************
public static void main(String args[]) {
String name =
JOptionPane.showInputDialog( "Enter the User name to open the program:" );
// create the message
if(!(name.equalsIgnoreCase("student"))){
String m1 =
String.format( "User name(%s ) isn't true!Try again!",name );
JOptionPane.showMessageDialog( null, m1 );
System.exit(0);}
else{
String message =
String.format( "Welcome to Painter Programming the User name (%s) correct==>", name );
JOptionPane.showMessageDialog( null, message );
}
Frame f = new Frame("Paint");
DrawTest drawTest = new DrawTest();
drawTest.init();
drawTest.start();
f.add("Center", drawTest);
f.setSize(800, 600);
f.show();
}
public String getAppletInfo() {
return "A simple drawing program.";
}
}
class DrawPanel extends Panel implements MouseListener, MouseMotionListener {
public static final int LINES = 0;
public static final int POINTS = 1;
public static final int BOX = 2;
public static final int CIRCLE = 3;
public static final int OVAL = 4;
public static final int ERASER = 5;
public static final int fillBOX = 6;
public static final int fillCIRCLE = 7;
public static final int fillOVAL = 8;
int mode = POINTS;
Vector lines = new Vector();
Vector box=new Vector();
Vector circle=new Vector();
Vector oval=new Vector();
Vector eraser=new Vector();
Vector fillbox=new Vector();
Vector fillcircle=new Vector();
Vector filloval=new Vector();
Vector colorsLines = new Vector();
Vector colorsBox = new Vector();
Vector colorsCircle = new Vector();
Vector colorsOval = new Vector();
Vector colorsEraser = new Vector();
Vector colorfillbox=new Vector();
Vector colorfillcircle=new Vector();
Vector colorfilloval=new Vector();
int x1,y1;
int x2,y2;
public DrawPanel() {
setBackground(Color.white);
addMouseMotionListener(this);
addMouseListener(this);
}
//*****************
public void destroy(int a) {
if(a==1){
lines.removeAllElements();
box.removeAllElements();
circle.removeAllElements();
oval.removeAllElements();
eraser.removeAllElements();
fillbox.removeAllElements();
fillcircle.removeAllElements();
filloval.removeAllElements();
colorsLines.removeAllElements();
colorsBox.removeAllElements();
colorsCircle.removeAllElements();
colorsOval.removeAllElements();
colorsEraser.removeAllElements();
colorfillbox.removeAllElements();
colorfillcircle.removeAllElements();
colorfilloval.removeAllElements();
}
else {}
}
//*********************
//*********************
public void setDrawMode(int mode) {
switch (mode) {
case LINES:
case POINTS:
case BOX:
case CIRCLE:
case OVAL:
case ERASER:
case fillBOX:
case fillCIRCLE:
case fillOVAL:
this.mode = mode;
break;
default:
throw new IllegalArgumentException();
}
}
public void mouseDragged(MouseEvent e) {
e.consume();
switch (mode) {
case CIRCLE:
case BOX:
case OVAL:
case LINES:
case fillBOX:
case fillCIRCLE:
case fillOVAL:
x2 = e.getX();
y2 = e.getY();
break;
case ERASER:
colorsEraser.addElement(getForeground());
eraser.addElement(new Rectangle(x1, y1, e.getX(), e.getY()));
x1 = e.getX();
y1 = e.getY();
break;
case POINTS:
default:
colorsLines.addElement(getForeground());
lines.addElement(new Rectangle(x1, y1, e.getX(), e.getY()));
x1 = e.getX();
y1 = e.getY();
break;
}
repaint();
}
public void mouseMoved(MouseEvent e) {
}
public void mousePressed(MouseEvent e) {
e.consume();
switch (mode) {
case CIRCLE:
case BOX:
case OVAL:
case LINES:
case fillBOX:
case fillCIRCLE:
case fillOVAL:
x1 = e.getX();
y1 = e.getY();
x2 = -1;
break;
case ERASER:
colorsEraser.addElement(getForeground());
eraser.addElement(new Rectangle(e.getX(), e.getY(), 5, 5));
x1 = e.getX();
y1 = e.getY();
repaint();
break;
case POINTS:
default:
colorsLines.addElement(getForeground());
lines.addElement(new Rectangle(e.getX(), e.getY(), -1, -1));
x1 = e.getX();
y1 = e.getY();
repaint();
break;
}
}
public void mouseReleased(MouseEvent e) {
e.consume();
switch (mode) {
case OVAL:
colorsOval.addElement(getForeground());
oval.addElement(new Rectangle(x1, y1, e.getX(), e.getY()));
x2 = -1;
break;
case CIRCLE:
colorsCircle.addElement(getForeground());
circle.addElement(new Rectangle(x1, y1, e.getX(), e.getY()));
x2 = -1;
break;
case BOX:
colorsBox.addElement(getForeground());
box.addElement(new Rectangle(x1, y1, e.getX(), e.getY()));
x2 = -1;
break;
case LINES:
colorsLines.addElement(getForeground());
lines.addElement(new Rectangle(x1, y1, e.getX(), e.getY()));
x2 = -1;
break;
/////////////////////////////////////
case fillBOX:
colorfillbox.addElement(getForeground());
fillbox.addElement(new Rectangle(x1, y1, e.getX(), e.getY()));
x2 = -1;
break;
case fillCIRCLE:
colorfillcircle.addElement(getForeground());
fillcircle.addElement(new Rectangle(x1, y1, e.getX(), e.getY()));
x2 = -1;
break;
case fillOVAL:
colorfilloval.addElement(getForeground());
filloval.addElement(new Rectangle(x1, y1, e.getX(), e.getY()));
x2 = -1;
break;
//////////////////////////////
case ERASER:
break;
case POINTS:
default:
break;
}
repaint();
}
public void mouseEntered(MouseEvent e) {
}
public void mouseExited(MouseEvent e) {
}
public void mouseClicked(MouseEvent e) {
}
public void paint(Graphics g) {
int i1,i2,i3,i4,i0,i5,i6,i7;
int n1 = lines.size();
int n2 = box.size();
int n3 = circle.size();
int n4 = oval.size();
int n0 = eraser.size();
int n5 = fillbox.size();
int n6 = fillcircle.size();
int n7 = filloval.size();
/* draw the current lines */
g.setColor(getForeground());
/////////////////////////
for ( i7=0; i7 < n7; i7++) {
Rectangle p = (Rectangle)filloval.elementAt(i7);
g.setColor((Color)colorfilloval.elementAt(i7));
if (p.width != -1) {
g.fillOval(p.x, p.y, p.width-p.x, p.height-p.y);
}
else
{
g.fillOval(p.x, p.y, p.x, p.y);
}
}
////**********************************************
//////////////////////////////////
for ( i5=0; i5 < n5; i5++) {
Rectangle p = (Rectangle)fillbox.elementAt(i5);
g.setColor((Color)colorfillbox.elementAt(i5));
if (p.width != -1) {
g.fillRect(p.x, p.y, p.width-p.x, p.height-p.y);
}
else
{
g.fillRect(p.x, p.y, p.x, p.y);
}
}
///////////////////////////////
//////////////---------------------------------
for ( i6=0; i6 < n6; i6++) {
Rectangle p = (Rectangle)fillcircle.elementAt(i6);
g.setColor((Color)colorfillcircle.elementAt(i6));
if (p.width != -1) {
////*****
int w1=p.width-p.x;
int w2=p.height-p.y;
if(w1>w2)
w1=w2;
else if(w1<w2)
w2=w1;
///*****
g.fillOval(p.x, p.y, w1,w2);
}
else
{
g.fillOval(p.x, p.y, p.x, p.y);
}
}
////////////////////////////////////////
for ( i1=0; i1 < n1; i1++) {
Rectangle p = (Rectangle)lines.elementAt(i1);
g.setColor((Color)colorsLines.elementAt(i1));
if (p.width != -1) {
g.drawLine(p.x, p.y, p.width, p.height);
}
else
{
g.drawLine(p.x, p.y, p.x, p.y);
}
}
//***********************
for ( i0=0; i0 < n0; i0++) {
Rectangle p = (Rectangle)eraser.elementAt(i0);
g.setColor((Color)colorsEraser.elementAt(i0));
if (p.width != -1) {
g.fillRect(p.x, p.y, 12, 12);
}
else
{
g.fillRect(p.x, p.y, p.x, p.y);
}
}
//************************
for ( i2=0; i2 < n2; i2++) {
Rectangle p = (Rectangle)box.elementAt(i2);
g.setColor((Color)colorsBox.elementAt(i2));
if (p.width != -1) {
g.drawRect(p.x, p.y, p.width-p.x, p.height-p.y);
}
else
{
g.drawRect(p.x, p.y, p.x, p.y);
}
}
////---------------------------------
//**************************
for ( i3=0; i3 < n3; i3++) {
Rectangle p = (Rectangle)circle.elementAt(i3);
g.setColor((Color)colorsCircle.elementAt(i3));
if (p.width != -1) {
////*****
int w1=p.width-p.x;
int w2=p.height-p.y;
if(w1>w2)
w1=w2;
else if(w1<w2)
w2=w1;
///*****
g.drawOval(p.x, p.y, w1,w2);
}
else
{
g.drawOval(p.x, p.y, p.x, p.y);
}
}
//********************************
for ( i4=0; i4 < n4; i4++) {
Rectangle p = (Rectangle)oval.elementAt(i4);
g.setColor((Color)colorsOval.elementAt(i4));
if (p.width != -1) {
g.drawOval(p.x, p.y, p.width-p.x, p.height-p.y);
}
else
{
g.drawOval(p.x, p.y, p.x, p.y);
}
}
//----------------------------------------------
if (mode == LINES) {
g.setColor(getForeground());
if (x2 != -1) {
g.drawLine(x1, y1, x2, y2);
}
}
//***********
if (mode == BOX) {
g.setColor(getForeground());
if (x2 != -2) {
g.drawRect(x1, y1, x2-x1, y2-y1);
}
}
//++++++++++++++++++++++++++++++++++++++++++
if (mode == fillBOX) {
g.setColor(getForeground());
if (x2 != -2) {
g.fillRect(x1, y1, x2-x1, y2-y1);
}
}
//***********
if (mode == CIRCLE) {
g.setColor(getForeground());
////*****
int r1=x2-x1;
int r2=y2-y1;
if(r1>r2){
r1=r2;
}
else if(r1<r2){
r2=r1;
}
///*****
if (x2 != -1) {
g.drawOval(x1, y1, r1, r2);
}
}
//++++++++++++++++++++++++++++++++++++++++++++++
if (mode == fillCIRCLE) {
g.setColor(getForeground());
////*****
int r1=x2-x1;
int r2=y2-y1;
if(r1>r2){
r1=r2;
}
else if(r1<r2){
r2=r1;
}
///*****
if (x2 != -1) {
g.fillOval(x1, y1, r1, r2);
}
}
//***************
if (mode == OVAL) {
g.setColor(getForeground());
if (x2 != -1) {
g.drawOval(x1, y1, x2-x1, y2-y1);
}
}
//+++++++++++++++++++++++++++++++++++++++++
if (mode == fillOVAL) {
g.setColor(getForeground());
if (x2 != -1) {
g.fillOval(x1, y1, x2-x1, y2-y1);
}
}
//---------------------------------------------
}
}
//***************************************************************
//***************************************************************
//***************************************************************
//***************************************************************
class DrawControls extends Panel implements ItemListener {
DrawPanel target;
public DrawControls(DrawPanel target) {
this.target = target;
setLayout(new BorderLayout());
setBackground(Color.LIGHT_GRAY);//panel color that contain list of choice the color and type of draw
target.setForeground(Color.black);
Choice s1 = new Choice();
s1.addItemListener(this);
s1.addItem("RED1");
s1.addItem("BLUE1");
s1.addItem("GREEN1");
s1.addItem("YELLOW1");
s1.addItem("BLACK1");
s1.addItem("WHITE1");
s1.addItem("CYAN1");
s1.addItem("ORANGE1");
s1.addItem("PINK1");
s1.addItem("MAGENTA1");
s1.setBackground(Color.yellow);
add(s1);
}
void ch(Color c){
target.setForeground(c);
}
public void itemStateChanged(ItemEvent e) {
if (e.getSource() instanceof Choice) {
String c=(String)e.getItem();
if(c.equals("RED1")){
target.setBackground(Color.red);
}
else if (c.equals("BLUE1")){
target.setBackground(Color.blue);
}
else if (c.equals("GREEN1")){
target.setBackground(Color.GREEN);
}
else if (c.equals("YELLOW1")){
target.setBackground(Color.YELLOW);
}
else if (c.equals("BLACK1")){
target.setBackground(Color.BLACK);
}
else if (c.equals("WHITE1")){
target.setBackground(Color.WHITE);
}
else if (c.equals("CYAN1")){
target.setBackground(Color.CYAN);
}
else if (c.equals("ORANGE1")){
target.setBackground(Color.ORANGE);
}
else if (c.equals("PINK1")){
target.setBackground(Color.PINK);
}
else if (c.equals("MAGENTA1")){
target.setBackground(Color.MAGENTA);
}
}
}
}
class myfram extends JFrame implements ActionListener{
private JTextArea textArea1;
private JTextArea textArea2;
private JButton cb;
private UIManager.LookAndFeelInfo[] looks;
private String[] lookNames;
private JRadioButton[] radio;
private ButtonGroup group;
private JButton button;
private JLabel label;
private JComboBox comboBox;
JMenuBar b;
JMenu mf;
JMenu mh;
JMenuItem mb;
JMenuItem me;
JMenuItem ma;
private JButton changeColorJButton;
private JButton changeColorJButton1;
private JButton changeColorJButton2;
private JButton changeColorJButton3;
Color color = Color.LIGHT_GRAY;
JPanel southPanel;
JPanel northPanel;
//***************************************************************
///************************************
public myfram(){
super("PAINTER");
Font f=new Font("Arial",Font.BOLD+Font.ITALIC,15);
Box box=Box.createHorizontalBox();
String d="this is ademo string to\n"+"illustrate copying text\nfrom one textarea to \n" +"naother textarea using an\nexternal event\n";
textArea1=new JTextArea (d,7,25);
box.add(new JScrollPane(textArea1));
cb=new JButton("******** The Text Selected In First Area Is => ********");
box.add(cb);
cb.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event){
textArea2.setText(textArea1.getSelectedText());
}
}
);
textArea2=new JTextArea(16,16);
textArea2.setEditable(false);
textArea2.setFont(f);
box.add(new JScrollPane(textArea2));
add(box);
///***********************************
looks = UIManager.getInstalledLookAndFeels();
lookNames = new String[ looks.length ];
for ( int i = 0; i < looks.length; i++ )
lookNames[ i ] = looks[ i ].getName();
northPanel = new JPanel();
northPanel.setLayout( new GridLayout( 3, 1, 0, 5 ) );
label = new JLabel( "This is a " + lookNames[0] + " look-and-feel",
SwingConstants.CENTER );
northPanel.add( label );
comboBox = new JComboBox( lookNames );
northPanel.add( comboBox );
radio = new JRadioButton[ looks.length ];
southPanel = new JPanel();
int rows = (int) Math.ceil( radio.length / 3.0 );
southPanel.setLayout( new GridLayout( rows, 3 ) );
group = new ButtonGroup();
ItemHandler handler = new ItemHandler();
for ( int count = 0; count < radio.length; count++ )
{
radio[ count ] = new JRadioButton( lookNames[ count ] );
radio[ count ].addItemListener( handler );
group.add( radio[ count ] );
southPanel.add( radio[ count ] );
} // end for
add( northPanel, BorderLayout.NORTH );
add( southPanel, BorderLayout.SOUTH );
radio[ 0 ].setSelected( true );
in();
setLayout(new FlowLayout());
setSize(1025,738);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setVisible(true);
///****************************************************
///*****************************************************
changeColorJButton = new JButton( "Change Color The Second Text Area " );
changeColorJButton.addActionListener(
new ActionListener()
{
public void actionPerformed( ActionEvent event )
{
color = JColorChooser.showDialog(
myfram.this, "Choose a color", color );
if ( color == null )
{
}
//*********
textArea2.setBackground(color);
//************
}
}
);
////***********************************************
changeColorJButton1 = new JButton( "Change Color The Text in Second Area " );
changeColorJButton1.addActionListener(
new ActionListener()
{
public void actionPerformed( ActionEvent event )
{
color = JColorChooser.showDialog(
myfram.this, "Choose a color", color );
if ( color == null )
{
}
//*********
textArea2.setForeground(color);
//************
}
}
);
//*******************************************
///*******************************************
changeColorJButton2 = new JButton( "Change Color first Text Area " );
changeColorJButton2.addActionListener(
new ActionListener()
{
public void actionPerformed( ActionEvent event )
{
color = JColorChooser.showDialog(
myfram.this, "Choose a color", color );
if ( color == null )
{
}
//*********
textArea1.setBackground(color);
//************
}
}
);
////***********************************************
changeColorJButton3 = new JButton( "Change Color The Text in first area " );
changeColorJButton3.addActionListener(
new ActionListener()
{
public void actionPerformed( ActionEvent event )
{
color = JColorChooser.showDialog(
myfram.this, "Choose a color", color );
if ( color == null )
{
}
//*********
textArea1.setForeground(color);
//************
}
}
);
/////**********************************************
////**********************************************
add( changeColorJButton2, BorderLayout.SOUTH );
add( changeColorJButton3, BorderLayout.SOUTH );
add( changeColorJButton, BorderLayout.SOUTH );
add( changeColorJButton1, BorderLayout.SOUTH );
setSize(getWidth(), getHeight() );
setVisible( true );
setBackground(color);
}
void in(){
final Container c=getContentPane();
b=new JMenuBar();
setJMenuBar(b);
mb=new JMenuItem("Change The Color of Panel");
mb.setMnemonic('B');
me=new JMenuItem("Exit");
me.setMnemonic('X');
ma=new JMenuItem("About");
ma.setMnemonic('A');
mf=new JMenu("File");
mf.setMnemonic('F');
mf.add(mb);
mf.add(me);
mh=new JMenu("Help");
mh.setMnemonic('H');
mh.add(ma);
b.add(mf);
b.add(mh);
mb.addActionListener(this);
me.addActionListener(this);
ma.addActionListener(this);
}
public void actionPerformed(ActionEvent event){
Object o=event.getSource();
if(o==ma){
JOptionPane.showMessageDialog(null,"This is simple painter program ");
}
else if (o==mb){
color = JColorChooser.showDialog(
myfram.this, "Choose a color", color );
if ( color == null ){}
//*********
getContentPane().setBackground(color);
southPanel.setBackground(color);
northPanel.setBackground(color);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
else if (o==me){
String name =
JOptionPane.showInputDialog( "Are You sure that you want To Exit? if NO enter ( NO ) " );
if((name.equalsIgnoreCase("NO"))){
String m1 =
String.format( "The Prpgram Isn't Exit!","" );
JOptionPane.showMessageDialog( null, m1 );
}
else{
String message =
String.format( "The Program Will Exit!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ", name );
JOptionPane.showMessageDialog( null, message );
System.exit(0);
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
private void changeTheLookAndFeel( int value )
{
try
{
UIManager.setLookAndFeel( looks[ value ].getClassName() );
SwingUtilities.updateComponentTreeUI( this );
}
catch ( Exception exception )
{
exception.printStackTrace();
}
}
private class ItemHandler implements ItemListener
{
public void itemStateChanged( ItemEvent event )
{
for ( int count = 0; count < radio.length; count++ )
{
if ( radio[ count ].isSelected() )
{
label.setText( String.format(
"This is a %s look-and-feel", lookNames[ count ] ) );
comboBox.setSelectedIndex( count );
changeTheLookAndFeel( count );
}
}
}
}
}
class s extends Panel implements MouseListener{
Label l;
s(){
l=new Label("-----------------");
addMouseListener(this);
add(l);
}
public void mouseClicked(MouseEvent e){}
public void mouseReleased(MouseEvent e){}
public void mousePressed(MouseEvent e){
GregorianCalendar c=new GregorianCalendar();
l.setText(c.getTime().toString());
}
public void mouseEntered(MouseEvent e){
setBackground(Color.black);
}
public void mouseExited (MouseEvent e){
setBackground(Color.gray);
}
}