- Beranda
- Komunitas
- Tech
- Programmer Forum
[ASK] JAVA GUI ERROR


TS
sandywicaksono
[ASK] JAVA GUI ERROR
gan ane punya source code ini gan
Nah pas ane running itu gan berhasil ngambil databasenya tapi pas ane teken proses muncul error
![[ASK] JAVA GUI ERROR](https://s.kaskus.id/images/2015/01/19/1976810_20150119093748.png)
![[ASK] JAVA GUI ERROR](https://s.kaskus.id/images/2015/01/19/1976810_20150119094026.png)
kenapa ya gan ? ane bingung ini soalnya udah gaada error menurut ane gan. kenapa kok tetep nullexception ya .
makasi gan atas bantuanya
Spoiler for java source:
Code:
package data_backup;
import java.io.File;
import java.math.BigInteger;
import java.net.URI;
import java.net.URISyntaxException;
import com.ibm.zurich.credsystem.utils.Locations;
import com.ibm.zurich.idmx.api.RecipientInterface;
import com.ibm.zurich.idmx.dm.Credential;
import com.ibm.zurich.idmx.dm.Values;
import com.ibm.zurich.idmx.issuance.IssuanceSpec;
import com.ibm.zurich.idmx.issuance.Issuer;
import com.ibm.zurich.idmx.issuance.Message;
import com.ibm.zurich.idmx.issuance.Recipient;
import com.ibm.zurich.idmx.key.IssuerKeyPair;
import com.ibm.zurich.idmx.utils.XMLSerializer;
import data_backup.dbase;
public class Cred_capA_e_v {
//Variabel-Variabel :
public static URI BASE_LOCATION = new File(System.getProperty("user.dir").toURI().resolve("files/parameter/");
public static URI BASE_ID = null;
public static URI ISSUER_ID = null;
public static URI TRUSTED_PARTY_ID = null;
static {
try {
BASE_ID = new URI("http://www.zurich.ibm.com/security/idmx/vx2/");
ISSUER_ID = new URI("http://www.issuer.com/");
TRUSTED_PARTY_ID = new URI("http://www.un.org/");
} catch (URISyntaxException e) {
}
}
public static URI ISSUER_LOCATION = BASE_LOCATION.resolve("../issuerData/");
public static String CRED_STRUCT_1A = "CredStruct1a";
public static String CRED1A_FN = "Credential_1a";
private static String COMM1_FN = "comm1.bin";
private static String COMM2_FN = "comm2.bin";
private static String COMM3_FN = "comm3.bin";
private static IssuerKeyPair issuerKey = null;
//---------------------------------------------------------------------------
//Fungsi-Fungsi
public static BigInteger string_to_biginteger(String s) {
byte [] byteArray = s.getBytes();
BigInteger big = new BigInteger(byteArray);
return big;
}
public dbase z =new dbase();
public String id_pasien2=z.id_pasien;
public String nama2=z.nama;
public String umur3=z.umur2;
public String tgl_lahir2=z.tgl_lahir;
public String noktp2=z.noktp;
public String pekerjaan2=z.pekerjaan;
public String alamat2=z.alamat;
public String kelurahan2=z.kelurahan;
public String kecamatan2=z.kecamatan;
public String kota2=z.kota;
public String propinsi2=z.propinsi;
public String notelp2=z.notelp;
public String jenis_kel2=z.jenis_kel;
public String agama2=z.agama;
public String id_asuransi2=z.id_asuransi;
public String wn2=z.wn;
public BigInteger ATTRIBUTE_VALUE_1 = (string_to_biginteger(id_pasien2));
public BigInteger ATTRIBUTE_VALUE_2 = (string_to_biginteger(nama2));
public BigInteger ATTRIBUTE_VALUE_3 = (string_to_biginteger(umur3));
public BigInteger ATTRIBUTE_VALUE_4 = (string_to_biginteger(tgl_lahir2));
public BigInteger ATTRIBUTE_VALUE_6 = (string_to_biginteger(pekerjaan2));
public BigInteger ATTRIBUTE_VALUE_13 = (string_to_biginteger(jenis_kel2));
public BigInteger ATTRIBUTE_VALUE_14 = (string_to_biginteger(agama2));
public BigInteger ATTRIBUTE_VALUE_15 = (string_to_biginteger(id_asuransi2));
public BigInteger ATTRIBUTE_VALUE_16 = (string_to_biginteger(wn2));
public final void setUp(){
URI iskLocation = BASE_LOCATION.resolve("../private/isk.xml");
URI ipkLocation = ISSUER_LOCATION.resolve("ipk.xml");
issuerKey=Locations.initIssuer(BASE_LOCATION, BASE_ID.toString(), iskLocation, ipkLocation,ISSUER_ID.resolve("ipk.xml"));
String issuerKey_String = issuerKey.toString();
String credential=issuerKey_String.substring(38);
System.out.println("KeyPairnya adalah : "+credential);
String credStruct = Cred_capA_e_v.CRED_STRUCT_1A;
URI credStructLocation = null, credStructId = null;
try {
credStructLocation = BASE_LOCATION.resolve("../issuerData/" + credStruct + ".xml");
credStructId = new URI("http://www.ngo.org/" + credStruct + ".xml");
} catch (URISyntaxException e1) {
}
Locations.init(credStructId, credStructLocation);
IssuanceSpec issuanceSpec = new IssuanceSpec(ISSUER_ID.resolve("ipk.xml"), credStructId);
Values values = new Values(issuerKey.getPublicKey().getGroupParams().getSystemParams());
values.add("id_pasien", ATTRIBUTE_VALUE_1);
values.add("nama", ATTRIBUTE_VALUE_2);
values.add("umur", ATTRIBUTE_VALUE_3);
values.add("tgl_lahir", ATTRIBUTE_VALUE_4);
values.add("pekerjaan", ATTRIBUTE_VALUE_6);
values.add("jenis_kel", ATTRIBUTE_VALUE_13);
values.add("agama", ATTRIBUTE_VALUE_14);
values.add("id_asuransi", ATTRIBUTE_VALUE_15);
values.add("wn", ATTRIBUTE_VALUE_16);
Issuer issuer = new Issuer(issuerKey, issuanceSpec, values);
RecipientInterface recipient = new Recipient(issuanceSpec, values);
Message msgToRecipient1 = issuer.round0();
if (msgToRecipient1 == null) {
}
Message msgToIssuer1 = recipient.round1(msgToRecipient1);
if (msgToIssuer1 == null) {
}
Message msgToRecipient2 = issuer.round2(msgToIssuer1);
if (msgToRecipient2 == null) {
}
Credential cred = recipient.round3(msgToRecipient2);
if (cred == null) {
}
XMLSerializer.getInstance().serialize(cred,BASE_LOCATION.resolve("../private/" + CRED1A_FN + ".xml"));
String a=cred.capA();
System.out.println("CapA:"+a);
String e=cred.e();
System.out.println("e:"+e);
String v=cred.v();
System.out.println("v:"+v);
}
//--------------------------------------------------------------------------
}
Spoiler for java gui source:
Code:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package data_backup;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.swing.JOptionPane;
import data_backup.Cred_capA_e_v;
/**
*
* @author HP
*/
public class dbase extends javax.swing.JFrame {
public static String nama,alamat,umur2,id_pasien,tgl_lahir,noktp,pekerjaan,kelurahan,kecamatan,kota,propinsi,notelp,jenis_kel,agama,id_asuransi,wn;
public static int umur;
private Connection con;
private Statement stat;
private ResultSet res;
/**
* Creates new form dbase
*/
public dbase() {
initComponents();
koneksi();
}
private void koneksi(){
try {
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection(""
+ "jdbc:mysql://localhost:3306/sakitrumah", "root", "");
stat=con.createStatement();
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
}
private void datatable(String cari){
try{
String query="Select * from master_pasien where id_pasien='"+cari+"';";
ResultSet res=stat.executeQuery(query);
while(res.next()){
id_pasien=res.getString("id_pasien");
nama=res.getString("nama");
umur=res.getInt("umur");
tgl_lahir =res.getString("tgl_lahir");
noktp=res.getString("noktp");
pekerjaan =res.getString("pekerjaan");
alamat=res.getString("alamat");
kelurahan=res.getString("kelurahan");
kecamatan=res.getString("kecamatan");
kota=res.getString("kota");
propinsi=res.getString("propinsi");
notelp=res.getString("notelp");
jenis_kel=res.getString("jenis_kel");
id_asuransi=res.getString("id_asuransi");
kecamatan=res.getString("kecamatan");
wn=res.getString("wn");
}
umur2 = Integer.toString(umur);
id_pasien=id_pasien.trim();
nama=nama.trim();
umur2=umur2.trim();
tgl_lahir =tgl_lahir.trim();
noktp=noktp.trim();
pekerjaan =pekerjaan.trim();
alamat=alamat.trim();
kelurahan=kelurahan.trim();
kecamatan=kecamatan.trim();
kota=kota.trim();
propinsi=propinsi.trim();
notelp=notelp.trim();
jenis_kel=jenis_kel.trim();
id_asuransi=id_asuransi.trim();
kecamatan=kecamatan.trim();
wn=wn.trim();
}catch (Exception e){
JOptionPane.showMessageDialog(null, "Jumlah = tidak ada" , "Hasil", JOptionPane.INFORMATION_MESSAGE);
}
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
cari2 = new javax.swing.JButton();
proses = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
jTextArea1 = new javax.swing.JTextArea();
jScrollPane2 = new javax.swing.JScrollPane();
cari121 = new javax.swing.JTextPane();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
cari2.setText("Cari");
cari2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cari2ActionPerformed(evt);
}
});
proses.setText("Proses");
proses.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
prosesActionPerformed(evt);
}
});
jTextArea1.setColumns(20);
jTextArea1.setRows(5);
jScrollPane1.setViewportView(jTextArea1);
jScrollPane2.setViewportView(cari121);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(proses)
.addGroup(layout.createSequentialGroup()
.addComponent(cari2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(0, 205, Short.MAX_VALUE)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(cari2)
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(proses)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 220, Short.MAX_VALUE)
.addContainerGap())
);
pack();
}// </editor-fold>
private void cari2ActionPerformed(java.awt.event.ActionEvent evt) {
String cari = cari121.getText();
datatable(cari);
JOptionPane.showMessageDialog(null, "Jumlah = " +umur2, "Hasil", JOptionPane.INFORMATION_MESSAGE);
// TODO add your handling code here:
}
private void prosesActionPerformed(java.awt.event.ActionEvent evt) {
Cred_capA_e_v D = new Cred_capA_e_v();
//String[] nilai = new String[3];
//nilai = L.setUp();
jTextArea1.setText("Nama adalah "+D.ATTRIBUTE_VALUE_1);
// TODO add your handling code here:
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(dbase.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(dbase.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(dbase.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(dbase.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new dbase().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JTextPane cari121;
private javax.swing.JButton cari2;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JTextArea jTextArea1;
private javax.swing.JButton proses;
// End of variables declaration
}
Spoiler for database.sql:
Code:
https://www.dropbox.com/s/46jfrhfzlnhir0n/master_pasien.sql?dl=0
Nah pas ane running itu gan berhasil ngambil databasenya tapi pas ane teken proses muncul error
![[ASK] JAVA GUI ERROR](https://s.kaskus.id/images/2015/01/19/1976810_20150119093748.png)
Spoiler for error:
Code:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at data_backup.Cred_capA_e_v.string_to_biginteger(Cred_capA_e_v.java:42)
at data_backup.Cred_capA_e_v.<init>(Cred_capA_e_v.java:70)
at data_backup.dbase.prosesActionPerformed(dbase.java:185)
at data_backup.dbase.access$100(dbase.java:18)
at data_backup.dbase$2.actionPerformed(dbase.java:132)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2346)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6525)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
at java.awt.Component.processEvent(Component.java:6290)
at java.awt.Container.processEvent(Container.java:2234)
at java.awt.Component.dispatchEventImpl(Component.java:4881)
at java.awt.Container.dispatchEventImpl(Container.java:2292)
at java.awt.Component.dispatchEvent(Component.java:4703)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4898)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4533)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4462)
at java.awt.Container.dispatchEventImpl(Container.java:2278)
at java.awt.Window.dispatchEventImpl(Window.java:2739)
at java.awt.Component.dispatchEvent(Component.java:4703)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:746)
at java.awt.EventQueue.access$400(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:697)
at java.awt.EventQueue$3.run(EventQueue.java:691)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.awt.EventQueue$4.run(EventQueue.java:719)
at java.awt.EventQueue$4.run(EventQueue.java:717)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:716)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
![[ASK] JAVA GUI ERROR](https://s.kaskus.id/images/2015/01/19/1976810_20150119094026.png)
kenapa ya gan ? ane bingung ini soalnya udah gaada error menurut ane gan. kenapa kok tetep nullexception ya .
makasi gan atas bantuanya

Diubah oleh sandywicaksono 19-01-2015 21:40
0
1.3K
Kutip
3
Balasan


Komentar yang asik ya
Urutan
Terbaru
Terlama


Komentar yang asik ya
Komunitas Pilihan