Results 1 to 13 of 13

Thread: Display on top

  1. #1
    karq is offline Member
    Join Date
    May 2010
    Posts
    63
    Rep Power
    0

    Default Display on top

    Hey,

    so, I'm trying to make a notifier for my app. It should popup the main GUI on screen(on top) when some time is reached. I know that I have to use a timer for that, but how can I display my swing gui on top when time is reached?

    gui.setVisibilite(true);?????

  2. #2
    Sno's Avatar
    Sno
    Sno is offline Senior Member
    Join Date
    Apr 2010
    Posts
    196
    Rep Power
    5

    Default

    What is is Visibilite? I think you mean. gui.setVisible(true);
    :rolleyes: ~ Sno ~ :rolleyes:
    '-~ B.S. Computer Science ~-'

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    Read the API doc for the JFrame and the Window classes for methods that may do what you want.

  4. #4
    karq is offline Member
    Join Date
    May 2010
    Posts
    63
    Rep Power
    0

    Default

    Quote Originally Posted by Sno View Post
    What is is Visibilite? I think you mean. gui.setVisible(true);
    yes that, sorry my english isnt very good.

  5. #5
    Webuser is offline Senior Member
    Join Date
    Dec 2008
    Posts
    526
    Rep Power
    0

    Default

    You can simply adapt you code to make visible or invisible your JFrame by using setVisible(boolean) method. Something like a...

    if(currentTime==(time+a))
    {
    frame.setVisible(true);
    }

    if(currentTime==(time+b))
    {
    frame.setVisible(false);

    }
    If my answer helped you. Please click my "REP" button and add a comment
    Have a Good Java Coding :)

  6. #6
    karq is offline Member
    Join Date
    May 2010
    Posts
    63
    Rep Power
    0

    Default

    Thanks, got notify working.

    But now I have another problem, When I start the app the notify class will be loaded. When I change the notify time in the file, then I have to restart my app to get that new time working.

    So is there a way to self-restart my app or a way that updates the timer so that it uses that new time?

  7. #7
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    When I change the notify time in the file, then I have to restart my app to get that new time working.
    How does the app know that the notify time in a disk file has been changed?
    Does it read the file to get the time when it starts?

    Can you explain a bit more about how your app works?

  8. #8
    karq is offline Member
    Join Date
    May 2010
    Posts
    63
    Rep Power
    0

    Default

    It reads the file when app starts. When I make changes(set new notify time) the notify class dosent know that I have made changes so I have to restart my app to read that file again.

  9. #9
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    So if you want you app to recognize that the file has changed without user prompting, you will need the app to capture the date last modified for the file and periodically test the file to see if the date has changed. Another place to use a Timer.

  10. #10
    karq is offline Member
    Join Date
    May 2010
    Posts
    63
    Rep Power
    0

    Default

    I'm stuck again. I made a timer for renewing the time. I know that I cant return something from a void method. So how can I fix it?

    Here is a sample code
    Java Code:
    //Recheck time file for changes
        private Date checkFile(){
        
            int delay = 0;
            int subseq = 1000;
    
            //Recheck time file for changes
            Timer CheckTimer = new Timer();
            
            //Checked date
            Date newdate = null;
    
            //Scheduled time file check
            CheckTimer.scheduleAtFixedRate(new TimerTask() {
               
                public void run() {  <--VOID
    
                       newdate = DateForTimer();   <--HAVE TO RETURN THIS?!?!+
                       
    
                }
                 
            },delay,subseq);
        
            //Return newdate
            return newdate
            
        
        }

  11. #11
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    Call a method in the surrounding class and pass the value to it.

  12. #12
    karq is offline Member
    Join Date
    May 2010
    Posts
    63
    Rep Power
    0

    Default

    I just dont get it. Made a FileWatcher what tracks modifications in the time file.
    GTimerRunning returns false when the timer file is modified. But now I dont know how to use that boolean to restart the notification timer, I used another timer that
    if(GTimerRunning == false){ GTimerRunning = true and run notification timer}.

    But it didnt work out as I hoped.

    So now I have this code and I dont know how to get it working.

    Java Code:
    public Notify(){
    //Check time file for modifications
            TimerTask task = new FileWatcher(new File("notify.dat")){
    
                protected void Changes(){
    
                    GTimerRunning = false;
    
                }
    
            };
    
            //Modification timer
            Timer ModiTimer = new Timer();
            ModiTimer.schedule(task,0, 1000);
    
            //Display main GUI when time is reached
            Timer TimerGUI = new Timer();
    
            TimerGUI.scheduleAtFixedRate(new TimerTask() {
                        public void run() {
    
                             dis.setVisible(true);
    
    
                        }
            },RenewDate,fonce_per_day);
    
    }

  13. #13
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    Can you make a small, complete, executable program that demos your problem?

Similar Threads

  1. no display
    By Kyle227 in forum Java Applets
    Replies: 6
    Last Post: 07-22-2010, 10:01 AM
  2. Replies: 1
    Last Post: 05-31-2010, 08:46 AM
  3. Display tag help
    By kirtichopra2003 in forum Advanced Java
    Replies: 0
    Last Post: 11-12-2009, 09:10 AM
  4. Replies: 8
    Last Post: 12-29-2008, 07:12 AM
  5. Replies: 0
    Last Post: 06-28-2008, 09:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •