Connect TrayIcon to JSP Login Page

how to connect awt to web page

Page 1 of 1

4 Replies - 2326 Views - Last Post: 02 January 2011 - 01:45 PM

#1 fauzi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 02-January 11

Connect TrayIcon to JSP Login Page

Posted 02 January 2011 - 04:48 AM

Dear

i have one awt page that is work as tray icon popup .
now i want to connect one jsp login page from this page..
kindly help me.


Here below is that class

TrayIconDemo.java

import java.awt.*;
import java.awt.event.*;
import java.net.URL;
import javax.swing.*;

public class TrayIconDemo {
    public static void main(String[] args) {
        /* Use an appropriate Look and Feel */
        try {
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
            //UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
        } catch (UnsupportedLookAndFeelException ex) {
            ex.printStackTrace();
        } catch (IllegalAccessException ex) {
            ex.printStackTrace();
        } catch (InstantiationException ex) {
            ex.printStackTrace();
        } catch (ClassNotFoundException ex) {
            ex.printStackTrace();
        }
        /* Turn off metal's use of bold fonts */
        UIManager.put("swing.boldMetal", Boolean.FALSE);
        //Schedule a job for the event-dispatching thread:
        //adding TrayIcon.
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                createAndShowGUI();
            }
        });
    }
    
    private static void createAndShowGUI() {
        //Check the SystemTray support
        if (!SystemTray.isSupported()) {
            System.out.println("SystemTray is not supported");
            return;
        }
        final PopupMenu popup = new PopupMenu();


Image img = Toolkit.getDefaultToolkit().getImage("C:/Reminder.jpg"); 
 final TrayIcon trayIcon = new TrayIcon(img, "UNITRANS REMINDER ", popup); 
   final SystemTray tray = SystemTray.getSystemTray();
                   
        MenuItem aboutItem = new MenuItem("Open");
        CheckboxMenuItem cb1 = new CheckboxMenuItem("Set auto size");
        
        MenuItem exitItem = new MenuItem("Exit"); 
        
        //Add components to popup menu
        popup.add(aboutItem);
        popup.addSeparator();
        popup.add(cb1);
        popup.addSeparator();
       
        popup.add(exitItem);
        
        trayIcon.setPopupMenu(popup);
        
        try {
            tray.add(trayIcon);
        } catch (AWTException e) {
            System.out.println("TrayIcon could not be added.");
            return;
        }
        
        trayIcon.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
				
             

               try
                 {   System.out.println("-------at line 89 in try");
                       URL url = new URL("http://abusofian.uispl:8080/login.html");
					   System.out.println("-------at line 91 in try");

                 }catch(java.net.MalformedURLException e1)
                  {
                      System.out.println("Test  threw a " + e1.getClass() +
					    "\n with message: " + e1.getMessage());
                   }
		          

              
            }
        });
        
        aboutItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
					  JOptionPane.showMessageDialog(null,
                        "This dialog box is run from the About menu item");
            }
        });
        
        cb1.addItemListener(new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
                int cb1Id = e.getStateChange();
                if (cb1Id == ItemEvent.SELECTED){
                    trayIcon.setImageAutoSize(true);
                } else {
                    trayIcon.setImageAutoSize(false);
                }
            }
        });
        
       
        
     
        
       
        
        exitItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                tray.remove(trayIcon);
                System.exit(0);
            }
        });
    }
    
    
}


MOD EDIT: When posting code...USE CODE TAGS!!!

:code:

This post has been edited by JackOfAllTrades: 02 January 2011 - 07:48 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Connect TrayIcon to JSP Login Page

#2 fauzi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 02-January 11

Re: Connect TrayIcon to JSP Login Page

Posted 02 January 2011 - 04:59 AM

Dear ,

i want to connect webpage from awt.
Was This Post Helpful? 0
  • +
  • -

#3 horace  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 768
  • View blog
  • Posts: 3,832
  • Joined: 25-October 06

Re: Connect TrayIcon to JSP Login Page

Posted 02 January 2011 - 05:18 AM

View Postfauzi, on 02 January 2011 - 10:59 AM, said:

Dear ,

i want to connect webpage from awt.

have a look at HttpURLConnection
http://download.orac...connecting.html

This post has been edited by horace: 02 January 2011 - 05:18 AM

Was This Post Helpful? 0
  • +
  • -

#4 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6246
  • View blog
  • Posts: 24,014
  • Joined: 23-August 08

Re: Connect TrayIcon to JSP Login Page

Posted 02 January 2011 - 07:50 AM

Merged duplicate topics. Please do NOT create duplicates.
Was This Post Helpful? 0
  • +
  • -

#5 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8378
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: Connect TrayIcon to JSP Login Page

Posted 02 January 2011 - 01:45 PM

Move to J2EE
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1