我正在使用提供用户界面来执行某些用户事件的Java项目。它不像在大多数Swing/Gui应用程序中那样作为main()中的Runnable线程执行。相反,它在源代码中有几个类和表单文件,并使用另一个Java程序从命令行运行。 但是当我试图通过单击某个输入按钮来读取某个文件时,系统无法读取该文件。系统将自定义错误消息写入保存在项目文件夹中的名为log.txt的文件中。 我试图 1.设置断点(应用程序没有在断点处停止) 2.做控制台打印即的System.out.println(有控制台上没有打印)在Java GUI应用程序中调试用户事件
因此,无论调试的方法已经失败。我正在使用Eclipse 3.5.2 SDK(伽利略)。我如何在应用程序上调试用户事件?
下面列出了项目DDMT中源类DataImportPanel的轮廓。它在DataImportPanel.openHeteroFile(File)方法中发出异常。
DDMT.core.DataImportPanel
...
DDMT.core.DataImportPanel.heteroDistributionModel
...
DDMT.core.DataImportPanel.initComponents()
DDMT.core.DataImportPanel.initComponents().new ActionListener() {...}
...
DDMT.core.DataImportPanel.initComponents().new MouseAdapter() {...}
DDMT.core.DataImportPanel.initComponents().new ActionListener() {...}
DDMT.core.DataImportPanel.jButton2ActionPerformed(ActionEvent)
...
DDMT.core.DataImportPanel.jButton3ActionPerformed(ActionEvent)
DDMT.core.DataImportPanel.openHeteroFile(File)
DDMT.core.DataImportPanel.jButton8ActionPerformed(ActionEvent)
DDMT.core.DataImportPanel.openFile(File)
DDMT.core.DataImportPanel.jButton15ActionPerformed(ActionEvent)
DDMT.core.DataImportPanel.jRadioButton1ActionPerformed(ActionEvent)
DDMT.core.DataImportPanel.buttonGroup1
...
DDMT.core.DataImportPanel.jButton8
DDMT.core.DataImportPanel.jButton9
DDMT.core.DataImportPanel.jLabel1
...
DDMT.core.DataImportPanel.jList1
...
DDMT.core.DataImportPanel.jPanel1
...
DDMT.core.DataImportPanel.jRadioButton1
...
DDMT.core.DataImportPanel.jScrollPane1
...
DDMT.core.DataImportPanel.jTabbedPane1
DDMT.core.DataImportPanel.DistributionTypes
DDMT.core.DataImportPanel.DoubleCellRenderer
这里是一个被扔在数据导入例外
private void openHeteroFile(File f)
{
File file = null;
try{
file = f;
file.createNewFile();
FileReader reader = new FileReader(file);
BufferedReader bReader = new BufferedReader(reader);
//The vector that holds the number of columns
attributeNames = new ArrayList<String>();
//Read in the number of pairs
String line = bReader.readLine();
//load the file
heteroDistributionModel = new DefaultListModel();
line = bReader.readLine();
while(line != null)
{
//Set up the RegEx matches
heteroDistM = heteroDistP.matcher(line);
firstM = firstP.matcher(line);
firstM.find();
String output1 = firstM.group()+" (";
for(int j = 0; j< nodeTypes[0].length; j++)
{
if(controlClass.nodes[Integer.parseInt(firstM.group())].getNodeType().equals(nodeTypes[1][j]))
{
output1 = output1+nodeTypes[0][j]+")";
}
}
String output2 = new String();
while(heteroDistM.find())
{
attributeNames.add(heteroDistM.group(1));
output2 = output2 + " "+heteroDistM.group(1);
}
heteroDistributionModel.addElement(new String[]{output1, output2});
line = bReader.readLine();
}
for (String attr : attributeNames)
System.out.println(attr); //debug
jList3.setModel(heteroDistributionModel);
jList3.setCellRenderer(new DoubleCellRenderer());
bReader.close();
reader.close();
}catch(IOException ex)
{
controlClass.showError("Data Import: Error: File "+file.getPath()+" is not a valid Heterogeneous data file!");
}catch(Exception ex)
{
ex.printStackTrace(); //debug
controlClass.showError("Data Import: Error: Unknown problem reading file "+file.getPath()+"!");
}
}
你在“调试”模式下运行吗?如果不是,则不会触发断点。 – user1329572 2012-07-05 12:51:44
是的我已经运行在调试模式下(调试透视图) – somnathchakrabarti 2012-07-05 12:57:10
如果您从命令行运行它,您是否将其设置为调试并连接到“远程Java应用程序”? – 2012-07-05 13:14:20