SENSORAvatar border
TS
SENSOR
jtable sedot CPU process (java)
ada yang punya ide? kenapa jtabel malah makan semua cpu process ya?



public class UserMenu extends JFrame {

private static JPanel contentPane;
private JTable userTables;
Connection conn ;
ResultSet rs = null;
PreparedStatement pst = null;
private JTable table;


private void Update_table (){
JInternalFrame internalFrame = new JInternalFrame("USER MENU");
internalFrame.setEnabled(false);
internalFrame.setBounds(185, 120, 650, 500);
contentPane.add(internalFrame);
internalFrame.getContentPane().setLayout(null);

JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(49, 72, 545, 101);
internalFrame.getContentPane().add(scrollPane);

userTables = new JTable();
userTables.setModel(new DefaultTableModel(
new Object[][] {
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
},
new String[] {
"New column", "New column", "New column"
}
));
scrollPane.setViewportView(userTables);

JSeparator separator_5 = new JSeparator();
separator_5.setBounds(0, 36, 1110, 10);
separator_5.setOrientation(SwingConstants.HORIZONTAL);
internalFrame.getContentPane().add(separator_5);

JSeparator separator_6 = new JSeparator();
separator_6.setBounds(111, 160, -47, 27);
separator_5.setOrientation(SwingConstants.HORIZONTAL);
internalFrame.getContentPane().add(separator_6);

JLabel lblNewLabelEX = new JLabel("Welcome ");
lblNewLabelEX.setBounds(10, 6, 260, 27);
lblNewLabelEX.setForeground(Color.BLUE);
lblNewLabelEX.setFont(new Font("Tahoma", Font.BOLD, 16));
internalFrame.getContentPane().add(lblNewLabelEX);

try{
JLabel lblNewLabel = new JLabel("Welcome " +Login.txtUname.getText());
lblNewLabel.setBounds(10, 6, 260, 27);
lblNewLabel.setForeground(Color.BLUE);
lblNewLabel.setFont(new Font("Tahoma", Font.BOLD, 16));
internalFrame.getContentPane().add(lblNewLabel);
setLocationRelativeTo(null);
}catch(NullPointerException e){}

try{
JButton btnNewButton = new JButton("GANTI USER");
btnNewButton.setBounds(528, 6, 102, 23);
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
dispose();
Login frame = new Login();
frame.setVisible(true);
}
});
btnNewButton.setForeground(Color.BLUE);
btnNewButton.setFont(new Font("Tahoma", Font.BOLD, 11));
internalFrame.getContentPane().add(btnNewButton);


JButton btnBack = new JButton("Kembali");
btnBack.setBounds(539, 433, 91, 23);
btnBack.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
MainMenu mm = new MainMenu();
mm.setVisible(true);
mm.setExtendedState( mm.getExtendedState()|JFrame.MAXIMIZED_BOTH );
MainMenu.CurrentDate();
dispose();
}
});
btnBack.setFont(new Font("Tahoma", Font.BOLD, 14));
btnBack.setForeground(Color.RED);


//internalFrame.add(contentPane);
//validate();
}catch(IllegalArgumentException iae){}
internalFrame.setVisible(true);


try {
String sql = "select * from login";
pst = (PreparedStatement) conn.prepareStatement(sql);
rs = pst.executeQuery(sql);
userTables.setModel(DbUtils.resultSetToTableModel(rs));

JButton btnNewButton_1 = new JButton("Kembali");
btnNewButton_1.setForeground(Color.RED);
btnNewButton_1.setFont(new Font("Tahoma", Font.BOLD, 14));
btnNewButton_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
MainMenu mm = new MainMenu();
mm.setVisible(true);
mm.setExtendedState( mm.getExtendedState()|JFrame.MAXIMIZED_BOTH );
MainMenu.CurrentDatex();
dispose();
}
});
btnNewButton_1.setBounds(539, 433, 91, 23);
internalFrame.getContentPane().add(btnNewButton_1);

} catch (SQLException e) {
// TODO Auto-generated catch block
//JOptionPane.showMessageDialog(null, e);
e.printStackTrace();
}
finally {
try {
pst.close();
rs.close();
conn.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}


}

}


/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
// MainMenu mm = new MainMenu();
UserMenu um = new UserMenu();
um.setVisible(true);
um.setExtendedState( um.getExtendedState()|JFrame.MAXIMIZED_BOTH );
//mm.setVisible(true);
//mm.setExtendedState( mm.getExtendedState()|JFrame.MAXIMIZED_BOTH );
} catch (Exception e) {
e.printStackTrace();
}
}
});
}

/**
* Create the frame.
*/
public UserMenu() {
setTitle("Warehouse");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100,1500, 1500);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);

try{
conn = (Connection) JavaConnect.ConnecrDb();
Update_table();
}catch(NullPointerException npe)
{
//JOptionPane.showMessageDialog(null, e);
npe.printStackTrace();
}

JSeparator separator = new JSeparator();
separator.setBounds(85, 196, 119, -47);
contentPane.add(separator);

JSeparator separator_1 = new JSeparator();
separator_1.setBounds(0, 76, 1110, 10);
contentPane.add(separator_1);


JSeparator separator_4 = new JSeparator();
separator_4.setBounds(111, 160, -47, 27);
contentPane.add(separator_4);
}
Diubah oleh SENSOR 16-04-2014 08:47
0
986
3
GuestAvatar border
Guest
Tulis komentar menarik atau mention replykgpt untuk ngobrol seru
Urutan
Terbaru
Terlama
GuestAvatar border
Guest
Tulis komentar menarik atau mention replykgpt untuk ngobrol seru
Komunitas Pilihan