/*
* TableMahasiswa.java
*
* Created on 15 Maret 2008, 0:05
*/
package sample;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
/**
*
* @author usu
*/
public class TableMahasiswa extends javax.swing.JFrame {
private DefaultTableModel model;
/** Creates new form TableMahasiswa */
public TableMahasiswa() {
model = new DefaultTableModel();
initComponents();
setGlassPane(glasspane);
glasspane.showPanel(tambahMahasiswa1, tambahMahasiswa1.getMinimumSize());
tambahMahasiswa1.getTombolTambah().addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
model.addMahasiswa(tambahMahasiswa1.getMahasiswa());
glasspane.setVisible(false);
}
});
for (int i = 0; i < table.getColumnCount(); i++) {
table.getColumnModel().getColumn(i).setCellRenderer(new RenderMahasiswa());
}
for (int i = 0; i < 100; i++) {
model.addMahasiswa(new Mahasiswa("Eko Kurniawan Khannedy", "10106031", "IF-1"));
}
}
/** 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() {
table = new javax.swing.JTable();
viewPort1 = new sample.ViewPort();
glasspane = new pelajaran14.GlassPanePanel();
tambahMahasiswa1 = new sample.TambahMahasiswa();
panelEfect1 = new pelajaran3.PanelEfect();
jScrollPane1 = new javax.swing.JScrollPane();
jLabel1 = new javax.swing.JLabel();
buttonTambah = new sample.Button();
table.setAutoCreateRowSorter(true);
table.setModel(model);
table.setOpaque(false);
viewPort1.setView(table);
javax.swing.GroupLayout glasspaneLayout = new javax.swing.GroupLayout(glasspane);
glasspane.setLayout(glasspaneLayout);
glasspaneLayout.setHorizontalGroup(
glasspaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100, Short.MAX_VALUE)
);
glasspaneLayout.setVerticalGroup(
glasspaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100, Short.MAX_VALUE)
);
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jScrollPane1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
jScrollPane1.setOpaque(false);
jScrollPane1.setViewport(viewPort1);
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
jLabel1.setForeground(new java.awt.Color(255, 255, 255));
jLabel1.setText("TABEL MAHASISWA");
buttonTambah.setText("Tambah Mahasiswa");
buttonTambah.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonTambahActionPerformed(evt);
}
});
javax.swing.GroupLayout panelEfect1Layout = new javax.swing.GroupLayout(panelEfect1);
panelEfect1.setLayout(panelEfect1Layout);
panelEfect1Layout.setHorizontalGroup(
panelEfect1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelEfect1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(panelEfect1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 544, Short.MAX_VALUE)
.addComponent(jLabel1)
.addComponent(buttonTambah, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
);
panelEfect1Layout.setVerticalGroup(
panelEfect1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelEfect1Layout.createSequentialGroup()
.addGap(28, 28, 28)
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 296, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(buttonTambah, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(21, 21, 21))
);
getContentPane().add(panelEfect1, java.awt.BorderLayout.CENTER);
pack();
}// </editor-fold>
private void buttonTambahActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
glasspane.setVisible(true);
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (ClassNotFoundException ex) {
Logger.getLogger(TableMahasiswa.class.getName()).log(Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
Logger.getLogger(TableMahasiswa.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
Logger.getLogger(TableMahasiswa.class.getName()).log(Level.SEVERE, null, ex);
} catch (UnsupportedLookAndFeelException ex) {
Logger.getLogger(TableMahasiswa.class.getName()).log(Level.SEVERE, null, ex);
} finally {
new TableMahasiswa().setVisible(true);
}
}
});
}
// Variables declaration - do not modify
private sample.Button buttonTambah;
private pelajaran14.GlassPanePanel glasspane;
private javax.swing.JLabel jLabel1;
private javax.swing.JScrollPane jScrollPane1;
private pelajaran3.PanelEfect panelEfect1;
private javax.swing.JTable table;
private sample.TambahMahasiswa tambahMahasiswa1;
private sample.ViewPort viewPort1;
// End of variables declaration
private static class DefaultTableModel extends javax.swing.table.DefaultTableModel {
public DefaultTableModel() {
super();
addColumn("NIM");
addColumn("NAMA");
addColumn("KELAS");
}
public void addMahasiswa(Mahasiswa mhs) {
addRow(new Object[]{
mhs.getNim(), mhs.getNama(), mhs.getKelas()
});
}
}
}
0 komentar:
Posting Komentar