Forum İçeriği > Çekirdek Java > JList'in Devamlı çalışması
|
|
Emrah Kahraman E - Hero 24 ay önce
Aktivite Puanı: 28
Sorduğum sorunun cevabını buldum burdan yayınladım.Butonun actionperformed
olayına mesajı gonderme ıslemını yazdım mesaj al metodu ıle ıse thread le
Jlıste yazdırdım.Thread devamlı çalıştıgı ıcın JLıst devamlı mesajları dınlıyor
Sınıfımın Constructorı public MsnClient() { super(); initialize(); try { msn =
(Msn) Naming.lookup("rmi://localhost:1099/MsnService"); } catch (Exception e) {
System.out.println("MSN RMI hatası: " + e.getMessage()); } // yeni bir thread
oluştur Thread t = new Thread(this); t.start(); } @Override public void run() {
while(true) { try { list.setListData(msn.mesajAl()); } catch (RemoteException
e) { System.err.println(e.getMessage()); } } } ve butonun olayı
btn.addActionListener(new java.awt.event.ActionListener() { public void
actionPerformed(java.awt.event.ActionEvent e) { String ad="EMRAH"; String
str=txt01.getText(); try { msn.mesajKaydet(ad,str); } catch (RemoteException
re) { System.err.println("RMI mesaj kaydetme hatası: " + re.getMessage()); }
txt01.setText(""); } }); } return btn; }
|
Aktivite Puanı: 28