List of usage examples for java.awt EventQueue invokeLater
public static void invokeLater(Runnable runnable)
From source file:net.rptools.maptool.client.ui.MapToolFrame.java
private JComponent createDrawTreePanel() { final JTree tree = new JTree(); drawablesPanel = new DrawablesPanel(); drawPanelTreeModel = new DrawPanelTreeModel(tree); tree.setModel(drawPanelTreeModel);/* w ww.j a v a 2s .c o m*/ tree.setCellRenderer(new DrawPanelTreeCellRenderer()); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION); JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); splitPane.setContinuousLayout(true); splitPane.setTopComponent(new JScrollPane(tree)); splitPane.setBottomComponent(drawablesPanel); splitPane.setDividerLocation(100); // Add mouse Event for right click menu tree.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { TreePath path = tree.getPathForLocation(e.getX(), e.getY()); if (path == null) { return; } Object row = path.getLastPathComponent(); int rowIndex = tree.getRowForLocation(e.getX(), e.getY()); if (SwingUtilities.isLeftMouseButton(e)) { if (!SwingUtil.isShiftDown(e) && !SwingUtil.isControlDown(e)) { tree.clearSelection(); } tree.addSelectionInterval(rowIndex, rowIndex); if (row instanceof DrawnElement) { if (e.getClickCount() == 2) { DrawnElement de = (DrawnElement) row; getCurrentZoneRenderer() .centerOn(new ZonePoint((int) de.getDrawable().getBounds().getCenterX(), (int) de.getDrawable().getBounds().getCenterY())); } } int[] treeRows = tree.getSelectionRows(); java.util.Arrays.sort(treeRows); drawablesPanel.clearSelectedIds(); for (int i = 0; i < treeRows.length; i++) { TreePath p = tree.getPathForRow(treeRows[i]); if (p.getLastPathComponent() instanceof DrawnElement) { DrawnElement de = (DrawnElement) p.getLastPathComponent(); drawablesPanel.addSelectedId(de.getDrawable().getId()); } } } if (SwingUtilities.isRightMouseButton(e)) { if (!isRowSelected(tree.getSelectionRows(), rowIndex) && !SwingUtil.isShiftDown(e)) { tree.clearSelection(); tree.addSelectionInterval(rowIndex, rowIndex); drawablesPanel.clearSelectedIds(); } final int x = e.getX(); final int y = e.getY(); EventQueue.invokeLater(new Runnable() { public void run() { DrawnElement firstElement = null; Set<GUID> selectedDrawSet = new HashSet<GUID>(); for (TreePath path : tree.getSelectionPaths()) { if (path.getLastPathComponent() instanceof DrawnElement) { DrawnElement de = (DrawnElement) path.getLastPathComponent(); if (firstElement == null) { firstElement = de; } selectedDrawSet.add(de.getDrawable().getId()); } } if (!selectedDrawSet.isEmpty()) { try { new DrawPanelPopupMenu(selectedDrawSet, x, y, getCurrentZoneRenderer(), firstElement).showPopup(tree); } catch (IllegalComponentStateException icse) { log.info(tree.toString(), icse); } } } }); } } }); // Add Zone Change event MapTool.getEventDispatcher().addListener(new AppEventListener() { public void handleAppEvent(AppEvent event) { drawPanelTreeModel.setZone((Zone) event.getNewValue()); } }, MapTool.ZoneEvent.Activated); return splitPane; }
From source file:com.t3.client.TabletopTool.java
public static void main(String[] args) { if (MAC_OS_X) { // On OSX the menu bar at the top of the screen can be enabled at any time, but the // title (ie. name of the application) has to be set before the GUI is initialized (by // creating a frame, loading a splash screen, etc). So we do it here. System.setProperty("apple.laf.useScreenMenuBar", "true"); System.setProperty("com.apple.mrj.application.apple.menu.about.name", "About TabletopTool..."); System.setProperty("apple.awt.brushMetalLook", "true"); }// w w w. j a v a2 s . c o m // Before anything else, create a place to store all the data try { AppUtil.getAppHome(); } catch (Throwable t) { t.printStackTrace(); // Create an empty frame so there's something to click on if the dialog goes in the background JFrame frame = new JFrame(); SwingUtil.centerOnScreen(frame); frame.setVisible(true); String errorCreatingDir = "Error creating data directory"; log.error(errorCreatingDir, t); JOptionPane.showMessageDialog(frame, t.getMessage(), errorCreatingDir, JOptionPane.ERROR_MESSAGE); System.exit(1); } verifyJavaVersion(); configureLogging(); // System properties System.setProperty("swing.aatext", "true"); // System.setProperty("sun.java2d.opengl", "true"); final SplashScreen splash = new SplashScreen(SPLASH_IMAGE, getVersion()); splash.showSplashScreen(); // Protocol handlers // cp:// is registered by the RPTURLStreamHandlerFactory constructor (why?) RPTURLStreamHandlerFactory factory = new RPTURLStreamHandlerFactory(); factory.registerProtocol("asset", new AssetURLStreamHandler()); URL.setURLStreamHandlerFactory(factory); MacroEngine.initialize(); configureJide(); //TODO find out how to not call this twice without destroying error windows final Toolkit tk = Toolkit.getDefaultToolkit(); tk.getSystemEventQueue().push(new T3EventQueue()); // LAF try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); configureJide(); if (WINDOWS) LookAndFeelFactory.installJideExtension(LookAndFeelFactory.XERTO_STYLE); else LookAndFeelFactory.installJideExtension(); if (MAC_OS_X) { macOSXicon(); } menuBar = new AppMenuBar(); } catch (Exception e) { TabletopTool.showError("msg.error.lafSetup", e); System.exit(1); } /** * This is a tweak that makes the Chinese version work better. * <p> * Consider reviewing <a * href="http://en.wikipedia.org/wiki/CJK_characters" * >http://en.wikipedia.org/wiki/CJK_characters</a> before making * changes. And http://www.scarfboy.com/coding/unicode-tool is also a * really cool site. */ if (Locale.CHINA.equals(Locale.getDefault())) { // The following font name appears to be "Sim Sun". It can be downloaded // from here: http://fr.cooltext.com/Fonts-Unicode-Chinese Font f = new Font("\u65B0\u5B8B\u4F53", Font.PLAIN, 12); FontUIResource fontRes = new FontUIResource(f); for (Enumeration<Object> keys = UIManager.getDefaults().keys(); keys.hasMoreElements();) { Object key = keys.nextElement(); Object value = UIManager.get(key); if (value instanceof FontUIResource) UIManager.put(key, fontRes); } } // Draw frame contents on resize tk.setDynamicLayout(true); EventQueue.invokeLater(new Runnable() { @Override public void run() { initialize(); EventQueue.invokeLater(new Runnable() { @Override public void run() { clientFrame.setVisible(true); splash.hideSplashScreen(); EventQueue.invokeLater(new Runnable() { @Override public void run() { postInitialize(); } }); } }); } }); // new Thread(new HeapSpy()).start(); }
From source file:me.paddingdun.gen.code.gui.view.dbtable.TableView.java
private void btnGenActionPerformed(java.awt.event.ActionEvent evt) { if (model != null) { fileChooser.setFileSelectionMode(JFileChooser.SAVE_DIALOG | JFileChooser.DIRECTORIES_ONLY); fileChooser.setCurrentDirectory(new File("D:\\home\\Desktop")); int opt = fileChooser.showSaveDialog(null); // ?;//from w w w . j a va2 s .c o m if (JFileChooser.APPROVE_OPTION == opt) { TaskHelper.runInNonEDT(new Callable<Integer[]>() { public Integer[] call() throws Exception { File saveFile = fileChooser.getSelectedFile(); if (!saveFile.exists()) saveFile.mkdirs(); // ; // ModelHelper.complexGetAndSimpleSet(TableView.this, // model); //?EditViewModel; EditView ev = perspective.getEditView(); ev.setModelValue(); EditViewModel evm = ev.getModel(); // model;ok ModelHelper.processTableViewModel(model, evm); String baseJavaContent = VelocityHelper.baseEntityBean(model); // System.out.println(javaContent); FileHelper.genBasePojoJavaFile(saveFile.getAbsolutePath(), model.getPojoFullPackageName(), model.getEntity().getEntityBeanName(), baseJavaContent); String javaContent = VelocityHelper.entityBean(model); // System.out.println(javaContent); FileHelper.genPojoJavaFile(saveFile.getAbsolutePath(), model.getPojoFullPackageName(), model.getEntity().getEntityBeanName(), javaContent); String sqlMapBaseContent = VelocityHelper.sqlBaseMap(model); FileHelper.genSqlMapBaseXmlFile(saveFile.getAbsolutePath(), model.getEntity().getEntityBeanName(), sqlMapBaseContent); String sqlMapContent = VelocityHelper.sqlMap(model); FileHelper.genSqlMapXmlFile(saveFile.getAbsolutePath(), model.getEntity().getEntityBeanName(), sqlMapContent); // System.out.println(sqlMapContent); String sqlMapBaseIDaoContent = VelocityHelper.sqlMapIDao(model); FileHelper.genSqlMapIDaoJavaFile(saveFile.getAbsolutePath(), model.getDaoFullPackageName(), model.getEntity().getEntityBeanName(), sqlMapBaseIDaoContent); String sqlMapIDaoContent = VelocityHelper.sqlMapBaseDao(model); FileHelper.genSqlMapBaseDaoJavaFile(saveFile.getAbsolutePath(), model.getDaoFullPackageName(), model.getEntity().getEntityBeanName(), sqlMapIDaoContent); if (!VelocityHelper.isMybtis()) { String sqlMapDaoImplContent = VelocityHelper.sqlMapDaoImpl(model); FileHelper.genSqlMapDaoImplJavaFile(saveFile.getAbsolutePath(), model.getDaoImplFullPackageName(), model.getEntity().getEntityBeanName(), sqlMapDaoImplContent); } String sqlMapBaseServiceContent = VelocityHelper.sqlMapBaseService(model); FileHelper.genSqlMapBaseServiceJavaFile(saveFile.getAbsolutePath(), model.getServiceFullPackageName(), model.getEntity().getEntityBeanName(), sqlMapBaseServiceContent); String sqlMapIServiceContent = VelocityHelper.sqlMapIService(model); FileHelper.genSqlMapIServiceJavaFile(saveFile.getAbsolutePath(), model.getServiceFullPackageName(), model.getEntity().getEntityBeanName(), sqlMapIServiceContent); String sqlMapBaseServiceImplContent = VelocityHelper.sqlMapBaseServiceImpl(model); FileHelper.genSqlMapBaseServiceImplJavaFile(saveFile.getAbsolutePath(), model.getServiceImplFullPackageName(), model.getEntity().getEntityBeanName(), sqlMapBaseServiceImplContent); String sqlMapServiceImplContent = VelocityHelper.sqlMapServiceImpl(model); FileHelper.genSqlMapServiceImplJavaFile(saveFile.getAbsolutePath(), model.getServiceImplFullPackageName(), model.getEntity().getEntityBeanName(), sqlMapServiceImplContent); String springWebActionContent = VelocityHelper.springWebAction(model); FileHelper.genSpringWebActionJavaFile(saveFile.getAbsolutePath(), model.getWebActionFullPackageName(), model.getEntity().getEntityBeanName(), springWebActionContent); // String bootstrapDataTableJspContent = // VelocityHelper.bootstrapDataTableJsp(model); // FileHelper.genBootstrapDataTableJspFile(saveFile.getAbsolutePath(), // model.getJspWebinfAfterDir(), // model.getEntity().getEntityBeanName(), // bootstrapDataTableJspContent); String easyuiListJspContent = VelocityHelper.easyuiListJsp(model); FileHelper.genEasyuiListJspFile(saveFile.getAbsolutePath(), model.getJspWebinfAfterDir(), model.getEntity().getEntityBeanName(), easyuiListJspContent); String easyuiEditJspContent = VelocityHelper.easyuiEditJsp(model); FileHelper.genEasyuiEditJspFile(saveFile.getAbsolutePath(), model.getJspWebinfAfterDir(), model.getEntity().getEntityBeanName(), easyuiEditJspContent); EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(null, "??!"); } }); return null; } }); } } }
From source file:xtrememp.XtremeMP.java
@Override public void playbackOpened(PlaybackEvent pe) { try {//from w w w . j a v a2 s .c o m audioPlayer.setGain(Settings.getGain() / 100.0F); audioPlayer.setMuted(Settings.isMuted()); } catch (PlayerException ex) { logger.error(ex.getMessage(), ex); } finally { if (currentPli != null) { if (!currentPli.isFile()) { currentPli.getTagInfo(); } setStatus(currentPli.getFormattedName()); } } EventQueue.invokeLater(() -> { stopButton.setEnabled(true); stopMenuItem.setEnabled(true); }); }
From source file:fur.shadowdrake.minecraft.InstallPanel.java
private void showReadMe() throws NetworkException { StringBuilder sb = new StringBuilder(); while (true) { result = ftpClient.openDataChannel((ActionEvent e) -> { if (e.getID() == FtpClient.FTP_OK) { try { InputStreamReader isr; char[] buffer = new char[4096]; int n; isr = new InputStreamReader(((Socket) e.getSource()).getInputStream()); while (true) { n = isr.read(buffer); if (n < 0) { break; }/*w w w . j av a 2 s.co m*/ sb.append(buffer, 0, n); } } catch (IOException ex) { Logger.getLogger(InstallPanel.class.getName()).log(Level.SEVERE, "Readme", ex); log.println("Faild retrieve readme."); ftpClient.closeDataChannel(); } } }); switch (result) { case FtpClient.FTP_OK: downloadSize = ftpClient.retr(workingPack + "/readme", (ActionEvent e) -> { ftpClient.closeDataChannel(); EventQueue.invokeLater(() -> { ReadmeBox rb = new ReadmeBox(parentFrame, true, sb.toString()); rb.setVisible(true); }); }); if (downloadSize >= 0) { } else { switch (downloadSize) { case FtpClient.FTP_NODATA: log.println( "Oops! Server's complaining about missing data channel, although I've opened it."); ftpClient.abandonDataChannel(); return; default: ftpClient.abandonDataChannel(); } } break; case FtpClient.FTP_TIMEOUT: if (reconnect()) { continue; } } break; } }
From source file:me.paddingdun.gen.code.gui.view.dbtable.TableView.java
/** * ?;/*from ww w .j a v a 2 s . com*/ * @param evt */ private void btnWorkGenActionPerformed(java.awt.event.ActionEvent evt) { if (model != null) { fileChooser.setFileSelectionMode(JFileChooser.SAVE_DIALOG | JFileChooser.DIRECTORIES_ONLY); fileChooser.setCurrentDirectory(new File("D:\\home\\Desktop")); int opt = fileChooser.showSaveDialog(null); // ?; if (JFileChooser.APPROVE_OPTION == opt) { TaskHelper.runInNonEDT(new Callable<Integer[]>() { public Integer[] call() throws Exception { File saveFile = fileChooser.getSelectedFile(); if (!saveFile.exists()) saveFile.mkdirs(); // ; // ModelHelper.complexGetAndSimpleSet(TableView.this, // model); //?EditViewModel; EditView ev = perspective.getEditView(); ev.setModelValue(); EditViewModel evm = ev.getModel(); // model;ok ModelHelper.processTableViewModel(model, evm); String java1 = VelocityHelper.commonJava(model, "template/velocity/work20170417/pojo.vm"); // System.out.println(javaContent); FileHelper.genCommonJavaFile(saveFile.getAbsolutePath(), model.getPojoFullPackageName(), model.getEntity().getEntityBeanName(), java1); EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(null, "??!"); } }); return null; } }); } } }
From source file:net.rptools.maptool.client.MapTool.java
public static void main(String[] args) { if (MAC_OS_X) { // On OSX the menu bar at the top of the screen can be enabled at any time, but the // title (ie. name of the application) has to be set before the GUI is initialized (by // creating a frame, loading a splash screen, etc). So we do it here. System.setProperty("apple.laf.useScreenMenuBar", "true"); System.setProperty("com.apple.mrj.application.apple.menu.about.name", "About MapTool..."); System.setProperty("apple.awt.brushMetalLook", "true"); }/*w ww . j a va 2 s.c o m*/ // Before anything else, create a place to store all the data try { AppUtil.getAppHome(); } catch (Throwable t) { t.printStackTrace(); // Create an empty frame so there's something to click on if the dialog goes in the background JFrame frame = new JFrame(); SwingUtil.centerOnScreen(frame); frame.setVisible(true); String errorCreatingDir = "Error creating data directory"; log.error(errorCreatingDir, t); JOptionPane.showMessageDialog(frame, t.getMessage(), errorCreatingDir, JOptionPane.ERROR_MESSAGE); System.exit(1); } verifyJavaVersion(); configureLogging(); // System properties System.setProperty("swing.aatext", "true"); // System.setProperty("sun.java2d.opengl", "true"); final SplashScreen splash = new SplashScreen(SPLASH_IMAGE, getVersion()); splash.showSplashScreen(); // Protocol handlers // cp:// is registered by the RPTURLStreamHandlerFactory constructor (why?) RPTURLStreamHandlerFactory factory = new RPTURLStreamHandlerFactory(); factory.registerProtocol("asset", new AssetURLStreamHandler()); URL.setURLStreamHandlerFactory(factory); final Toolkit tk = Toolkit.getDefaultToolkit(); tk.getSystemEventQueue().push(new MapToolEventQueue()); // LAF try { // If we are running under Mac OS X then save native menu bar look & feel components // Note the order of creation for the AppMenuBar, this specific chronology // allows the system to set up system defaults before we go and modify things. // That is, please don't move these lines around unless you test the result on windows and mac String lafname; if (MAC_OS_X) { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); menuBar = new AppMenuBar(); lafname = "net.rptools.maptool.client.TinyLookAndFeelMac"; UIManager.setLookAndFeel(lafname); macOSXicon(); } // If running on Windows based OS, CJK font is broken when using TinyLAF. // else if (WINDOWS) { // UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); // menuBar = new AppMenuBar(); // } else { lafname = "de.muntjak.tinylookandfeel.TinyLookAndFeel"; UIManager.setLookAndFeel(lafname); menuBar = new AppMenuBar(); } // After the TinyLAF library is initialized, look to see if there is a Default.theme // in our AppHome directory and load it if there is. Unfortunately, changing the // search path for the default theme requires subclassing TinyLAF and because // we have both the original and a Mac version that gets cumbersome. (Really // the Mac version should use the default and then install the keystroke differences // but what we have works and I'm loathe to go playing with it at 1.3b87 -- yes, 87!) File f = AppUtil.getAppHome("config"); if (f.exists()) { File f2 = new File(f, "Default.theme"); if (f2.exists()) { if (Theme.loadTheme(f2)) { // re-install the Tiny Look and Feel UIManager.setLookAndFeel(lafname); // Update the ComponentUIs for all Components. This // needs to be invoked for all windows. //SwingUtilities.updateComponentTreeUI(rootComponent); } } } com.jidesoft.utils.Lm.verifyLicense("Trevor Croft", "rptools", "5MfIVe:WXJBDrToeLWPhMv3kI2s3VFo"); LookAndFeelFactory.addUIDefaultsCustomizer(new LookAndFeelFactory.UIDefaultsCustomizer() { public void customize(UIDefaults defaults) { // Remove red border around menus defaults.put("PopupMenu.foreground", Color.lightGray); } }); LookAndFeelFactory.installJideExtension(LookAndFeelFactory.XERTO_STYLE); /**************************************************************************** * For TinyLAF 1.3.04 this is how the color was changed for a * button. */ // Theme.buttonPressedColor[Theme.style] = new ColorReference(Color.gray); /**************************************************************************** * And this is how it's done in TinyLAF 1.4.0 (no idea about the * intervening versions). */ Theme.buttonPressedColor = new SBReference(Color.GRAY, 0, -6, SBReference.SUB3_COLOR); configureJide(); } catch (Exception e) { MapTool.showError("msg.error.lafSetup", e); System.exit(1); } /** * This is a tweak that makes the Chinese version work better. * <p> * Consider reviewing <a * href="http://en.wikipedia.org/wiki/CJK_characters" * >http://en.wikipedia.org/wiki/CJK_characters</a> before making * changes. And http://www.scarfboy.com/coding/unicode-tool is also a * really cool site. */ if (Locale.CHINA.equals(Locale.getDefault())) { // The following font name appears to be "Sim Sun". It can be downloaded // from here: http://fr.cooltext.com/Fonts-Unicode-Chinese Font f = new Font("\u65B0\u5B8B\u4F53", Font.PLAIN, 12); FontUIResource fontRes = new FontUIResource(f); for (Enumeration<Object> keys = UIManager.getDefaults().keys(); keys.hasMoreElements();) { Object key = keys.nextElement(); Object value = UIManager.get(key); if (value instanceof FontUIResource) UIManager.put(key, fontRes); } } // Draw frame contents on resize tk.setDynamicLayout(true); EventQueue.invokeLater(new Runnable() { public void run() { initialize(); EventQueue.invokeLater(new Runnable() { public void run() { clientFrame.setVisible(true); splash.hideSplashScreen(); EventQueue.invokeLater(new Runnable() { public void run() { postInitialize(); } }); } }); } }); // new Thread(new HeapSpy()).start(); }
From source file:xtrememp.XtremeMP.java
@Override public void playbackPlaying(PlaybackEvent pe) { EventQueue.invokeLater(() -> { playPauseButton.setPauseIcon();/* w w w .j a v a 2s . c om*/ playPauseMenuItem.setText(tr("MainFrame.Menu.Player.Pause")); }); }
From source file:net.rptools.maptool.client.ui.MapToolFrame.java
private JComponent createTokenTreePanel() { final JTree tree = new JTree(); tokenPanelTreeModel = new TokenPanelTreeModel(tree); tree.setModel(tokenPanelTreeModel);// www .j a v a 2s. c o m tree.setCellRenderer(new TokenPanelTreeCellRenderer()); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION); tree.addMouseListener(new MouseAdapter() { // TODO: Make this a handler class, not an aic @Override public void mousePressed(MouseEvent e) { // tree.setSelectionPath(tree.getPathForLocation(e.getX(), e.getY())); TreePath path = tree.getPathForLocation(e.getX(), e.getY()); if (path == null) { return; } Object row = path.getLastPathComponent(); int rowIndex = tree.getRowForLocation(e.getX(), e.getY()); if (SwingUtilities.isLeftMouseButton(e)) { if (!SwingUtil.isShiftDown(e) && !SwingUtil.isControlDown(e)) { tree.clearSelection(); } tree.addSelectionInterval(rowIndex, rowIndex); if (row instanceof Token) { if (e.getClickCount() == 2) { Token token = (Token) row; getCurrentZoneRenderer().clearSelectedTokens(); getCurrentZoneRenderer().centerOn(new ZonePoint(token.getX(), token.getY())); // Pick an appropriate tool getToolbox().setSelectedTool(token.isToken() ? PointerTool.class : StampTool.class); getCurrentZoneRenderer().setActiveLayer(token.getLayer()); getCurrentZoneRenderer().selectToken(token.getId()); getCurrentZoneRenderer().requestFocusInWindow(); } } } if (SwingUtilities.isRightMouseButton(e)) { if (!isRowSelected(tree.getSelectionRows(), rowIndex) && !SwingUtil.isShiftDown(e)) { tree.clearSelection(); tree.addSelectionInterval(rowIndex, rowIndex); } final int x = e.getX(); final int y = e.getY(); EventQueue.invokeLater(new Runnable() { public void run() { Token firstToken = null; Set<GUID> selectedTokenSet = new HashSet<GUID>(); for (TreePath path : tree.getSelectionPaths()) { if (path.getLastPathComponent() instanceof Token) { Token token = (Token) path.getLastPathComponent(); if (firstToken == null) { firstToken = token; } if (AppUtil.playerOwns(token)) { selectedTokenSet.add(token.getId()); } } } if (!selectedTokenSet.isEmpty()) { try { if (firstToken.isStamp()) { new StampPopupMenu(selectedTokenSet, x, y, getCurrentZoneRenderer(), firstToken).showPopup(tree); } else { new TokenPopupMenu(selectedTokenSet, x, y, getCurrentZoneRenderer(), firstToken).showPopup(tree); } } catch (IllegalComponentStateException icse) { log.info(tree.toString(), icse); } } } }); } } }); MapTool.getEventDispatcher().addListener(new AppEventListener() { public void handleAppEvent(AppEvent event) { tokenPanelTreeModel.setZone((Zone) event.getNewValue()); } }, MapTool.ZoneEvent.Activated); return tree; }
From source file:xtrememp.XtremeMP.java
@Override public void playbackProgress(PlaybackEvent pe) { if (currentPli != null && !seekSlider.getValueIsAdjusting() && !seekSlider.isPressed() && mainFrame.isVisible()) { acUpdateTime(seekSlider.getOldValue() + Math.round(pe.getPosition() / 1000F)); // Shoutcast stream title. Map properties = pe.getProperties(); String streamTitleKey = "mp3.shoutcast.metadata.StreamTitle"; if (!currentPli.isFile() && properties.containsKey(streamTitleKey)) { String streamTitle = ((String) properties.get(streamTitleKey)).trim(); TagInfo tagInfo = currentPli.getTagInfo(); if (!streamTitle.isEmpty() && (tagInfo != null)) { String sTitle = Utilities.isNullOrEmpty(tagInfo.getTitle()) ? "" : " (" + tagInfo.getTitle() + ")"; if (!currentPli.getFormattedName().equals(streamTitle + sTitle)) { currentPli.setFormattedName(streamTitle + sTitle); EventQueue.invokeLater(() -> { playlistManager.refreshRow(playlist.indexOf(currentPli)); setStatus(currentPli.getFormattedName()); });/*from w w w. ja v a2s. c om*/ } } } } }