imageicon

Cant choose a default path in java when using ImageIcon in Java

南笙酒味 提交于 2019-12-25 18:18:08
问题 Whenever i need to load some image i have difficulties with its path Like i use eclipse and by putting it in src folder and then using this path ImageIcon = new ImageIcon ("/image.png"); It does not load image i need to put it somewhere in my computer and then copy paste its path ....Its not Actually better option as when i tend to run my code in some other computer i need to change the paths of all images in my code back again please help Thanks 回答1: Create "resource" folder into your

I want to use animated GIF images the application using JFC/Swing tookkit. I am confused about this toolkit

痴心易碎 提交于 2019-12-25 18:12:27
问题 I just load an animated GIF images as an ImageIcon . The image of my Swing program running on Window 2000 PC Note that I am using Java/JDK 1.4.x release. Here is code, but it is not working: /** * DevDaily.com * A sample program showing how to use an animated gif image * in a Java Swing application. */ package giftest; import java.awt.*; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JLabel; import javax.swing.ImageIcon; public class MainFrame extends JFrame { JPanel

I want to use animated GIF images the application using JFC/Swing tookkit. I am confused about this toolkit

时光怂恿深爱的人放手 提交于 2019-12-25 18:12:16
问题 I just load an animated GIF images as an ImageIcon . The image of my Swing program running on Window 2000 PC Note that I am using Java/JDK 1.4.x release. Here is code, but it is not working: /** * DevDaily.com * A sample program showing how to use an animated gif image * in a Java Swing application. */ package giftest; import java.awt.*; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JLabel; import javax.swing.ImageIcon; public class MainFrame extends JFrame { JPanel

Set icon in JFrame

社会主义新天地 提交于 2019-12-25 13:43:07
问题 I want to change the icon of the project instead of java icon. When the program icon is being displayed in status bar, it should be displaying the customized icon instead of default java icon. I am using the following code. Please suggest me what's wrong in this code. class newframe extends JFrame { Container cp; newframe() { cp=this.getContentPane(); cp.setLayout(null); } public static void main(String args[]) { newframe frm= new newframe(); frm.setbounds(0,0,1000,800); frm.setVisible(true);

Adding icons to jTable in different rows

梦想的初衷 提交于 2019-12-24 12:47:24
问题 I have a jTable that I have created to display the names of countries and the flag icons in the cells next to the names. How can I display each icon in the same column but different rows using the ImageIcon class, without displaying just a string? The following is what I have written to display the France flag icon at a certain place in the jTable but it just displays the string ImageIcon icon = new ImageIcon("http://www.stoma.fr/assets/images/French_Flag_Small_Icon.jpg"); jTable.setValueAt

Show ImageIcon from class to JSF page?

南笙酒味 提交于 2019-12-24 11:08:22
问题 I'm studying JSF 2.0 and I have an ImageIcon in a class. Can I show this ImageIcon to JSF page? 回答1: There's some major conceptual misunderstanding going on. Java/JSF runs on webserver and produces HTML. HTML runs on webbrowser and can reference CSS/JS/image files by (relative) URLs in <link> , <script> and <img> elements. ImageIcon is part of Swing and has nothing to do with this all. Swing does not produce any HTML at all. When you still attempt to run it "the Swing way" in a Java class

Change ImageIcon being displayed in JFrame

空扰寡人 提交于 2019-12-24 00:47:38
问题 I have here this code. I want it to first display an image file as input by the user when calling the main method, then apply changes to it. My first function is grayscale(). I have provided a grayscale button in a JMenuBar such that when clicked, it will create a grayscale version of the current image. It works, however I can't get the new image to display in the JFrame after the method is applied. I tried calling show(); within the method, but that just opens the original image again. I

JLabel refresh icon with updated image

拥有回忆 提交于 2019-12-23 19:48:35
问题 I'm trying to make an experiment in image manipulation. Basically I have an image that is continously updated by a timer and i display that image in a JLabel. My problem is that JLabel does'nt refresh the image. Here is my timer code: Timer timer = new Timer(200, new ActionListener() { public void actionPerformed(ActionEvent e) { count++; System.out.println("timer"); System.out.println(filename); ImageIcon icon = new ImageIcon(filename); label = new JLabel(); label.setIcon(icon); label

Possible to layer ImageIcons?

孤街浪徒 提交于 2019-12-23 17:48:12
问题 I was wondering if it were possible to layer ImageIcons in Java. I will be working with GIF images, and will have a grid of ImageIcons representing the "background" of my JPane. When a certain condition is true, I need to be able to add an image that has transparency on top of the other image. Regards, Jack Hunt 回答1: yes that's possible and there are two correct ways 1) if is there only one Image then put JLabel with Icon to the GlassPane 2) use LayeredPane for <= Java6 (not Java7 user there

The method about ImageIcons does not work

一曲冷凌霜 提交于 2019-12-23 13:15:53
问题 import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Cards extends JFrame { private GridLayout grid1; JButton []bt=new JButton[52]; ImageIcon tail=new ImageIcon(getClass().getResource("b1fv.png")); ImageIcon ori; public Cards(){ grid1=new GridLayout(7,9,2,2); setLayout(grid1); for(int i=0;i<bt.length;i++){ ImageIcon c=new ImageIcon(getClass().getResource(i+1+".png")); bt[i]=new JButton(c); bt[i].addActionListener(new RatingMouseListener(i)); add( bt[i]); } } public