List of usage examples for javax.swing JOptionPane showMessageDialog
public static void showMessageDialog(Component parentComponent, Object message) throws HeadlessException
From source file:Main.java
public static void main(String[] args) { TimePanel label = new TimePanel(); JOptionPane.showMessageDialog(null, label); }
From source file:Main.java
public static void main(String[] args) throws Exception { URL urlImage1 = new URL("http://www.java2s.com/style/download.png"); final Image fgImage = ImageIO.read(urlImage1); int w = fgImage.getWidth(null); int h = fgImage.getHeight(null); final BufferedImage bgImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); final BufferedImage finalImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); Graphics2D g = finalImage.createGraphics(); g.drawImage(bgImage, 0, 0, null);//from www . j av a 2 s. c o m g.drawImage(fgImage, 0, 0, null); g.dispose(); Runnable r = new Runnable() { @Override public void run() { JPanel gui = new JPanel(new GridLayout(1, 0, 5, 5)); gui.add(new JLabel(new ImageIcon(bgImage))); gui.add(new JLabel(new ImageIcon(fgImage))); gui.add(new JLabel(new ImageIcon(finalImage))); JOptionPane.showMessageDialog(null, gui); } }; SwingUtilities.invokeLater(r); }
From source file:TimerTest.java
public static void main(String[] args) { ActionListener listener = new TimePrinter(); // construct a timer that calls the listener // once every 10 seconds Timer t = new Timer(10000, listener); t.start();/*from w ww. java 2 s. co m*/ JOptionPane.showMessageDialog(null, "Quit program?"); System.exit(0); }
From source file:Main.java
public static void main(String[] args) { final JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JButton loadButton = new JButton("Display Image"); loadButton.addActionListener(ev -> { JFileChooser fc = new JFileChooser(System.getProperty("user.home")); fc.addChoosableFileFilter(/*w w w .j av a2 s. c om*/ new FileNameExtensionFilter("Image files", new String[] { "png", "jpg", "jpeg", "gif" })); if (fc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { try { Image image = ImageIO.read(fc.getSelectedFile()); if (image != null) { JPanel panel = new JPanel(new BorderLayout(10, 10)); panel.add(new JLabel(fc.getSelectedFile().toString()), BorderLayout.NORTH); panel.add(new JLabel(new ImageIcon(image))); JOptionPane.showMessageDialog(frame, panel); } } catch (Exception ex) { ex.printStackTrace(); } } }); frame.add(loadButton); frame.pack(); frame.setLocationByPlatform(true); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) throws Exception { Object[][] data = { { "A", new Integer(3), new Double(7.23), new Boolean(true) }, { "J", new Integer(2), new Double(4.64), new Boolean(false) }, { "S", new Integer(1), new Double(8.81), new Boolean(true) } }; String[] columns = { "Col", "Col", "Col", "Col" }; JTable table = new JTable(data, columns); JScrollPane scroll = new JScrollPane(table); JFrame f = new JFrame(); f.setContentPane(scroll);/*from w w w .j a v a 2 s .c om*/ f.pack(); int x = (int) table.getTableHeader().getSize().getWidth(); int y = (int) table.getTableHeader().getSize().getHeight() + (int) table.getSize().getHeight(); BufferedImage bi = new BufferedImage((int) x, (int) y, BufferedImage.TYPE_INT_RGB); Graphics g = bi.createGraphics(); table.getTableHeader().paint(g); g.translate(0, table.getTableHeader().getHeight()); table.paint(g); g.dispose(); JOptionPane.showMessageDialog(null, new JLabel(new ImageIcon(bi))); ImageIO.write(bi, "png", new File("c:/Java_Dev/table.png")); System.exit(0); }
From source file:Main.java
public static void main(String[] args) { Runnable r = new Runnable() { @Override/*from ww w. j a v a 2 s . c o m*/ public void run() { JPanel gui = new JPanel(); final AnimatedImage[] tiles = new AnimatedImage[2]; for (int ii = 0; ii < tiles.length; ii++) { tiles[ii] = new AnimatedImage(); gui.add(new JLabel(new ImageIcon(tiles[ii]))); } ActionListener listener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { for (int i = 0; i < tiles.length; i++) { tiles[i].paintImage(); gui.repaint(); } } }; Timer timer = new Timer(50, listener); timer.start(); JOptionPane.showMessageDialog(null, gui); timer.stop(); } }; SwingUtilities.invokeLater(r); }
From source file:Main.java
public static void main(String[] argv) { JOptionPane.showMessageDialog(null, new IntegerField()); }
From source file:Main.java
public static void main(String[] args) throws AWTException { Runnable r = new Runnable() { @Override//from w ww .ja va 2 s . com public void run() { try { URL url = new URL("http://www.java2s.com/style/download.png"); BufferedImage bi = ImageIO.read(url); JPanel gui = new JPanel(new GridLayout(1, 2, 2, 2)); gui.add(new JLabel(new ImageIcon(bi))); gui.add(new JLabel(new ImageIcon(getFlippedImage(bi)))); JOptionPane.showMessageDialog(null, gui); } catch (Exception e) { e.printStackTrace(); } } }; SwingUtilities.invokeLater(r); }
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 BufferedImage bi = ImageIO.read(url); SwingUtilities.invokeLater(new Runnable() { @Override// w w w. j a v a 2s . co m public void run() { int strokeWidth = 12; int pad = 50; Shape shape = new Rectangle(pad, pad, bi.getWidth() - (2 * pad), bi.getHeight() - (2 * pad)); Image i = getStrokedImage(bi, shape, strokeWidth); JOptionPane.showMessageDialog(null, new JLabel(new ImageIcon(i))); } }); }
From source file:pwr.lab5.Window.java
public static void main(String[] args) { try {//from ww w. j a v a 2s . c o m JFrame frame = new JFrame(); Window win = new Window(); // frame.add(pane); frame.add(win); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); frame.pack(); JButton tab[] = new JButton[] { win.jButton1, win.jButton2, win.jButton3, win.jButton4, win.jButton5 }; for (JButton jb : tab) { jb.addActionListener(win); } } catch (Exception e) { JOptionPane.showMessageDialog(null, e.getMessage()); } }