List of usage examples for javax.swing SwingUtilities invokeLater
public static void invokeLater(Runnable doRun)
From source file:org.openaltimeter.desktopapp.annotations.AltimeterChartMouseListener.java
@Override public void chartMouseClicked(final ChartMouseEvent event) { SwingUtilities.invokeLater(new Runnable() { public void run() { XYPlot xyplot = (XYPlot) cp.getChart().getPlot(); double x, y; x = xyplot.getDomainCrosshairValue(); y = xyplot.getRangeCrosshairValue(); am.addUserHeightAnnotation(x, y); int onmask = InputEvent.SHIFT_DOWN_MASK; if ((event.getTrigger().getModifiersEx() & (onmask)) == onmask) am.addUserVarioAnnotation(lastAnnotationX, lastAnnotationY, x, y); lastAnnotationX = x;/* ww w .j a v a 2 s .c o m*/ lastAnnotationY = y; } }); }
From source file:Main.java
private void moveButton(final Point p) { SwingUtilities.invokeLater(new Runnable() { @Override/*www . j a v a 2s. c om*/ public void run() { button.setLocation(p); } }); }
From source file:Main.java
/** * Sends a Runnable to the EDT for the execution. */ private static void execute(Runnable command) { SwingUtilities.invokeLater(command); }
From source file:ca.sqlpower.wabit.swingui.chart.WabitJFreeChartPanel.java
@Override public void paintComponent(Graphics g) { if (getChart() == null) { return;/*from w ww. j a v a2 s . c om*/ } Graphics2D g2 = (Graphics2D) g.create(); float baseline = getXaxisBaseline(); ChartGradientPainter.paintChartGradient(g2, getBounds(), (int) baseline); g2.setColor(getForeground()); super.paintComponent(g2); // this rendering has a different layout than last time; // have to paint again to update gradient position if (Math.abs(baseline - getXaxisBaseline()) > 1f) { SwingUtilities.invokeLater(new Runnable() { public void run() { repaint(); } }); } g2.dispose(); }
From source file:org.sunzoft.sunstock.StockMain.java
protected void initGUI() { final JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(1024, 600);//from w w w . j a v a2s .c o m frame.setLocationRelativeTo(null); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { // Container contentPane = frame.getContentPane(); contentPane.setLayout(new BorderLayout(0, 0)); JFreeChart chart = createChart(); // 6:chartPanel chartPanel = new ChartPanel(chart); chartPanel.setMouseZoomable(true); contentPane.add(chartPanel, BorderLayout.CENTER); JPanel pCtrl = new JPanel(); if (profits.size() > 0) { startInput.setText(profits.get(0).date); endInput.setText(profits.get(profits.size() - 1).date); } else { startInput.setText("20100101"); endInput.setText("20100101"); } pCtrl.add(new JLabel("")); pCtrl.add(startInput); pCtrl.add(new JLabel("")); pCtrl.add(endInput); JButton confirm = new JButton(""); confirm.addActionListener(StockMain.this); pCtrl.add(confirm); contentPane.add(pCtrl, BorderLayout.NORTH); JPanel pStatus = new JPanel(); statusLabel = new JLabel(getStatusText()); pStatus.add(statusLabel); contentPane.add(pStatus, BorderLayout.SOUTH); frame.setExtendedState(frame.getExtendedState() | JFrame.MAXIMIZED_BOTH); frame.setVisible(true); //dataSource.close(); } }); }
From source file:fxts.stations.transport.tradingapi.processors.BusinessMessageRejectProcessor.java
public void process(ITransportable aTransportable) { TradingServerSession aTradingServerSession = TradingServerSession.getInstance(); final BusinessMessageReject aBmr = (BusinessMessageReject) aTransportable; mLogger.debug("client inc: business message request = " + aBmr); String reqID = aTradingServerSession.getRequestID(); if (reqID != null && reqID.equals(aBmr.getBusinessRejectRefID())) { aTradingServerSession.doneProcessing(); } else {/*from w w w . ja v a2 s .c om*/ SwingUtilities.invokeLater(new Runnable() { public void run() { MainFrame mainFrame = TradeApp.getInst().getMainFrame(); JOptionPane.showMessageDialog(mainFrame, OraCodeFactory.toMessage(aBmr.getText()), "Problem with your request..", JOptionPane.ERROR_MESSAGE); } }); } }
From source file:com.jug.MotherMachine.java
/** * PROJECT MAIN/*w w w. j a v a 2 s . c om*/ * ============ * * @param args * muh! */ public static void main(final String[] args) { try { final MotherMachine main = new MotherMachine(); guiFrame = new JFrame("Interactive MotherMachine"); main.initMainWindow(guiFrame); props = main.loadParams(); BGREM_TEMPLATE_XMIN = Integer .parseInt(props.getProperty("BGREM_TEMPLATE_XMIN", Integer.toString(BGREM_TEMPLATE_XMIN))); BGREM_TEMPLATE_XMAX = Integer .parseInt(props.getProperty("BGREM_TEMPLATE_XMAX", Integer.toString(BGREM_TEMPLATE_XMAX))); BGREM_X_OFFSET = Integer .parseInt(props.getProperty("BGREM_X_OFFSET", Integer.toString(BGREM_X_OFFSET))); GL_OFFSET_BOTTOM = Integer .parseInt(props.getProperty("GL_OFFSET_BOTTOM", Integer.toString(GL_OFFSET_BOTTOM))); GL_OFFSET_TOP = Integer.parseInt(props.getProperty("GL_OFFSET_TOP", Integer.toString(GL_OFFSET_TOP))); GL_OFFSET_LATERAL = Integer .parseInt(props.getProperty("GL_OFFSET_LATERAL", Integer.toString(GL_OFFSET_LATERAL))); MIN_CELL_LENGTH = Integer .parseInt(props.getProperty("MIN_CELL_LENGTH", Integer.toString(MIN_CELL_LENGTH))); MIN_GAP_CONTRAST = Double .parseDouble(props.getProperty("MIN_GAP_CONTRAST", Double.toString(MIN_GAP_CONTRAST))); SIGMA_PRE_SEGMENTATION_X = Double.parseDouble( props.getProperty("SIGMA_PRE_SEGMENTATION_X", Double.toString(SIGMA_PRE_SEGMENTATION_X))); SIGMA_PRE_SEGMENTATION_Y = Double.parseDouble( props.getProperty("SIGMA_PRE_SEGMENTATION_Y", Double.toString(SIGMA_PRE_SEGMENTATION_Y))); SIGMA_GL_DETECTION_X = Double .parseDouble(props.getProperty("SIGMA_GL_DETECTION_X", Double.toString(SIGMA_GL_DETECTION_X))); SIGMA_GL_DETECTION_Y = Double .parseDouble(props.getProperty("SIGMA_GL_DETECTION_Y", Double.toString(SIGMA_GL_DETECTION_Y))); DEFAULT_PATH = props.getProperty("DEFAULT_PATH", DEFAULT_PATH); GUI_POS_X = Integer.parseInt(props.getProperty("GUI_POS_X", Integer.toString(DEFAULT_GUI_POS_X))); GUI_POS_Y = Integer.parseInt(props.getProperty("GUI_POS_Y", Integer.toString(DEFAULT_GUI_POS_X))); GUI_WIDTH = Integer.parseInt(props.getProperty("GUI_WIDTH", Integer.toString(GUI_WIDTH))); GUI_HEIGHT = Integer.parseInt(props.getProperty("GUI_HEIGHT", Integer.toString(GUI_HEIGHT))); GUI_CONSOLE_WIDTH = Integer .parseInt(props.getProperty("GUI_CONSOLE_WIDTH", Integer.toString(GUI_CONSOLE_WIDTH))); // Iterate over all currently attached monitors and check if sceen position is actually possible, // otherwise fall back to the DEFAULT values and ignore the ones coming from the properties-file. boolean pos_ok = false; final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); final GraphicsDevice[] gs = ge.getScreenDevices(); for (int i = 0; i < gs.length; i++) { final DisplayMode dm = gs[i].getDisplayMode(); if (gs[i].getDefaultConfiguration().getBounds() .contains(new java.awt.Point(GUI_POS_X, GUI_POS_Y))) { pos_ok = true; } } // None of the screens contained the top-left window coordinates --> fall back onto default values... if (!pos_ok) { GUI_POS_X = DEFAULT_GUI_POS_X; GUI_POS_Y = DEFAULT_GUI_POS_Y; } String path = props.getProperty("import_path", System.getProperty("user.home")); final File fPath = main.showStartupDialog(guiFrame, path); path = fPath.getAbsolutePath(); props.setProperty("import_path", fPath.getAbsolutePath()); // Setting up console window and window snapper... main.initConsoleWindow(); main.showConsoleWindow(); final JFrameSnapper snapper = new JFrameSnapper(); snapper.addFrame(main.frameConsoleWindow); snapper.addFrame(guiFrame); // --------------------------------------------------- main.processDataFromFolder(path); // --------------------------------------------------- System.out.print("Build and show GUI..."); // show loaded and annotated data ImageJFunctions.show(main.imgRaw, "Rotated & cropped raw data"); ImageJFunctions.show(main.imgTemp, "Temporary"); ImageJFunctions.show(main.imgAnnotated, "Annotated ARGB data"); final MotherMachineGui gui = new MotherMachineGui(new MotherMachineModel(main)); gui.setVisible(true); main.ij = new ImageJ(); guiFrame.add(gui); guiFrame.setSize(GUI_WIDTH, GUI_HEIGHT); guiFrame.setLocation(GUI_POS_X, GUI_POS_Y); guiFrame.setVisible(true); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { snapper.snapFrames(main.frameConsoleWindow, guiFrame, JFrameSnapper.EAST); } }); System.out.println(" done!"); } catch (final UnsatisfiedLinkError ulr) { JOptionPane.showMessageDialog(MotherMachine.guiFrame, "Could initialize Gurobi.\n" + "You might not have installed Gurobi properly or you miss a valid license.\n" + "Please visit 'www.gurobi.com' for further information.\n\n" + ulr.getMessage(), "Gurobi Error?", JOptionPane.ERROR_MESSAGE); } }
From source file:de.atomfrede.tools.evalutation.util.DialogUtil.java
public void showStandardDialog(final JDialog dialogToShow) { SwingUtilities.invokeLater(new Runnable() { @Override/* w w w . j av a 2s . c o m*/ public void run() { dialogToShow.setVisible(true); } }); }
From source file:Main.java
private void setButtonMargin(final Insets margin) { SwingUtilities.invokeLater(new Runnable() { @Override//w w w. ja va 2 s .co m public void run() { button.setMargin(margin); } }); }
From source file:com.konifar.material_icon_generator.FilterComboBox.java
private void initListener() { final JTextField textfield = (JTextField) this.getEditor().getEditorComponent(); textfield.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent event) { switch (event.getKeyCode()) { case KeyEvent.VK_ENTER: case KeyEvent.VK_ESCAPE: requestFocus(false);/* www. j av a2 s. co m*/ break; case KeyEvent.VK_UP: case KeyEvent.VK_DOWN: break; default: SwingUtilities.invokeLater(new Runnable() { public void run() { filter(textfield.getText()); } }); } } }); getAccessibleContext().addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (AccessibleContext.ACCESSIBLE_STATE_PROPERTY.equals(event.getPropertyName()) && AccessibleState.FOCUSED.equals(event.getNewValue()) && getAccessibleContext().getAccessibleChild(0) instanceof ComboPopup) { ComboPopup popup = (ComboPopup) getAccessibleContext().getAccessibleChild(0); JList list = popup.getList(); if (list.getSelectedValue() != null) { setSelectedItem(String.valueOf(list.getSelectedValue())); } } } }); }