📄 replacetool.java
字号:
/*************************************************************************************
* 类名: ReplaceTool
*
* 功能: 此类为” 替换对话框“的工具类
*
**************************************************************************************/
package edit.com;
import javax.swing.JLabel;
import java.awt.Color;
import javax.swing.JComboBox;
import java.awt.Dimension;
import javax.swing.JButton;
import java.awt.Color;
import java.awt.event.ActionListener;
class ReplaceTool extends NewTool
implements ReplaceTools {
public JLabel createLabel( String s, Color c ) {
JLabel label = new JLabel( s );
label.setBackground( c );
return label;
}
public JLabel createLabel( String s ) {
JLabel label = new JLabel( s );
return label;
}
public JComboBox createText( Dimension min , Dimension max ) {
JComboBox text = new JComboBox();
text.setMaximumSize( min );
text.setMaximumSize( max );
return text;
}
public JButton createButton( String s, Dimension max, Color c, ActionListener a ) {
JButton button = new JButton( s );
button.setBackground( c );
button.setMaximumSize( max );
button.addActionListener( a );
return button;
}
public boolean addEnable( String editText , int count , String[] range ) {
for ( int i = 0 ; i < count ; i++ ) {
if( editText.equals( range[i] ) ) {
return false;
}
}
return true;
}
public String[] getAllItems( int count , JComboBox combox ) {
String[] items = new String[ count ];
for( int i = 0 ; i < combox.getItemCount() ; i++ )
{
items[i] = ( String )combox.getItemAt( i );
}
return items;
}
public void addItems( JComboBox findText , JComboBox replaceText ) {
String editText;
int count;
String[] range;
if( ( ( editText = ( String )findText.getSelectedItem() ) == null ) ||
( ( editText = ( String )findText.getSelectedItem() ).equals( "" ) ) )
{}
else
{
count = findText.getItemCount();
range = getAllItems( count , findText );
if( addEnable( editText , count , range ) )
{
findText.addItem( editText );
}
}
if( ( ( editText = ( String )replaceText.getSelectedItem() ) == null ) ||
( ( editText = ( String )replaceText.getSelectedItem() ).equals( "" ) ) )
{}
else
{
count = replaceText.getItemCount();
range = getAllItems( count , replaceText );
if( addEnable( editText , count , range ) )
{
replaceText.addItem( editText );
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -