List Coding
List Coding
List Coding
import java.sql.DriverManager;
import java.sql.SQLException;
/**
*
* @author ODI
*/
public class KoneksiDB {
private static java.sql.Connection koneksi;
LOGIN.java
/*
* 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 PROGRAM;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.KeyEvent;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
/**
*
* @author USER
*/
public class LOGIN extends javax.swing.JFrame {
/**
* Creates new form LOGIN
*/
public LOGIN() throws SQLException {
initComponents();
Dimension layar = Toolkit.getDefaultToolkit().getScreenSize();
int x = layar.width / 2 - this.getSize().width / 2;
int y = layar.height / 2 - this.getSize().height / 2;
this.setLocation(x, y);
Connection c=KoneksiDB.getKoneksi();
/**
* 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() {
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
pack();
}// </editor-fold>
/**
* @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(LOGIN.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(LOGIN.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(LOGIN.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(LOGIN.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
//</editor-fold>
DASHBOARD.java
/*
* 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 PROGRAM;
import java.awt.Font;
import java.io.File;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Collections;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.filechooser.FileFilter;
import javax.swing.filechooser.FileNameExtensionFilter;
import javax.swing.table.DefaultTableModel;
/**
*
* @author ODI
*/
public class DASHBOARD extends javax.swing.JFrame {
String filename;
DefaultTableModel modelinput;
DefaultTableModel modelinput2;
DefaultTableModel modelIkanPatin;
DefaultTableModel modelIkanLele;
DefaultTableModel modelIkanNila;
DefaultTableModel modelIkanMas;
DefaultTableModel modelIkanKakap;
DefaultTableModel modelIkanBandeng;
DefaultTableModel modelIkanKerapu;
DefaultTableModel modelUdang;
DefaultTableModel modelPeramalan;
public DASHBOARD() {
initComponents();
this.setExtendedState(JFrame.MAXIMIZED_BOTH);
panel_INPUT.setVisible(true);
panel_PREDIKSI.setVisible(false);
String [] headerinput= {"No", "Tahun" , "Ikan Patin", "Ikan Lele", "Ikan Nila" , "Ikan Mas", "Ikan Kakap", "Ikan
Bandeng", "Ikan Kerapu", "Udang"};
modelinput = new DefaultTableModel(headerinput, 0);
tbl_input.setModel(modelinput);
tbl_input.getTableHeader().setFont(new Font("Tahoma", Font.BOLD, 12));
String [] headerinput2= {"No", "Tahun" , "Ikan Patin", "Ikan Lele", "Ikan Nila" , "Ikan Mas", "Ikan Kakap", "Ikan
Bandeng", "Ikan Kerapu", "Udang"};
modelinput2 = new DefaultTableModel(headerinput, 0);
tbl_input2.setModel(modelinput2);
tbl_input2.getTableHeader().setFont(new Font("Tahoma", Font.BOLD, 12));
String [] headerFuzzyfikasi= {"No", "Tahun" , "Data Aktual", "Fuzzyfikasi", "Nilai FLRG" , "NILAI PERAMALAN"};
modelIkanPatin = new DefaultTableModel(headerFuzzyfikasi, 0);
tbl_1.setModel(modelIkanPatin);
tbl_1.getTableHeader().setFont(new Font("Tahoma", Font.BOLD, 12));
tampilInput();
tampilInput2();
}
while (rs.next()){
String data[]=
{String.valueOf(no),rs.getString(1),rs.getString(2),rs.getString(3),rs.getString(4),rs.getString(5),rs.getString(6),rs.getS
tring(7),rs.getString(8),rs.getString(9)};
modelinput.addRow(data);
no++;
}
tbl_input.setModel(modelinput);
} catch (SQLException ex) {
System.out.println("GAGAL TAMPILKAN DARI DATABASE");
}
}
private void tampilInput2(){
int row=tbl_input2.getRowCount();
for(int a=0 ; a<row ; a++){
modelinput2.removeRow(0);
}
int no=1;
try {
Connection cn = KoneksiDB.getKoneksi();
ResultSet rs= cn.createStatement() .executeQuery("SELECT * FROM tabel_produksi_ikan");
while (rs.next()){
String data[]=
{String.valueOf(no),rs.getString(1),rs.getString(2),rs.getString(3),rs.getString(4),rs.getString(5),rs.getString(6),rs.getS
tring(7),rs.getString(8),rs.getString(9)};
modelinput2.addRow(data);
no++;
}
tbl_input2.setModel(modelinput2);
} catch (SQLException ex) {
System.out.println("GAGAL TAMPILKAN DARI DATABASE");
}
}
private void reset(){
cmb_tahun.setSelectedIndex(0);
txt_patin.setText("");
txt_lele.setText("");
txt_nila.setText("");
txt_mas.setText("");
txt_kakap.setText("");
txt_bandeng.setText("");
txt_kerapu.setText("");
txt_udang.setText("");
}
private void tambah(){
String tahun=(String) cmb_tahun.getSelectedItem();
String patin=txt_patin.getText();
String lele=txt_lele.getText();
String nila=txt_nila.getText();
String mas=txt_mas.getText();
String kakap=txt_kakap.getText();
String bandeng=txt_bandeng.getText();
String kerapu=txt_kerapu.getText();
String udang=txt_udang.getText();
try {
Connection cn=KoneksiDB.getKoneksi();
cn.createStatement().executeUpdate("insert into tabel_produksi_ikan
values"+"('"+tahun+"','"+patin+"','"+lele+"','"+nila+"','"+mas+"','"+kakap+"','"+bandeng+"','"+kerapu+"','"+udang+"'
)");
JOptionPane.showMessageDialog(null, "Berhasil Mengisi Data");
tampilInput();
reset();
}catch(Exception e){
JOptionPane.showMessageDialog(null, "GAGAL MENAMBAHKAN DATA");
}
}
private void edit(){
String tahun=(String) cmb_tahun.getSelectedItem();
String patin=txt_patin.getText();
String lele=txt_lele.getText();
String nila=txt_nila.getText();
String mas=txt_mas.getText();
String kakap=txt_kakap.getText();
String bandeng=txt_bandeng.getText();
String kerapu=txt_kerapu.getText();
String udang=txt_udang.getText();
try {
Connection cn = KoneksiDB.getKoneksi();
cn.createStatement().executeUpdate("update tabel_produksi_ikan set
patin='"+patin+"',lele='"+lele+"',nila='"+nila+"',mas='"+mas+"',kakap='"+kakap+"',bandeng='"+bandeng+"',kerapu='
"+kerapu+"',udang='"+udang+"' where tahun='"+tahun+"'");
JOptionPane.showMessageDialog(null,"BERHASIL DI UPDATE !!!");
tampilInput();
reset();
} catch (SQLException ex) {
JOptionPane.showMessageDialog(null,"ADA KESALAHAN MENGEDIT DATA !!!");
}
}
private void hapus(){
String tahun=(String) cmb_tahun.getSelectedItem();
int jawab = JOptionPane.showOptionDialog(this,
"Anda Akan Menghapus Data Tahun "+tahun+", TETAP LANJUTKAN...? ",
"WARNING!!!",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE, null, null, null);
if(jawab == JOptionPane.YES_OPTION){
try {
Connection cn = KoneksiDB.getKoneksi();
cn.createStatement().executeUpdate("delete from tabel_produksi_ikan where tahun='"+tahun+"'");
JOptionPane.showMessageDialog(null,"DATA PRODUKSI IKAN TAHUN "+tahun+" BERHASIL DIHAPUS !!!");
tampilInput();
reset();
}catch (SQLException e){
JOptionPane.showMessageDialog(null,"Periksa Kembali !!!");
}
}
}
modelIkanPatin.setRowCount(0);
modelIkanLele.setRowCount(0);
modelIkanNila.setRowCount(0);
modelIkanMas.setRowCount(0);
modelIkanKakap.setRowCount(0);
modelIkanBandeng.setRowCount(0);
modelIkanKerapu.setRowCount(0);
modelUdang.setRowCount(0);
modelPeramalan.setRowCount(0);
}
a1_1.setText("A1 : "+df.format(a1));
a2_1.setText("A2 : "+df.format(a2));
a3_1.setText("A3 : "+df.format(a3));
a4_1.setText("A4 : "+df.format(a4));
int no=1;
String fz="";
ArrayList <Double> flrg=new ArrayList<>();
double mape=0;
for (int i = 0; i < row; i++) {
if(data.get(i)>=a1_min && data.get(i)<=a1_max){
fz="A1";
}else if (data.get(i)>a2_min && data.get(i) <=a2_max) {
fz="A2";
}else if (data.get(i)>a3_min && data.get(i) <=a3_max) {
fz="A3";
}else if (data.get(i)>a4_min && data.get(i) <=a4_max) {
fz="A4";
}
if(fz.equals("A1")){
flrg.add(a1);
}else if(fz.equals("A2")){
flrg.add(a2);
}else if(fz.equals("A3")){
flrg.add(a3);
}else if(fz.equals("A4")){
flrg.add(a4);
}
double peramalan=0;
if(i==0){
String obj[]={String.valueOf(no),String.valueOf(tbl_input2.getValueAt(i,
1)),String.valueOf(data.get(i)),fz,String.valueOf(df.format(flrg.get(i))),"NAN"};
modelIkanPatin.addRow(obj);
no++;
tbl_1.setModel(modelIkanPatin);
}else if(i==row-1){
String obj[]={String.valueOf(no),String.valueOf(tbl_input2.getValueAt(i,
1)),String.valueOf(data.get(i)),"-","-",String.valueOf(df.format(flrg.get(i-1)))};
modelIkanPatin.addRow(obj);
no++;
tbl_1.setModel(modelIkanPatin);
mape=Math.abs(data.get(i)-flrg.get(i-1))/data.get(i)*100;
mape_1.setText("MAPE : "+df.format(mape)+" %");
}else{
String obj[]={String.valueOf(no),String.valueOf(tbl_input2.getValueAt(i,
1)),String.valueOf(data.get(i)),fz,String.valueOf(df.format(flrg.get(i))),String.valueOf(df.format(flrg.get(i-1)))};
modelIkanPatin.addRow(obj);
no++;
tbl_1.setModel(modelIkanPatin);
}
}
}
a1_2.setText("A1 : "+df.format(a1));
a2_2.setText("A2 : "+df.format(a2));
a3_2.setText("A3 : "+df.format(a3));
a4_2.setText("A4 : "+df.format(a4));
int no=1;
String fz="";
ArrayList <Double> flrg=new ArrayList<>();
double mape=0;
for (int i = 0; i < row; i++) {
if(data.get(i)>=a1_min && data.get(i)<=a1_max){
fz="A1";
}else if (data.get(i)>a2_min && data.get(i) <=a2_max) {
fz="A2";
}else if (data.get(i)>a3_min && data.get(i) <=a3_max) {
fz="A3";
}else if (data.get(i)>a4_min && data.get(i) <=a4_max) {
fz="A4";
}
if(fz.equals("A1")){
flrg.add(a1);
}else if(fz.equals("A2")){
flrg.add(a2);
}else if(fz.equals("A3")){
flrg.add(a3);
}else if(fz.equals("A4")){
flrg.add(a4);
}
double peramalan=0;
if(i==0){
String obj[]={String.valueOf(no),String.valueOf(tbl_input2.getValueAt(i,
1)),String.valueOf(data.get(i)),fz,String.valueOf(df.format(flrg.get(i))),"NAN"};
modelIkanLele.addRow(obj);
no++;
tbl_2.setModel(modelIkanLele);
}else if(i==row-1){
String obj[]={String.valueOf(no),String.valueOf(tbl_input2.getValueAt(i,
1)),String.valueOf(data.get(i)),"-","-",String.valueOf(df.format(flrg.get(i-1)))};
modelIkanLele.addRow(obj);
no++;
tbl_2.setModel(modelIkanLele);
mape=Math.abs(data.get(i)-flrg.get(i-1))/data.get(i)*100;
mape_2.setText("MAPE : "+df.format(mape)+" %");
}else{
String obj[]={String.valueOf(no),String.valueOf(tbl_input2.getValueAt(i,
1)),String.valueOf(data.get(i)),fz,String.valueOf(df.format(flrg.get(i))),String.valueOf(df.format(flrg.get(i-1)))};
modelIkanLele.addRow(obj);
no++;
tbl_2.setModel(modelIkanLele);
}
}
}
a1_3.setText("A1 : "+df.format(a1));
a2_3.setText("A2 : "+df.format(a2));
a3_3.setText("A3 : "+df.format(a3));
a4_3.setText("A4 : "+df.format(a4));
int no=1;
String fz="";
ArrayList <Double> flrg=new ArrayList<>();
double mape=0;
for (int i = 0; i < row; i++) {
if(data.get(i)>=a1_min && data.get(i)<=a1_max){
fz="A1";
}else if (data.get(i)>a2_min && data.get(i) <=a2_max) {
fz="A2";
}else if (data.get(i)>a3_min && data.get(i) <=a3_max) {
fz="A3";
}else if (data.get(i)>a4_min && data.get(i) <=a4_max) {
fz="A4";
}
if(fz.equals("A1")){
flrg.add(a1);
}else if(fz.equals("A2")){
flrg.add(a2);
}else if(fz.equals("A3")){
flrg.add(a3);
}else if(fz.equals("A4")){
flrg.add(a4);
}
double peramalan=0;
if(i==0){
String obj[]={String.valueOf(no),String.valueOf(tbl_input2.getValueAt(i,
1)),String.valueOf(data.get(i)),fz,String.valueOf(df.format(flrg.get(i))),"NAN"};
modelIkanNila.addRow(obj);
no++;
tbl_3.setModel(modelIkanNila);
}else if(i==row-1){
String obj[]={String.valueOf(no),String.valueOf(tbl_input2.getValueAt(i,
1)),String.valueOf(data.get(i)),"-","-",String.valueOf(df.format(flrg.get(i-1)))};
modelIkanNila.addRow(obj);
no++;
tbl_3.setModel(modelIkanNila);
mape=Math.abs(data.get(i)-flrg.get(i-1))/data.get(i)*100;
mape_3.setText("MAPE : "+df.format(mape)+" %");
}else{
String obj[]={String.valueOf(no),String.valueOf(tbl_input2.getValueAt(i,
1)),String.valueOf(data.get(i)),fz,String.valueOf(df.format(flrg.get(i))),String.valueOf(df.format(flrg.get(i-1)))};
modelIkanNila.addRow(obj);
no++;
tbl_3.setModel(modelIkanNila);
}
}
}
a1_4.setText("A1 : "+df.format(a1));
a2_4.setText("A2 : "+df.format(a2));
a3_4.setText("A3 : "+df.format(a3));
a4_4.setText("A4 : "+df.format(a4));
int no=1;
String fz="";
ArrayList <Double> flrg=new ArrayList<>();
double mape=0;
for (int i = 0; i < row; i++) {
if(data.get(i)>=a1_min && data.get(i)<=a1_max){
fz="A1";
}else if (data.get(i)>a2_min && data.get(i) <=a2_max) {
fz="A2";
}else if (data.get(i)>a3_min && data.get(i) <=a3_max) {
fz="A3";
}else if (data.get(i)>a4_min && data.get(i) <=a4_max) {
fz="A4";
}
if(fz.equals("A1")){
flrg.add(a1);
}else if(fz.equals("A2")){
flrg.add(a2);
}else if(fz.equals("A3")){
flrg.add(a3);
}else if(fz.equals("A4")){
flrg.add(a4);
}
double peramalan=0;
if(i==0){
String obj[]={String.valueOf(no),String.valueOf(tbl_input2.getValueAt(i,
1)),String.valueOf(data.get(i)),fz,String.valueOf(df.format(flrg.get(i))),"NAN"};
modelIkanMas.addRow(obj);
no++;
tbl_4.setModel(modelIkanMas);
}else if(i==row-1){
String obj[]={String.valueOf(no),String.valueOf(tbl_input2.getValueAt(i,
1)),String.valueOf(data.get(i)),"-","-",String.valueOf(df.format(flrg.get(i-1)))};
modelIkanMas.addRow(obj);
no++;
tbl_4.setModel(modelIkanMas);
mape=Math.abs(data.get(i)-flrg.get(i-1))/data.get(i)*100;
mape_4.setText("MAPE : "+df.format(mape)+" %");
}else{
String obj[]={String.valueOf(no),String.valueOf(tbl_input2.getValueAt(i,
1)),String.valueOf(data.get(i)),fz,String.valueOf(df.format(flrg.get(i))),String.valueOf(df.format(flrg.get(i-1)))};
modelIkanMas.addRow(obj);
no++;
tbl_4.setModel(modelIkanMas);
}
}
}
a1_5.setText("A1 : "+df.format(a1));
a2_5.setText("A2 : "+df.format(a2));
a3_5.setText("A3 : "+df.format(a3));
a4_5.setText("A4 : "+df.format(a4));
int no=1;
String fz="";
ArrayList <Double> flrg=new ArrayList<>();
double mape=0;
for (int i = 0; i < row; i++) {
if(data.get(i)>=a1_min && data.get(i)<=a1_max){
fz="A1";
}else if (data.get(i)>a2_min && data.get(i) <=a2_max) {
fz="A2";
}else if (data.get(i)>a3_min && data.get(i) <=a3_max) {
fz="A3";
}else if (data.get(i)>a4_min && data.get(i) <=a4_max) {
fz="A4";
}
if(fz.equals("A1")){
flrg.add(a1);
}else if(fz.equals("A2")){
flrg.add(a2);
}else if(fz.equals("A3")){
flrg.add(a3);
}else if(fz.equals("A4")){
flrg.add(a4);
}
double peramalan=0;
if(i==0){
String obj[]={String.valueOf(no),String.valueOf(tbl_input2.getValueAt(i,
1)),String.valueOf(data.get(i)),fz,String.valueOf(df.format(flrg.get(i))),"NAN"};
modelIkanKakap.addRow(obj);
no++;
tbl_5.setModel(modelIkanKakap);
}else if(i==row-1){
String obj[]={String.valueOf(no),String.valueOf(tbl_input2.getValueAt(i,
1)),String.valueOf(data.get(i)),"-","-",String.valueOf(df.format(flrg.get(i-1)))};
modelIkanKakap.addRow(obj);
no++;
tbl_5.setModel(modelIkanKakap);
mape=Math.abs(data.get(i)-flrg.get(i-1))/data.get(i)*100;
mape_5.setText("MAPE : "+df.format(mape)+" %");
}else{
String obj[]={String.valueOf(no),String.valueOf(tbl_input2.getValueAt(i,
1)),String.valueOf(data.get(i)),fz,String.valueOf(df.format(flrg.get(i))),String.valueOf(df.format(flrg.get(i-1)))};
modelIkanKakap.addRow(obj);
no++;
tbl_5.setModel(modelIkanKakap);
}
}
}
a1_6.setText("A1 : "+df.format(a1));
a2_6.setText("A2 : "+df.format(a2));
a3_6.setText("A3 : "+df.format(a3));
a4_6.setText("A4 : "+df.format(a4));
int no=1;
String fz="";
ArrayList <Double> flrg=new ArrayList<>();
double mape=0;
for (int i = 0; i < row; i++) {
if(data.get(i)>=a1_min && data.get(i)<=a1_max){
fz="A1";
}else if (data.get(i)>a2_min && data.get(i) <=a2_max) {
fz="A2";
}else if (data.get(i)>a3_min && data.get(i) <=a3_max) {
fz="A3";
}else if (data.get(i)>a4_min && data.get(i) <=a4_max) {
fz="A4";
}
if(fz.equals("A1")){
flrg.add(a1);
}else if(fz.equals("A2")){
flrg.add(a2);
}else if(fz.equals("A3")){
flrg.add(a3);
}else if(fz.equals("A4")){
flrg.add(a4);
}
double peramalan=0;
if(i==0){
String obj[]={String.valueOf(no),String.valueOf(tbl_input2.getValueAt(i,
1)),String.valueOf(data.get(i)),fz,String.valueOf(df.format(flrg.get(i))),"NAN"};
modelIkanBandeng.addRow(obj);
no++;
tbl_6.setModel(modelIkanBandeng);
}else if(i==row-1){
String obj[]={String.valueOf(no),String.valueOf(tbl_input2.getValueAt(i,
1)),String.valueOf(data.get(i)),"-","-",String.valueOf(df.format(flrg.get(i-1)))};
modelIkanBandeng.addRow(obj);
no++;
tbl_6.setModel(modelIkanBandeng);
mape=Math.abs(data.get(i)-flrg.get(i-1))/data.get(i)*100;
mape_6.setText("MAPE : "+df.format(mape)+" %");
}else{
String obj[]={String.valueOf(no),String.valueOf(tbl_input2.getValueAt(i,
1)),String.valueOf(data.get(i)),fz,String.valueOf(df.format(flrg.get(i))),String.valueOf(df.format(flrg.get(i-1)))};
modelIkanBandeng.addRow(obj);
no++;
tbl_6.setModel(modelIkanBandeng);
}
}
}
a1_7.setText("A1 : "+df.format(a1));
a2_7.setText("A2 : "+df.format(a2));
a3_7.setText("A3 : "+df.format(a3));
a4_7.setText("A4 : "+df.format(a4));
int no=1;
String fz="";
ArrayList <Double> flrg=new ArrayList<>();
double mape=0;
for (int i = 0; i < row; i++) {
if(data.get(i)>=a1_min && data.get(i)<=a1_max){
fz="A1";
}else if (data.get(i)>a2_min && data.get(i) <=a2_max) {
fz="A2";
}else if (data.get(i)>a3_min && data.get(i) <=a3_max) {
fz="A3";
}else if (data.get(i)>a4_min && data.get(i) <=a4_max) {
fz="A4";
}
if(fz.equals("A1")){
flrg.add(a1);
}else if(fz.equals("A2")){
flrg.add(a2);
}else if(fz.equals("A3")){
flrg.add(a3);
}else if(fz.equals("A4")){
flrg.add(a4);
}
double peramalan=0;
if(i==0){
String obj[]={String.valueOf(no),String.valueOf(tbl_input2.getValueAt(i,
1)),String.valueOf(data.get(i)),fz,String.valueOf(df.format(flrg.get(i))),"NAN"};
modelIkanKerapu.addRow(obj);
no++;
tbl_7.setModel(modelIkanKerapu);
}else if(i==row-1){
String obj[]={String.valueOf(no),String.valueOf(tbl_input2.getValueAt(i,
1)),String.valueOf(data.get(i)),"-","-",String.valueOf(df.format(flrg.get(i-1)))};
modelIkanKerapu.addRow(obj);
no++;
tbl_7.setModel(modelIkanKerapu);
mape=Math.abs(data.get(i)-flrg.get(i-1))/data.get(i)*100;
mape_7.setText("MAPE : "+df.format(mape)+" %");
}else{
String obj[]={String.valueOf(no),String.valueOf(tbl_input2.getValueAt(i,
1)),String.valueOf(data.get(i)),fz,String.valueOf(df.format(flrg.get(i))),String.valueOf(df.format(flrg.get(i-1)))};
modelIkanKerapu.addRow(obj);
no++;
tbl_7.setModel(modelIkanKerapu);
}
}
}
a1_8.setText("A1 : "+df.format(a1));
a2_8.setText("A2 : "+df.format(a2));
a3_8.setText("A3 : "+df.format(a3));
a4_8.setText("A4 : "+df.format(a4));
int no=1;
String fz="";
ArrayList <Double> flrg=new ArrayList<>();
double mape=0;
for (int i = 0; i < row; i++) {
if(data.get(i)>=a1_min && data.get(i)<=a1_max){
fz="A1";
}else if (data.get(i)>a2_min && data.get(i) <=a2_max) {
fz="A2";
}else if (data.get(i)>a3_min && data.get(i) <=a3_max) {
fz="A3";
}else if (data.get(i)>a4_min && data.get(i) <=a4_max) {
fz="A4";
}
if(fz.equals("A1")){
flrg.add(a1);
}else if(fz.equals("A2")){
flrg.add(a2);
}else if(fz.equals("A3")){
flrg.add(a3);
}else if(fz.equals("A4")){
flrg.add(a4);
}
double peramalan=0;
if(i==0){
String obj[]={String.valueOf(no),String.valueOf(tbl_input2.getValueAt(i,
1)),String.valueOf(data.get(i)),fz,String.valueOf(df.format(flrg.get(i))),"NAN"};
modelUdang.addRow(obj);
no++;
tbl_8.setModel(modelUdang);
}else if(i==row-1){
String obj[]={String.valueOf(no),String.valueOf(tbl_input2.getValueAt(i,
1)),String.valueOf(data.get(i)),"-","-",String.valueOf(df.format(flrg.get(i-1)))};
modelUdang.addRow(obj);
no++;
tbl_8.setModel(modelUdang);
mape=Math.abs(data.get(i)-flrg.get(i-1))/data.get(i)*100;
mape_8.setText("MAPE : "+df.format(mape)+" %");
}else{
String obj[]={String.valueOf(no),String.valueOf(tbl_input2.getValueAt(i,
1)),String.valueOf(data.get(i)),fz,String.valueOf(df.format(flrg.get(i))),String.valueOf(df.format(flrg.get(i-1)))};
modelUdang.addRow(obj);
no++;
tbl_8.setModel(modelUdang);
}
}
}
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
tbl_input2.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null}
},
new String [] {
"Title 1", "Title 2", "Title 3", "Title 4"
}
));
jScrollPane2.setViewportView(tbl_input2);
tbl_1.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null}
},
new String [] {
"Title 1", "Title 2", "Title 3", "Title 4"
}
));
jScrollPane3.setViewportView(tbl_1);
txt_IntervalA1_1.setText("A1");
txt_IntervalA2_1.setText("A2");
txt_IntervalA3_1.setText("A3");
txt_IntervalA4_1.setText("A4");
a1_1.setText("A1 :");
a2_1.setText("A2 :");
a3_1.setText("A3 :");
a4_1.setText("A4 :");
txt_IntervalA1_2.setText("A1");
txt_IntervalA2_2.setText("A2");
txt_IntervalA3_2.setText("A3");
txt_IntervalA4_2.setText("A4");
a1_2.setText("A1 :");
a2_2.setText("A2 :");
a3_2.setText("A3 :");
a4_2.setText("A4 :");
tbl_2.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null}
},
new String [] {
"Title 1", "Title 2", "Title 3", "Title 4"
}
));
jScrollPane5.setViewportView(tbl_2);
txt_IntervalA1_3.setText("A1");
txt_IntervalA2_3.setText("A2");
txt_IntervalA3_3.setText("A3");
txt_IntervalA4_3.setText("A4");
a1_3.setText("A1 :");
a2_3.setText("A2 :");
a3_3.setText("A3 :");
a4_3.setText("A4 :");
tbl_3.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null}
},
new String [] {
"Title 1", "Title 2", "Title 3", "Title 4"
}
));
jScrollPane6.setViewportView(tbl_3);
txt_IntervalA1_4.setText("A1");
txt_IntervalA2_4.setText("A2");
txt_IntervalA3_4.setText("A3");
txt_IntervalA4_4.setText("A4");
a1_4.setText("A1 :");
a2_4.setText("A2 :");
a3_4.setText("A3 :");
a4_4.setText("A4 :");
javax.swing.GroupLayout jPanel15Layout = new javax.swing.GroupLayout(jPanel15);
jPanel15.setLayout(jPanel15Layout);
jPanel15Layout.setHorizontalGroup(
jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel15Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(a1_4, javax.swing.GroupLayout.DEFAULT_SIZE, 350, Short.MAX_VALUE)
.addComponent(a2_4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addComponent(a3_4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addComponent(a4_4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
.addContainerGap())
);
jPanel15Layout.setVerticalGroup(
jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel15Layout.createSequentialGroup()
.addComponent(a1_4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(a2_4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(a3_4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(a4_4))
);
tbl_4.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null}
},
new String [] {
"Title 1", "Title 2", "Title 3", "Title 4"
}
));
jScrollPane7.setViewportView(tbl_4);
txt_IntervalA1_5.setText("A1");
txt_IntervalA2_5.setText("A2");
txt_IntervalA3_5.setText("A3");
txt_IntervalA4_5.setText("A4");
javax.swing.GroupLayout jPanel16Layout = new javax.swing.GroupLayout(jPanel16);
jPanel16.setLayout(jPanel16Layout);
jPanel16Layout.setHorizontalGroup(
jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel16Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txt_IntervalA1_5, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel16Layout.createSequentialGroup()
.addGroup(jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(txt_intervalKelas5, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(txt_banyakKelas5, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(txt_rentangKelas5, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(txt_max5, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(txt_min5, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(0, 0, Short.MAX_VALUE))
.addComponent(txt_IntervalA2_5, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(txt_IntervalA3_5, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(txt_IntervalA4_5, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
jPanel16Layout.setVerticalGroup(
jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel16Layout.createSequentialGroup()
.addComponent(txt_max5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txt_min5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txt_banyakKelas5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txt_rentangKelas5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txt_intervalKelas5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txt_IntervalA1_5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txt_IntervalA2_5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txt_IntervalA3_5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txt_IntervalA4_5)
.addContainerGap())
);
jPanel17.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "NILAI FLRG",
javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new
java.awt.Font("Tahoma", 1, 15))); // NOI18N
a1_5.setText("A1 :");
a2_5.setText("A2 :");
a3_5.setText("A3 :");
a4_5.setText("A4 :");
tbl_5.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null}
},
new String [] {
"Title 1", "Title 2", "Title 3", "Title 4"
}
));
jScrollPane8.setViewportView(tbl_5);
mape_5.setFont(new java.awt.Font("Tahoma", 1, 16)); // NOI18N
mape_5.setForeground(new java.awt.Color(255, 255, 255));
mape_5.setText("MAPE :");
txt_IntervalA1_6.setText("A1");
txt_IntervalA2_6.setText("A2");
txt_IntervalA3_6.setText("A3");
txt_IntervalA4_6.setText("A4");
a1_6.setText("A1 :");
a2_6.setText("A2 :");
a3_6.setText("A3 :");
a4_6.setText("A4 :");
txt_IntervalA1_7.setText("A1");
txt_IntervalA2_7.setText("A2");
txt_IntervalA3_7.setText("A3");
txt_IntervalA4_7.setText("A4");
a1_7.setText("A1 :");
a2_7.setText("A2 :");
a3_7.setText("A3 :");
a4_7.setText("A4 :");
tbl_7.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null}
},
new String [] {
"Title 1", "Title 2", "Title 3", "Title 4"
}
));
jScrollPane10.setViewportView(tbl_7);
txt_IntervalA1_8.setText("A1");
txt_IntervalA2_8.setText("A2");
txt_IntervalA3_8.setText("A3");
txt_IntervalA4_8.setText("A4");
a1_8.setText("A1 :");
a2_8.setText("A2 :");
a3_8.setText("A3 :");
a4_8.setText("A4 :");
javax.swing.GroupLayout jPanel23Layout = new javax.swing.GroupLayout(jPanel23);
jPanel23.setLayout(jPanel23Layout);
jPanel23Layout.setHorizontalGroup(
jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel23Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(a1_8, javax.swing.GroupLayout.DEFAULT_SIZE, 350, Short.MAX_VALUE)
.addComponent(a2_8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addComponent(a3_8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addComponent(a4_8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
.addContainerGap())
);
jPanel23Layout.setVerticalGroup(
jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel23Layout.createSequentialGroup()
.addComponent(a1_8)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(a2_8)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(a3_8)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(a4_8)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
tbl_8.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null}
},
new String [] {
"Title 1", "Title 2", "Title 3", "Title 4"
}
));
jScrollPane11.setViewportView(tbl_8);
jTabbedPane1.addTab("UDANG", udang);
tbl_Peramalan.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null}
},
new String [] {
"Title 1", "Title 2", "Title 3", "Title 4"
}
));
jScrollPane4.setViewportView(tbl_Peramalan);
tbl_input.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null}
},
new String [] {
"Title 1", "Title 2", "Title 3", "Title 4"
}
));
tbl_input.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
tbl_inputMouseClicked(evt);
}
});
jScrollPane1.setViewportView(tbl_input);
pack();
}// </editor-fold>
}catch(Exception e){
JOptionPane.showMessageDialog(null, e,"GAGAL UPLOAD FILE, PERIKSA FORMAT FILE
ANDA",JOptionPane.ERROR_MESSAGE);
}
}
}
/**
* @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(DASHBOARD.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(DASHBOARD.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(DASHBOARD.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(DASHBOARD.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>