Thread: [TUT]Adding tray system[/TUT]

Results 1 to 10 of 10
  1. #1 [TUT]Adding tray system[/TUT] 
    Donator


    Join Date
    Nov 2008
    Posts
    1,017
    Thanks given
    20
    Thanks received
    31
    Rep Power
    169
    Purpose:Making a tray system for your client.
    Difficulty:1/10.
    Assumed Knowledge: C&P.
    Classes Modified: Gui.java, JFrame.java.
    Refactored/Non-Refactored?: Refactored but work on all clients

    Step 1 :
    Open your Gui.java or JFrame.java and add this method

    Code:
    public void setTray() {
    		boolean showTip = false;
    		if (tray == null) {
    			showTip = true;
    			final Image image = Toolkit.getDefaultToolkit().getImage(
    					"/icon.png");// change the image location
    			tray = new TrayIcon(image, "Client Title", null);
    			tray.setImageAutoSize(true);
    			tray.addMouseListener(new MouseListener() {
    				public void mouseClicked(MouseEvent arg0) {
    				}
    
    				public void mouseEntered(MouseEvent arg0) {
    				}
    
    				public void mouseExited(MouseEvent arg0) {
    				}
    
    				public void mouseReleased(MouseEvent arg0) {
    				}
    
    				public void mousePressed(MouseEvent arg0) {
    					SystemTray.getSystemTray().remove(tray);
    					frame.setVisible(true);
    				}
    			});
    		}
    		try {
    			SystemTray.getSystemTray().add(tray);
    			if (showTip) {
    				tray.displayMessage(
    						"Tray icon message title",
    						"Anything you want use "\n" to break a line.",
    						MessageType.INFO);
    			}
    		} catch (Exception ignored) {
    		}
    		frame.setVisible(false);
    	}

    Step 2:

    use setTray(); to call that method, you can make a JButton hides your client or if you want to make it hide it self on windows minimize you have to use WindowListener.

    Thanks.
    Reply With Quote  
     

  2. #2  
    <3

    Join Date
    Jun 2011
    Posts
    190
    Thanks given
    43
    Thanks received
    28
    Rep Power
    10
    And what is a Tray system exactly, Codes seem clean but i don't understand what it does?
    Reply With Quote  
     

  3. #3  
    Banned
    Join Date
    Sep 2010
    Posts
    610
    Thanks given
    5
    Thanks received
    15
    Rep Power
    0
    Quote Originally Posted by Warrior` View Post
    And what is a Tray system exactly, Codes seem clean but i don't understand what it does?
    u obviosily dont know simple java then
    Reply With Quote  
     

  4. #4  
    Registered Member

    Join Date
    Aug 2008
    Posts
    2,730
    Thanks given
    336
    Thanks received
    311
    Rep Power
    845
    Quote Originally Posted by pk flavor View Post
    u obviosily dont know simple java then
    Don't flame him you stupid shit, he's asking a simple question.


    Quote Originally Posted by Warrior` View Post
    And what is a Tray system exactly, Codes seem clean but i don't understand what it does?
    It shows an icon in the system tray I believe.
    >Animes
    Reply With Quote  
     

  5. #5  
    q.q


    Join Date
    Dec 2010
    Posts
    6,053
    Thanks given
    841
    Thanks received
    2,901
    Rep Power
    3142
    Useful for knowing, doubt i'll use.

    Thanks
    Reply With Quote  
     

  6. #6  
    Donator


    Join Date
    Nov 2008
    Posts
    1,017
    Thanks given
    20
    Thanks received
    31
    Rep Power
    169
    Bump
    Reply With Quote  
     

  7. #7  
    Registered Member
    Samuel's Avatar
    Join Date
    Nov 2010
    Age
    18
    Posts
    3,260
    Thanks given
    577
    Thanks received
    555
    Rep Power
    470
    Quote Originally Posted by pk flavor View Post
    u obviosily dont know simple java then
    wtf you cracking on about... you dont need to know java to know what it is...
    Reply With Quote  
     

  8. #8  
    Banned
    Join Date
    Aug 2008
    Age
    21
    Posts
    835
    Thanks given
    53
    Thanks received
    62
    Rep Power
    0
    A "tray system" allows you to minimize the application to the system tray (lower right hand corner, with the icons, time, etc) instead of staying on the taskbar. It also lowers the priority of the application, making it use less CPU, when sent to the system tray. You can open it again by clicking the icon.
    Reply With Quote  
     

  9. #9  
    Registered Member Kandarin's Avatar
    Join Date
    Jan 2011
    Posts
    158
    Thanks given
    0
    Thanks received
    9
    Rep Power
    0
    I don't quite understand... why? What's so hard about closing the client when you're not using it?

    I only see this helpful to a person who's programming? No use to ordinary player lol.
    Reply With Quote  
     

  10. #10  
    Registered Member
    owner blade's Avatar
    Join Date
    Nov 2009
    Posts
    2,810
    Thanks given
    89
    Thanks received
    601
    Rep Power
    455
    ordinary player will have less lagg on his pc when u minimalize the client with this tut added

    rofl
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Java tray system
    By Peter in forum Application Development
    Replies: 4
    Last Post: 06-01-2011, 08:21 PM
  2. Replies: 1
    Last Post: 09-13-2009, 11:23 PM
  3. Windows Tray Icons
    By quest rs in forum Application Development
    Replies: 1
    Last Post: 08-19-2009, 04:03 PM
  4. [508] Running a server in the tray!
    By xthexder in forum Tutorials
    Replies: 13
    Last Post: 07-24-2009, 10:47 PM
  5. Sandwich Lady Tray!
    By Runite in forum Configuration
    Replies: 12
    Last Post: 12-27-2007, 02:33 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •