繁体   English   中英

Applet隐藏的classnotfound异常

[英]Applet hidden classnotfound exception

我正在开发一个行为异常的applet:这不是通常的“我无法在浏览器中启动applet”问题,而是一些更微妙的问题。

该小程序包含一个带有8个选项卡的jtabbedpane,每个选项卡在工作流中进行一些数据操作,并且用户有两个按钮(后退和前进)来循环浏览这些选项卡。

当我将其运行到浏览器中(最新的chrome或firefox,但这无关紧要)时,从第7个标签页转到第8个标签页时,我注意到速度持续下降:在后者中,我在该标签页中放置了一个带有自定义表格模型的jtable,在日食中运行正常。 几个调试步骤之后,我注意到jvm为类RateTableModel抛出了classnotfoundexception,这是我的自定义表模型。 奇怪的是,即使我在IDE中以及作为浏览器中的自签名小程序都测试了该小程序,该异常也不会在任何控制台中引发。 我到处都进行了验证:没有空的catch块,每个异常都会始终打印其stackstrace,如果我将tablemodel的初始化代码放在try / catch块中,则永远不会捕获该异常。 更有趣的是,经过一段随机的时间后,执行继续,就好像什么都没发生一样(这次仅在IDE中),而在浏览器中,GUI的行为就像一个正常的例外:它将所有事情弄乱了。

我想问的是关于发生这种情况的任何想法。

RateTableModel类位于geotel.utils包中,在该类中,我必须定期实例化其他类,然后才能加载该类,并验证了该类是否存在于jar中。

有关开发的详细信息(也许对阅读此内容的人可能有用):

使用以下命令对小程序进行签名

jarsigner -keystore keystore3 C:\GestioneOneri.jar me3

小程序是从以下html文件运行的:

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
            <title>Titolo</title>
    </head>
    <body>
        <script src="http://www.java.com/js/deployJava.js"></script>
        <script> 
            var attributes = {code:'geotel.gui.Login.class', 
                    archive:'GestioneOneri.jar,mysql-connector-java-5.1.20-bin.jar,poi-3.9-20121203.jar,forms-1.3.0.jar', 
                    width:1024, height:700} ;
            var parameters = {jnlp_href:'gestioneoneri.jnlp', portalUrl:'http://192.168.146.145:8080/GestioneOneriServlet', nomeUtente:'', numeroPratica:'', percorsoFileCalcoloOneri:"/", nomeFileCalcoloOneri:"calcoloOneri.xls"} ; 
            var version = '1.6' ;
            deployJava.runApplet(attributes, parameters, version);  
        </script>
        <noscript>This page requires JavaScript.</noscript>
    </body>
</html>

JNLP文件如下:

<?xml version="1.0" encoding="UTF-8"?>
    <jnlp href="gestioneoneri.jnlp">
        <information>
            <title>Gestione Oneri Urbanistici</title>
            <vendor>Geotel soc. coop.</vendor>
            <offline-allowed />
        </information>
        <resources>
            <j2se version ="1.6+" initial-heap-size="128m" max-heap-size="1024m"
  href="http://java.sun.com/products/autodl/j2se" />
            <jar href="GestioneOneri.jar" main="true" />
        <jar href="mysql-connector-java-5.1.20-bin.jar"/>
        <jar href="poi-3.9-20121203.jar"/>
        <jar href="forms-1.3.0.jar"/>
        </resources>
        <applet-desc
            name="Gestione Oneri Urbanistici"
            main-class="geotel.gui.Login"
            width="1024"
            height="700"/>
    </jnlp>

导致ClassNotFoundException的代码如下:class DatiRatePanel

this.tm = new geotel.utils.RateTableModel(columnNames, oneriPratica, rate, rateizzazioniPreviste);

并且RateTableModel类的定义是

public class RateTableModel extends AbstractTableModel

编辑:经过更多调试步骤后,我发现在调试视图中屏幕截图中存在这种情况 除错

我绝对不知道这些键代表什么,但是如果我一直按F5(进入)这些键就会消失,接下来的步骤将继续执行,并且类加载器将神奇地能够找到类RateTableModel。 我该如何摆脱呢?

