Dynamic Input to MarqueePane

This is the forum for JIDE Common Layer which is open sourced at https://github.com/jidesoft/jide-oss. Please note, JIDE technical support doesn't monitor this forum as often as other forums. Please consider subscribe for technical support for JIDE Common Layer so that you can use customer only forum to get a timely response.

Moderator: JIDE Support

Forum rules
Community driven forum for open source JIDE Common Layer. JIDE technical support doesn't monitor this forum as often as other forums. If you only use JIDE Common Layer, please consider subscribing for technical support for JIDE Common Layer so that you can use customer only forum to get a timely response.

Dynamic Input to MarqueePane

Postby dinsacet » Tue Aug 11, 2009 2:36 am

Hi, everybody

Is it possible to update the MarqueePane running Text dynamically? If possible pls help me how to do that.

Thanks,
Dinesh Kumar K.
dinsacet
 
Posts: 4
Joined: Fri Oct 31, 2008 10:35 am

Re: Dynamic Input to MarqueePane

Postby JIDE Support » Tue Aug 11, 2009 6:33 am

Please invoke MarqueePane#startAutoScrolling() after you reset the parameters.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Re: Dynamic Input to MarqueePane

Postby dinsacet » Tue Aug 11, 2009 10:55 pm

Hi,

Thank you very much. I have identified the problem. I have already set startAutoScrolling option when I reset the parameter. But the reset parameter is smaller than the Marquee Pane size, that’s why the text is not running.

I have one more doubt; my requirement in Marquee is for Trading Application

1.) Dynamically update the Marquee running text with the specified field only. While update, the running text is not restarted. Instead it will update only the specified field.

For example,
Symbol – TCS, Last night price – 1000, Current price – 1002
Symbol – Infosys, Last night price – 2000, Current price - 1999

I will display the List of Information (symbol, price) in the Marquee Pane. Price gets updated frequently.

While price updates, we don’t want restart the running text, only that value updated is enough. Could you please guide me?

Regards,
Dinesh Kumar K.
dinsacet
 
Posts: 4
Joined: Fri Oct 31, 2008 10:35 am

Re: Dynamic Input to MarqueePane

Postby JIDE Support » Wed Aug 12, 2009 6:16 am

Please try just update your List and it should be able to be updated in the MarqueePane. I tried in our MarqueePaneDemo and it works.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Re: Dynamic Input to MarqueePane

Postby dinsacet » Wed Aug 12, 2009 8:55 pm

Hi,

Can i get the sample program for the above scenario ? It would be more helpful for me.

Thanks,
Dinesh Kumar k.
dinsacet
 
Posts: 4
Joined: Fri Oct 31, 2008 10:35 am

Re: Dynamic Input to MarqueePane

Postby JIDE Support » Thu Aug 13, 2009 6:32 am

Please try the following code. We update the text in StyledLabel while clicking the button "Update text" then you'll see it gets changed in UI. Please try do the same thing to your list. Just make sure you invoke yourList#repaint() to update the UI if necessary.
Code: Select all
/*
 * @(#)MarqueePaneDemo.java 6/9/2009
 *
 * Copyright 2002 - 2009 JIDE Software Inc. All rights reserved.
 *
 */

import com.jidesoft.grid.JideTable;
import com.jidesoft.plaf.LookAndFeelFactory;
import com.jidesoft.swing.*;

import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.ActionEvent;

/**
 * Demoed Component: {@link com.jidesoft.swing.MarqueePane} <br> Required jar files: jide-common.jar <br> Required L&F:
 * any L&F
 */
public class MarqueePaneDemo extends AbstractDemo {
    private static final long serialVersionUID = 5611828470716987509L;
    MarqueePane _horizonMarqueeLeft;
    MarqueePane _verticalMarqueeUp;
    MarqueePane _verticalMarqueeDown;
    StyledLabel _styledLabel;

    public MarqueePaneDemo() {
    }

