Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * 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 rfid;
- import java.sql.Connection;
- import java.sql.DriverManager;
- 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.table.DefaultTableModel;
- /**
- *
- * @author ASUS
- */
- public class Schedule extends javax.swing.JFrame {
- /**
- * Creates new form Schedule
- */
- public Schedule() {
- initComponents();
- tampilkandata();
- }
- public Connection conn;
- public void koneksi() throws SQLException {
- try {
- conn=null;
- Class.forName("com.mysql.jdbc.Driver");
- conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/rfid", "root", "");
- } catch (ClassNotFoundException ex) {
- Logger.getLogger(Schedule.class.getName()).log(Level.SEVERE, null, ex);
- } catch (SQLException e) {
- Logger.getLogger(Schedule.class.getName()).log(Level.SEVERE, null, e);
- } catch (Exception es) {
- Logger.getLogger(Schedule.class.getName()).log(Level.SEVERE, null, es);
- }
- }
- public void tampilkandata() {
- DefaultTableModel tabelmapel = new DefaultTableModel();
- tabelmapel.addColumn("Day");
- tabelmapel.addColumn("Subject");
- tabelmapel.addColumn("Time");
- tabelmapel.addColumn("Class");
- tabelmapel.addColumn("Room");
- try {
- koneksi();
- String sql = "select * from jadwal";
- Statement stat = conn.createStatement();
- ResultSet res=stat.executeQuery(sql);
- while (res.next()) {
- tabelmapel.addRow(new Object[]{res.getString(1),res.getString(2),res.getString(3), res.getString(4), res.getString(5)});
- }
- tabel.setModel(tabelmapel);
- } catch (Exception e) {
- }
- }
- /**
- * 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() {
- jPanel1 = new javax.swing.JPanel();
- jScrollPane1 = new javax.swing.JScrollPane();
- tabel = new javax.swing.JTable();
- jButton1 = new javax.swing.JButton();
- jPanel2 = new javax.swing.JPanel();
- jLabel1 = new javax.swing.JLabel();
- jLabel2 = new javax.swing.JLabel();
- setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
- jPanel1.setBackground(new java.awt.Color(255, 0, 0));
- tabel.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
- tabel.setModel(new javax.swing.table.DefaultTableModel(
- new Object [][] {
- {null, null, null, null, null},
- {null, null, null, null, null},
- {null, null, null, null, null},
- {null, null, null, null, null}
- },
- new String [] {
- "Day", "Subject", "Time", "Class", "Room"
- }
- ));
- jScrollPane1.setViewportView(tabel);
- jButton1.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
- jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/rfid/image/icons8_Go_Back_48px.png"))); // NOI18N
- jButton1.setText("BACK");
- jButton1.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton1ActionPerformed(evt);
- }
- });
- jPanel2.setBackground(new java.awt.Color(255, 255, 51));
- jLabel1.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
- jLabel1.setText(" SCHEDULE");
- jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/rfid/image/icons8_Schedule_48px.png"))); // NOI18N
- javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
- jPanel2.setLayout(jPanel2Layout);
- jPanel2Layout.setHorizontalGroup(
- jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel2Layout.createSequentialGroup()
- .addGap(191, 191, 191)
- .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- );
- jPanel2Layout.setVerticalGroup(
- jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel2Layout.createSequentialGroup()
- .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel2Layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGroup(jPanel2Layout.createSequentialGroup()
- .addGap(20, 20, 20)
- .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)))
- .addContainerGap(22, Short.MAX_VALUE))
- );
- javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
- jPanel1.setLayout(jPanel1Layout);
- jPanel1Layout.setHorizontalGroup(
- jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
- .addContainerGap(93, Short.MAX_VALUE)
- .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
- .addGroup(jPanel1Layout.createSequentialGroup()
- .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 149, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(140, 140, 140))
- .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 427, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGap(71, 71, 71))
- .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- );
- 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)
- .addGap(20, 20, 20)
- .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(107, 107, 107)
- .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(0, 77, Short.MAX_VALUE))
- );
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- );
- pack();
- }// </editor-fold>
- private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
- // TODO add your handling code here:
- this.setVisible(false);
- Menu me = new Menu();
- me.setVisible(true);
- }
- /**
- * @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(Schedule.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (InstantiationException ex) {
- java.util.logging.Logger.getLogger(Schedule.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (IllegalAccessException ex) {
- java.util.logging.Logger.getLogger(Schedule.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (javax.swing.UnsupportedLookAndFeelException ex) {
- java.util.logging.Logger.getLogger(Schedule.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 Schedule().setVisible(true);
- }
- });
- }
- // Variables declaration - do not modify
- private javax.swing.JButton jButton1;
- private javax.swing.JLabel jLabel1;
- private javax.swing.JLabel jLabel2;
- private javax.swing.JPanel jPanel1;
- private javax.swing.JPanel jPanel2;
- private javax.swing.JScrollPane jScrollPane1;
- private javax.swing.JTable tabel;
- // End of variables declaration
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement