Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.util.swing.plaf
Class SIPCommTextFieldUI

java.lang.Object
  extended by javax.swing.plaf.ComponentUI
      extended by javax.swing.plaf.TextUI
          extended by javax.swing.plaf.basic.BasicTextUI
              extended by javax.swing.plaf.basic.BasicTextFieldUI
                  extended by javax.swing.plaf.metal.MetalTextFieldUI
                      extended by net.java.sip.communicator.util.swing.plaf.SIPCommTextFieldUI
All Implemented Interfaces:
MouseListener, MouseMotionListener, EventListener, ViewFactory, Skinnable
Direct Known Subclasses:
DialPadFieldUI, GlobalShortcutDialog.ShortcutFieldUI, SearchFieldUI

public class SIPCommTextFieldUI
extends MetalTextFieldUI
implements Skinnable, MouseMotionListener, MouseListener

SIPCommTextFieldUI implementation.

Author:
Yana Stamcheva, Adam Netocny

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.plaf.basic.BasicTextUI
BasicTextUI.BasicCaret, BasicTextUI.BasicHighlighter
 
Field Summary
protected static int BUTTON_GAP
          The gap between the delete button and the text in the field.
protected  SIPCommButton deleteButton
          The delete text button shown on the right of the field.
protected  boolean isDeleteMouseOver
          Indicates if the mouse is currently over the delete button.
 
Constructor Summary
SIPCommTextFieldUI()
          Creates a SIPCommTextFieldUI.
 
Method Summary
static ComponentUI createUI(JComponent c)
          Creates a UI for a SIPCommTextFieldUI.
protected  void customPaintBackground(Graphics g)
          Paints the background of the associated component.
protected  Rectangle getDeleteButtonRect()
          Calculates the delete button rectangle.
protected  Rectangle getVisibleEditorRect()
          If we are in the case of disabled delete button, we simply call the parent implementation of this method, otherwise we recalculate the editor rectangle in order to leave place for the delete button.
protected  void installListeners()
          Adds the custom mouse listeners defined in this class to the installed listeners.
 boolean isDeleteButtonEnabled()
          Returns true if the delete buttons is enabled and false - otherwise.
 void loadSkin()
          Reloads skin information.
 void mouseClicked(MouseEvent e)
          Updates the delete icon when the mouse was clicked.
 void mouseDragged(MouseEvent e)
          Updates the delete icon when the mouse is dragged over.
 void mouseEntered(MouseEvent e)
          Updates the delete icon when the mouse is enters the component area.
 void mouseExited(MouseEvent e)
          Updates the delete icon when the mouse exits the component area.
 void mouseMoved(MouseEvent e)
          Updates the delete icon when the mouse is moved over.
 void mousePressed(MouseEvent e)
           
 void mouseReleased(MouseEvent e)
           
 void setBgBorderEndColor(Color bgBorderEndColor)
           
 void setBgBorderStartColor(Color bgBorderStartColor)
           
 void setBgEndColor(Color bgEndColor)
           
 void setBgStartColor(Color bgStartColor)
           
 void setDeleteButtonEnabled(boolean isDeleteButtonEnabled)
          Updates the isDeleteButtonEnabled field.
protected  void uninstallListeners()
          Uninstalls listeners for the UI.
protected  void updateDeleteIcon(MouseEvent evt)
          Updates the delete icon, changes the cursor and deletes the content of the associated text component when the mouse is pressed over the delete icon.
 
Methods inherited from class javax.swing.plaf.metal.MetalTextFieldUI
propertyChange
 
Methods inherited from class javax.swing.plaf.basic.BasicTextFieldUI
create, getBaseline, getBaselineResizeBehavior, getPropertyPrefix
 
Methods inherited from class javax.swing.plaf.basic.BasicTextUI
create, createCaret, createHighlighter, createKeymap, damageRange, damageRange, getComponent, getEditorKit, getKeymapName, getMaximumSize, getMinimumSize, getNextVisualPositionFrom, getPreferredSize, getRootView, getToolTipText, installDefaults, installKeyboardActions, installUI, modelChanged, modelToView, modelToView, paint, paintBackground, paintSafely, setView, uninstallDefaults, uninstallKeyboardActions, uninstallUI, update, viewToModel, viewToModel
 
Methods inherited from class javax.swing.plaf.ComponentUI
contains, getAccessibleChild, getAccessibleChildrenCount
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

