List of usage examples for javax.swing JFrame setIconImage
public void setIconImage(Image image)
From source file:Main.java
public static void main(String[] args) { Image image = new BufferedImage(32, 32, BufferedImage.TYPE_INT_RGB); JFrame f = new JFrame(); f.setIconImage(image); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.pack();/*from ww w. ja v a2 s . c o m*/ f.setSize(600, 400); f.setVisible(true); JFileChooser chooser = new JFileChooser(); chooser.showOpenDialog(f); }
From source file:MainClass.java
public static void main(String[] unused) { JFrame f = new JFrame("FrameIcon"); Image im = Toolkit.getDefaultToolkit().getImage("FrameIcon.gif"); f.setIconImage(im); f.setSize(100, 100);/*from w w w. j a va 2 s. co m*/ f.setLocation(200, 200); f.setVisible(true); }
From source file:com.lcdfx.pipoint.PiPoint.java
public static void main(final String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException { SwingUtilities.invokeLater(new Runnable() { public void run() { JFrame frame = new PiPoint(args); frame.setTitle(APPLICATION_NAME); frame.setIconImage( new ImageIcon(PiPoint.class.getResource("/resources/pipoint_icon.png")).getImage()); frame.pack();//from ww w. j av a 2s .com frame.setVisible(true); } }); }
From source file:com.adito.upgrade.Upgrade.java
/** * @param args//from w w w . j a v a 2 s .com * @throws Exception on any error */ public static void main(String[] args) throws Exception { boolean gui = System.getProperty("os.name").toLowerCase().startsWith("windows") || System.getenv("DISPLAY") != null; if (args.length == 2 || !gui) { Upgrader upgrader = new CommandLineUpgrader(args); upgrader.upgrade(); } else { JFrame f = new JFrame("0.1.16 to 0.2.5+ Upgrader"); final Upgrader upgrader = new GUIUpgrader(); f.setIconImage(new ImageIcon(Upgrade.class.getResource("upgrader-32x32.png")).getImage()); f.getContentPane().setLayout(new BorderLayout()); f.getContentPane().add((JPanel) upgrader, BorderLayout.CENTER); f.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); JPanel bp = new JPanel(new FlowLayout(FlowLayout.RIGHT)); final JButton start = new JButton("Start"); ; final JButton close = new JButton("Close"); start.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { start.setEnabled(false); close.setEnabled(false); upgrader.upgrade(); } catch (Exception ex) { upgrader.error("Failed to upgrade.", ex); } finally { close.setEnabled(true); } } }); close.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (close.isEnabled()) System.exit(0); } }); bp.add(start); bp.add(close); f.getContentPane().add(bp, BorderLayout.SOUTH); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent evt) { if (close.isEnabled()) System.exit(0); } }); f.setSize(new Dimension(480, 460)); UIUtil.positionComponent(SwingConstants.CENTER, f); f.setVisible(true); } }
From source file:edu.ku.brc.specify.tools.StrLocalizerApp.java
/** * @param args// www .j ava2 s . co m */ public static void main(String[] args) { setAppName("Specify"); //$NON-NLS-1$ System.setProperty(AppPreferences.factoryName, "edu.ku.brc.specify.config.AppPrefsDBIOIImpl"); // Needed by AppReferences //$NON-NLS-1$ for (String s : args) { String[] pairs = s.split("="); //$NON-NLS-1$ if (pairs.length == 2) { if (pairs[0].startsWith("-D")) //$NON-NLS-1$ { //System.err.println("["+pairs[0].substring(2, pairs[0].length())+"]["+pairs[1]+"]"); System.setProperty(pairs[0].substring(2, pairs[0].length()), pairs[1]); } } else { String symbol = pairs[0].substring(2, pairs[0].length()); //System.err.println("["+symbol+"]"); System.setProperty(symbol, symbol); } } // Now check the System Properties String appDir = System.getProperty("appdir"); if (StringUtils.isNotEmpty(appDir)) { UIRegistry.setDefaultWorkingPath(appDir); } String appdatadir = System.getProperty("appdatadir"); if (StringUtils.isNotEmpty(appdatadir)) { UIRegistry.setBaseAppDataDir(appdatadir); } // Then set this IconManager.setApplicationClass(Specify.class); IconManager.loadIcons(XMLHelper.getConfigDir("icons.xml")); //$NON-NLS-1$ //ImageIcon icon = IconManager.getIcon("AppIcon", IconManager.IconSize.Std16); try { ResourceBundle.getBundle("resources", Locale.getDefault()); //$NON-NLS-1$ } catch (MissingResourceException ex) { Locale.setDefault(Locale.ENGLISH); UIRegistry.setResourceLocale(Locale.ENGLISH); } try { if (!System.getProperty("os.name").equals("Mac OS X")) { UIManager.setLookAndFeel(new Plastic3DLookAndFeel()); PlasticLookAndFeel.setPlasticTheme(new DesertBlue()); } } catch (Exception e) { //whatever } AppPreferences localPrefs = AppPreferences.getLocalPrefs(); localPrefs.setDirPath(UIRegistry.getAppDataDir()); boolean doIt = false; if (doIt) { Charset utf8charset = Charset.forName("UTF-8"); Charset iso88591charset = Charset.forName("ISO-8859-1"); ByteBuffer inputBuffer = ByteBuffer.wrap(new byte[] { (byte) 0xC3, (byte) 0xA2 }); // decode UTF-8 CharBuffer data = utf8charset.decode(inputBuffer); // encode ISO-8559-1 ByteBuffer outputBuffer = iso88591charset.encode(data); byte[] outputData = outputBuffer.array(); System.out.println(new String(outputData)); return; } SwingUtilities.invokeLater(new Runnable() { @Override public void run() { try { UIHelper.OSTYPE osType = UIHelper.getOSType(); if (osType == UIHelper.OSTYPE.Windows) { UIManager.setLookAndFeel(new PlasticLookAndFeel()); PlasticLookAndFeel.setPlasticTheme(new ExperienceBlue()); } else if (osType == UIHelper.OSTYPE.Linux) { UIManager.setLookAndFeel(new PlasticLookAndFeel()); } } catch (Exception e) { log.error("Can't change L&F: ", e); //$NON-NLS-1$ } JFrame frame = new JFrame(getResourceString("StrLocalizerApp.AppTitle")); frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); final StrLocalizerApp sl = new StrLocalizerApp(); sl.addMenuBar(frame); frame.setContentPane(sl); frame.setSize(768, 1024); //Dimension size = frame.getPreferredSize(); //size.height = 500; //frame.setSize(size); frame.addWindowListener(sl); IconManager.setApplicationClass(Specify.class); frame.setIconImage(IconManager.getImage(IconManager.makeIconName("SpecifyWhite32")).getImage()); UIHelper.centerAndShow(frame); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { sl.startUp(); } }); } }); }
From source file:edu.ku.brc.specify.tools.l10nios.StrLocalizerAppForiOS.java
/** * @param args/*from w ww . ja va2 s . c o m*/ */ public static void main(String[] args) { setAppName("Specify"); //$NON-NLS-1$ System.setProperty(AppPreferences.factoryName, "edu.ku.brc.specify.config.AppPrefsDBIOIImpl"); // Needed by AppReferences //$NON-NLS-1$ for (String s : args) { String[] pairs = s.split("="); //$NON-NLS-1$ if (pairs.length == 2) { if (pairs[0].startsWith("-D")) //$NON-NLS-1$ { //System.err.println("["+pairs[0].substring(2, pairs[0].length())+"]["+pairs[1]+"]"); System.setProperty(pairs[0].substring(2, pairs[0].length()), pairs[1]); } } else { String symbol = pairs[0].substring(2, pairs[0].length()); //System.err.println("["+symbol+"]"); System.setProperty(symbol, symbol); } } // Now check the System Properties String appDir = System.getProperty("appdir"); if (StringUtils.isNotEmpty(appDir)) { UIRegistry.setDefaultWorkingPath(appDir); } String appdatadir = System.getProperty("appdatadir"); if (StringUtils.isNotEmpty(appdatadir)) { UIRegistry.setBaseAppDataDir(appdatadir); } // Then set this IconManager.setApplicationClass(Specify.class); IconManager.loadIcons(XMLHelper.getConfigDir("icons.xml")); //$NON-NLS-1$ //ImageIcon icon = IconManager.getIcon("AppIcon", IconManager.IconSize.Std16); try { ResourceBundle.getBundle("resources", Locale.getDefault()); //$NON-NLS-1$ } catch (MissingResourceException ex) { Locale.setDefault(Locale.ENGLISH); UIRegistry.setResourceLocale(Locale.ENGLISH); } try { if (!System.getProperty("os.name").equals("Mac OS X")) { UIManager.setLookAndFeel(new Plastic3DLookAndFeel()); PlasticLookAndFeel.setPlasticTheme(new DesertBlue()); } } catch (Exception e) { //whatever } AppPreferences localPrefs = AppPreferences.getLocalPrefs(); localPrefs.setDirPath(UIRegistry.getAppDataDir()); boolean doIt = false; if (doIt) { Charset utf8charset = Charset.forName("UTF-8"); Charset iso88591charset = Charset.forName("ISO-8859-1"); ByteBuffer inputBuffer = ByteBuffer.wrap(new byte[] { (byte) 0xC3, (byte) 0xA2 }); // decode UTF-8 CharBuffer data = utf8charset.decode(inputBuffer); // encode ISO-8559-1 ByteBuffer outputBuffer = iso88591charset.encode(data); byte[] outputData = outputBuffer.array(); System.out.println(new String(outputData)); return; } SwingUtilities.invokeLater(new Runnable() { @Override public void run() { try { UIHelper.OSTYPE osType = UIHelper.getOSType(); if (osType == UIHelper.OSTYPE.Windows) { UIManager.setLookAndFeel(new PlasticLookAndFeel()); PlasticLookAndFeel.setPlasticTheme(new ExperienceBlue()); } else if (osType == UIHelper.OSTYPE.Linux) { UIManager.setLookAndFeel(new PlasticLookAndFeel()); } } catch (Exception e) { log.error("Can't change L&F: ", e); //$NON-NLS-1$ } JFrame frame = new JFrame(getResourceString("StrLocalizerApp.AppTitle")); frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); final StrLocalizerAppForiOS sl = new StrLocalizerAppForiOS(); sl.addMenuBar(frame); frame.setContentPane(sl); frame.setSize(768, 1024); //Dimension size = frame.getPreferredSize(); //size.height = 500; //frame.setSize(size); frame.addWindowListener(sl); IconManager.setApplicationClass(Specify.class); frame.setIconImage(IconManager.getImage(IconManager.makeIconName("SpecifyWhite32")).getImage()); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { sl.startUp(); } }); } }); }
From source file:Main.java
public static void main() { JFrame frame = new JFrame(); Image icon = Toolkit.getDefaultToolkit().getImage("icon.gif"); frame.setIconImage(icon); }
From source file:Main.java
public static JFrame createFrame(Container content) { JFrame jf = new JFrame(); jf.setContentPane(content);//ww w .ja v a 2 s . com jf.pack(); if (DEFAULT_FRAME_ICON != null) { jf.setIconImage(DEFAULT_FRAME_ICON.getImage()); } return jf; }
From source file:com.clank.launcher.swing.SwingHelper.java
public static void setIconImage(JFrame frame, Class<?> clazz, String path) { BufferedImage image = readIconImage(clazz, path); if (image != null) { frame.setIconImage(image); }//from w ww . j a v a 2 s. co m }
From source file:GUI.Main.java
static private WebPanel createAdminPanel(String url, String firstName, String lastName, final int myId) throws IOException { mainPanel.setPaintFocus(true);// w w w . j a v a2 s .co m // Text field input Search textSearchField = new WebTextField(15); textSearchField.setInputPrompt("Search"); textSearchField.setInputPromptFont(textSearchField.getFont().deriveFont(Font.ROMAN_BASELINE)); textSearchField.setTrailingComponent(new WebImage("resources/search.png")); System.out.println("My id" + myId); // Boite Message WebButton boiteMessageButton = new WebButton("Ouvrir ma Boite Message"); boiteMessageButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JFrame boiteFrame = new JFrame("Boite de messages"); boiteFrame.setLocationRelativeTo(null); JPanel boite = new JPanel(new BorderLayout()); boite.add(new BoiteReception(myId), BorderLayout.CENTER); boiteFrame.add(boite); boiteFrame.setIconImage(new ImageIcon(getClass().getResource("/images/message.png")).getImage()); boiteFrame.pack(); boiteFrame.setLocationRelativeTo(boite); boiteFrame.setVisible(true); } }); // Text Button Search WebButton SearchButton = new WebButton("Search"); SearchButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { new ListOfOffres1().openListOfOffresFrameagn(1, textSearchField.getText(), myId); } catch (IOException ex) { Logger.getLogger(ListOfOffres1.class.getName()).log(Level.SEVERE, null, ex); } } }); // Exit Button WebButton logOutButton = new WebButton("Exit"); logOutButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ListOfOffresFrame.setVisible(false); //you can't see me! ListOfOffresFrame.dispose(); //Destroy the JFrame object ListOfOffresFrame = null; System.exit(0); } }); // Text Button Retour exitButton = new WebButton("Retour"); exitButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.out.println("Retour clicked"); ListOfOffres1.openPleaseWait(); try { System.out.println("aaaaaaaaaaaaaaaaaaaaaaaa" + myId); new ListOfOffres1().openListOfOffresFrameagn(0, "", myId); } catch (IOException ex) { Logger.getLogger(ListOfOffres1.class.getName()).log(Level.SEVERE, null, ex); } } }); final WebPanel descPanel = new WebPanel(false); GroupPanel OffrePanel = new GroupPanel(GroupingType.fillFirst, 5, false); descPanel.setOpaque(false); descPanel.setMargin(50, 50, 50, 50); mainPanel.setPaintFocus(true); mainPanel.setMargin(10); System.out.print(url); // load the image once mainPanel.setPreferredSize(new Dimension(300, 100)); OffrePanel.add(new GroupPanel(GroupingType.fillFirst, 5, false, loadImageX(url), new WebLabel("<html><body><h1><font color=#555555>" + firstName + " " + lastName + "</font></h1></body></html>", WebLabel.CENTER), textSearchField, SearchButton, new WhiteSpace(), new GroupPanel(GroupingType.fillFirst, false, new WhiteSpace(), boiteMessageButton, new GroupPanel(GroupingType.fillFirstAndLast, 5, true, exitButton, logOutButton)))); mainPanel.add(OffrePanel); return mainPanel; }