Example usage for javax.swing SwingUtilities isEventDispatchThread

List of usage examples for javax.swing SwingUtilities isEventDispatchThread

Introduction

In this page you can find the example usage for javax.swing SwingUtilities isEventDispatchThread.

Prototype

public static boolean isEventDispatchThread() 

Source Link

Document

Returns true if the current thread is an AWT event dispatching thread.

Usage

From source file:org.yccheok.jstock.gui.JStock.java

/**
 * Set the visibility of exchange rate label on status bar.
 *
 * @param visible true to make the exchange rate label visible. Else false
 *//*from   w ww  . j  av  a 2s  .  c  o m*/
public void setStatusBarExchangeRateVisible(final boolean visible) {
    if (SwingUtilities.isEventDispatchThread()) {
        statusBar.setExchangeRateVisible(visible);
    } else {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                statusBar.setExchangeRateVisible(visible);
            }
        });
    }
}

From source file:org.yccheok.jstock.gui.JStock.java

/**
 * Set the tool tip text of exchange rate label on status bar.
 *
 * @param text the tool tip text//from  w w w .  ja v a2 s  . c  om
 */
public void setStatusBarExchangeRateToolTipText(final String text) {
    if (SwingUtilities.isEventDispatchThread()) {
        statusBar.setExchangeRateToolTipText(text);
    } else {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                statusBar.setExchangeRateToolTipText(text);
            }
        });
    }
}

From source file:org.yccheok.jstock.gui.JStock.java

/**
 * Update the status bar.// www . j  a  v a 2s  .c o  m
 *
 * @param progressBar true to make progress bar busy. Else false
 * @param mainMessage message on the left
 */
public void setStatusBar(final boolean progressBar, final String mainMessage) {
    if (SwingUtilities.isEventDispatchThread()) {
        isStatusBarBusy = progressBar;
        statusBar.setProgressBar(progressBar);
        statusBar.setMainMessage(mainMessage);
    } else {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                isStatusBarBusy = progressBar;
                statusBar.setProgressBar(progressBar);
                statusBar.setMainMessage(mainMessage);
            }
        });
    }
}

From source file:org.yccheok.jstock.gui.JStock.java

public void displayStockNews(Stock stock) {
    assert (SwingUtilities.isEventDispatchThread());

    final StockInfo stockInfo = StockInfo.newInstance(stock.code, stock.symbol);
    final String title = stock.symbol + " (" + stock.code + ")";
    final StockNewsJFrame stockNewsJFrame = new StockNewsJFrame(this, stockInfo, title);
}

From source file:org.yccheok.jstock.gui.JStock.java

public void displayPopupMessage(final String caption, final String message) {
    if (trayIcon == null) {
        return;/*from   www.j  a v a2 s .  c o  m*/
    }

    if (SwingUtilities.isEventDispatchThread()) {
        trayIcon.displayMessage(caption, message, TrayIcon.MessageType.INFO);
    } else {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                trayIcon.displayMessage(caption, message, TrayIcon.MessageType.INFO);
            }
        });
    }
}

From source file:org.yccheok.jstock.gui.MainFrame.java

/**
 * Activate specified watchlist.//  w  w w .j  av  a2s.  c o  m
 *
 * @param watchlist Watchlist name
 */
public void selectActiveWatchlist(String watchlist) {
    assert (SwingUtilities.isEventDispatchThread());
    // Save current watchlist.
    MainFrame.this.saveWatchlist();
    // Save current GUI options.
    // Do not call MainFrame.this.saveGUIOptions() (Pay note on the underscore)
    // , as that will save portfolio's and indicator scanner's as well.
    MainFrame.this._saveGUIOptions();
    // And switch to new portfolio.
    MainFrame.this.getJStockOptions().setWatchlistName(watchlist);
    MainFrame.this.initWatchlist();
    // I guess user wants to watch the current active watchlist right now.
    // We will help him to turn to the stock watchlist page.
    MainFrame.this.jTabbedPane1.setSelectedIndex(0);

    // No matter how, just stop progress bar, and display best message.
    this.setStatusBar(false, this.getBestStatusBarMessage());
}

From source file:org.yccheok.jstock.gui.MainFrame.java

/**
 * Activate specified portfolio./*ww  w  .  j  a  v a2 s.c  o m*/
 *
 * @param portfolio Portfolio name
 */
public void selectActivePortfolio(String portfolio) {
    assert (SwingUtilities.isEventDispatchThread());
    // Save current portfolio.
    MainFrame.this.portfolioManagementJPanel.savePortfolio();
    // Save current GUI options.
    MainFrame.this.portfolioManagementJPanel.saveGUIOptions();
    // And switch to new portfolio.
    MainFrame.this.getJStockOptions().setPortfolioName(portfolio);
    MainFrame.this.portfolioManagementJPanel.initPortfolio();
    // I guess user wants to watch the current active portfolio right now.
    // We will help him to turn to the portfolio page.
    MainFrame.this.jTabbedPane1.setSelectedIndex(3);

    MainFrame.this.portfolioManagementJPanel.updateTitledBorder();

    // No matter how, just stop progress bar, and display best message.
    this.setStatusBar(false, this.getBestStatusBarMessage());
}

From source file:org.yccheok.jstock.gui.PortfolioManagementJPanel.java

public void refreshGUIAfterOptionsJDialog() {
    if (SwingUtilities.isEventDispatchThread()) {
        _refreshGUIAfterOptionsJDialog();
    } else {/*from   ww  w .  j a v  a 2  s  . c o m*/
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                _refreshGUIAfterOptionsJDialog();
            }
        });
    }
}

From source file:org.yccheok.jstock.gui.PortfolioManagementJPanel.java

public void refreshGUIAfterFeeCalculationEnabledOptionsChanged() {
    if (SwingUtilities.isEventDispatchThread()) {
        _refreshGUIAfterFeeCalculationEnabledOptionsChanged();
    } else {//from   ww w  .j a  va  2s .com
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                _refreshGUIAfterFeeCalculationEnabledOptionsChanged();
            }
        });
    }
}

From source file:org.yccheok.jstock.gui.PortfolioManagementJPanel.java

private void refershGUIAfterInitPortfolio(final BuyPortfolioTreeTableModelEx buyPortfolioTreeTableModel,
        final SellPortfolioTreeTableModelEx sellPortfolioTreeTableModel, final DividendSummary _dividendSummary,
        final DepositSummary _depositSummary) {
    if (SwingUtilities.isEventDispatchThread()) {
        _refershGUIAfterInitPortfolio(buyPortfolioTreeTableModel, sellPortfolioTreeTableModel, _dividendSummary,
                _depositSummary);// w  ww. j  a  va2  s .c o m
    } else {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                _refershGUIAfterInitPortfolio(buyPortfolioTreeTableModel, sellPortfolioTreeTableModel,
                        _dividendSummary, _depositSummary);
            }
        });
    }
}