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
    21
    Thanks received
    32
    Rep Power
    161
    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
    609
    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,823
    Thanks given
    362
    Thanks received
    448
    Rep Power
    965
    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.
    Reply With Quote  
     

  5. #5  
    q.q


    Join Date
    Dec 2010
    Posts
    6,519
    Thanks given
    1,072
    Thanks received
    3,535
    Rep Power
    4752
    Useful for knowing, doubt i'll use.

    Thanks
    Reply With Quote  
     

  6. #6  
    Donator


    Join Date
    Nov 2008
    Posts
    1,017
    Thanks given
    21
    Thanks received
    32
    Rep Power
    161
    Bump
    Reply With Quote  
     

  7. #7  
    Registered Member
    thim slug's Avatar
    Join Date
    Nov 2010
    Age
    28
    Posts
    4,132
    Thanks given
    1,077
    Thanks received
    1,137
    Rep Power
    5000
    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
    31
    Posts
    832
    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
    157
    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
    Join Date
    Nov 2009
    Posts
    3,052
    Thanks given
    112
    Thanks received
    838
    Rep Power
    740
    ordinary player will have less lagg on his pc when u minimalize the client with this tut added
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

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


User Tag List

Similar Threads

  1. Java tray system
    By Peter in forum Application Development
    Replies: 4
    Last Post: 06-01-2011, 08:21 PM
  2. changing the system tray/top left corner image?
    By sylas in forum Application Development
    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, 03: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
  •