谢谢!

EDIT2:我研究了Eclipse文档中的按键图标,发现它们是锁定对象上的监视器。 据我所知,监视器出现在有同步代码块的地方,而我在这里没有(我确信这些块没有被调用)。 真让我生气...

EDIT3:我尝试将一些printlns放在每条指令所需的时间上,以下是源代码和输出。 我不明白为什么在打印2和4中时间会被“重置”(或看起来如此),似乎还有更多线程看不到时间变量已初始化(但这是不可能的!)。

Long time = System.currentTimeMillis();
this.tm = new RateTableModel(columnNames, oneriPratica, rate, rateizzazioniPreviste);
time = System.currentTimeMillis() - time;
System.out.println("DatiRatePanel2.populatePanel() 1 time: " + time);
rateTable = new MyTable(tm, columnModel, this);
time = System.currentTimeMillis() - time;
System.out.println("DatiRatePanel2.populatePanel() 2 time: " + time);
table = new ExcelAdapter(rateTable);
time = System.currentTimeMillis() - time;
System.out.println("DatiRatePanel2.populatePanel() 3 time: " + time);
scrollPane = new JScrollPane(rateTable);
time = System.currentTimeMillis() - time;
System.out.println("DatiRatePanel2.populatePanel() 4 time: " + time);
scrollPane.getVerticalScrollBar().setUnitIncrement(10);
this.add(scrollPane, "1, 3, fill, fill");
aggiornaTotali();
this.invalidate();
this.validate();
this.repaint();
time = System.currentTimeMillis() - time;
System.out.println("DatiRatePanel2.populatePanel() 5 time: " + time);

输出:

DatiRatePanel2.populatePanel() 1 time: 2
DatiRatePanel2.populatePanel() 2 time: 1364288266968
DatiRatePanel2.populatePanel() 3 time: 2
DatiRatePanel2.populatePanel() 4 time: 1364288266969
DatiRatePanel2.populatePanel() 5 time: 3

EDIT4:在Java插件控制台中激活了5级,这就是我得到的:

DettagliPratichePanel.updateObjects() impostazione oneri
network: Connessione a http://192.168.146.145:8080/GestioneOneriServlet/findWhereNomeConfigurazioneEqualsConfRateizzazioni con proxy=DIRECT
network: Connessione a http://192.168.146.145:8080/GestioneOneriServlet/findWhereNomeConfigurazioneEqualsConfRateizzazioni con proxy=DIRECT
network: Connessione a http://192.168.146.145:8080/GestioneOneriServlet/findWhereNomeConfigurazioneEqualsConfRateizzazioni con proxy=DIRECT
network: Connessione a http://192.168.146.145:8080/GestioneOneriServlet/findWhereNomeConfigurazioneEqualsConfRateizzazioni con proxy=DIRECT
network: Connessione a http://192.168.146.145:8080/GestioneOneriServlet/findByConfRateizzazioniConfRata con proxy=DIRECT
network: Connessione a http://192.168.146.145:8080/GestioneOneriServlet/findByConfRateizzazioniConfRata con proxy=DIRECT
network: Connessione a http://192.168.146.145:8080/GestioneOneriServlet/findByConfRateizzazioniConfRata con proxy=DIRECT
network: Connessione a http://192.168.146.145:8080/GestioneOneriServlet/findByConfRateizzazioniConfRata con proxy=DIRECT
DettagliPratichePanel.updateObjects() polizza
basic: JNLP2ClassLoader.findClass: geotel.utils.RateTableModel: try again ..
DatiRatePanel2.populatePanel() 1 time: 2
DatiRatePanel2.populatePanel() 3 time: 1364309403101
DatiRatePanel2.populatePanel() 4 time: 3
DatiRatePanel2.populatePanel() 5 time: 1364309403102
basic: JNLP2ClassLoader.findClass: geotel.utils.MyTable$ButtonsCellRenderer: try again ..
------------------------------------------------------------------------ Here starts trouble
network: Connessione a http://192.168.146.129:8091/Scia/sportello-unico-edilizia/archivio-pratiche-edilizie/permesso_di_costruire.2012-10-25.0455740504/portal_url/++resource++java/GestioneOneri.jar con proxy=DIRECT
network: Connessione a http://192.168.146.129:8091/ con proxy=DIRECT
network: Connessione http://192.168.146.129:8091/Scia/sportello-unico-edilizia/archivio-pratiche-edilizie/permesso_di_costruire.2012-10-25.0455740504/portal_url/++resource++java/GestioneOneri.jar con cookie "__ac="Qt/t/I4Nt7/qj0H5vhUrqR+ZrJYgcHJvZ2V0dGlzdGEx"; _ZopeId="97847822A52RRctuIzM""
network: CleanupThread used 1 us
network: Scaricamento risorsa: http://192.168.146.129:8091/Scia/sportello-unico-edilizia/archivio-pratiche-edilizie/permesso_di_costruire.2012-10-25.0455740504/portal_url/++resource++java/GestioneOneri.jar
    Content-Length: 1.940.942
    Content-Encoding: null
network: URL http://192.168.146.129:8091/Scia/sportello-unico-edilizia/archivio-pratiche-edilizie/permesso_di_costruire.2012-10-25.0455740504/portal_url/++resource++java/GestioneOneri.jar scritto su file C:\Users\Andrea\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\51\58374d33-15459ea4-temp
security: File lista librerie sicure non trovato
cache: Create from verifier: JarSigningData{hasOnlySignedEntries=true, hasSingleCodeSource=true, hasMissingSignedEntries=false}
network: CleanupThread used 2 us
cache: Replacing MemoryCache entry (cnt=2) for http://192.168.146.129:8091/Scia/sportello-unico-edilizia/archivio-pratiche-edilizie/permesso_di_costruire.2012-10-25.0455740504/portal_url/++resource++java/GestioneOneri.jarwas=com.sun.deploy.cache.CacheEntry (29348568) now=com.sun.deploy.cache.CacheEntry (24374818)
network: Connessione a http://192.168.146.129:8091/Scia/sportello-unico-edilizia/archivio-pratiche-edilizie/permesso_di_costruire.2012-10-25.0455740504/portal_url/++resource++java/GestioneOneri.jar con proxy=DIRECT
network: Connessione a http://192.168.146.129:8091/ con proxy=DIRECT
network: Connessione http://192.168.146.129:8091/Scia/sportello-unico-edilizia/archivio-pratiche-edilizie/permesso_di_costruire.2012-10-25.0455740504/portal_url/++resource++java/GestioneOneri.jar con cookie "__ac="Qt/t/I4Nt7/qj0H5vhUrqR+ZrJYgcHJvZ2V0dGlzdGEx"; _ZopeId="97847822A52RRctuIzM""
network: CleanupThread used 1 us
network: Scaricamento risorsa: http://192.168.146.129:8091/Scia/sportello-unico-edilizia/archivio-pratiche-edilizie/permesso_di_costruire.2012-10-25.0455740504/portal_url/++resource++java/GestioneOneri.jar
    Content-Length: 1.940.942
    Content-Encoding: null
network: URL http://192.168.146.129:8091/Scia/sportello-unico-edilizia/archivio-pratiche-edilizie/permesso_di_costruire.2012-10-25.0455740504/portal_url/++resource++java/GestioneOneri.jar scritto su file C:\Users\Andrea\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\51\58374d33-27c7ae17-temp
security: File lista librerie sicure non trovato
cache: Create from verifier: JarSigningData{hasOnlySignedEntries=true, hasSingleCodeSource=true, hasMissingSignedEntries=false}
network: CleanupThread used 1 us
cache: Replacing MemoryCache entry (cnt=3) for http://192.168.146.129:8091/Scia/sportello-unico-edilizia/archivio-pratiche-edilizie/permesso_di_costruire.2012-10-25.0455740504/portal_url/++resource++java/GestioneOneri.jarwas=com.sun.deploy.cache.CacheEntry (24374818) now=com.sun.deploy.cache.CacheEntry (8045053)

-------------------------------------This block is repeated at least 30 times before this
cache: Closing CachedJarFile C:\Users\Andrea\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\23\5d616017-2432b323
cache: MemoryCache: removed entry http://192.168.146.129:8091/Scia/sportello-unico-edilizia/archivio-pratiche-edilizie/permesso_di_costruire.2012-10-25.0455740504/portal_url/++resource++java/GestioneOneri.jar
cache: Closing CachedJarFile C:\Users\Andrea\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\51\58374d33-515e0fde
cache: Closing CachedJarFile C:\Users\Andrea\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\51\58374d33-515e0fde
cache: Closing CachedJarFile C:\Users\Andrea\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\51\58374d33-642e11c6
cache: Closing CachedJarFile C:\Users\Andrea\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\51\58374d33-642e11c6
cache: Closing CachedJarFile C:\Users\Andrea\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\51\58374d33-36c18954
cache: Closing CachedJarFile C:\Users\Andrea\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\51\58374d33-36c18954
cache: Closing CachedJarFile C:\Users\Andrea\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\51\58374d33-3dd37d44
cache: Closing CachedJarFile C:\Users\Andrea\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\51\58374d33-3dd37d44
cache: Closing CachedJarFile C:\Users\Andrea\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\51\58374d33-74a8c32b
cache: Closing CachedJarFile C:\Users\Andrea\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\51\58374d33-74a8c32b
cache: Closing CachedJarFile C:\Users\Andrea\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\51\58374d33-2278e899
cache: Closing CachedJarFile C:\Users\Andrea\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\51\58374d33-2278e899
cache: Closing CachedJarFile C:\Users\Andrea\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\51\58374d33-36a95dca
cache: Closing CachedJarFile C:\Users\Andrea\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\51\58374d33-36a95dca
cache: Closing CachedJarFile C:\Users\Andrea\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\51\58374d33-15459ea4
cache: Closing CachedJarFile C:\Users\Andrea\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\51\58374d33-15459ea4
cache: Create from verifier: JarSigningData{hasOnlySignedEntries=true, hasSingleCodeSource=true, hasMissingSignedEntries=false}
network: CleanupThread used 2 us
cache: Adding MemoryCache entry: http://192.168.146.129:8091/Scia/sportello-unico-edilizia/archivio-pratiche-edilizie/permesso_di_costruire.2012-10-25.0455740504/portal_url/++resource++java/GestioneOneri.jar
network: Connessione a http://192.168.146.129:8091/Scia/sportello-unico-edilizia/archivio-pratiche-edilizie/permesso_di_costruire.2012-10-25.0455740504/portal_url/++resource++java/GestioneOneri.jar con proxy=DIRECT
network: Connessione a http://192.168.146.129:8091/ con proxy=DIRECT
cache: Closing CachedJarFile C:\Users\Andrea\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\23\5d616017-1cffa7d0
cache: Closing CachedJarFile C:\Users\Andrea\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\14\39df63ce-72747a9e
cache: Closing CachedJarFile C:\Users\Andrea\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\15\7e499c8f-55d9e14b
cache: Closing CachedJarFile C:\Users\Andrea\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\23\5d616017-1ff05f86
cache: Closing CachedJarFile C:\Users\Andrea\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\14\39df63ce-3623cf5c
cache: Closing CachedJarFile C:\Users\Andrea\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\15\7e499c8f-767f4e5c
cache: Closing CachedJarFile C:\Users\Andrea\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\51\58374d33-78a94a0b
network: Connessione http://192.168.146.129:8091/Scia/sportello-unico-edilizia/archivio-pratiche-edilizie/permesso_di_costruire.2012-10-25.0455740504/portal_url/++resource++java/GestioneOneri.jar con cookie "__ac="Qt/t/I4Nt7/qj0H5vhUrqR+ZrJYgcHJvZ2V0dGlzdGEx"; _ZopeId="97847822A52RRctuIzM""
cache: Closing CachedJarFile C:\Users\Andrea\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\51\58374d33-16cf3e35
cache: Closing CachedJarFile C:\Users\Andrea\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\14\39df63ce-3d8f935b
cache: Closing CachedJarFile C:\Users\Andrea\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\15\7e499c8f-2b757fb1
cache: Closing CachedJarFile C:\Users\Andrea\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\23\5d616017-65139493
cache: Closing CachedJarFile C:\Users\Andrea\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\14\39df63ce-1d5deb21
cache: Closing CachedJarFile C:\Users\Andrea\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\15\7e499c8f-3a4f46c6
cache: Closing CachedJarFile C:\Users\Andrea\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\51\58374d33-48a86fb3
cache: Closing CachedJarFile C:\Users\Andrea\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\51\58374d33-4b1ec669
cache: Closing CachedJarFile C:\Users\Andrea\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\23\5d616017-1c1ed2e1
cache: Closing CachedJarFile C:\Users\Andrea\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\14\39df63ce-35f43fda
cache: Closing CachedJarFile C:\Users\Andrea\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\15\7e499c8f-14bf2ddf
cache: Closing CachedJarFile C:\Users\Andrea\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\51\58374d33-10a0c30f
network: CleanupThread used 1 us
network: Scaricamento risorsa: http://192.168.146.129:8091/Scia/sportello-unico-edilizia/archivio-pratiche-edilizie/permesso_di_costruire.2012-10-25.0455740504/portal_url/++resource++java/GestioneOneri.jar
    Content-Length: 1.940.942
    Content-Encoding: null
network: URL http://192.168.146.129:8091/Scia/sportello-unico-edilizia/archivio-pratiche-edilizie/permesso_di_costruire.2012-10-25.0455740504/portal_url/++resource++java/GestioneOneri.jar scritto su file C:\Users\Andrea\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\51\58374d33-203bfb91-temp
security: File lista librerie sicure non trovato
cache: Create from verifier: JarSigningData{hasOnlySignedEntries=true, hasSingleCodeSource=true, hasMissingSignedEntries=false}
network: CleanupThread used 1 us
cache: Replacing MemoryCache entry (cnt=3) for http://192.168.146.129:8091/Scia/sportello-unico-edilizia/archivio-pratiche-edilizie/permesso_di_costruire.2012-10-25.0455740504/portal_url/++resource++java/GestioneOneri.jarwas=com.sun.deploy.cache.CacheEntry (20330403) now=com.sun.deploy.cache.CacheEntry (8313353)
cache: MemoryCache: removed entry http://192.168.146.129:8091/Scia/sportello-unico-edilizia/archivio-pratiche-edilizie/permesso_di_costruire.2012-10-25.0455740504/portal_url/++resource++java/GestioneOneri.jar
cache: Closing CachedJarFile C:\Users\Andrea\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\51\58374d33-25fd39ec
cache: Closing CachedJarFile C:\Users\Andrea\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\51\58374d33-25fd39ec

我在这里可以理解的是,在该类加载器搜索内部类ButtonsCellRenderer之后,它会开始泛洪(最终将阻止网页中的所有内容,包括Java控制台)。 这个问题可能是由于它是内部类引起的吗?

正如Joop Eggen所问,我正在发布JTable的代码。 软件包geotel.utils;

import geotel.configuration.Configuration;
import geotel.gui.DatiPersonaliPanel;
import geotel.gui.DatiRatePanel2;
import geotel.gui.GestionePratichePanel;
import geotel.gui.IManager;
import geotel.gui.ImportazionePanel;

import java.awt.Color;
import java.awt.Component;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.net.URL;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumnModel;
import javax.swing.table.TableModel;

public class MyTable extends JTable
{
class ButtonsCellRenderer extends JPanel implements TableCellRenderer
{
    private static final long serialVersionUID = -4945689480058875463L;

    public Component getTableCellRendererComponent(final JTable table, Object value, boolean isSelected, boolean hasFocus, final int row, int column)
    {
        this.setLayout(new GridLayout(1, 1));
        if(gestione instanceof ImportazionePanel)
        {
            if(column == 0)
            {
                URL editUrl = getClass().getResource("/resource/images/051.gif");
                Image editImage = Toolkit.getDefaultToolkit().getImage(editUrl);
                JButton edit = new JButton(new ImageIcon(editImage));
                edit.setBorderPainted(false);
                edit.setContentAreaFilled(false);
                edit.setFocusPainted(false);
                edit.setOpaque(false);
                this.add(edit);
            }
            else
            {
                new Exception("else non gestito").printStackTrace();
            }
        }
        else
        {
            if(column == 0)
            {
                URL editUrl = getClass().getResource("/resource/images/005.gif");
                Image editImage = Toolkit.getDefaultToolkit().getImage(editUrl);
                JButton editB = new JButton(new ImageIcon(editImage));
                editB.setBorderPainted(false);
                editB.setContentAreaFilled(false);
                editB.setFocusPainted(false);
                editB.setOpaque(false);
                if(gestione instanceof GestionePratichePanel)
                {
                    if(Configuration.getRuoloUtenteConnesso().getModificaPratica())
                    {
                        if(edit)
                            editB.setEnabled(true);
                        else
                            editB.setEnabled(false);
                    }
                    else
                        editB.setEnabled(false);
                }
                else if(gestione instanceof DatiRatePanel2)
                {
                    if(getValueAt(row, 5) != null && !getValueAt(row, 5).equals(""))
                        editB.setEnabled(false);
                    else if(Configuration.getRuoloUtenteConnesso().getModificaPagamento())
                    {
                        if(edit)
                            editB.setEnabled(true);
                        else
                            editB.setEnabled(false);
                    }
                    else
                        editB.setEnabled(false);
                }
                else if(gestione instanceof DatiPersonaliPanel)
                {
                    if(edit)
                        editB.setEnabled(true);
                    else
                        editB.setEnabled(false);
                }
                this.add(editB);
            }
            else
            {
                URL removeUrl = getClass().getResource("/resource/images/003.gif");
                Image removeImage = Toolkit.getDefaultToolkit().getImage(removeUrl);
                JButton remove = new JButton(new ImageIcon(removeImage));
                remove.setBorderPainted(false);
                remove.setContentAreaFilled(false);
                remove.setFocusPainted(false);
                remove.setOpaque(false);
                if(gestione instanceof GestionePratichePanel)
                {
                    if(Configuration.getRuoloUtenteConnesso().getEliminaPratica())
                    {
                        if(edit)
                            remove.setEnabled(true);
                        else
                            remove.setEnabled(false);
                    }
                    else
                        remove.setEnabled(false);
                }
                else if(gestione instanceof DatiRatePanel2)
                {
                    if(getValueAt(row, 5) != null && !getValueAt(row, 5).equals(""))
                        remove.setEnabled(false);
                    else if(Configuration.getRuoloUtenteConnesso().getEliminaPagamento())
                    {
                        if(edit)
                            remove.setEnabled(true);
                        else
                            remove.setEnabled(false);
                    }
                    else
                        remove.setEnabled(false);
                }
                else if(gestione instanceof DatiPersonaliPanel)
                {
                    if(edit)
                        remove.setEnabled(true);
                    else
                        remove.setEnabled(false);
                }
                this.add(remove);
            }
        }
        return this;
    }
}

class MyTableButtonMouseListener implements MouseListener
{
    private JTable ptable;

    public MyTableButtonMouseListener(JTable table)
    {
        ptable = table;
    }

    private void forwardEventToButton(MouseEvent e)
    {
        TableColumnModel columnModel = ptable.getColumnModel();
        int column = columnModel.getColumnIndexAtX(e.getX());
        int row = e.getY() / ptable.getRowHeight();
        int value;

        if(gestione instanceof ImportazionePanel)
        {
            if(row < ptable.getRowCount() && row >= 0 && column >= 0 && column < 1)
            {
                ((ImportazionePanel) gestione).importSelected((String) ptable.getValueAt(row, 1));
                ptable.repaint();
            }
        }
        else
        {
            if(row < ptable.getRowCount() && row >= 0 && column >= 0 && column < 2)
            {
                try
                {
                    value = (Integer) ptable.getValueAt(row, 2);
                    switch(column)
                    {
                        case 0:
                        {
                            gestione.editAction(value);
                            break;
                        }
                        case 1:
                        {
                            gestione.deleteAction(value);
                            break;
                        }
                        default:
                            break;
                    }
                    ptable.repaint();
                }
                catch(Exception e1)
                {
                    e1.printStackTrace();
                }
            }
        }
    }

    public void mouseClicked(MouseEvent e)
    {
        forwardEventToButton(e);
    }

    public void mouseEntered(MouseEvent e)
    {
    }

    public void mouseExited(MouseEvent e)
    {
    }

    public void mousePressed(MouseEvent e)
    {
    }

    public void mouseReleased(MouseEvent e)
    {
    }
}

private static final long serialVersionUID = 3591458853529380099L;

protected IManager gestione;
protected TableModel tm;
protected boolean edit;

public MyTable()
{
    super();
    this.setBackground(new Color(244, 244, 244));
    this.setShowHorizontalLines(true);
    this.setShowVerticalLines(true);
    this.getTableHeader().setReorderingAllowed(false);
    this.setRowSelectionAllowed(true);
    this.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    this.setFillsViewportHeight(true);
    this.addMouseListener(new MyTableButtonMouseListener(this));
}

public MyTable(TableModel tm, TableColumnModel columns, IManager gestione, boolean edit)
{
    super(tm, columns);
    this.tm = tm;
    this.gestione = gestione;
    this.edit = edit;
    // this.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    this.setBackground(new Color(244, 244, 244));
    this.setShowHorizontalLines(true);
    this.setShowVerticalLines(true);
    this.getTableHeader().setReorderingAllowed(false);
    this.setRowSelectionAllowed(true);
    this.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    this.setFillsViewportHeight(true);
    this.addMouseListener(new MyTableButtonMouseListener(this));
}

public TableCellRenderer getCellRenderer(int row, int column)
{
    if(this.gestione instanceof ImportazionePanel)
    {
        if(column < 1)
        {
            return new ButtonsCellRenderer();
        }
        else
            return super.getCellRenderer(row, column);
    }
    else
    {
        if(column < 2)
        {
            return new ButtonsCellRenderer();
        }
        else
        {
            return super.getCellRenderer(row, column);
        }
    }
}

public RataTableRow getRowObjectByIndex(int row)
{
    if(gestione instanceof DatiRatePanel2)
    {
        return ((RateTableModel) tm).getRowObjectByIndex(row);
    }
    return null;
}

public Object[] getRowObjectById(Integer id)
{
    Object[] ret = null;
    for(int i = 0; i < tm.getRowCount(); i++)
    {
        if(tm.getValueAt(i, 2).equals(id))
        {
            ret = new Object[tm.getColumnCount()];
            for(int j = 0; j < tm.getColumnCount(); j++)
                ret[j] = tm.getValueAt(i, j);
            break;
        }
    }
    return ret;
}

public Component prepareRenderer(TableCellRenderer renderer, int Index_row, int Index_col)
{
    Component comp = super.prepareRenderer(renderer, Index_row, Index_col);
    // even index, selected or not selected
    if(Index_row % 2 == 0)
    {
        if(!isCellSelected(Index_row, Index_col))
            comp.setBackground(new Color(240, 240, 240));
        else
        {
            comp.setForeground(Color.black);
            comp.setBackground(Color.green);
        }
    }
    else
    {
        if(!isCellSelected(Index_row, Index_col))
            comp.setBackground(Color.white);
        else
        {
            comp.setForeground(Color.black);
            comp.setBackground(Color.green);
        }
    }
    return comp;
}
}

根据我的经验,类未找到的问题源于附带问题,调试环境,类加载信息,首次加载等。

对于表模型,可能会产生沉重的代价,例如在TreeModel中,TreeNode错误地递归实例化其所有子TreeTree。

