Postingan lainnya
error java ketika mau membatasi hanya 1 jinternalframe yang sama yang tampil
Dear All, kode saya berikut mainnya
public class frame3 extends JFrame {
public JPanel contentPane;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
frame3 frame = new frame3();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public frame3() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 800, 600);
JDesktopPane desktop = new JDesktopPane();
JMenuBar menuBar = new JMenuBar();
setJMenuBar(menuBar);
JMenu mnDataKaryawan = new JMenu("Data Employee");
menuBar.add(mnDataKaryawan);
JMenuItem mntmData = new JMenuItem("Data");
mntmData.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
data.getInstance().setVisible(true);
data.getInstance().setBounds(1, 1, 450, 300);
desktop.add(data.getInstance());
}
});
mnDataKaryawan.add(mntmData);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(new CardLayout(0, 0));
contentPane.add(desktop, "name_19268387084787");
}
}
lalu
public class data extends JInternalFrame {
private JTable table;
static Connection connection = null;
public void refreshTable(){
PreparedStatement forquery = null;
//kondisi PreparedStatement awal kosong(null)
ResultSet resultr=null;
//kondisi PreparedStatement awal kosong(null)
try{
String queryqry2="select * from karyawan";
forquery = connection.prepareStatement(queryqry2);
resultr=forquery.executeQuery();
table.setModel(DbUtils.resultSetToTableModel(resultr));
forquery.close();
resultr.close();
}
catch(Exception error){
error.printStackTrace();
}
}
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
data frame = new data();
frame.setVisible(true);
connection.close();
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
private static data myInstance;
public data() {
connection=xamppkonek.konekdb();
setResizable(true);
setMaximizable(true);
setIconifiable(true);
setClosable(true);
setBounds(100, 100, 450, 300);
getContentPane().setLayout(null);
JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(10, 11, 414, 165);
getContentPane().add(scrollPane);
table = new JTable();
scrollPane.setViewportView(table);
refreshTable();
}
public static data getInstance() {
if (myInstance == null)
{
myInstance = new data();
}
return myInstance;
}
}
dirun bisa cuma ketika saya klik ke dua kalinya di menu data untuk tes tidak berulang ada error java.lang.IllegalArgumentException
catatan = saya menggunakan IDE Eclipse dengan windowbuilder
mohon bantuannya all
0
Belum ada Jawaban. Jadi yang pertama Jawaban
Login untuk ikut Jawaban