List of usage examples for java.lang Runnable Runnable
Runnable
From source file:Main.java
public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { @Override/*from w w w. j a va2 s . c o m*/ public void run() { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); Panel panel = new Panel(); frame.setContentPane(panel); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); } }); }
From source file:Main.java
public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { JFrame frame = new JFrame(); frame.add(new TestImage()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack();//w w w . j a v a 2 s . c om frame.setVisible(true); } }); }
From source file:Main.java
public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { @Override/*from w w w . j a va 2s . c o m*/ public void run() { new FormattedTextFieldExample(); } }); }
From source file:Main.java
public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { @Override//from w w w . j a v a 2s. co m public void run() { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(new MyPanel()); f.pack(); f.setVisible(true); } }); }
From source file:Main.java
public static void main(String args[]) { SwingUtilities.invokeLater(new Runnable() { public void run() { try { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); BufferedImage image = ImageIO.read(new URL("http://www.java2s.com/style/download.png")); f.getContentPane().add(new JLabel(new ImageIcon(dye(image, new Color(255, 0, 0, 128))))); f.pack();/*w w w . j a va 2 s. c o m*/ f.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); }
From source file:Main.java
public static void main(String[] args) throws Exception { URL url = new URL("http://www.java2s.com/style/download.png"); final Image img = ImageIO.read(url); Runnable r = new Runnable() { @Override// w w w . j a v a2s . c o m public void run() { JOptionPane.showMessageDialog(null, new JLabel(new ImageIcon(img))); } }; SwingUtilities.invokeLater(r); }
From source file:Main.java
public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { @Override/*ww w . j a v a2s . c om*/ public void run() { try { Image img = null; img = ImageIO.read(new URL("http://www.java2s.com/style/download.png")); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new BorderLayout()); frame.add(new ImagePanel(img)); frame.pack(); frame.setVisible(true); } catch (Exception exp) { exp.printStackTrace(); } } }); }
From source file:Main.java
public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { @Override/*from w w w. j a v a2 s . co m*/ public void run() { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new TestPane()); frame.pack(); frame.setVisible(true); } }); }
From source file:Main.java
public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); BufferedImage image = new BufferedImage(400, 300, BufferedImage.TYPE_INT_RGB); Graphics2D imageGraphics = image.createGraphics(); GradientPaint gp = new GradientPaint(20f, 20f, Color.red, 380f, 280f, Color.orange); imageGraphics.setPaint(gp);//from w w w . j a v a 2 s . c om imageGraphics.fillRect(0, 0, 400, 300); JLabel textLabel = new JLabel("java2s.com"); textLabel.setSize(textLabel.getPreferredSize()); Dimension d = textLabel.getPreferredSize(); BufferedImage bi = new BufferedImage(d.width, d.height, BufferedImage.TYPE_INT_ARGB); Graphics g = bi.createGraphics(); g.setColor(new Color(255, 200, 255, 128)); g.fillRoundRect(0, 0, bi.getWidth(f), bi.getHeight(f), 15, 10); g.setColor(Color.black); textLabel.paint(g); Graphics g2 = image.getGraphics(); g2.drawImage(bi, 20, 20, f); ImageIcon ii = new ImageIcon(image); JLabel imageLabel = new JLabel(ii); f.getContentPane().add(imageLabel); f.pack(); f.setVisible(true); } }); }
From source file:Main.java
public static void main(String[] args) { List<Runnable> runnables = Arrays.asList(new Runnable[] { new Runnable() { public void run() { out.println("I'm the one"); }// w ww . ja va2 s. c om }, new Runnable() { public void run() { out.println("I'm the two"); } }, new Runnable() { public void run() { out.println("I'm the three"); } }, new Runnable() { public void run() { out.println("I'm the four"); } }, }); for (Runnable run : runnables) { new ExecuteTask(run).start(); } }