isDeleteMouseOver

protected boolean isDeleteMouseOver
Indicates if the mouse is currently over the delete button.


BUTTON_GAP

protected static int BUTTON_GAP
The gap between the delete button and the text in the field.


deleteButton

protected SIPCommButton deleteButton
The delete text button shown on the right of the field.

Constructor Detail

SIPCommTextFieldUI

public SIPCommTextFieldUI()
Creates a SIPCommTextFieldUI.

Method Detail

isDeleteButtonEnabled

public boolean isDeleteButtonEnabled()
Returns true if the delete buttons is enabled and false - otherwise.

Returns:
true if the delete buttons is enabled and false - otherwise

setDeleteButtonEnabled

public void setDeleteButtonEnabled(boolean isDeleteButtonEnabled)
Updates the isDeleteButtonEnabled field.

Parameters:
isDeleteButtonEnabled - indicates if the delete buttons is enabled or not

installListeners

protected void installListeners()
Adds the custom mouse listeners defined in this class to the installed listeners.

Overrides:
installListeners in class BasicTextUI

uninstallListeners

protected void uninstallListeners()
Uninstalls listeners for the UI.

Overrides:
uninstallListeners in class BasicTextUI

customPaintBackground

protected void customPaintBackground(Graphics g)
Paints the background of the associated component.

Parameters:
g - the Graphics object used for painting

updateDeleteIcon

protected void updateDeleteIcon(MouseEvent evt)
Updates the delete icon, changes the cursor and deletes the content of the associated text component when the mouse is pressed over the delete icon.

Parameters:
evt - the mouse event that has prompted us to update the delete icon.

getDeleteButtonRect

protected Rectangle getDeleteButtonRect()
Calculates the delete button rectangle.

Returns:
the delete button rectangle

getVisibleEditorRect

protected Rectangle getVisibleEditorRect()
If we are in the case of disabled delete button, we simply call the parent implementation of this method, otherwise we recalculate the editor rectangle in order to leave place for the delete button.

Overrides:
getVisibleEditorRect in class BasicTextUI
Returns:
the visible editor rectangle

setBgStartColor

public void setBgStartColor(Color bgStartColor)
Parameters:
bgStartColor - the bgStartColor to set

setBgEndColor

public void setBgEndColor(Color bgEndColor)
Parameters:
bgEndColor - the bgEndColor to set

setBgBorderStartColor

public void setBgBorderStartColor(Color bgBorderStartColor)
Parameters:
bgBorderStartColor - the bgBorderStartColor to set

setBgBorderEndColor

public void setBgBorderEndColor(Color bgBorderEndColor)
Parameters:
bgBorderEndColor - the bgBorderEndColor to set

loadSkin

public void loadSkin()
Reloads skin information.

Specified by:
loadSkin in interface Skinnable

mouseClicked

public void mouseClicked(MouseEvent e)
Updates the delete icon when the mouse was clicked.

Specified by:
mouseClicked in interface MouseListener
Parameters:
e - the MouseEvent that notified us of the click

mouseEntered

public void mouseEntered(MouseEvent e)
Updates the delete icon when the mouse is enters the component area.

Specified by:
mouseEntered in interface MouseListener
Parameters:
e - the MouseEvent that notified us

mouseExited

public void mouseExited(MouseEvent e)
Updates the delete icon when the mouse exits the component area.

Specified by:
mouseExited in interface MouseListener
Parameters:
e - the MouseEvent that notified us

mousePressed

public void mousePressed(MouseEvent e)
Specified by:
mousePressed in interface MouseListener

mouseReleased

public void mouseReleased(MouseEvent e)
Specified by:
mouseReleased in interface MouseListener

mouseDragged

public void mouseDragged(MouseEvent e)
Updates the delete icon when the mouse is dragged over.

Specified by:
mouseDragged in interface MouseMotionListener
Parameters:
e - the MouseEvent that notified us

mouseMoved

public void mouseMoved(MouseEvent e)
Updates the delete icon when the mouse is moved over.

Specified by:
mouseMoved in interface MouseMotionListener
Parameters:
e - the MouseEvent that notified us

createUI

public static ComponentUI createUI(JComponent c)
Creates a UI for a SIPCommTextFieldUI.

Parameters:
c - the text field
Returns:
the UI

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.