📄 gototool.java
字号:
/************************************************************************************** 类名: GotoTool * * 功能: 此类的主要功能为作为“goto对话框”类的工具类,此类作为一个方法封装类,其中* 的所有实现方法都是提供给“goto对话框”类及其相关联类所使用,此类实现了* GotoTools接口* **************************************************************************************/package edit.com;import java.awt.Component;import javax.swing.JOptionPane;import javax.swing.JLabel;import java.awt.Font;import java.awt.Color;import javax.swing.JTextField;import java.awt.Dimension;import javax.swing.JButton;import java.awt.event.ActionListener;class GotoTool extends NewTool implements GotoTools { public void findLine( Component c, GotoSet gotoSet, String gotoText ) { int position = 0; int i = 0; int lineToBeFind = 1; while( true ) { position = gotoSet.getSourceString().indexOf( '\12' , position ); if( position == -1 ) { break; } gotoSet.addToLineNumber( i++ , position++ ); } try { lineToBeFind = Integer.parseInt( gotoText ); } catch( NumberFormatException n ) { } if( lineToBeFind < 2 || lineToBeFind > gotoSet.getTotalLine() ) { if( lineToBeFind < 2 ) { gotoSet.setLineFind( 0 ); }else { gotoSet.setLineFind( gotoSet.getSourceString().length() ); JOptionPane.showMessageDialog( c , "end of file" , "error" , JOptionPane.WARNING_MESSAGE ); } }else { gotoSet.setLineFind( gotoSet.getLineNumber( lineToBeFind - 2 ) + 1 ); } } public JLabel createLael( String s , Font f , Color c ) { JLabel label = new JLabel( s ); label.setFont( f ); label.setForeground( c ); return label; } public JTextField createText( Dimension min , Dimension max ) { JTextField text = new JTextField(); text.setMaximumSize( min ); text.setPreferredSize( max ); return text; } public JButton createButton( String text , Font f , Color c , ActionListener a ) { JButton button = new JButton( text ); button.setFont( new Font( null , Font.BOLD , 12 ) ); button.setBackground( Color.orange ); button.addActionListener( a ); return button; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -