⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nimrodtextfieldui.java

📁 NimROD L&F是一个具有多种主题的Swing皮肤
💻 JAVA
字号:
/* *                 (C) Copyright 2005 Nilo J. Gonzalez * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser Gereral Public Licence as published by the Free * Software Foundation; either version 2 of the Licence, or (at your opinion) any * later version. *  * This library is distributed in the hope that it will be usefull, but WITHOUT ANY * WARRANTY; without even the implied warranty of merchantability or fitness for a * particular purpose. See the GNU Lesser General Public Licence for more details. *  * You should have received a copy of the GNU Lesser General Public Licence along * with this library; if not, write to the Free Software Foundation, Inc., 59 * Temple Place, Suite 330, Boston, Ma 02111-1307 USA. * * http://www.gnu.org/licenses/lgpl.html (English) * http://gugs.sindominio.net/gnu-gpl/lgpl-es.html (Espa駉l) * * * Original author: Nilo J. Gonz醠ez */ /** * Esta clase implementa los TextField. * Esta clase se usa desde un monton de sitios (Combos, PasswordField...), asi que extenderla * tiene resultados mas alla de los campos de texto. * @author Nilo J. Gonzalez */  package com.nilo.plaf.nimrod;import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.text.*;import javax.swing.plaf.*;import javax.swing.plaf.basic.*;public class NimRODTextFieldUI extends BasicTextFieldUI {  private boolean rollover = false;  private boolean focus = false;  private MiTextML miTextML;    NimRODTextFieldUI( JComponent c) {    super();  }  public static ComponentUI createUI( JComponent c) {    return new NimRODTextFieldUI( c);  }    protected  void installListeners() {    super.installListeners();    miTextML = new MiTextML();    getComponent().addMouseListener( miTextML);    getComponent().addFocusListener( miTextML);  }    protected  void uninstallListeners() {    super.uninstallListeners();    getComponent().removeMouseListener( miTextML);    getComponent().removeFocusListener( miTextML);  }    protected void paintBackground( Graphics g) {    super.paintBackground( g);        JTextComponent c = (JTextComponent)getComponent();    if ( c.getBorder() != null ) {      NimRODUtils.paintFocus( g, 0,0, c.getWidth()-1, c.getHeight()-1, 0, 0, 3.0f, NimRODLookAndFeel.getControl());    }        if ( (focus || rollover ) && c.isEnabled() && c.isEditable() ) {      if ( focus ) {        NimRODUtils.paintFocus( g, 1, 1, c.getWidth()-2, c.getHeight()-2, 2, 2, NimRODLookAndFeel.getFocusColor());      }      else if ( rollover ) {        NimRODUtils.paintFocus( g, 1, 1, c.getWidth()-2, c.getHeight()-2, 2, 2, NimRODUtils.getColorAlfa( NimRODLookAndFeel.getFocusColor(), 150));      }    }  }    //////////////////////////    public class MiTextML extends MouseAdapter implements FocusListener{    public void mouseExited( MouseEvent e) {      rollover = false;      getComponent().repaint();    }        public void mouseEntered( MouseEvent e) {      rollover = true;      getComponent().repaint();    }        public void focusGained( FocusEvent e) {      focus = true;      getComponent().repaint();    }          public void focusLost( FocusEvent e) {        focus = false;        getComponent().repaint();    }  }  }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -