Class ButtonLess

public class ButtonLess
extends MouseAdapter
implements MouseMotionListener

Title: CS187 - Project 3

Description: class representing a butonless mouse

CGWU CS187 Design of User Interface

Version:
1.0
Author:
Grace (Eun H.) Cho
Field Detail

enterTimer

Timer enterTimer
Timer monitroing enter action

exitTimer

Timer exitTimer
Timer monitoing exit action - right now, not much of use

insideTimer

Timer insideTimer
Timer monitoring action inside the component

NO_DELAY

public static final int NO_DELAY
Delay amount: no delay

SHORT_DELAY

public static final int SHORT_DELAY
Delay amount: short delay

MID_DELAY

public static final int MID_DELAY
Delay amount: medium delay

LONG_DELAY

public static final int LONG_DELAY
Delay amount: long delay

Flag_

private static boolean Flag_
For JPanel color switch

First_

private static boolean First_
For JPanel

currentComponent_

private JComponent currentComponent_
The component that the buttonless mouse is actiong on

mouseEvent_

private MouseEvent mouseEvent_
Mouse Event

jump_

private boolean jump_
For JSlider and JScrollBar: if jump_=true: jump, slide/scroll, otherwise

debug_

private boolean debug_
Debug flag

Ier_

private int Ier_
Error Code

Constructor Detail

ButtonLess

public ButtonLess()

Construct a buttonless mouse by creating enterTimer, exitTimer, and insideTimer.

The enterTimer and exitTimer's delay is set as the default NO_DELAY. The insideTimer's delay is set as the default SHORT_DELAY

ButtonLess

public ButtonLess(int insideDelay)

Construct a buttonless mouse by creating enterTimer, exitTimer, and insideTimer

The enterTimer and exitTimer's delay is set as the default NO_DELAY. The insideTimer's delay is set by the given "insideDelay"
Parameters:
insideDelay - int

Method Detail

getDelay

public int getDelay()
Returns the delay before click, in milliseconds
Returns:
an integer representing the delay value before clicking, in milliseconds

getInitialDelay

public int getInitialDelay()
Returns the initial delay value.
Returns:
an integer representing the initial delay value, in milliseconds

setDelay

public void setDelay(int delay)
Set delay before click, in milliseconds
Parameters:
delay - the number of milliseconds to delay before clicking the button

setInitialDelay

public void setInitialDelay(int delay)
Specifies the delay value.
Parameters:
delay - the number of milliseconds to delay (after the cursor has paused) before displaying the tooltip
See Also:
#getDelay

setJump

public void setJump(boolean jump)
Parameters:
jump - boolean

registerComponent

public void registerComponent(JComponent component)
Registers a component to the mouseListener.
Parameters:
component - JComponent

unregisterComponent

public void unregisterComponent(JComponent component)
Unregisters a component to the mouseListener.
Parameters:
component - JComponent

mouseClicked

public void mouseClicked(MouseEvent event)

Override MouseAdapter.mouseClicked - called when the mouse is clicked on this component.

Stop all Timers and set currentComponent_ = null. (so that no action would be taken by the buttonless mouse, until the mouse exit and reenters.)
Parameters:
event - MouseEvent

mouseEntered

public void mouseEntered(MouseEvent event)

Override MouseAdapter.mouseEntered - called when the mouse enters to this component.

Stop the exitTimer; Restart the enterTimer and InsideTimer.
Parameters:
event - MouseEvent

mouseExited

public void mouseExited(MouseEvent event)

Override MouseAdapter.mouseExited - called when the mouse exits from this component.

Stop all Timers and set currentComponent_ = null.
Parameters:
event - the event in question

mousePressed

public void mousePressed(MouseEvent event)

Override MouseAdapter.mousePressed - called when the mouse button is pressed on this component.

Stop all Timers and set currentComponent_ = null.
Parameters:
event - the event in question

mouseReleased

public void mouseReleased(MouseEvent event)

Override MouseAdapter.mouseReleased - called when the mouse button is released on this component.

Stop all Timers and set currentComponent_ = null.
Parameters:
event - the event in question

mouseDragged

public void mouseDragged(MouseEvent event)

Override MouseMotionListener.mouseDragged - called when the mouse is pressed and dragged.

Right now, does nothing
Parameters:
event - the event in question

mouseMoved

public void mouseMoved(MouseEvent event)

Override MouseMotionListener.mouseMoved - called when the mouse is moved.

Right now, does nothing
Parameters:
event - the event in question

doSomething_

private void doSomething_(JComponent component)
Calls appropriate action depending on the component
Parameters:
component - JComponent

backToDefault_

private void backToDefault_(JComponent component)
For some component: set the default values - So far, only for JPanel
Parameters:
component - JComponent

click_

private void click_(AbstractButton button)
Simulate mouse click on a button
Parameters:
button - AbstractButton

changeCaretPosition_

private void changeCaretPosition_(JTextComponent textComp)
Simulate mouse click on a text field
Parameters:
textComp - JTextComponent

slide_

private void slide_(JSlider slider,
                    boolean jump)
Simulate mouse click on a slider
Parameters:
slider - JSlider
jump - boolean

scroll_

private void scroll_(JScrollBar scrollBar,
                     boolean jump)
Simulate mouse click on a scroll bar
Parameters:
scrollBar - JScrollBar
jump - boolean

panelShow_

private void panelShow_(JPanel panel)
Parameters:
panel - JPanel

normalized_

private int normalized_(double pos,
                        double width,
                        double length,
                        int range)
Given the position of the mouse, compute the corresponding value for the model
Parameters:
pos - double
width - int
length - int
range - int
Returns:
int

print_

private void print_(String eventDescription,
                    MouseEvent event)
Print debug statements
Parameters:
eventDescription - String
event - MouseEvent

print_

private void print_(ButtonLessTimerListener listener)
Print debug statements
Parameters:
listener - ButtonLessTimerListener

print_

private void print_(String st)
Print debug statements
Parameters:
st - String

Hosted by www.Geocities.ws

1