/** * Returns a {@link JLabel} containing this picture, for embedding in a {@link JPanel}, * {@link JFrame} or other GUI widget. * * @return the {@code JLabel} */ public JLabel getJLabel() { if (image == null) return null; // no image available ImageIcon icon = new ImageIcon(image); return new JLabel(icon); }
/** * show the image as JFrame on desktop */ public void show() { JLabel label = new JLabel(new ImageIcon(this.image)); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(label); f.pack(); f.setVisible(true); }
public Splash (Frame frame, String imageFile, int minMillis) { super(frame); this.minMillis = minMillis; getContentPane().add(new JLabel(new ImageIcon(Splash.class.getResource(imageFile))), BorderLayout.CENTER); pack(); setLocationRelativeTo(null); setVisible(true); startTime = System.currentTimeMillis(); }
menu.setHorizontalTextPosition(SwingConstants.CENTER); menu.setVerticalTextPosition(SwingConstants.BOTTOM); menu.setIcon(new ImageIcon(image)); menuBar.add(menu); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true);
this.setIconImages(icons); this.blueArrow = new ImageIcon( MainWindow.class.getResource("/img/blue_big.png")); this.redArrow = new ImageIcon( MainWindow.class.getResource("/img/red_big.png")); this.blueArrowSmall = new ImageIcon( MainWindow.class.getResource("/img/blue_small.png")); this.redArrowSmall = new ImageIcon( MainWindow.class.getResource("/img/red_small.png")); this.getContentPane().setLayout(new CardLayout(0, 0)); fileDialog.setTitle(Localization.get("image_types")); this.getContentPane().add(createInputPanel(), "input"); this.getContentPane().add(createOutputPanel(), "output");
public static void main(String[] args) throws Exception { JFrame frame = new JFrame("Test"); ImageIcon loading = new ImageIcon("ajax-loader.gif"); frame.add(new JLabel("loading... ", loading, JLabel.CENTER)); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(400, 300); frame.setVisible(true); }
public static final ImageIcon ICON_COMPUTER = new ImageIcon(""); public static final ImageIcon ICON_DISK = new ImageIcon("defaults1.png"); public static final ImageIcon ICON_FOLDER = new ImageIcon("fol_orig.png"); public static final ImageIcon ICON_EXPANDEDFOLDER = new ImageIcon("folder_open.png"); s.getViewport().add(m_tree); getContentPane().add(s, BorderLayout.CENTER); setVisible(true);
public Splash (Frame frame, String imageFile, int minMillis) { super(frame); this.minMillis = minMillis; getContentPane().add(new JLabel(new ImageIcon(Splash.class.getResource(imageFile))), BorderLayout.CENTER); pack(); setLocationRelativeTo(null); setVisible(true); startTime = System.currentTimeMillis(); }
/** * Returns a {@link JLabel} containing this picture, for embedding in a {@link JPanel}, * {@link JFrame} or other GUI widget. * * @return the {@code JLabel} */ public JLabel getJLabel() { if (image == null) return null; // no image available ImageIcon icon = new ImageIcon(image); return new JLabel(icon); }
import javax.swing.JFrame; import javax.swing.ImageIcon; class JFrameTest { public static void main(String _[]) { JFrame jFrame = new JFrame("Hello World!!"); jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jFrame.setIconImage(new ImageIcon("c:/home/ravi/creampink.png").getImage()); jFrame.setSize(400,400); jFrame.setVisible(true); } }
public CategoryNodeRenderer() { _panel.setBackground(UIManager.getColor("Tree.textBackground")); if (_sat == null) { // Load the satellite image. String resource = "/org/apache/log4j/lf5/viewer/images/channelexplorer_satellite.gif"; URL satURL = getClass().getResource(resource); _sat = new ImageIcon(satURL); } setOpaque(false); _checkBox.setOpaque(false); _panel.setOpaque(false); // The flowlayout set to LEFT is very important so that the editor // doesn't jump around. _panel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); _panel.add(_checkBox); _panel.add(this); setOpenIcon(_sat); setClosedIcon(_sat); setLeafIcon(_sat); }
public static void main(String[] args) throws MalformedURLException { URL url = new URL("<URL to your Animated GIF>"); Icon icon = new ImageIcon(url); JLabel label = new JLabel(icon); JFrame f = new JFrame("Animation"); f.getContentPane().add(label); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.pack(); f.setLocationRelativeTo(null); f.setVisible(true); }
package com.stackoverflow.test; import java.net.URL; import javax.swing.*; // Wild carded for brevity. // Actual code imports single classes public class Main { public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable(){ public void run() { URL url = Main.class.getResource( "/resources/stackoverflow.png"); ImageIcon icon = new ImageIcon(url); JFrame frame = new JFrame(); frame.add(new JLabel(icon)); frame.pack(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLocationRelativeTo(null); frame.setVisible(true); } }); } }
public AboutDialog(JFrame parent) { this.setResizable(false); this.setSize(new Dimension(400, 250)); this.getContentPane().setLayout(new BorderLayout(0, 0)); JLabel lblResizer = new JLabel(Localization.get("app_name") + " " + Configuration.getVersion()); lblResizer.setBorder(new EmptyBorder(10, 10, 10, 10)); lblResizer.setVerticalTextPosition(SwingConstants.BOTTOM); lblResizer.setIconTextGap(10); lblResizer.setFont(lblResizer.getFont().deriveFont( lblResizer.getFont().getStyle() | Font.BOLD, 16f)); lblResizer.setIcon(new ImageIcon(AboutDialog.class .getResource("/img/icon_64.png"))); this.getContentPane().add(lblResizer, BorderLayout.NORTH); JTextArea txtrResizerIsA = new JTextArea(); txtrResizerIsA.setEditable(false); txtrResizerIsA.setWrapStyleWord(true); txtrResizerIsA.setBorder(new EmptyBorder(0, 10, 10, 10)); txtrResizerIsA.setFont(UIManager.getFont("Label.font")); txtrResizerIsA.setLineWrap(true); txtrResizerIsA.setText(Localization.get("about_text")); txtrResizerIsA.setBackground(new Color(0, 0, 0, 0)); this.getContentPane().add(txtrResizerIsA, BorderLayout.CENTER); this.setLocationRelativeTo(parent); }
private JComponent getBanner() { try { BufferedImage img = ImageIO.read(getClass().getResource("splash.png")); JLabel title = new JLabel(new ImageIcon(img)); title.setPreferredSize(new Dimension(img.getWidth() + 10, img.getHeight())); title.setOpaque(true); title.setBackground(new Color(238, 238, 255)); return title; } catch (Exception ignore) { } return new JLabel(); }
DemoRootPane() { textArea = createTextArea(); setText("JavaExample.txt"); textArea.setSyntaxEditingStyle(SYNTAX_STYLE_JAVA); scrollPane = new RTextScrollPane(textArea, true); Gutter gutter = scrollPane.getGutter(); gutter.setBookmarkingEnabled(true); URL url = getClass().getResource("bookmark.png"); gutter.setBookmarkIcon(new ImageIcon(url)); getContentPane().add(scrollPane); ErrorStrip errorStrip = new ErrorStrip(textArea); //errorStrip.setBackground(java.awt.Color.blue); getContentPane().add(errorStrip, BorderLayout.LINE_END); setJMenuBar(createMenuBar()); }
/** * show the images as stream of JFrame on desktop */ public void show() { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setVisible(true); JLabel label = null; while (true) { for (int i = 0; i < this.frames.size(); i++) { Frame frame = this.frames.get(i); if (label == null) { label = new JLabel(new ImageIcon(frame.image)); f.getContentPane().add(label); f.pack(); } else { label.getGraphics().drawImage(frame.image,0,0, label); } try {Thread.sleep(frame.delayMillis);} catch (InterruptedException e) {} } } } }
private JComponent getNorthLabel() { final JLabel text = new JLabel("PlantUML (" + Version.versionString() + ")"); final Font font = text.getFont().deriveFont(Font.BOLD, (float) 20.0); text.setFont(font); final JPanel ptext = new JPanel(); ptext.add(text); final JLabel icon = new JLabel(new ImageIcon(PSystemVersion.getPlantumlImage())); final JPanel result = new JPanel(new BorderLayout()); result.add(ptext, BorderLayout.CENTER); result.add(icon, BorderLayout.EAST); return result; }