List of usage examples for java.lang Runnable Runnable
Runnable
From source file:PrintTest.java
public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { JFrame frame = new PrintTestFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true);/*from w ww .j a va2s . c o m*/ } }); }
From source file:dpcs.AppPackagesList.java
public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { AppPackagesList frame = new AppPackagesList(); frame.setVisible(true);// w w w . j a v a 2s.c o m } catch (Exception e) { e.printStackTrace(); } } }); }
From source file:RenderQualityTest.java
public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { JFrame frame = new RenderQualityTestFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true);// ww w .j a va 2 s . c o m } }); }
From source file:org.eclipse.swt.snippets.Snippet174.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("OpenGL in SWT"); shell.setLayout(new FillLayout()); final Canvas canvas = new Canvas(shell, SWT.NO_BACKGROUND); canvas.addControlListener(new ControlAdapter() { public void controlResized(ControlEvent e) { resize(canvas);//from w w w. ja v a 2 s . c om } }); final GLContext context = init(canvas); shell.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { context.dispose(); } }); new Runnable() { public void run() { if (canvas.isDisposed()) return; render(); context.swapBuffers(); canvas.getDisplay().timerExec(50, this); } }.run(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet174.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("OpenGL in SWT"); shell.setLayout(new FillLayout()); GLData data = new GLData(); data.doubleBuffer = true;/*from ww w . j a v a2 s . co m*/ final GLCanvas canvas = new GLCanvas(shell, SWT.NO_BACKGROUND, data); canvas.addControlListener(ControlListener.controlResizedAdapter(e -> { resize(canvas); })); init(canvas); new Runnable() { @Override public void run() { if (canvas.isDisposed()) return; render(); canvas.swapBuffers(); canvas.getDisplay().timerExec(50, this); } }.run(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:gtu._work.ui.JSFMakerUI_attrDialog.java
/** * Auto-generated main method to display this JDialog *//* ww w . j a v a 2 s .com*/ public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { JFrame frame = new JFrame(); JSFMakerUI_attrDialog inst = new JSFMakerUI_attrDialog(frame); gtu.swing.util.JFrameUtil.setVisible(true, inst); } }); }
From source file:StylesExample2.java
public static void main(String[] args) { try {/* w ww .j a va 2 s . c o m*/ UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); } catch (Exception evt) { } JFrame f = new JFrame("Styles Example 2"); // Create the StyleContext, the document and the pane StyleContext sc = new StyleContext(); final DefaultStyledDocument doc = new DefaultStyledDocument(sc); JTextPane pane = new JTextPane(doc); // Create and add the main document style Style defaultStyle = sc.getStyle(StyleContext.DEFAULT_STYLE); final Style mainStyle = sc.addStyle("MainStyle", defaultStyle); StyleConstants.setLeftIndent(mainStyle, 16); StyleConstants.setRightIndent(mainStyle, 16); StyleConstants.setFirstLineIndent(mainStyle, 16); StyleConstants.setFontFamily(mainStyle, "serif"); StyleConstants.setFontSize(mainStyle, 12); // Create and add the constant width style final Style cwStyle = sc.addStyle("ConstantWidth", null); StyleConstants.setFontFamily(cwStyle, "monospaced"); StyleConstants.setForeground(cwStyle, Color.green); // Create and add the heading style final Style heading2Style = sc.addStyle("Heading2", null); StyleConstants.setForeground(heading2Style, Color.red); StyleConstants.setFontSize(heading2Style, 16); StyleConstants.setFontFamily(heading2Style, "serif"); StyleConstants.setBold(heading2Style, true); StyleConstants.setLeftIndent(heading2Style, 8); StyleConstants.setFirstLineIndent(heading2Style, 0); try { SwingUtilities.invokeAndWait(new Runnable() { public void run() { try { // Set the logical style doc.setLogicalStyle(0, mainStyle); // Add the text to the document doc.insertString(0, text, null); // Apply the character attributes doc.setCharacterAttributes(49, 13, cwStyle, false); doc.setCharacterAttributes(223, 14, cwStyle, false); doc.setCharacterAttributes(249, 14, cwStyle, false); doc.setCharacterAttributes(286, 8, cwStyle, false); doc.setCharacterAttributes(475, 14, cwStyle, false); doc.setCharacterAttributes(497, 21, cwStyle, false); doc.setCharacterAttributes(557, 9, cwStyle, false); doc.setCharacterAttributes(639, 12, cwStyle, false); doc.setCharacterAttributes(733, 21, cwStyle, false); doc.setCharacterAttributes(759, 9, cwStyle, false); // Finally, apply the style to the heading doc.setParagraphAttributes(0, 1, heading2Style, false); } catch (BadLocationException e) { } } }); } catch (Exception e) { System.out.println("Exception when constructing document: " + e); System.exit(1); } f.getContentPane().add(new JScrollPane(pane)); f.setSize(400, 300); f.setVisible(true); }
From source file:ShapeTest.java
public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { JFrame frame = new ShapeTestFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true);/*from w w w . j av a 2 s. co m*/ } }); }
From source file:Snippet151.java
public static void main(String[] args) { final Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); final Table table = new Table(shell, SWT.BORDER | SWT.VIRTUAL); table.addListener(SWT.SetData, new Listener() { public void handleEvent(Event e) { TableItem item = (TableItem) e.item; int index = table.indexOf(item); item.setText("Item " + data[index]); }/*www .ja va 2 s .com*/ }); Thread thread = new Thread() { public void run() { int count = 0; Random random = new Random(); while (count++ < 500) { if (table.isDisposed()) return; // add 10 random numbers to array and sort int grow = 10; int[] newData = new int[data.length + grow]; System.arraycopy(data, 0, newData, 0, data.length); int index = data.length; data = newData; for (int j = 0; j < grow; j++) { data[index++] = random.nextInt(); } Arrays.sort(data); display.syncExec(new Runnable() { public void run() { if (table.isDisposed()) return; table.setItemCount(data.length); table.clearAll(); } }); try { Thread.sleep(500); } catch (Throwable t) { } } } }; thread.start(); shell.open(); while (!shell.isDisposed() || thread.isAlive()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:FormatTest.java
public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { FormatTestFrame frame = new FormatTestFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true);//from ww w . j a va2s.co m } }); }