GrayColorChooser
Class GrayColorChooser

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Window
                    |
                    +--java.awt.Frame
                          |
                          +--GrayColorChooser.GrayColorChooser

public class GrayColorChooser
extends Frame
implements MouseListener, WindowListener, MouseMotionListener

This class create a gray color chooser.

Version:
1.0
Author:
Sebastien Baehni
See Also:
Serialized Form

Field Summary
protected  Label choosen_color
          The label for the choosen color.
protected  boolean clicked
          Tells if the user has clicked or not on a color.
protected  int colorClicked
          The value of the color that the user has clicked on.
protected  boolean colorFrameOpen
          Tells if the frame is open or not.
protected  Label current_color
          The label for the current color.
protected  Label gray
          The Label for the current gray value.
protected  GrayCanvas gray_canvas
          The canvas containing the gray palette.
protected  Label gray_choosen
          The Label for the choosen gray value.
protected  Label informations
          The information Label.
 
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
GrayColorChooser()
          The main constructor.
 
Method Summary
 boolean clicked()
          This method returns if the user has clicked on the frame in order to choose a color or not.
 void clicked(boolean set)
          This method set the clicked parameters.
 int colorClicked()
          This method returns the rgb value of the color choosen by the user.
 boolean colorFrameOpen()
          This method returns if the frame is open or not.
 void mouseClicked(MouseEvent e)
          This method capture the mouse clicked event and then we refresh the choosen color.
 void mouseDragged(MouseEvent e)
          The different functions re-implemented for a dragging mouse.
 void mouseEntered(MouseEvent e)
          When we enter the canvas, we refresh the gray label and the current color.
 void mouseExited(MouseEvent e)
          When we exit the canvas, we refresh the gray label.
 void mouseMoved(MouseEvent e)
          If the mouse is moved in the canvas, we refresh the label and the current color.
 void mousePressed(MouseEvent e)
          When the mouse is pressed.
 void mouseReleased(MouseEvent e)
          When the mouse is released.
 void start()
          We show the window and then we paint the canvas.
 void windowActivated(WindowEvent e)
          When you active the window.
 void windowClosed(WindowEvent e)
          When you close the window.
 void windowClosing(WindowEvent e)
          To close the window.
 void windowDeactivated(WindowEvent e)
          When you deactivate the window.
 void windowDeiconified(WindowEvent e)
          When you deiconify the window.
 void windowIconified(WindowEvent e)
          When you iconify the window.
 void windowOpened(WindowEvent e)
          When you open the window.
 
Methods inherited from class java.awt.Frame
addNotify, finalize, getCursorType, getFrames, getIconImage, getMenuBar, getState, getTitle, isResizable, paramString, remove, removeNotify, setCursor, setIconImage, setMenuBar, setResizable, setState, setTitle
 
Methods inherited from class java.awt.Window
addWindowListener, applyResourceBundle, applyResourceBundle, dispose, getFocusOwner, getInputContext, getLocale, getOwnedWindows, getOwner, getToolkit, getWarningString, isShowing, pack, postEvent, processEvent, processWindowEvent, removeWindowListener, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, remove, removeAll, removeContainerListener, setFont, setLayout, update, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputMethodRequests, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

gray

protected Label gray
The Label for the current gray value.

gray_choosen

protected Label gray_choosen
The Label for the choosen gray value.

choosen_color

protected Label choosen_color
The label for the choosen color.

current_color

protected Label current_color
The label for the current color.

informations

protected Label informations
The information Label.

gray_canvas

protected GrayCanvas gray_canvas
The canvas containing the gray palette.

colorFrameOpen

protected boolean colorFrameOpen
Tells if the frame is open or not.

colorClicked

protected int colorClicked
The value of the color that the user has clicked on.

clicked

protected boolean clicked
Tells if the user has clicked or not on a color.
Constructor Detail

GrayColorChooser

public GrayColorChooser()
The main constructor. It places the different fields of the frame to have a estetic view of the all.
Method Detail

start

public void start()
We show the window and then we paint the canvas.

mouseClicked

public void mouseClicked(MouseEvent e)
This method capture the mouse clicked event and then we refresh the choosen color.
Specified by:
mouseClicked in interface MouseListener
Parameters:
e - The mouse event.

mousePressed

public void mousePressed(MouseEvent e)
When the mouse is pressed.
Specified by:
mousePressed in interface MouseListener
Parameters:
e - The mouse event.

mouseReleased

public void mouseReleased(MouseEvent e)
When the mouse is released.
Specified by:
mouseReleased in interface MouseListener
Parameters:
e - The mouse event.

mouseEntered

public void mouseEntered(MouseEvent e)
When we enter the canvas, we refresh the gray label and the current color.
Specified by:
mouseEntered in interface MouseListener
Parameters:
e - The mouse event.

mouseExited

public void mouseExited(MouseEvent e)
When we exit the canvas, we refresh the gray label.
Specified by:
mouseExited in interface MouseListener
Parameters:
e - The mouse event.

mouseDragged

public void mouseDragged(MouseEvent e)
The different functions re-implemented for a dragging mouse.
Specified by:
mouseDragged in interface MouseMotionListener
Parameters:
e - The mouse event.

mouseMoved

public void mouseMoved(MouseEvent e)
If the mouse is moved in the canvas, we refresh the label and the current color.
Specified by:
mouseMoved in interface MouseMotionListener
Parameters:
e - The mouse event.

windowClosing

public void windowClosing(WindowEvent e)
To close the window.
Specified by:
windowClosing in interface WindowListener
Parameters:
e - The window event.

windowOpened

public void windowOpened(WindowEvent e)
When you open the window.
Specified by:
windowOpened in interface WindowListener
Parameters:
e - The window event.

windowIconified

public void windowIconified(WindowEvent e)
When you iconify the window.
Specified by:
windowIconified in interface WindowListener
Parameters:
e - The window event.

windowDeiconified

public void windowDeiconified(WindowEvent e)
When you deiconify the window.
Specified by:
windowDeiconified in interface WindowListener
Parameters:
e - The window event.

windowDeactivated

public void windowDeactivated(WindowEvent e)
When you deactivate the window.
Specified by:
windowDeactivated in interface WindowListener
Parameters:
e - The window event.

windowClosed

public void windowClosed(WindowEvent e)
When you close the window.
Specified by:
windowClosed in interface WindowListener
Parameters:
e - The window event.

windowActivated

public void windowActivated(WindowEvent e)
When you active the window.
Specified by:
windowActivated in interface WindowListener
Parameters:
e - The window event.

colorFrameOpen

public boolean colorFrameOpen()
This method returns if the frame is open or not.
Returns:
True is the frame is open, false otherwise.

colorClicked

public int colorClicked()
This method returns the rgb value of the color choosen by the user.
Returns:
The rgb value of the color choosen by the user.

clicked

public boolean clicked()
This method returns if the user has clicked on the frame in order to choose a color or not.
Returns:
True if the user has clicked on the color frame.

clicked

public void clicked(boolean set)
This method set the clicked parameters.
Parameters:
set - Set the clicked parameters to the set value.