将行分类器设置为表时出现异常。我通过println检查了它实际上是空的,但我无法清楚地看到原因。这是我的主类和抽象表模型实现类。
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.util.Calendar;
import java.util.Date;
import java.util.regex.PatternSyntaxException;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JMenuBar;
import javax.swing.JScrollPane;
import javax.swing.JSpinner;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.JTextPane;
import javax.swing.RowFilter;
import javax.swing.SpinnerDateModel;
import javax.swing.SpringLayout;
import javax.swing.WindowConstants;
import javax.swing.table.TableModel;
import javax.swing.table.TableRowSorter;
public class Framer{
final static JTextPane money =new JTextPane();
static String moneyS ="0";
// static DialogWin dialog;
static Filer filer;
public static JTextField name;
private static JTextField surname;
private static JTextField cost;
static JTextPane clientsNum;
static String forward;
public static JTable table_1;
static SModel dmodel;
private static JTextField search;
static TableRowSorter<TableModel> sorter;
public static void filter(){
table_1.setRowSorter(sorter);
final String text=search.getText();
if(text.length()==0){
sorter.setRowFilter(null);
}else{
try{
sorter.setRowFilter(RowFilter.regexFilter (text));
}catch(final PatternSyntaxException pse){
System.err.println("Bad regex pattern");
}
}
}
public static void load() throws Exception{
if(!filer.empty){
dmodel.vv=filer.FilerRead().vv;
dmodel.fireTableDataChanged();
}
}
public static void main(final String args[]) throws Exception{
// for(int i=0;i<headings.length;i++){
// data[i][i]="#";
// }
filer=new Filer();
final JFrame jFrame=new JFrame("Кассовый Журнал");
jFrame.setSize(769,708);
/*
* final UIManager.LookAndFeelInfo[] info=UIManager
* .getInstalledLookAndFeels(); for(final LookAndFeelInfo element:info){
* System.out.print(element); } try{
* UIManager.setLookAndFeel(info[info.length-4].getClassName ());
* }catch(final ClassNotFoundException e){ // TODO Auto- generated catch
* block e.printStackTrace(); }catch(final InstantiationException e){ //
* TODO Auto-generated catch block e.printStackTrace(); } catch(final
* IllegalAccessException e){ // TODO Auto-generated catch block
* e.printStackTrace(); }catch(final UnsupportedLookAndFeelException e){
* // TODO Auto-generated catch block e.printStackTrace(); }
*/
jFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
final JMenuBar menuBar=new JMenuBar();
jFrame.setJMenuBar(menuBar);
final JTextPane textPane_2=new JTextPane();
textPane_2.setEditable(false);
textPane_2.setText("Всего за период:");
menuBar.add(textPane_2);
clientsNum=new JTextPane();
clientsNum.setEditable(false);
menuBar.add(clientsNum);
final JTextPane textPane_3=new JTextPane();
textPane_3.setEditable(false);
textPane_3.setText("Доходы");
menuBar.add(textPane_3);
menuBar.add(money);
search=new JTextField();
search.addFocusListener(new FocusAdapter(){
@Override
public void focusGained(final FocusEvent arg0){
search.setText("");
}
});
final JButton button_3=new JButton("Найти");
button_3.addActionListener(new ActionListener(){
@Override
public void actionPerformed(final ActionEvent arg0){
filter();
}
});
menuBar.add(button_3);
search.setBackground(new Color(255,255,0));
search.setText("Поиск");
menuBar.add(search);
search.setColumns(10);
jFrame.getContentPane().setLayout(new BorderLayout(0,0));
dmodel=new SModel();
final JDesktopPane desktopPane=new JDesktopPane();
jFrame.getContentPane().add(desktopPane);
final SpringLayout springLayout=new SpringLayout();
desktopPane.setLayout(springLayout);
final JInternalFrame DateFrame=new JInternalFrame("Фильтрация по дате");
DateFrame.setRequestFocusEnabled(false);
springLayout.putConstraint(SpringLayout.NORTH,DateFrame,0,
SpringLayout.NORTH,desktopPane);
springLayout.putConstraint(SpringLayout.WEST,DateFrame,0,
SpringLayout.WEST,desktopPane);
springLayout.putConstraint(SpringLayout.EAST,DateFrame,229,
SpringLayout.WEST,desktopPane);
desktopPane.add(DateFrame);
final JInternalFrame TableFrame=new JInternalFrame("Список приемов");
springLayout.putConstraint(SpringLayout.NORTH,TableFrame,0,
SpringLayout.NORTH,DateFrame);
springLayout.putConstraint(SpringLayout.WEST,TableFrame,0,
SpringLayout.EAST,DateFrame);
springLayout.putConstraint(SpringLayout.EAST,TableFrame,0,
SpringLayout.EAST,desktopPane);
TableFrame.setVisible(true);
desktopPane.add(TableFrame);
final JInternalFrame AddFrame=new JInternalFrame("Создать новую запись");
springLayout.putConstraint(SpringLayout.SOUTH,TableFrame,-10,
SpringLayout.SOUTH,AddFrame);
springLayout.putConstraint(SpringLayout.SOUTH,DateFrame,-1,
SpringLayout.NORTH,AddFrame);
springLayout.putConstraint(SpringLayout.WEST,AddFrame,0,
SpringLayout.WEST,desktopPane);
springLayout.putConstraint(SpringLayout.EAST,AddFrame,0,
SpringLayout.EAST,DateFrame);
springLayout.putConstraint(SpringLayout.NORTH,AddFrame,177,
SpringLayout.NORTH,desktopPane);
springLayout.putConstraint(SpringLayout.SOUTH,AddFrame,0,
SpringLayout.SOUTH,desktopPane);
TableFrame.getContentPane().setLayout(new BorderLayout(0,0));
final JScrollPane scrollPane=new JScrollPane();
TableFrame.getContentPane().add(scrollPane,BorderLayout.CENTER);
load();
refresh();
final JTable table_1=new JTable(dmodel);
table_1.setAutoCreateRowSorter(true);
scrollPane.setViewportView(table_1);
final SpringLayout springLayout_1=new SpringLayout();
DateFrame.getContentPane().setLayout(springLayout_1);
final JLabel label=new JLabel("С:");
DateFrame.getContentPane().add(label);
final JSpinner from=new JSpinner();
from.setModel(new SpinnerDateModel(Calendar.getInstance().getTime(),
new Date(1325358000000L),null,Calendar.WEEK_OF_MONTH));
springLayout_1.putConstraint(SpringLayout.NORTH,from,10,
SpringLayout.NORTH,DateFrame.getContentPane());
springLayout_1.putConstraint(SpringLayout.WEST,from,29,
SpringLayout.WEST,DateFrame.getContentPane());
springLayout_1.putConstraint(SpringLayout.EAST,from,-10,
SpringLayout.EAST,DateFrame.getContentPane());
springLayout_1.putConstraint(SpringLayout.NORTH,label,6,
SpringLayout.NORTH,from);
springLayout_1.putConstraint(SpringLayout.EAST,label,-6,
SpringLayout.WEST,from);
DateFrame.getContentPane().add(from);
final JLabel label_1=new JLabel("По:");
springLayout_1.putConstraint(SpringLayout.NORTH,label_1,34,
SpringLayout.SOUTH,label);
springLayout_1.putConstraint(SpringLayout.EAST,label_1,0,
SpringLayout.EAST,label);
DateFrame.getContentPane().add(label_1);
final JSpinner till=new JSpinner();
springLayout_1.putConstraint(SpringLayout.NORTH,till,22,
SpringLayout.SOUTH,from);
springLayout_1.putConstraint(SpringLayout.WEST,till,0,
SpringLayout.WEST,from);
springLayout_1.putConstraint(SpringLayout.EAST,till,-10,
SpringLayout.EAST,DateFrame.getContentPane());
till.setModel(new SpinnerDateModel(Calendar.getInstance().getTime(),
new Date(1325358000000L),null,Calendar.WEEK_OF_MONTH));
DateFrame.getContentPane().add(till);
final JButton breport=new JButton("Отчет");
springLayout_1.putConstraint(SpringLayout.NORTH,breport,23,
SpringLayout.SOUTH,till);
springLayout_1.putConstraint(SpringLayout.EAST,breport,0,
SpringLayout.EAST,from);
DateFrame.getContentPane().add(breport);
final JButton button=new JButton("Загрузить");
button.addActionListener(new ActionListener(){
@Override
public void actionPerformed(final ActionEvent arg0){
try{
load();
}catch(final Exception e){
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
springLayout_1.putConstraint(SpringLayout.NORTH,button,23,
SpringLayout.SOUTH,till);
springLayout_1.putConstraint(SpringLayout.WEST,breport,6,
SpringLayout.EAST,button);
springLayout_1.putConstraint(SpringLayout.WEST,button,0,
SpringLayout.WEST,label_1);
DateFrame.getContentPane().add(button);
desktopPane.add(AddFrame);
final SpringLayout springLayout_2=new SpringLayout();
AddFrame.getContentPane().setLayout(springLayout_2);
final JLabel label_2=new JLabel("Имя");
AddFrame.getContentPane().add(label_2);
final JLabel label_3=new JLabel("Фамилия");
springLayout_2.putConstraint(SpringLayout.WEST,label_2,0,
SpringLayout.WEST,label_3);
springLayout_2.putConstraint(SpringLayout.SOUTH,label_2,-6,
SpringLayout.NORTH,label_3);
AddFrame.getContentPane().add(label_3);
name=new JTextField();
name.addFocusListener(new FocusAdapter(){
@Override
public void focusGained(final FocusEvent arg0){
name.setText("");
}
});
name.setText("Введите значение");
name.setToolTipText("");
springLayout_2.putConstraint(SpringLayout.WEST,name,65,
SpringLayout.WEST,AddFrame.getContentPane());
springLayout_2.putConstraint(SpringLayout.EAST,name,-10,
SpringLayout.EAST,AddFrame.getContentPane());
springLayout_2.putConstraint(SpringLayout.NORTH,name,0,
SpringLayout.NORTH,AddFrame.getContentPane());
AddFrame.getContentPane().add(name);
name.setColumns(10);
surname=new JTextField();
surname.addFocusListener(new FocusAdapter(){
@Override
public void focusGained(final FocusEvent arg0){
surname.setText("");
}
});
springLayout_2.putConstraint(SpringLayout.NORTH,label_3,3,
SpringLayout.NORTH,surname);
springLayout_2.putConstraint(SpringLayout.WEST,surname,65,
SpringLayout.WEST,AddFrame.getContentPane());
springLayout_2.putConstraint(SpringLayout.EAST,surname,-10,
SpringLayout.EAST,AddFrame.getContentPane());
surname.setText("Введите значение");
springLayout_2.putConstraint(SpringLayout.NORTH,surname,4,
SpringLayout.SOUTH,name);
surname.setColumns(10);
AddFrame.getContentPane().add(surname);
final JSpinner date=new JSpinner();
springLayout_2.putConstraint(SpringLayout.NORTH,date,6,
SpringLayout.SOUTH,surname);
springLayout_2.putConstraint(SpringLayout.EAST,date,-10,
SpringLayout.EAST,AddFrame.getContentPane());
date.setModel(new SpinnerDateModel(Calendar.getInstance().getTime(),
new Date(1325358000000L),null,Calendar.DAY_OF_MONTH));
AddFrame.getContentPane().add(date);
cost=new JTextField();
cost.addFocusListener(new FocusAdapter(){
@Override
public void focusGained(final FocusEvent arg0){
cost.setText("");
}
});
springLayout_2.putConstraint(SpringLayout.WEST,cost,65,
SpringLayout.WEST,AddFrame.getContentPane());
cost.setText("Введите значение");
springLayout_2.putConstraint(SpringLayout.NORTH,cost,6,
SpringLayout.SOUTH,date);
springLayout_2.putConstraint(SpringLayout.EAST,cost,-10,
SpringLayout.EAST,AddFrame.getContentPane());
AddFrame.getContentPane().add(cost);
cost.setColumns(10);
final JCheckBox forward_1=new JCheckBox("Предоплата");
springLayout_2.putConstraint(SpringLayout.EAST,forward_1,-20,
SpringLayout.EAST,AddFrame.getContentPane());
AddFrame.getContentPane().add(forward_1);
final JLabel label_4=new JLabel("Дата");
springLayout_2.putConstraint(SpringLayout.WEST,label_3,0,
SpringLayout.WEST,label_4);
springLayout_2.putConstraint(SpringLayout.WEST,date,39,
SpringLayout.EAST,label_4);
springLayout_2.putConstraint(SpringLayout.NORTH,label_4,3,
SpringLayout.NORTH,date);
AddFrame.getContentPane().add(label_4);
final JLabel label_6=new JLabel("Доктор");
springLayout_2.putConstraint(SpringLayout.WEST,label_4,0,
SpringLayout.WEST,label_6);
springLayout_2.putConstraint(SpringLayout.WEST,label_6,0,
SpringLayout.WEST,AddFrame.getContentPane());
AddFrame.getContentPane().add(label_6);
final JLabel label_5=new JLabel("Стоимость");
springLayout_2.putConstraint(SpringLayout.NORTH,label_5,3,
SpringLayout.NORTH,cost);
springLayout_2.putConstraint(SpringLayout.WEST,label_5,0,
SpringLayout.WEST,label_6);
AddFrame.getContentPane().add(label_5);
final JButton badd=new JButton("Добавить");
springLayout_2.putConstraint(SpringLayout.NORTH,badd,-126,
SpringLayout.SOUTH,AddFrame.getContentPane());
springLayout_2.putConstraint(SpringLayout.WEST,badd,10,
SpringLayout.WEST,AddFrame.getContentPane());
springLayout_2.putConstraint(SpringLayout.SOUTH,badd,-103,
SpringLayout.SOUTH,AddFrame.getContentPane());
springLayout_2.putConstraint(SpringLayout.EAST,badd,-10,
SpringLayout.EAST,AddFrame.getContentPane());
AddFrame.getContentPane().add(badd);
final JButton bclear=new JButton("Очистить всю историю!");
springLayout_2.putConstraint(SpringLayout.NORTH,bclear,-39,
SpringLayout.SOUTH,AddFrame.getContentPane());
springLayout_2.putConstraint(SpringLayout.WEST,bclear,10,
SpringLayout.WEST,AddFrame.getContentPane());
springLayout_2.putConstraint(SpringLayout.SOUTH,bclear,-16,
SpringLayout.SOUTH,AddFrame.getContentPane());
springLayout_2.putConstraint(SpringLayout.EAST,bclear,-10,
SpringLayout.EAST,AddFrame.getContentPane());
sorter=new TableRowSorter<TableModel>(dmodel);
bclear.addActionListener(new ActionListener(){
@Override
public void actionPerformed(final ActionEvent arg0){
dmodel.revomeAll();
dmodel.fireTableDataChanged();
try{
refresh();
}catch(final Exception e){
// TODO Auto-generated catch block
e.printStackTrace();
}
try{
// table_1.setModel(filer.FilerRead());
}catch(final Exception e1){
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
});
AddFrame.getContentPane().add(bclear);
final JComboBox doctor=new JComboBox();
doctor.addFocusListener(new FocusAdapter(){
@Override
public void focusGained(final FocusEvent arg0){
doctor.setSelectedItem("");
}
});
springLayout_2.putConstraint(SpringLayout.NORTH,label_6,3,
SpringLayout.NORTH,doctor);
springLayout_2.putConstraint(SpringLayout.NORTH,doctor,6,
SpringLayout.SOUTH,cost);
springLayout_2.putConstraint(SpringLayout.NORTH,forward_1,14,
SpringLayout.SOUTH,doctor);
doctor.setEditable(true);
springLayout_2.putConstraint(SpringLayout.EAST,doctor,0,
SpringLayout.EAST,name);
doctor.setModel(new DefaultComboBoxModel(new String[]{"Введите текст"}));
springLayout_2.putConstraint(SpringLayout.WEST,doctor,0,
SpringLayout.WEST,name);
AddFrame.getContentPane().add(doctor);
final JButton button_1=new JButton("Распечатать");
springLayout_2.putConstraint(SpringLayout.WEST,button_1,10,
SpringLayout.WEST,AddFrame.getContentPane());
springLayout_2.putConstraint(SpringLayout.EAST,button_1,-10,
SpringLayout.EAST,AddFrame.getContentPane());
AddFrame.getContentPane().add(button_1);
final JButton button_2=new JButton("Удалить прием");
button_2.addActionListener(new ActionListener(){
@Override
public void actionPerformed(final ActionEvent arg0){
dmodel.removeSelected(table_1.getSelectedRow());
try{
refresh();
}catch(final Exception e){
// TODO Auto-generated catch block
e.printStackTrace();
}
dmodel.fireTableDataChanged();
}
});
springLayout_2.putConstraint(SpringLayout.SOUTH,button_1,-6,
SpringLayout.NORTH,button_2);
springLayout_2.putConstraint(SpringLayout.EAST,button_2,0,
SpringLayout.EAST,name);
springLayout_2.putConstraint(SpringLayout.WEST,button_2,10,
SpringLayout.WEST,AddFrame.getContentPane());
springLayout_2.putConstraint(SpringLayout.SOUTH,button_2,-6,
SpringLayout.NORTH,bclear);
AddFrame.getContentPane().add(button_2);
badd.addActionListener(new ActionListener(){
@Override
public void actionPerformed(final ActionEvent arg0){
final Object[] o=new Object[6];
o[0]=name.getText();
o[1]=surname.getText();
o[2]=date.getValue().toString();
o[3]=cost.getText();
o[4]=doctor.getSelectedItem();
if(forward_1.isSelected()){
o[5]="Да";
}else{
o[5]="Нет";
}
dmodel.addRow(o);
table_1.setModel(dmodel);
try{
refresh();
}catch(final Exception e){
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
AddFrame.setVisible(true);
DateFrame.setVisible(true);
// dialog.getdata(table);
jFrame.setVisible(true);
}
public static void refresh() throws Exception{
filer.FilerWrite(dmodel);
// dmodel=filer.FilerRead();
dmodel.fireTableDataChanged();
final StringBuffer s=new StringBuffer();
final int i=dmodel.getRowCount();
s.append(i);
clientsNum.setText(s.toString());
int mm=0;
try{
for(int j=0;j<dmodel.getRowCount();j++){
final Integer m=new Integer((String)dmodel.vv.elementAt(j)
.elementAt(3));
mm+=m.intValue();
}
s.delete(0,s.capacity());
s.append(mm);
money.setText(s.toString());
}catch(final Exception e){}
}
}
这是AbstractTableModel实现
import java.io.Serializable;
import java.util.Vector;
import javax.swing.table.AbstractTableModel;
public class SModel extends AbstractTableModel implements Serializable{
final static String[] headings =new String[] {"Имя","Фамилия",
"Дата приема","Стоимость приема (тыс.сум.)","Врач","Предоплата"};
// final UIManager.LookAndFeelInfo[] info =UIManager
// .getInstalledLookAndFeels();
Vector v;
Vector<Vector<Object>> vv =new Vector<Vector<Object>>();
public void addRow(final Object[] o){
v=new Vector<Object>();
for(final Object element:o){
v.add(element);
}
vv.add(v);
fireTableDataChanged();
}
@Override
public int getColumnCount(){
// TODO Auto-generated method stub
return headings.length;
}
@Override
public String getColumnName(final int column){
return headings[column];
}
@Override
public int getRowCount(){
// TODO Auto-generated method stub
return vv.size();
}
@Override
public Object getValueAt(final int arg0,final int arg1){
return vv.get(arg0).get(arg1);
}
public void removeSelected(final int i){
vv.removeElementAt(i);
}
public void revomeAll(){
vv.removeAllElements();
}
}
如果需要Filer类来编写数据或确切的表格模型并再次阅读
import java.io.BufferedWriter;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
public class Filer{
File dat;
DataOutputStream doutput;
DataInputStream dinput;
BufferedWriter bwriter;
ObjectOutputStream objout;
FileOutputStream writer;
FileInputStream reader;
ObjectInputStream objin;
public boolean empty =true;
public Filer() throws IOException,ClassNotFoundException{
dat=new File(".//data//data.dat");
if(!dat.exists()){
// System.out.println("here"+dat.getAbsolutePath());
dat.createNewFile();
empty=true;
}else{
empty=false;
}
}
public SModel FilerRead() throws Exception{
reader=new FileInputStream(dat);
objin=new ObjectInputStream(reader);
final SModel n=(SModel)objin.readObject();
objin.close();
return n;
}
public void FilerWrite(final SModel s) throws IOException{
writer=new FileOutputStream(dat,false);
objout=new ObjectOutputStream(writer);
objout.writeObject(s);
objout.close();
}
}
它可能非常酷,如果还有助于数据排序,用户将通过左上角内部框架中的jspinners定义。提前谢谢!
确定。对不起这是日志:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at Framer.filter(Framer.java:46)
at Framer$2.actionPerformed(Framer.java:109)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
当我输入文本到文本字段并尝试通过单击按钮对表进行排序时出现问题。这是中风:
public static void filter(){
table_1.setRowSorter(sorter);//It is here. table_1 equals null but I can't see why.
final String text=search.getText();
if(text.length()==0){
sorter.setRowFilter(null);
}else{
try{
sorter.setRowFilter(RowFilter.regexFilter(text));
}catch(final PatternSyntaxException pse){
System.err.println("Bad regex pattern");
}
}
}
哦,谢谢,我现在看到了。我只是在主要版本中重新编写了它。