protected boolean setDir(JTextField txf, String strValue) { String strTxt = txf.getText(); String strName = txf.getName(); boolean bSet = false; if ((strTxt == null || strTxt.trim().length() == 0 || strTxt.equals(INFOSTR)) && strName.equalsIgnoreCase("value")) { if (timer != null) { timer.cancel(); txf.setForeground(Color.black); } bSet = true; txf.setText(strValue); txf.grabFocus(); } return bSet; }
@Override public void newImageUpdate(JSONObject tags) { if (tags == null) { return; } updateLabels(tags); try { if (vad_.acquisitionIsRunning() && vad_.getNextWakeTime() > 0) { final long nextImageTime = vad_.getNextWakeTime(); if (System.nanoTime() / 1000000 < nextImageTime) { final java.util.Timer timer = new java.util.Timer("Next frame display"); TimerTask task = new TimerTask() { public void run() { double timeRemainingS = (nextImageTime - System.nanoTime() / 1000000) / 1000; if (timeRemainingS > 0 && vad_.acquisitionIsRunning()) { setStatusLabel( "Next frame: " + NumberUtils.doubleToDisplayString(1 + timeRemainingS) + " s"); } else { timer.cancel(); setStatusLabel(""); } } }; timer.schedule(task, 2000, 100); } } } catch (Exception ex) { ReportingUtils.logError(ex); } }
private void showDropDownListWithDelay() { java.util.Timer timer = new Timer("showJComboBoxDropDownList", false); timer.schedule( new TimerTask() { @Override public void run() { showJComboBoxDropDownList(); } }, 18000); }
protected void doBlink() { if (timer != null) timer.cancel(); timer = new java.util.Timer(); timer.schedule( new TimerTask() { public void run() { WUtil.blink(validateButton); } }, delay, delay); }
/** * The Memory Monitor sets up a 5 second Timer which displays the amount of remaining memory * (compared to the total memory we have). */ private void setupMemoryMonitor() { memoryTimer = new java.util.Timer("Memory monitor", true); memoryTimer.schedule( new TimerTask() { @Override public void run() { // We need to set this off in the Event Thread. SwingUtilities.invokeLater( new Runnable() { @Override public void run() { // Calculate the memory we have. long value = (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / (1024 * 1024); long max = Runtime.getRuntime().maxMemory() / (1024 * 1024); int percentage = (int) (((double) value) / max * 100); // Set the progress bar. progressBar.setMinimum(0); progressBar.setMaximum(100); progressBar.setValue(percentage); progressBar.setString( value + " MB out of " + max + " MB (" + percentage + "%)"); } }); } }, new Date(), 5000); // Every five seconds. }
private void startMap() { g = new DirectedSparseMultigraph<>(); layout = new StaticLayout<>(g); vv = new VisualizationViewer<>(layout, getSize()); timer = new Timer(); timer.schedule(new UpdateMapTask(), PublicData.refreshInter, PublicData.refreshInter); // vv.repaint(); }
public ControleurPaiement( JPanel p, CardLayout cl, Table[] t, Component[] lC, Component[] pC, Component[] sC, VuePaiement v) { this.modeleTable = new ModeleTable(); setLogComponents(lC); setPayComponents(pC); setStatComponents(sC); this.tables = t; this.panneau = p; this.cartes = cl; this.tableCounter = 0; this.difTemps = 0; // On raffraichi toutes les minutes java.util.Timer timer = new java.util.Timer(); timer.schedule(new Refresh(this.tables, v), 0, 30000); }
public void actionPerformed(ActionEvent e) { String cmd = e.getActionCommand(); if (cmd.equals("close")) { if (m_nType == CONFIG) saveData(); else if (m_nType == DEFAULT && m_pnlAccPolicy != null) m_pnlAccPolicy.saveData(); setVisible(false); dispose(); } else if (cmd.equals("validate")) { if (timer != null) timer.cancel(); if (m_nType == CHECKSUM && m_pnlChecksum != null) m_pnlChecksum.checksumValidation(); else doSysValidation(); validateButton.setBackground(closeButton.getBackground()); } else if (cmd.equals("checksum")) { String strValue = m_pnlChecksum.getChecksum(); m_pnlChecksum.setData(strValue); } else if (cmd.equals("checksumdir")) { m_pnlChecksum.setData(""); } else if (cmd.equals("cancel")) { // build(m_bAccPolicy); setVisible(false); dispose(); } else if (cmd.equals("help")) displayHelp(); }
public JMenu buildModeMenu() { JMenu menu = new JMenu("Android"); JMenuItem item; item = new JMenuItem("Sketch Permissions"); item.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { new Permissions(sketch); } }); menu.add(item); menu.addSeparator(); /*item = new JMenuItem("Signing Key Setup"); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { new Keys(AndroidEditor.this); } }); item.setEnabled(false); menu.add(item); */ final JMenu deviceMenu = new JMenu("Select device"); JMenuItem noDevicesItem = new JMenuItem("No connected devices"); noDevicesItem.setEnabled(false); deviceMenu.add(noDevicesItem); menu.add(deviceMenu); // start updating device menus UpdateDeviceListTask task = new UpdateDeviceListTask(deviceMenu); java.util.Timer timer = new java.util.Timer(); timer.schedule(task, 5000, 5000); menu.addSeparator(); final JMenu sdkMenu = new JMenu("Select target SDK"); JMenuItem defaultItem = new JCheckBoxMenuItem("No available targets"); defaultItem.setEnabled(false); sdkMenu.add(defaultItem); new Thread() { @Override public void run() { while (androidMode == null || androidMode.getSDK() == null) { try { Thread.sleep(3000); } catch (InterruptedException e) { e.printStackTrace(); } } updateSdkMenu(sdkMenu); } }.start(); menu.add(sdkMenu); menu.addSeparator(); item = new JMenuItem("Android SDK Manager"); item.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { File file = androidMode.getSDK().getAndroidTool(); try { Runtime.getRuntime().exec(new String[] {file.getAbsolutePath(), "sdk"}); } catch (IOException e1) { e1.printStackTrace(); } } }); menu.add(item); item = new JMenuItem("Android AVD Manager"); item.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { File file = androidMode.getSDK().getAndroidTool(); PApplet.exec(new String[] {file.getAbsolutePath(), "avd"}); } }); menu.add(item); item = new JMenuItem("Reset Connections"); item.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { // editor.statusNotice("Resetting the Android Debug Bridge server."); Devices.killAdbServer(); } }); menu.add(item); return menu; }