    public String getName() {
        return "MarqueePane Demo";
    }

    public String getProduct() {
        return PRODUCT_NAME_COMMON;
    }

    @Override
    public String getDescription() {
        return "MarqueePane is a subclass of JScrollPane to display components with a limited space by rolling it left and right, up and down.\n" +
                "Demoed classes:\n" +
                "com.jidesoft.swing.MarqueePane";
    }

    @Override
    public int getAttributes() {
        return ATTRIBUTE_NEW;
    }

    @Override
    public Component getOptionsPanel() {
        JPanel panel = new JPanel(new GridLayout(0, 1, 5, 5));
        JCheckBox freezeCheckBox = new JCheckBox("Freeze Auto Scrolling");
        freezeCheckBox.addItemListener(new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
                if (e.getStateChange() == ItemEvent.SELECTED) {
                    _horizonMarqueeLeft.stopAutoScrolling();
                    _verticalMarqueeUp.stopAutoScrolling();
                    _verticalMarqueeDown.stopAutoScrolling();
                }
                else {
                    _horizonMarqueeLeft.startAutoScrolling();
                    _verticalMarqueeUp.startAutoScrolling();
                    _verticalMarqueeDown.startAutoScrolling();
                }
            }
        });

        JButton button = new JButton(new AbstractAction("Update text") {
            private static final long serialVersionUID = 3433227364758002853L;

            public void actionPerformed(ActionEvent e) {
                _styledLabel.setText("GOOG   431.11   -6.51          DIA   87.64   -0.1          FXI   39.19   +1.12          GLD   93.62   -0.21          USO   39   +0.81          MSFT   22.25   +0.17");
            }
        });
        panel.add(freezeCheckBox);
        panel.add(button);
        return panel;
    }

    public Component getDemoPanel() {
        StyledLabel styledLabel = new StyledLabel();
        customizeStyledLabel(styledLabel);
        _styledLabel = styledLabel;

        MarqueePane horizonMarqueeLeft = new MarqueePane(styledLabel);
        horizonMarqueeLeft.setPreferredSize(new Dimension(250, 40));
        horizonMarqueeLeft.setBorder(BorderFactory.createCompoundBorder(new JideTitledBorder(new PartialEtchedBorder(PartialEtchedBorder.LOWERED, PartialSide.NORTH), "Scroll Left", JideTitledBorder.LEADING, JideTitledBorder.ABOVE_TOP),
                BorderFactory.createEmptyBorder(0, 0, 0, 0)));

        JPanel demoPanel = new JPanel(new BorderLayout(5, 5));
        demoPanel.add(horizonMarqueeLeft, BorderLayout.BEFORE_FIRST_LINE);

        JTable table = new JideTable(new QuoteTableModel());

        MultilineLabel textArea = new MultilineLabel();
        textArea.setText("Obama welcomes bill to regulate tobacco \n" +
                "Fake Rockefeller found guilty of kidnapping \n" +
                "Al Qaeda fighters relocating, officials say \n" +
                "Navarrette: Haters looking for scapegoats \n" +
                "Avlon: 'Wingnuts' spread hate of Obama, Jews \n" +
                "Ticker: Palin knocks 'perverted' Letterman \n" +
                "Spokesman: Chastity Bono changing gender \n" +
                "iReport.com: Share stories of gender change \n" +
                "Robin Meade: Packing for presidential skydive \n" +
                "WLUK: Girl gets excuse note from Obama \n" +
                "Woman gives up home, car to help kids \n" +
                "9-month-old snatched from home  \n" +
                "WPLG: Cat killings becoming more violent \n" +
                "Cargo containers become beautiful homes \n" +
                "Fortune: Dare you ask for a raise now? \n" +
                "Truck loses load of cash, causes car jam  \n" +
                "Flying fish smack boater in head   \n" +
                "Dog eats bag of pot, gets high");

        MarqueePane verticalMarqueeUp = new MarqueePane(textArea);
        verticalMarqueeUp.setScrollDirection(MarqueePane.SCROLL_DIRECTION_UP);
        verticalMarqueeUp.setPreferredSize(new Dimension((int) horizonMarqueeLeft.getPreferredSize().getWidth(), 38));
        verticalMarqueeUp.setScrollAmount(1);
        verticalMarqueeUp.setStayPosition(14);
        verticalMarqueeUp.setBorder(BorderFactory.createCompoundBorder(new JideTitledBorder(new PartialEtchedBorder(PartialEtchedBorder.LOWERED, PartialSide.NORTH), "Scroll Up", JideTitledBorder.LEADING, JideTitledBorder.ABOVE_TOP),
                BorderFactory.createEmptyBorder(0, 0, 0, 0)));

        MarqueePane verticalMarqueeDown = new MarqueePane(table);
        verticalMarqueeDown.setScrollDirection(MarqueePane.SCROLL_DIRECTION_DOWN);
        verticalMarqueeDown.setScrollDelay(200);
        verticalMarqueeDown.setStayDelay(1000);
        verticalMarqueeDown.setPreferredSize(new Dimension((int) horizonMarqueeLeft.getPreferredSize().getWidth(), 320));
        verticalMarqueeDown.setBorder(BorderFactory.createCompoundBorder(new JideTitledBorder(new PartialEtchedBorder(PartialEtchedBorder.LOWERED, PartialSide.NORTH), "Scroll Down", JideTitledBorder.LEADING, JideTitledBorder.ABOVE_TOP),
                BorderFactory.createEmptyBorder(0, 0, 0, 0)));

        demoPanel.add(verticalMarqueeUp, BorderLayout.CENTER);
        demoPanel.add(verticalMarqueeDown, BorderLayout.AFTER_LAST_LINE);
        _horizonMarqueeLeft = horizonMarqueeLeft;
        _verticalMarqueeUp = verticalMarqueeUp;
        _verticalMarqueeDown = verticalMarqueeDown;
        return demoPanel;
    }

    private void customizeStyledLabel(StyledLabel styledLabel) {
        styledLabel.setText("GOOG   429.11   -6.51          DIA   87.64   -0.1          FXI   39.19   +1.12          GLD   93.62   -0.21          USO   39   +0.81          MSFT   22.25   +0.17");
        styledLabel.setForeground(Color.WHITE);
        int[] steps = new int[]{16, 5, 24, 4, 24, 5, 24, 5, 21, 5, 25, 5};
        int index = 0;
        for (int i = 0; i < steps.length; i++) {
            if (i % 2 == 0) {
                styledLabel.addStyleRange(new StyleRange(index, steps[i], Font.PLAIN, Color.WHITE, Color.BLACK, 0, Color.WHITE));
            }
            else {
                if (styledLabel.getText().charAt(index) == '-') {
                    styledLabel.addStyleRange(new StyleRange(index, steps[i], Font.PLAIN, Color.RED, Color.BLACK, 0, Color.WHITE));
                }
                else {
                    styledLabel.addStyleRange(new StyleRange(index, steps[i], Font.PLAIN, Color.GREEN, Color.BLACK, 0, Color.WHITE));
                }
            }
            index += steps[i];
        }
    }

    @Override
    public String getDemoFolder() {
        return "B8.JideScrollPane";
    }

    static public void main(String[] s) {
        LookAndFeelFactory.installDefaultLookAndFeelAndExtension();
        showAsFrame(new MarqueePaneDemo());
    }

    static String[] QUOTE_COLUMNS = new String[]{"Symbol", "Name", "Last", "Change", "Volume"};

    static Object[][] QUOTES = new Object[][]{
            new Object[]{"AA", "ALCOA INC", "32.88", "+0.53 (1.64%)", "4156200"},
            new Object[]{"AIG", "AMER INTL GROUP", "69.53", "-0.58 (0.83%)", "4369200"},
            new Object[]{"AXP", "AMER EXPRESS CO", "48.90", "-0.35 (0.71%)", "4103600"},
            new Object[]{"BA", "BOEING CO", "49.14", "-0.18 (0.36%)", "3573700"},
            new Object[]{"C", "CITIGROUP", "44.21", "-0.89 (1.97%)", "28594900"},
            new Object[]{"CAT", "CATERPILLAR INC", "79.40", "+0.62 (0.79%)", "1458200"},
            new Object[]{"DD", "DU PONT CO", "42.62", "-0.14 (0.33%)", "1832700"},
            new Object[]{"DIS", "WALT DISNEY CO", "23.87", "-0.32 (1.32%)", "4443600"},
            new Object[]{"GE", "GENERAL ELEC CO", "33.37", "+0.24 (0.72%)", "31429500"},
            new Object[]{"GM", "GENERAL MOTORS", "43.94", "-0.20 (0.45%)", "3722100"},
            new Object[]{"HD", "HOME DEPOT INC", "34.33", "-0.18 (0.52%)", "5367900"},
            new Object[]{"HON", "HONEYWELL INTL", "35.70", "+0.23 (0.65%)", "4092100"},
            new Object[]{"HPQ", "HEWLETT-PACKARD", "19.65", "-0.25 (1.26%)", "11003000"},
            new Object[]{"IBM", "INTL BUS MACHINE", "84.02", "-0.11 (0.13%)", "6880500"},
            new Object[]{"INTC", "INTEL CORP", "23.15", "-0.23 (0.98%)", "95177008"},
            new Object[]{"JNJ", "JOHNSON&JOHNSON", "55.35", "-0.57 (1.02%)", "5428000"},
            new Object[]{"JPM", "JP MORGAN CHASE", "36.00", "-0.45 (1.23%)", "12135300"},
            new Object[]{"KO", "COCA COLA CO", "50.84", "-0.32 (0.63%)", "4143600"},
            new Object[]{"MCD", "MCDONALDS CORP", "27.91", "+0.12 (0.43%)", "6110800"},
            new Object[]{"MMM", "3M COMPANY", "88.62", "+0.43 (0.49%)", "2073800"},
            new Object[]{"MO", "ALTRIA GROUP", "48.20", "-0.80 (1.63%)", "6005500"},
            new Object[]{"MRK", "MERCK & CO", "44.71", "-0.97 (2.12%)", "5472100"},
            new Object[]{"MSFT", "MICROSOFT CP", "27.87", "-0.26 (0.92%)", "46717716"},
            new Object[]{"PFE", "PFIZER INC", "32.58", "-1.43 (4.20%)", "28783200"},
            new Object[]{"PG", "PROCTER & GAMBLE", "55.01", "-0.07 (0.13%)", "5538400"},
            new Object[]{"SBC", "SBC COMMS", "23.00", "-0.54 (2.29%)", "6423400"},
            new Object[]{"UTX", "UNITED TECH CP", "91.00", "+1.16 (1.29%)", "1868600"},
            new Object[]{"VZ", "VERIZON COMMS", "34.81", "-0.35 (1.00%)", "4182600"},
            new Object[]{"WMT", "WAL-MART STORES", "52.33", "-0.25 (0.48%)", "6776700"},
            new Object[]{"XOM", "EXXON MOBIL", "45.32", "-0.14 (0.31%)", "7838100"}
    };

    static class QuoteTableModel extends DefaultTableModel {
        private static final long serialVersionUID = -9125734576564111643L;

        public QuoteTableModel() {
            super(QUOTES, QUOTE_COLUMNS);
        }

        @Override
        public boolean isCellEditable(int row, int column) {
            return false;
        }
    }
}

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am


Return to JIDE Common Layer Open Source Project Discussion (Community Driven)

Who is online

Users browsing this forum: No registered users and 80 guests