com.alee.laf.text.WebTextArea Maven / Gradle / Ivy
/*
* This file is part of WebLookAndFeel library.
*
* WebLookAndFeel library is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* WebLookAndFeel library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with WebLookAndFeel library. If not, see .
*/
package com.alee.laf.text;
import com.alee.extended.painter.Painter;
import com.alee.laf.WebLookAndFeel;
import com.alee.managers.language.LanguageManager;
import com.alee.managers.language.LanguageMethods;
import com.alee.managers.language.updaters.LanguageUpdater;
import com.alee.managers.settings.DefaultValue;
import com.alee.managers.settings.SettingsManager;
import com.alee.managers.settings.SettingsMethods;
import com.alee.managers.settings.SettingsProcessor;
import com.alee.utils.ReflectUtils;
import com.alee.utils.SwingUtils;
import com.alee.utils.swing.FontMethods;
import javax.swing.*;
import javax.swing.text.Document;
import java.awt.*;
/**
* User: mgarin Date: 22.08.11 Time: 12:40
*/
public class WebTextArea extends JTextArea implements LanguageMethods, SettingsMethods, FontMethods
{
public WebTextArea ()
{
super ();
}
public WebTextArea ( final String text )
{
super ( text );
}
public WebTextArea ( final int rows, final int columns )
{
super ( rows, columns );
}
public WebTextArea ( final String text, final int rows, final int columns )
{
super ( text, rows, columns );
}
public WebTextArea ( final Document doc )
{
super ( doc );
}
public WebTextArea ( final Document doc, final String text, final int rows, final int columns )
{
super ( doc, text, rows, columns );
}
/**
* Additional component methods
*/
public void clear ()
{
setText ( "" );
}
/**
* UI methods
*/
public void setMargin ( final int top, final int left, final int bottom, final int right )
{
setMargin ( new Insets ( top, left, bottom, right ) );
}
public void setMargin ( final int spacing )
{
setMargin ( spacing, spacing, spacing, spacing );
}
public String getInputPrompt ()
{
return getWebUI ().getInputPrompt ();
}
public void setInputPrompt ( final String inputPrompt )
{
getWebUI ().setInputPrompt ( inputPrompt );
}
public Font getInputPromptFont ()
{
return getWebUI ().getInputPromptFont ();
}
public void setInputPromptFont ( final Font inputPromptFont )
{
getWebUI ().setInputPromptFont ( inputPromptFont );
}
public Color getInputPromptForeground ()
{
return getWebUI ().getInputPromptForeground ();
}
public void setInputPromptForeground ( final Color inputPromptForeground )
{
getWebUI ().setInputPromptForeground ( inputPromptForeground );
}
public int getInputPromptHorizontalPosition ()
{
return getWebUI ().getInputPromptHorizontalPosition ();
}
public void setInputPromptHorizontalPosition ( final int inputPromptHorizontalPosition )
{
getWebUI ().setInputPromptHorizontalPosition ( inputPromptHorizontalPosition );
}
public int getInputPromptVerticalPosition ()
{
return getWebUI ().getInputPromptVerticalPosition ();
}
public void setInputPromptVerticalPosition ( final int inputPromptVerticalPosition )
{
getWebUI ().setInputPromptVerticalPosition ( inputPromptVerticalPosition );
}
public boolean isHideInputPromptOnFocus ()
{
return getWebUI ().isHideInputPromptOnFocus ();
}
public void setHideInputPromptOnFocus ( final boolean hideInputPromptOnFocus )
{
getWebUI ().setHideInputPromptOnFocus ( hideInputPromptOnFocus );
}
public Painter getPainter ()
{
return getWebUI ().getPainter ();
}
public void setPainter ( final Painter painter )
{
getWebUI ().setPainter ( painter );
}
public WebTextAreaUI getWebUI ()
{
return ( WebTextAreaUI ) getUI ();
}
@Override
public void updateUI ()
{
if ( getUI () == null || !( getUI () instanceof WebTextAreaUI ) )
{
try
{
setUI ( ( WebTextAreaUI ) ReflectUtils.createInstance ( WebLookAndFeel.textAreaUI ) );
}
catch ( final Throwable e )
{
e.printStackTrace ();
setUI ( new WebTextAreaUI () );
}
}
else
{
setUI ( getUI () );
}
invalidate ();
}
/**
* Language methods
*/
/**
* {@inheritDoc}
*/
@Override
public void setLanguage ( final String key, final Object... data )
{
LanguageManager.registerComponent ( this, key, data );
}
/**
* {@inheritDoc}
*/
@Override
public void updateLanguage ( final Object... data )
{
LanguageManager.updateComponent ( this, data );
}
/**
* {@inheritDoc}
*/
@Override
public void updateLanguage ( final String key, final Object... data )
{
LanguageManager.updateComponent ( this, key, data );
}
/**
* {@inheritDoc}
*/
@Override
public void removeLanguage ()
{
LanguageManager.unregisterComponent ( this );
}
/**
* {@inheritDoc}
*/
@Override
public boolean isLanguageSet ()
{
return LanguageManager.isRegisteredComponent ( this );
}
/**
* {@inheritDoc}
*/
@Override
public void setLanguageUpdater ( final LanguageUpdater updater )
{
LanguageManager.registerLanguageUpdater ( this, updater );
}
/**
* {@inheritDoc}
*/
@Override
public void removeLanguageUpdater ()
{
LanguageManager.unregisterLanguageUpdater ( this );
}
/**
* Settings methods
*/
/**
* {@inheritDoc}
*/
@Override
public void registerSettings ( final String key )
{
SettingsManager.registerComponent ( this, key );
}
/**
* {@inheritDoc}
*/
@Override
public void registerSettings ( final String key, final Class defaultValueClass )
{
SettingsManager.registerComponent ( this, key, defaultValueClass );
}
/**
* {@inheritDoc}
*/
@Override
public void registerSettings ( final String key, final Object defaultValue )
{
SettingsManager.registerComponent ( this, key, defaultValue );
}
/**
* {@inheritDoc}
*/
@Override
public void registerSettings ( final String group, final String key )
{
SettingsManager.registerComponent ( this, group, key );
}
/**
* {@inheritDoc}
*/
@Override
public void registerSettings ( final String group, final String key, final Class defaultValueClass )
{
SettingsManager.registerComponent ( this, group, key, defaultValueClass );
}
/**
* {@inheritDoc}
*/
@Override
public void registerSettings ( final String group, final String key, final Object defaultValue )
{
SettingsManager.registerComponent ( this, group, key, defaultValue );
}
/**
* {@inheritDoc}
*/
@Override
public void registerSettings ( final String key, final boolean loadInitialSettings, final boolean applySettingsChanges )
{
SettingsManager.registerComponent ( this, key, loadInitialSettings, applySettingsChanges );
}
/**
* {@inheritDoc}
*/
@Override
public void registerSettings ( final String key, final Class defaultValueClass,
final boolean loadInitialSettings, final boolean applySettingsChanges )
{
SettingsManager.registerComponent ( this, key, defaultValueClass, loadInitialSettings, applySettingsChanges );
}
/**
* {@inheritDoc}
*/
@Override
public void registerSettings ( final String key, final Object defaultValue, final boolean loadInitialSettings,
final boolean applySettingsChanges )
{
SettingsManager.registerComponent ( this, key, defaultValue, loadInitialSettings, applySettingsChanges );
}
/**
* {@inheritDoc}
*/
@Override
public void registerSettings ( final String group, final String key, final Class defaultValueClass,
final boolean loadInitialSettings, final boolean applySettingsChanges )
{
SettingsManager.registerComponent ( this, group, key, defaultValueClass, loadInitialSettings, applySettingsChanges );
}
/**
* {@inheritDoc}
*/
@Override
public void registerSettings ( final String group, final String key, final Object defaultValue, final boolean loadInitialSettings,
final boolean applySettingsChanges )
{
SettingsManager.registerComponent ( this, group, key, defaultValue, loadInitialSettings, applySettingsChanges );
}
/**
* {@inheritDoc}
*/
@Override
public void registerSettings ( final SettingsProcessor settingsProcessor )
{
SettingsManager.registerComponent ( this, settingsProcessor );
}
/**
* {@inheritDoc}
*/
@Override
public void unregisterSettings ()
{
SettingsManager.unregisterComponent ( this );
}
/**
* {@inheritDoc}
*/
@Override
public void loadSettings ()
{
SettingsManager.loadComponentSettings ( this );
}
/**
* {@inheritDoc}
*/
@Override
public void saveSettings ()
{
SettingsManager.saveComponentSettings ( this );
}
/**
* Font methods
*/
/**
* {@inheritDoc}
*/
@Override
public WebTextArea setPlainFont ()
{
return SwingUtils.setPlainFont ( this );
}
/**
* {@inheritDoc}
*/
@Override
public WebTextArea setPlainFont ( final boolean apply )
{
return SwingUtils.setPlainFont ( this, apply );
}
/**
* {@inheritDoc}
*/
@Override
public boolean isPlainFont ()
{
return SwingUtils.isPlainFont ( this );
}
/**
* {@inheritDoc}
*/
@Override
public WebTextArea setBoldFont ()
{
return SwingUtils.setBoldFont ( this );
}
/**
* {@inheritDoc}
*/
@Override
public WebTextArea setBoldFont ( final boolean apply )
{
return SwingUtils.setBoldFont ( this, apply );
}
/**
* {@inheritDoc}
*/
@Override
public boolean isBoldFont ()
{
return SwingUtils.isBoldFont ( this );
}
/**
* {@inheritDoc}
*/
@Override
public WebTextArea setItalicFont ()
{
return SwingUtils.setItalicFont ( this );
}
/**
* {@inheritDoc}
*/
@Override
public WebTextArea setItalicFont ( final boolean apply )
{
return SwingUtils.setItalicFont ( this, apply );
}
/**
* {@inheritDoc}
*/
@Override
public boolean isItalicFont ()
{
return SwingUtils.isItalicFont ( this );
}
/**
* {@inheritDoc}
*/
@Override
public WebTextArea setFontStyle ( final boolean bold, final boolean italic )
{
return SwingUtils.setFontStyle ( this, bold, italic );
}
/**
* {@inheritDoc}
*/
@Override
public WebTextArea setFontStyle ( final int style )
{
return SwingUtils.setFontStyle ( this, style );
}
/**
* {@inheritDoc}
*/
@Override
public WebTextArea setFontSize ( final int fontSize )
{
return SwingUtils.setFontSize ( this, fontSize );
}
/**
* {@inheritDoc}
*/
@Override
public WebTextArea changeFontSize ( final int change )
{
return SwingUtils.changeFontSize ( this, change );
}
/**
* {@inheritDoc}
*/
@Override
public int getFontSize ()
{
return SwingUtils.getFontSize ( this );
}
/**
* {@inheritDoc}
*/
@Override
public WebTextArea setFontSizeAndStyle ( final int fontSize, final boolean bold, final boolean italic )
{
return SwingUtils.setFontSizeAndStyle ( this, fontSize, bold, italic );
}
/**
* {@inheritDoc}
*/
@Override
public WebTextArea setFontSizeAndStyle ( final int fontSize, final int style )
{
return SwingUtils.setFontSizeAndStyle ( this, fontSize, style );
}
/**
* {@inheritDoc}
*/
@Override
public WebTextArea setFontName ( final String fontName )
{
return SwingUtils.setFontName ( this, fontName );
}
/**
* {@inheritDoc}
*/
@Override
public String getFontName ()
{
return SwingUtils.getFontName ( this );
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy