Sunday, 29 November 2009

TrayIcon

import java.awt.SystemTray;
import java.awt.TrayIcon;
import javax.swing.ImageIcon;

public class postingan extends javax.swing.JFrame {

/** Creates new form postingan */
SystemTray sistem;
ImageIcon gambar;
TrayIcon ikon;
public postingan() {
initComponents();
gambar = new ImageIcon(getClass().getResource("/logo_garuda.jpg"));
ikon = new TrayIcon(gambar.getImage(), "Ini Trayicon");
sistem = SystemTray.getSystemTray();
try
{
sistem.add(ikon);
}catch(Exception e)
{
}
}
@SuppressWarnings("unchecked")
//
private void initComponents() {

jLabel1 = new javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Demo JfileChooser");
setLocationByPlatform(true);
getContentPane().setLayout(null);

jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/logo_garuda.jpg"))); // NOI18N
getContentPane().add(jLabel1);
jLabel1.setBounds(130, 70, 150, 90);

java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
setBounds((screenSize.width-416)/2, (screenSize.height-272)/2, 416, 272);
}//

public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new postingan().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JLabel jLabel1;
// End of variables declaration
}
Hasilnya :


Sekarang Perhatikan Di Notifications areanya, Terdapat Icon Sebagai Berikut :

No comments:

Post a comment