imageicon

Switch imageIcon in java?

一个人想着一个人 提交于 2019-12-17 10:04:52
问题 I have many planes(threads) that move in window, and I want switch the ImageIcon according to the direction of the plane. For example: if a plane goes to the right, the imageIcon of the plane is right and then plane goes to the left, exchange the imageIcon for the plane is left. How can I do that in method paintComponent? Sorry for my bad english. 回答1: If you're talking about swapping the ImageIcon displayed by a JLabel, then you should not switch ImageIcons in paintComponent but rather

C# console application icon

感情迁移 提交于 2019-12-17 07:42:55
问题 Does anyone know how to set a C# console application's icon in the code (not using project properties in Visual Studio)? 回答1: You can't specify an executable's icon in code - it's part of the binary file itself. From the command line you'd use /win32icon:<file> if that's any help, but you can't specify it within the code of the application. Don't forget that most of the time the application's icon is displayed, your app isn't running at all! That's assuming you mean the icon for the file

Insert a GIF image into JFrame and make it visible and invisible on demand

感情迁移 提交于 2019-12-14 03:29:05
问题 In my application I am extracting data from a project DB. When I do that I want to signal to user that data extraction is in progress. I want to achieve this by making my current frame view.getFrame2() invisible and making view.getFrame3() visible. Frame 3 will have GIF image with frame titled as "Extraction is in progress". I am able to achieve my target but I am not able to view the image in the frame. It's blank. Below is the code snippet I am using; one class is used for view, another one

Adding image in JApplet

限于喜欢 提交于 2019-12-13 21:17:35
问题 ImageIcon icon= new ImageIcon("a.gif"); JLabel jLabel1=new JLabel(icon); jLabel1.setVisible(true); card1.add(jLabel1); I am a newbie to Java and I am facing a problem to add image in a panel in applet. My image is in the same folder. My applet is visible without any problem but only image is not displayed. 回答1: public void init() URL imageURL = new URL(getDocumentBase(), "a.gif"); Image image = getImage(imageURL); ImageIcon icon = new ImageIcon(image); // ... The ImageIcon constructor that

Resizing JLabel ImageIcon with HTML

十年热恋 提交于 2019-12-13 18:40:27
问题 So I looked through this thread and saw the suggestion of using HTML for resizing. I've been going through the Oracle website but it only provided example for text customization in JLabels using HTML. Can I get an example of a JLabel with HTML parameters? 回答1: This basically requires you to have a URL reference to the image in question. This is quite easy to achieve if the image is an embedded resource (as demonstrated below), but you should be able to generate a URL from file using File

JButton from image

与世无争的帅哥 提交于 2019-12-13 17:41:36
问题 I want to make JButton from image. But when i do it like this: private void AddMainActionsButtons(Container powZawartosci){ JPanel mainActionButtons = new JPanel(); JButton applyButton = createImageButton("obrazki/apply.png"); mainActionButtons.add(applyButton); powZawartosci.add(mainActionButtons); mainActionButtons.setBounds(150,530,400,90); } private JButton createImageButton(String imagePath){ ImageIcon icon = uploadImage(imagePath,""); JButton button = new JButton(icon); return button; }

Exception in thread “Thread” java.lang.OutOfMemoryError: Requested array size exceeds VM limit

戏子无情 提交于 2019-12-13 05:58:55
问题 The only thing difference is there is two different crop location. The question is why i get this error?? Method call CropRealOriginalImage1 orderName = new CropRealOriginalImage1(); FourAreaCropAgain1 orderNameFirst=new FourAreaCropAgain1(); orderNameFirst.orderNameFirst(); Decode decode= new Decode(); decode.inputImage("C:/TEMP/Image/Embed Image/Four Area/OrderFirst.png"); if(decode.s.equals("")){ System.out.println("OderFirst=null"); }else{ //put b into txt file System.out.println("decode

Netbeans ImageIcon not displaying

无人久伴 提交于 2019-12-13 03:37:48
问题 I am using the NetBeans GUIBuilder to make a JPanel Form. I added a JLabel and used NetBeans' interface to give it an icon from an external image (.png). The path is verified and the image shows up on the GUIBuilder screen. It even shows up when I click the "Preview Design" button. It DOES NOT show up when I RUN the project. The rest of the GUI appears as it should. Do any of you know why this happening and/or how to fix it? A lot of you have been asking for an SSCCE. Since the code is

Java - delete an ImageIcon?

痴心易碎 提交于 2019-12-13 03:23:26
问题 Is there any way to easily delete an ImageIcon completely from the screen? I can't find one anywhere. ImageIcon image = new ImageIcon("candle.gif"); image.paintIcon(this, g, 150, 80) For example, if I wanted to get rid of "image" later on when a button is pressed, what would be the appropriate code? (Not for the button, I know how to do that). 回答1: Don't reinvent the wheel. The easiest way to paint an Icon is to use a JLabel. The code would be something like: ImageIcon icon = new ImageIcon(..

Click action to my Icon in JTable

丶灬走出姿态 提交于 2019-12-13 02:31:46
问题 I create class ImageRenderer that which allows me to display in JTable icon png, i would like to add a action when i click on the icon in JTable, ImageRenderer import java.awt.Component; import javax.swing.ImageIcon; import javax.swing.JLabel; import javax.swing.JTable; import javax.swing.table.DefaultTableCellRenderer; class ImageRenderer extends DefaultTableCellRenderer { JLabel lbl = new JLabel(); public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected