2013-03-21 38 views
5

Tôi đang phát triển một applet hoạt động lạ lùng: đây không phải là điều bình thường "Tôi không thể khởi động applet trong trình duyệt", nhưng điều gì đó tinh tế hơn.Applet hidden exceptionnotfound exception

Ứng dụng này bao gồm một jtabbedpane với 8 tab, mỗi tab thực hiện một số thao tác dữ liệu trong luồng công việc và người dùng có hai nút (quay lại và tiến lên) để chuyển qua các tab.

Khi tôi chạy trình duyệt vào trình duyệt (chrome hoặc firefox mới nhất, nhưng điều này không quan trọng), tôi nhận thấy sự chậm lại nhất quán khi chuyển từ tab thứ 7 đến tab thứ 8: sau đó tôi đặt một jtable với bảng tùy chỉnh trong tab đó và trong nhật thực nó chạy tốt. Một vài bước gỡ lỗi sau này tôi nhận thấy rằng jvm ném một classnotfoundexception cho lớp RateTableModel, đó là bảng mô hình tùy chỉnh của tôi. Điều kỳ lạ là mặc dù tôi thử nghiệm applet cả trong IDE và như một applet tự ký vào trình duyệt mà ngoại lệ không bao giờ được ném vào bất kỳ giao diện điều khiển nào. Tôi xác nhận ở khắp mọi nơi: không có khối catch trống, mọi ngoại lệ luôn luôn được xếp chồng lên nhau và nếu tôi đặt mã khởi tạo của tablemodel của tôi trong khối try/catch mà ngoại lệ không bao giờ bị bắt. Điều thú vị hơn là sau một khoảng thời gian ngẫu nhiên, việc thực hiện tiếp tục như không có gì xảy ra (chỉ trong IDE lần này), trong khi trong trình duyệt, GUI hoạt động giống như một ngoại lệ bình thường: nó làm mọi thứ lộn xộn.

Điều tôi muốn hỏi là cho bất kỳ ý tưởng nào về lý do điều này xảy ra.

Lớp RateTableModel nằm trong gói geotel.utils, nơi tôi có các lớp khác mà tôi thường xuyên khởi tạo trước khi tôi phải tải lớp này và tôi đã xác minh rằng lớp này có trong jar.

Chi tiết về sự phát triển (có thể cho những người đọc này có thể hữu ích):

Các applet được ký bằng lệnh

jarsigner -keystore keystore3 C:\GestioneOneri.jar me3 

applet được chạy từ file html sau:

<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> 

các tập tin JNLP như sau:

<?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> 

Mã gây ra ClassNotFoundException như sau: lớp DatiRatePanel

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

và định nghĩa của RateTableModel lớp là

public class RateTableModel extends AbstractTableModel 

EDIT: sau hơn một vài bước gỡ lỗi, tôi thấy rằng trong chế độ xem gỡ lỗi, có tình huống trong ảnh chụp màn hình Debug

Tôi hoàn toàn không có ý tưởng những gì các phím đứng, nhưng nếu tôi tiếp tục nhấn F5 (Bước vào) những chìa khóa biến mất, các bước sau đây thực hiện tiếp tục và classloader kỳ diệu sẽ trở thành có thể tìm thấy lớp RateTableModel. Làm thế nào tôi có thể thoát khỏi điều này?

Cảm ơn bạn!

EDIT2: Tôi đã nghiên cứu một chút về các biểu tượng phím trong tài liệu Eclipse và phát hiện ra chúng là các màn hình trên các đối tượng bị khóa. Theo như tôi biết màn hình xuất hiện, nơi có khối mã đồng bộ, mà tôi không có ở đây (và tôi chắc chắn rằng những khối không được gọi). Nó khiến tôi phát điên ...

EDIT3: Tôi đã thử đặt một số bản in về lượng thời gian mỗi lệnh cần thiết, sau đây là mã nguồn và đầu ra. Tôi không hiểu tại sao thời gian được "thiết lập lại" (hoặc như vậy có vẻ như) trong in 2 và 4, có vẻ như có nhiều chủ đề mà không thấy biến thời gian khởi tạo (nhưng nó không thể!).

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); 

Output:

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: kích hoạt mức 5 trong java plugin của giao diện điều khiển và đây là những gì tôi nhận:

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 

Những gì tôi có thể hiểu ở đây là sau khi classloader mà tìm kiếm cho lớp bên trong ButtonsCellRenderer nó bắt đầu lũ lụt này (mà cuối cùng khối tất cả mọi thứ trong trang web, bao gồm cả giao diện điều khiển java). Vấn đề này có thể được gây ra bởi thực tế nó là một lớp bên trong?

Như Joop Eggen đã hỏi, tôi đăng mã của JTable của tôi. gói 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; 
} 
} 
+0

Có thể có một số phụ thuộc bên trong lớp geotel.utils.RateTableModel không được thêm vào bình, xem lại các lớp được nhập bởi lớp này, thử loại bỏ từng cái một và kiểm tra lại một lần nữa để xem có hoạt động không . – fmodos

+0

Cảm ơn bạn đã trả lời (tôi không thấy nó trước đây). Tôi sẽ kiểm tra xem mỗi lớp nhập khẩu có trong bình không. Dù sao tôi muốn hỏi bạn một điều: nếu bình không hoạt động bây giờ, làm sao nó có thể hoạt động nếu tôi loại bỏ từng lớp một? Ý tôi là, đã có sự thừa nhận không theo lớp, tôi sẽ không thêm một classnotfoundexception khác làm như vậy sao? – Andrea

+0

nhập khẩu geotel.dao.factory.RataDaoFactory; nhập geotel.domain.OnerePratica; nhập geotel.domain.Rata; nhập geotel.domain.RateizzazionePrevista; nhập java.math.BigDecimal; nhập java.util.ArrayList; nhập java.util.Collections; nhập java.util.Date; nhập javax.swing.table.AbstractTableModel; Đây là danh sách nhập đầy đủ: các lớp học của tôi (gói geotel. *) Đều nằm trong bình. Các lớp khác là các lớp java tiêu chuẩn NÊN có mặt trong jvm ... – Andrea

Trả lời

1

Lang thang trên mạng tôi thấy chủ đề này: jar downloaded multiple times Kể từ giữa các vấn đề applet của tôi có là một tương tự như sau Tôi làm theo các hướng dẫn trong một trong các câu trả lời (đặc biệt là tắt Control panel/java/tab general/các tệp Internet tạm thời/Giữ các tệp Internet tạm thời trên máy tính của tôi) và đoán xem ... sự cố của nhiều lần tải xuống đã biến mất và ít nhất là trong trình duyệt ngoại lệ khiến giao diện người dùng bị đóng băng dường như biến mất. Tôi sẽ thử trong trình gỡ lỗi nhật thực những gì đang xảy ra. Bất kỳ ai cũng có thể giải thích ý nghĩa của người dùng trong hai bài đăng cuối cùng? Giới thiệu về tomcat đặt bộ lọc cache. Làm thế nào tôi có thể kiểm tra điều đó?Tôi nên tìm gì với Wireshark? Cảm ơn bạn

4

Với một số kinh nghiệm tôi đoán là, rằng vấn đề đẳng cấp not-found xuất phát từ một phụ vấn đề, môi trường gỡ lỗi, thông tin lớp xếp hàng, bốc đầu hoặc lâu hơn.

Với một mô hình bảng, một hình phạt nặng có thể phát sinh, như trong TreeModel, nơi một TreeNode tạo ra một cách đệ quy tất cả các TreeNode con của nó một cách sai lầm.

Trước tiên tôi sẽ tìm kiếm hành vi tương tự, có thể lược tả lớp mô hình bảng của bạn. Chắc chắn tôi sẽ chuyển đổi một số tab nếu có thể, để xem liệu có mã dọn dẹp trong tab trước hay không.

Đối với những gì tôi có thể thấy, bạn đang sử dụng JDBC trong applet. Điều này là tốn kém, vì vậy chắc chắn đăng nhập tất cả các cuộc gọi SQL.

Không phải là câu trả lời cụ thể, nhưng tôi tò mò liệu tôi đã đúng một phần (giống như bất kỳ hành trình rõ ràng nào của charlatan).


Sau khi mã câu hỏi mở rộng

Vấn đề là ở chỗ có quá nhiều công việc trong các renderer. Làm như sau. Nó có thể được viết gọn hơn.

Điều gì vẫn còn nghi ngờ, là cũ JButton.isEnabled() được duy trì trong bản gốc và mã này.

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; 
} 
+0

Bạn có ý gì khi "định hình lớp mô hình bảng"? – Andrea

+0

Điều đó có thể có hoạt động chậm lặp đi lặp lại. Ví dụ: liên tục tìm nạp một hàng cho mỗi cột, nơi tìm nạp hàng chậm. –

+0

Tôi không biết nếu bạn nhận thấy, nhưng tôi đã thêm một phần "EDIT4", nơi tôi đặt nhật ký JVM chi tiết. Đoán xem .. có một hoạt động lặp đi lặp lại khoảng 30 lần. Bạn có biết nó là gì không và cách loại bỏ nó? – Andrea