1. #1
    Sencha User
    Join Date
    Dec 2007
    Posts
    57
    Vote Rating
    1
    MickeyMiner is on a distinguished road

      0  

    Default Answered: How to refresh a visible window after using addText()

    Answered: How to refresh a visible window after using addText()


    Hi,

    I have a very simple Logging class, which accepts messages and shows the 100 newest ones in a static window. From any class I call then Logger.log("This is my message to log")
    The added messages are not shown immediately, but only after resizing this Logger window.
    How do I tell the window to repaint, or to render the newly added message and scroll down to it immediately?

    Thank you for your support,

    MickeyMiner

    PS: Things like win.repaint() or win.render() did not work for me...

    Code:
    import com.extjs.gxt.ui.client.Style.Scroll;
    import com.extjs.gxt.ui.client.widget.Window;
    import com.extjs.gxt.ui.client.widget.layout.VBoxLayout;
    
    public class Logger {
    
        static Window win;
    
        Logger() {
            win = new Window();
            win.setSize(400, 100);
            win.setHeading("Logger");
            win.setLayout(new VBoxLayout());
            win.setScrollMode(Scroll.AUTO);
        }
        public static void log(String message) {
            if (win.getItemCount() >= 100)
                win.remove(win.getWidget(0));
            win.addText(message);
            win.scrollIntoView(win.getItem(win.getItemCount()-1));
        }
        public void show() {
            win.setVisible(true);
        }
    }

  2. have you tried to call layout() on your window ?

  3. #2
    Sencha User
    Join Date
    Jun 2011
    Location
    Iasi, Romania
    Posts
    144
    Answers
    5
    Vote Rating
    0
    catalin.ciobanu is on a distinguished road

      0  

    Default


    have you tried to call layout() on your window ?

  4. #3
    Sencha User
    Join Date
    Dec 2007
    Posts
    57
    Vote Rating
    1
    MickeyMiner is on a distinguished road

      0  

    Default


    Thank you! Worked.

    However the win.scrollIntoView(win.getItem(win.getItemCount()-1)); will not scroll onto last element... And the Window does not have any scroll bar even thought win.setScrollMode(Scroll.AUTO); was called.

    Can you pleas help me on this one?

    mm

  5. #4
    Sencha User
    Join Date
    Jun 2011
    Location
    Iasi, Romania
    Posts
    144
    Answers
    5
    Vote Rating
    0
    catalin.ciobanu is on a distinguished road

      0  

    Default


    try to add it using css if it doesn't work using the gxt methods

    Code:
    window.setStyleAttribute("overflow","scroll");
    it might just work ... but first make sure you tried this by using the object's methods .. setScroll(Scroll.AUTOY)

    this code is not tested, it's meant to guide you ...

  6. #5
    Sencha User
    Join Date
    Dec 2007
    Posts
    57
    Vote Rating
    1
    MickeyMiner is on a distinguished road

      0  

    Default


    Very good! Everything works now like it should...
    Thank you for your quick and competent response!
    m.

    My final Logger class looks like this:

    Code:
    package de.mike.client;
    
    import com.extjs.gxt.ui.client.Style.Scroll;
    import com.extjs.gxt.ui.client.core.XDOM;
    import com.extjs.gxt.ui.client.util.Size;
    import com.extjs.gxt.ui.client.widget.LayoutContainer;
    import com.extjs.gxt.ui.client.widget.Text;
    import com.extjs.gxt.ui.client.widget.Window;
    import com.extjs.gxt.ui.client.widget.layout.FitLayout;
    
    public class Logger {
    
        static Window win;
        static LayoutContainer lc;
        
        Logger() {
            win = new Window();
            win.setSize(800, 300);
            win.setPlain(true);
            win.setModal(false);
            win.setHeading("Logger");
            win.setAutoHide(false);
            win.setLayout(new FitLayout());
            lc = new LayoutContainer();
            lc.setScrollMode(Scroll.AUTO);
            win.add(lc);
        }
    
        public static void log(String message) {
            // Maximum of 100 Messages in the buffer
            if (lc.getItemCount() > 100)
                lc.remove(lc.getWidget(0));
            
            // Add new Message and scroll to it
            Text text = new Text("<pre style='font-size:90%'>" + message + "</pre>"); 
            lc.add(text);
            lc.layout();
            lc.scrollIntoView(text);
        }
    
        public void show() {
            win.show();
            // Move the window to lower right corner
            Size s = XDOM.getViewportSize();
            int left = s.width - win.getWidth() - 10;
            int top = s.height - win.getHeight() - 10;
            win.setPosition(left, top);
        }
    
    }

Thread Participants: 1

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar