synchronized void append(String val) { values.add(val); if (queue) { queue = false; EventQueue.invokeLater(this); } }
public static void main(String[] args) { StringBuffer result = new StringBuffer("<html><body><h1>Fibonacci Sequence</h1><ol>"); long f1 = 0; long f2 = 1; for (int i = 0; i < 50; i++) { result.append("<li>"); result.append(f1); long temp = f2; f2 = f1 + f2; f1 = temp; } result.append("</ol></body></html>"); JEditorPane jep = new JEditorPane("text/html", result.toString()); jep.setEditable(false); // new FibonocciRectangles().execute(); JScrollPane scrollPane = new JScrollPane(jep); JFrame f = new JFrame("Fibonacci Sequence"); f.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); f.setContentPane(scrollPane); f.setSize(512, 342); EventQueue.invokeLater(new FrameShower(f)); }
public static void main(String[] args) { EventQueue.invokeLater( new Runnable() { public void run() { new Server(); } }); }
public static void main(String... args) { EventQueue.invokeLater( new Runnable() { @Override public void run() { createAndShowGUI(); } }); }
public static void main(String[] args) { EventQueue.invokeLater( new Runnable() { public void run() { JFrame frame = new PostTestFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } }); }
synchronized void clear() { clear = true; curLength = 0; lengths.clear(); values.clear(); if (queue) { queue = false; EventQueue.invokeLater(this); } }
public static void main(String[] args) throws Exception { EventQueue.invokeLater( new Runnable() { public void run() { JFrame frame = new SwingWorkerFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } }); }
public void fireShowJoystickError(final String msg) { final Component owner = this.joyFrm; if ((owner != null) && (msg != null)) { EventQueue.invokeLater( new Runnable() { @Override public void run() { BasicDlg.showErrorDlg(owner, msg); } }); } }
// used to actually bring up the window public void run() { // this creates the window Runnable runner = new Runnable() { public void run() { // create the main frame frame = new JFrame("Search result: " + myFName); frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); // create the area to display the text JTextArea textArea = new JTextArea(); textArea.setLineWrap(true); textArea.insert(stringToCheck, 0); JScrollPane scrollPane = new JScrollPane(textArea); frame.add(scrollPane, BorderLayout.CENTER); // create the button and the area where it is displated JPanel dotPanel = new JPanel(new BorderLayout()); JButton myButton; if (myFileList.size() != 0) myButton = new JButton("Onto next file"); else myButton = new JButton("Done"); dotPanel.add(myButton, BorderLayout.CENTER); frame.add(dotPanel, BorderLayout.SOUTH); // this listens for a user to click the "done" button ActionListener buttonListener = new ActionListener() { public void actionPerformed(ActionEvent e) { iAmDone.release(1); frame.dispose(); } }; // add the button and make the frame visible myButton.addActionListener(buttonListener); frame.setSize(500, 500); frame.setVisible(true); } }; // run the window EventQueue.invokeLater(runner); }
private void updJoystickFrm(final int joyNum) { final JoystickFrm joyFrm = this.joyFrm; if ((joyFrm != null) && (joyNum >= 0) && (joyNum < this.joyThreads.length)) { int nJoys = 0; EmuSys emuSys = this.emuSys; if (emuSys != null) { nJoys = emuSys.getSupportedJoystickCount(); } final boolean emulated = (joyNum < nJoys); final boolean connected = (this.joyThreads[joyNum] != null); EventQueue.invokeLater( new Runnable() { @Override public void run() { joyFrm.setJoystickState(joyNum, emulated, connected); } }); } }
@Override public void run() { this.emuRunning = true; while (this.emuRunning) { try { /* * Pruefen, ob ein Programm geladen oder der Emulator * tatsaechlich zurueckgesetzt werden soll */ LoadData loadData = null; synchronized (this.monitor) { loadData = this.loadData; if (loadData != null) { this.loadData = null; } else { if (this.resetLevel == ResetLevel.POWER_ON) { Arrays.fill(this.ram, (byte) 0); } } } if (loadData != null) { loadData.loadIntoMemory(this); this.z80cpu.setRegPC(loadData.getStartAddr()); if (this.emuSys != null) { int spInitValue = this.emuSys.getAppStartStackInitValue(); if (spInitValue > 0) { this.z80cpu.setRegSP(spInitValue); } } } else { if ((this.resetLevel == ResetLevel.COLD_RESET) || (this.resetLevel == ResetLevel.POWER_ON)) { this.z80cpu.resetCPU(true); } else { this.z80cpu.resetCPU(false); } if (this.emuSys != null) { this.emuSys.reset(this.resetLevel, Main.getProperties()); this.z80cpu.setRegPC(this.emuSys.getResetStartAddress(this.resetLevel)); } } // RAM-Floppies und Druckmanager zuruecksetzen this.printMngr.reset(); this.ramFloppy1.reset(); this.ramFloppy2.reset(); if ((this.emuSys != null) && (this.resetLevel == ResetLevel.POWER_ON) && Main.getBooleanProperty("jkcemu.ramfloppy.clear_on_power_on", false)) { if (this.emuSys.supportsRAMFloppy1() && (this.ramFloppy1.getUsedSize() > 0)) { this.ramFloppy1.clear(); } if (this.emuSys.supportsRAMFloppy2() && (this.ramFloppy2.getUsedSize() > 0)) { this.ramFloppy2.clear(); } } // Fenster informieren final Frame[] frms = Frame.getFrames(); if (frms != null) { EventQueue.invokeLater( new Runnable() { @Override public void run() { for (Frame f : frms) { if (f instanceof BasicFrm) { ((BasicFrm) f).resetFired(); } } } }); } // in die Z80-Emulation verzweigen this.resetLevel = ResetLevel.NO_RESET; this.z80cpu.run(); } catch (Z80ExternalException ex) { } catch (Exception ex) { this.emuRunning = false; EventQueue.invokeLater(new ErrorMsg(this.screenFrm, ex)); } } }