本文整理了Java中java.awt.Window.setIconImage()
方法的一些代码示例,展示了Window.setIconImage()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Window.setIconImage()
方法的具体详情如下:
包路径:java.awt.Window
类名称:Window
方法名:setIconImage
暂无
代码示例来源:origin: huxi/sulky
@Deprecated
public static void setIconImage(Window window, Image image)
{
window.setIconImage(image);
}
代码示例来源:origin: com.barchart.pivot/pivot-wtk
@Override
public void run() {
java.awt.Window hostWindow = getDisplay().getHostWindow();
if (DesktopDisplayHost.this.rootOwner == null) {
((TitledWindow)hostWindow).setTitle(DEFAULT_HOST_WINDOW_TITLE);
hostWindow.setIconImage(null);
} else {
((TitledWindow)hostWindow).setTitle(DesktopDisplayHost.this.rootOwner.getTitle());
java.util.ArrayList<BufferedImage> iconImages = new java.util.ArrayList<BufferedImage>();
for (Image icon : DesktopDisplayHost.this.rootOwner.getIcons()) {
if (icon instanceof Picture) {
iconImages.add(((Picture) icon).getBufferedImage());
}
}
if (iconImages.size() == 1) {
hostWindow.setIconImage(iconImages.get(0));
} else if (iconImages.size() > 1) {
hostWindow.setIconImages(iconImages);
}
}
updateHostWindowTitleBarCallback = null;
}
};
代码示例来源:origin: stackoverflow.com
public static void setIconImages(final java.awt.Window window,
final List<? extends Image> icons)
{
try
{
Method setIconImagesMethod;
setIconImagesMethod = // use reflection to get the setIconImages method.
setIconImagesMethod.invoke(window, icons);
}
catch(final NoSuchMethodException ex)
{
// fall back to the single image method
window.setIconImage(icons.get(0));
}
}
代码示例来源:origin: org.apache.pivot/pivot-wtk
@Override
public void run() {
java.awt.Window hostWindow = getDisplay().getHostWindow();
if (DesktopDisplayHost.this.rootOwner == null) {
((TitledWindow)hostWindow).setTitle(DEFAULT_HOST_WINDOW_TITLE);
hostWindow.setIconImage(null);
} else {
((TitledWindow)hostWindow).setTitle(DesktopDisplayHost.this.rootOwner.getTitle());
java.util.ArrayList<BufferedImage> iconImages = new java.util.ArrayList<BufferedImage>();
for (Image icon : DesktopDisplayHost.this.rootOwner.getIcons()) {
if (icon instanceof Picture) {
iconImages.add(((Picture) icon).getBufferedImage());
}
}
if (iconImages.size() == 1) {
hostWindow.setIconImage(iconImages.get(0));
} else if (iconImages.size() > 1) {
hostWindow.setIconImages(iconImages);
}
}
DesktopDisplayHost.this.updateHostWindowTitleBarCallback = null;
}
};
代码示例来源:origin: stackoverflow.com
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
public class IconImageUtilities
{
public static void setIconImage(Window window)
{
try
{
InputStream imageInputStream = window.getClass().getResourceAsStream("/Icon.png");
BufferedImage bufferedImage = ImageIO.read(imageInputStream);
window.setIconImage(bufferedImage);
} catch (IOException exception)
{
exception.printStackTrace();
}
}
}
代码示例来源:origin: stackoverflow.com
javax.swing.JFileChooser jfc = new javax.swing.JFileChooser(new java.io.File("C:/Users/Documents")) {
@Override
protected javax.swing.JDialog createDialog(java.awt.Component parent) throws java.awt.HeadlessException {
javax.swing.JDialog dialog = super.createDialog(parent);
dialog.setIconImage(new
javax.swing.ImageIcon("C:/Img.png").getImage());
return dialog;
}
};
代码示例来源:origin: SKCraft/Launcher
public static void setIconImage(Window frame, Class<?> clazz, String path) {
BufferedImage image = readIconImage(clazz, path);
if (image != null) {
frame.setIconImage(image);
}
}
代码示例来源:origin: net.sf.doolin/doolin-gui
/**
* @see Window#setIconImage(java.awt.Image)
* @see SwingUtils#toImage(Icon)
*/
@Override
public void setIcon(Icon icon) {
this.window.setIconImage(SwingUtils.toImage(icon));
}
代码示例来源:origin: de.alpharogroup/swing-components
/**
* Sets the icon image from the given resource name and add it to the given window object.
*
* @param resourceName
* The name from the resource. This includes the absolute path to the image icon from
* the classpath.
* @param window
* the window in which to set the icon image.
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public static void setIconImage(final String resourceName, final Window window)
throws IOException
{
final InputStream isLogo = ClassExtensions.getResourceAsStream(resourceName);
final BufferedImage biLogo = ImageIO.read(isLogo);
window.setIconImage(biLogo);
}
}
代码示例来源:origin: stackoverflow.com
import java.awt.*;
import java.io.IOException;
import java.io.InputStream;
import java.net.URISyntaxException;
import java.util.Scanner;
public class WindowUtilities
{
public static void setIconImage(Window window)
{
window.setIconImage(Toolkit.getDefaultToolkit().getImage(WindowUtilities.class.getResource("/Icon.jpg")));
}
public static String resourceToString(String filePath) throws IOException, URISyntaxException
{
InputStream inputStream = WindowUtilities.class.getClassLoader().getResourceAsStream(filePath);
return toString(inputStream);
}
// http://stackoverflow.com/a/5445161/3764804
private static String toString(InputStream inputStream)
{
try (Scanner scanner = new Scanner(inputStream, "UTF-8").useDelimiter("\\A"))
{
return scanner.hasNext() ? scanner.next() : "";
}
}
}
代码示例来源:origin: stackoverflow.com
import javax.swing.JOptionPane;
import javax.swing.JDialog;
import javax.imageio.ImageIO;
import java.awt.Image;
import java.net.URL;
class OptionPaneIcon {
public static void main(String[] args) throws Exception {
JOptionPane jop = new JOptionPane(
"Message",
JOptionPane.QUESTION_MESSAGE,
JOptionPane.DEFAULT_OPTION
);
JDialog dialog = jop.createDialog("Dialog Title");
Image image = ImageIO.read(new URL(
"http://www.gravatar.com/avatar/f1d58f7932b6ae8027c4e1d84f440ffe?s=128&d=identicon&r=PG"));
dialog.setIconImage( image );
dialog.setVisible(true);
}
}
代码示例来源:origin: org.codehaus.izpack/izpack-installer
/**
* Constructs a {@code LanguageDialog}.
*
* //@param frame the parent frame
* @param resources the resources
* @param locales the locales
* @param installData the installation data
*/
public LanguageDialog(Resources resources, Locales locales, GUIInstallData installData, IconsDatabase icons)
{
super();
ImageIcon imageIcon = icons.get("JFrameIcon");
super.getOwner().setIconImage(imageIcon.getImage());
this.resources = resources;
this.locales = locales;
this.installData = installData;
this.setName(GuiId.DIALOG_PICKER.id);
initialise();
}
代码示例来源:origin: stackoverflow.com
dialog.setIconImage(new BufferedImage(1, 1,
BufferedImage.TYPE_INT_ARGB_PRE));
} else {
dialog.setIconImage(icon.getImage());
代码示例来源:origin: stackoverflow.com
MainMenu.setIconImage(LoadIcon("/SimpleSoccer/icon1.png"));
MainMenu.setResizable(false);
JPanel MainMenuPanel = new JPanel();
TeamMenu.setIconImage(LoadIcon("/SimpleSoccer/icon1.png"));
TeamMenu.setResizable(false);
JPanel TeamMenuPanel = new JPanel();
window.setIconImage(LoadIcon("/SimpleSoccer/icon1.png"));
buffer = new BufferedImage(WindowWidth, WindowHeight, BufferedImage.TYPE_INT_RGB);
hdcBackBuffer = buffer.createGraphics();
代码示例来源:origin: cpesch/RouteConverter
public void run() throws HelpSetException, MalformedURLException {
HelpBroker broker = Application.getInstance().getContext().getHelpBroker();
CSH.DisplayHelpFromFocus helpFromFocus = new CSH.DisplayHelpFromFocus(broker);
helpFromFocus.actionPerformed(getEvent());
final Window window = ((DefaultHelpBroker) broker).getWindowPresentation().getHelpWindow();
window.setIconImage(WindowHelper.getFrame().getIconImage());
if (window instanceof JFrame) {
JRootPane rootPane = ((JFrame) window).getRootPane();
rootPane.registerKeyboardAction(new ActionListener() {
public void actionPerformed(ActionEvent e) {
window.setVisible(false);
}
}, getKeyStroke(VK_ESCAPE, 0), WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
}
}
}
代码示例来源:origin: org.xworker/xworker_core
obj.setIconImage(iconImage);
内容来源于网络,如有侵权,请联系作者删除!