ADSENSE HERE!
Huft iseng2 dari pada ga ada yang dikerjain ane mau share nih gimana cara membuat back up restore pada aplikasi netbean yang anda buat .....nah kurang lebih tampilan nya begini nih...::::::
nah gitu tuh ,, yang tulisan back up ,, ya untuk nge back up data kita gan tapi yang restore untuk mengembalikan data kita hehhehe ,,, simple2 ajaa kn yang penting terkoneksi sama data base
disini ane make database nya mysql gan
coding nya bgini nih,,,,
\/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* BackupRestore.java
*
* Created on May 5, 2013, 5:43:08 PM
*/
package santanaapplication.Gui;
import javax.swing.JOptionPane;
import javax.swing.filechooser.FileNameExtensionFilter;
/**
*
* @author Ami
*/
public class BackupRestore extends java.awt.Dialog {
/** Creates new form BackupRestore */
public BackupRestore(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
}
/** 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.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jFileChooser1 = new javax.swing.JFileChooser();
jPanel1 = new javax.swing.JPanel();
jPanel2 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jTabbedPane1 = new javax.swing.JTabbedPane();
jPanel4 = new javax.swing.JPanel();
btnRestore = new javax.swing.JButton();
txtLokasiRestore = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
btnCariRestore = new javax.swing.JButton();
buttonTransparan_11 = new santana.tema.ButtonTransparan_1();
jPanel3 = new javax.swing.JPanel();
jLabel2 = new javax.swing.JLabel();
btnCariBackup = new javax.swing.JButton();
jLabel3 = new javax.swing.JLabel();
txtLokasiBackup = new javax.swing.JTextField();
btnBackup = new javax.swing.JButton();
setLocationRelativeTo(null);
setUndecorated(true);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
closeDialog(evt);
}
});
jPanel1.setBackground(new java.awt.Color(255, 255, 255));
jPanel2.setBackground(new java.awt.Color(153, 204, 255));
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 16));
jLabel1.setText("Backup & Restore Database");
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addContainerGap(188, Short.MAX_VALUE))
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel4.setBackground(new java.awt.Color(255, 255, 255));
btnRestore.setText("Restore");
btnRestore.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnRestoreActionPerformed(evt);
}
});
txtLokasiRestore.setText("jTextField1");
jLabel4.setText("Lokasi File");
jLabel5.setText("Pilih Lokasi");
btnCariRestore.setText("Cari");
btnCariRestore.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnCariRestoreActionPerformed(evt);
}
});
buttonTransparan_11.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gambar/10.png"))); // NOI18N
buttonTransparan_11.setText("buttonTransparan_11");
buttonTransparan_11.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonTransparan_11ActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
jPanel4.setLayout(jPanel4Layout);
jPanel4Layout.setHorizontalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel5)
.addComponent(jLabel4))
.addGap(34, 34, 34)
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtLokasiRestore, javax.swing.GroupLayout.DEFAULT_SIZE, 297, Short.MAX_VALUE)
.addComponent(btnCariRestore)))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
.addComponent(buttonTransparan_11, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(69, 69, 69)
.addComponent(btnRestore)))
.addContainerGap())
);
jPanel4Layout.setVerticalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel5)
.addComponent(btnCariRestore))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(txtLokasiRestore, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(btnRestore)
.addComponent(buttonTransparan_11, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jTabbedPane1.addTab("Restore Database", jPanel4);
jPanel3.setBackground(new java.awt.Color(255, 255, 255));
jLabel2.setText("Pilih Lokasi");
btnCariBackup.setText("Cari");
btnCariBackup.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnCariBackupActionPerformed(evt);
}
});
jLabel3.setText("Lokasi File");
txtLokasiBackup.setText("jTextField1");
btnBackup.setText("Backup");
btnBackup.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnBackupActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel2)
.addComponent(jLabel3))
.addGap(34, 34, 34)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtLokasiBackup, javax.swing.GroupLayout.DEFAULT_SIZE, 297, Short.MAX_VALUE)
.addComponent(btnCariBackup)))
.addComponent(btnBackup, javax.swing.GroupLayout.Alignment.TRAILING))
.addContainerGap())
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(btnCariBackup))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(txtLokasiBackup, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addComponent(btnBackup)
.addContainerGap(25, Short.MAX_VALUE))
);
jTabbedPane1.addTab("Backup Database", jPanel3);
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(10, 10, 10)
.addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 406, Short.MAX_VALUE)
.addGap(10, 10, 10))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 159, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jTabbedPane1.getAccessibleContext().setAccessibleName("ggg");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
);
pack();
}// </editor-fold>
/** Closes the dialog */
private void closeDialog(java.awt.event.WindowEvent evt) {
setVisible(false);
dispose();
}
private void btnCariBackupActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
FileNameExtensionFilter filter = new FileNameExtensionFilter("sql file", "sql");
jFileChooser1.setFileFilter(filter);
int returnVal = jFileChooser1.showSaveDialog(this);
if(returnVal == jFileChooser1.APPROVE_OPTION) {
txtLokasiBackup.setText(jFileChooser1.getSelectedFile().getPath()+".sql");
}
}
private void btnCariRestoreActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
FileNameExtensionFilter filter = new FileNameExtensionFilter("sql file", "sql");
jFileChooser1.setFileFilter(filter);
int returnVal = jFileChooser1.showOpenDialog(this);
if(returnVal == jFileChooser1.APPROVE_OPTION) {
txtLokasiRestore.setText(jFileChooser1.getSelectedFile().getPath());
}
}
private void btnBackupActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
try{
Process menjalankancmd=Runtime.getRuntime().exec("c:\\xampp\\mysql\\bin\\mysqldump -hlocalhost -uroot cv_sentana -r "+"\""+txtLokasiBackup.getText()+"\"");
JOptionPane.showMessageDialog(null, "Backup database sukses");
} catch(Exception a){
JOptionPane.showMessageDialog(null, "Tidak dpt menjalankan cmd");
}
}
private void btnRestoreActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String database="cv_sentana";
String user="root";
String pass="";
try{
String[] kata = new String[]{"c:\\xampp\\mysql\\bin\\mysql", database, "-u" + user,
"-e", " source "+txtLokasiRestore.getText()};
Process menjalankancmd=Runtime.getRuntime().exec(kata);
JOptionPane.showMessageDialog(null, "Restore database sukses");
} catch(Exception a){
JOptionPane.showMessageDialog(null, "Tidak dpt menjalankan cmd");
}
}
private void buttonTransparan_11ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
this.dispose();
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
BackupRestore dialog = new BackupRestore(new java.awt.Frame(), true);
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
dialog.setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton btnBackup;
private javax.swing.JButton btnCariBackup;
private javax.swing.JButton btnCariRestore;
private javax.swing.JButton btnRestore;
private santana.tema.ButtonTransparan_1 buttonTransparan_11;
private javax.swing.JFileChooser jFileChooser1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanel4;
private javax.swing.JTabbedPane jTabbedPane1;
private javax.swing.JTextField txtLokasiBackup;
private javax.swing.JTextField txtLokasiRestore;
// End of variables declaration
}
\
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* BackupRestore.java
*
* Created on May 5, 2013, 5:43:08 PM
*/
package santanaapplication.Gui;
import javax.swing.JOptionPane;
import javax.swing.filechooser.FileNameExtensionFilter;
/**
*
* @author Ami
*/
public class BackupRestore extends java.awt.Dialog {
/** Creates new form BackupRestore */
public BackupRestore(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
}
/** 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.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jFileChooser1 = new javax.swing.JFileChooser();
jPanel1 = new javax.swing.JPanel();
jPanel2 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jTabbedPane1 = new javax.swing.JTabbedPane();
jPanel4 = new javax.swing.JPanel();
btnRestore = new javax.swing.JButton();
txtLokasiRestore = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
btnCariRestore = new javax.swing.JButton();
buttonTransparan_11 = new santana.tema.ButtonTransparan_1();
jPanel3 = new javax.swing.JPanel();
jLabel2 = new javax.swing.JLabel();
btnCariBackup = new javax.swing.JButton();
jLabel3 = new javax.swing.JLabel();
txtLokasiBackup = new javax.swing.JTextField();
btnBackup = new javax.swing.JButton();
setLocationRelativeTo(null);
setUndecorated(true);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
closeDialog(evt);
}
});
jPanel1.setBackground(new java.awt.Color(255, 255, 255));
jPanel2.setBackground(new java.awt.Color(153, 204, 255));
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 16));
jLabel1.setText("Backup & Restore Database");
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addContainerGap(188, Short.MAX_VALUE))
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel4.setBackground(new java.awt.Color(255, 255, 255));
btnRestore.setText("Restore");
btnRestore.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnRestoreActionPerformed(evt);
}
});
txtLokasiRestore.setText("jTextField1");
jLabel4.setText("Lokasi File");
jLabel5.setText("Pilih Lokasi");
btnCariRestore.setText("Cari");
btnCariRestore.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnCariRestoreActionPerformed(evt);
}
});
buttonTransparan_11.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gambar/10.png"))); // NOI18N
buttonTransparan_11.setText("buttonTransparan_11");
buttonTransparan_11.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonTransparan_11ActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
jPanel4.setLayout(jPanel4Layout);
jPanel4Layout.setHorizontalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel5)
.addComponent(jLabel4))
.addGap(34, 34, 34)
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtLokasiRestore, javax.swing.GroupLayout.DEFAULT_SIZE, 297, Short.MAX_VALUE)
.addComponent(btnCariRestore)))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
.addComponent(buttonTransparan_11, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(69, 69, 69)
.addComponent(btnRestore)))
.addContainerGap())
);
jPanel4Layout.setVerticalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel5)
.addComponent(btnCariRestore))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(txtLokasiRestore, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(btnRestore)
.addComponent(buttonTransparan_11, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jTabbedPane1.addTab("Restore Database", jPanel4);
jPanel3.setBackground(new java.awt.Color(255, 255, 255));
jLabel2.setText("Pilih Lokasi");
btnCariBackup.setText("Cari");
btnCariBackup.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnCariBackupActionPerformed(evt);
}
});
jLabel3.setText("Lokasi File");
txtLokasiBackup.setText("jTextField1");
btnBackup.setText("Backup");
btnBackup.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnBackupActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel2)
.addComponent(jLabel3))
.addGap(34, 34, 34)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtLokasiBackup, javax.swing.GroupLayout.DEFAULT_SIZE, 297, Short.MAX_VALUE)
.addComponent(btnCariBackup)))
.addComponent(btnBackup, javax.swing.GroupLayout.Alignment.TRAILING))
.addContainerGap())
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(btnCariBackup))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(txtLokasiBackup, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addComponent(btnBackup)
.addContainerGap(25, Short.MAX_VALUE))
);
jTabbedPane1.addTab("Backup Database", jPanel3);
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(10, 10, 10)
.addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 406, Short.MAX_VALUE)
.addGap(10, 10, 10))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 159, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jTabbedPane1.getAccessibleContext().setAccessibleName("ggg");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
);
pack();
}// </editor-fold>
/** Closes the dialog */
private void closeDialog(java.awt.event.WindowEvent evt) {
setVisible(false);
dispose();
}
private void btnCariBackupActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
FileNameExtensionFilter filter = new FileNameExtensionFilter("sql file", "sql");
jFileChooser1.setFileFilter(filter);
int returnVal = jFileChooser1.showSaveDialog(this);
if(returnVal == jFileChooser1.APPROVE_OPTION) {
txtLokasiBackup.setText(jFileChooser1.getSelectedFile().getPath()+".sql");
}
}
private void btnCariRestoreActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
FileNameExtensionFilter filter = new FileNameExtensionFilter("sql file", "sql");
jFileChooser1.setFileFilter(filter);
int returnVal = jFileChooser1.showOpenDialog(this);
if(returnVal == jFileChooser1.APPROVE_OPTION) {
txtLokasiRestore.setText(jFileChooser1.getSelectedFile().getPath());
}
}
private void btnBackupActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
try{
Process menjalankancmd=Runtime.getRuntime().exec("c:\\xampp\\mysql\\bin\\mysqldump -hlocalhost -uroot cv_sentana -r "+"\""+txtLokasiBackup.getText()+"\"");
JOptionPane.showMessageDialog(null, "Backup database sukses");
} catch(Exception a){
JOptionPane.showMessageDialog(null, "Tidak dpt menjalankan cmd");
}
}
private void btnRestoreActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String database="cv_sentana";
String user="root";
String pass="";
try{
String[] kata = new String[]{"c:\\xampp\\mysql\\bin\\mysql", database, "-u" + user,
"-e", " source "+txtLokasiRestore.getText()};
Process menjalankancmd=Runtime.getRuntime().exec(kata);
JOptionPane.showMessageDialog(null, "Restore database sukses");
} catch(Exception a){
JOptionPane.showMessageDialog(null, "Tidak dpt menjalankan cmd");
}
}
private void buttonTransparan_11ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
this.dispose();
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
BackupRestore dialog = new BackupRestore(new java.awt.Frame(), true);
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
dialog.setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton btnBackup;
private javax.swing.JButton btnCariBackup;
private javax.swing.JButton btnCariRestore;
private javax.swing.JButton btnRestore;
private santana.tema.ButtonTransparan_1 buttonTransparan_11;
private javax.swing.JFileChooser jFileChooser1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanel4;
private javax.swing.JTabbedPane jTabbedPane1;
private javax.swing.JTextField txtLokasiBackup;
private javax.swing.JTextField txtLokasiRestore;
// End of variables declaration
}
\
selmat mencobaaaa!!!!!!
ADSENSE HERE!
2 comments:
Nuhunnya ^_^
Sami2
Post a Comment