我首先会寻找类似的行为,也许是分析您的表模型类。 当然,如果可能的话,我会切换一些选项卡,以查看先前的选项卡中是否有清除代码。

对于我所看到的,您正在applet中使用JDBC。 这很昂贵,因此绝对要记录所有SQL调用。

这不是一个具体的答案,但我很好奇自己是否部分正确(就像任何偷偷摸摸的骗子一样)。


扩展问题代码后

问题在于渲染器中的工作太多。 请执行下列操作。 它可以写得更紧凑。

仍然令人怀疑的是,旧的JButton.isEnabled()是在原始代码和此代码中维护的。

private JButton editB = new JButton();
private final Icon ICON_051;
private final Icon ICON_005;
private final Icon ICON_003;

public ButtonsCellRenderer()
{
    {
        URL editUrl = getClass().getResource("/resource/images/051.gif");
        Image editImage = Toolkit.getDefaultToolkit().getImage(editUrl);
        ICON_051 = new ImageIcon(editImage);
    }
    {
        URL editUrl = getClass().getResource("/resource/images/005.gif");
        Image editImage = Toolkit.getDefaultToolkit().getImage(editUrl);
        ICON_005 = new ImageIcon(editImage);
    }
    {
        URL editUrl = getClass().getResource("/resource/images/003.gif");
        Image editImage = Toolkit.getDefaultToolkit().getImage(editUrl);
        ICON_003 = new ImageIcon(editImage);
    }
    this.setLayout(new GridLayout(1, 1));
    editB.setBorderPainted(false);
    editB.setContentAreaFilled(false);
    editB.setFocusPainted(false);
    editB.setOpaque(false);
    this.add(editB);
}

public Component getTableCellRendererComponent(final JTable table, Object value, boolean isSelected, boolean hasFocus, final int row, int column)
{
    if(gestione instanceof ImportazionePanel)
    {
        if(column == 0)
        {
            editB.setIcon(ICON_051);
        }
        else
        {
            new Exception("else non gestito").printStackTrace();
        }
    }
    else
    {
        boolean enabled = editB.isEnabled();
        if(column == 0)
        {
            editB.setIcon(ICON_005);
            if(gestione instanceof GestionePratichePanel)
            {
                enabled = Configuration.getRuoloUtenteConnesso().getModificaPratica() && edit;
            }
            else if(gestione instanceof DatiRatePanel2)
            {
                if(getValueAt(row, 5) != null && !getValueAt(row, 5).equals(""))
                    enabled = false;
                else
                    enabled = Configuration.getRuoloUtenteConnesso().getModificaPagamento() && edit;
               else
                    enabled = false;
            }
            else if(gestione instanceof DatiPersonaliPanel)
            {
                enabled = edit;
            }
        }
        else
        {
            editB.setIcon(ICON_003);
            if(gestione instanceof GestionePratichePanel)
            {
                enabled = Configuration.getRuoloUtenteConnesso().getEliminaPratica() && edit;
            }
            else if(gestione instanceof DatiRatePanel2)
            {
                if(getValueAt(row, 5) != null && !getValueAt(row, 5).equals(""))
                    enabled = false;
                else
                    enabled = Configuration.getRuoloUtenteConnesso().getEliminaPagamento() && edit;
            }
            else if(gestione instanceof DatiPersonaliPanel)
            {
                eenabled = true;
            }
        }
        editB.setEnabled(enabled);
    }
    return this;
}

在网上徘徊,我发现了这个线程: jar下载了多次因为我的小程序问题中有一个与此类似的问题,所以我按照其中一项答复中的说明进行了操作(特别是关闭了控制面板/ java /常规选项卡/ Internet临时文件/保持我的计算机上的Internet临时文件),然后猜怎么着……多次下载的问题已经消失了,至少在浏览器中,导致UI冻结的异常似乎也消失了。 我将在Eclipse调试器中尝试发生的事情。 任何人都可以在最近的两个帖子中解释用户的意思吗? 关于tomcat设置缓存过滤器。 我该如何检查? 我应该用Wireshark寻找什么? 谢谢

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM