imageicon

Problems about ActionListener.image editing

你离开我真会死。 提交于 2019-12-13 01:37:45
问题 I got an assignment that i have to make a programm in Java that takes an Image.Creates 3 Buttons named(Align left,right and center).2 textfields Width and Height that i can input numbers there and a button resize.The 4 buttons(align left,right,center and resize) have to change the image place to left right or center and resize the image as the numbers were given respectively I have written the code just for going left but i cant figure what to do...I also have no idea what to do on resizing..

nullpointerexception when declaring new ImageIcon

一个人想着一个人 提交于 2019-12-13 01:30:43
问题 I am trying to load multiple images on the same window, so to prevent a lot of copy and paste, I made an image class called badgeIMG that looks like this: package BattleSim; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Image; import javax.swing.ImageIcon; import javax.swing.JPanel; public class badgeIMG extends JPanel{ Image badgeIcon; String badgePath; int x = 0; int y = 0; public badgeIMG() { ImageIcon ii = new ImageIcon(this.getClass().getClassLoader().getResource

How to find JLabel that was clicked and show ImageIcon from it?

风格不统一 提交于 2019-12-12 07:28:49
问题 Here is my code. I want to know which l was clicked and then in a new frame, display that ImageIcon. The e.getSource() is not working... final JFrame shirts = new JFrame("T-shirts"); JPanel panel = new JPanel(new GridLayout(4, 4, 3, 3)); for (int i = 1; i < 13; i++) { l = new JLabel(new ImageIcon("T-shirts/"+i+".jpg"), JLabel.CENTER); l.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED)); l.setFont(l.getFont().deriveFont(20f)); panel.add(l); }//end of for loop panel

How to tint an ImageIcon [duplicate]

旧巷老猫 提交于 2019-12-12 06:35:09
问题 This question already has an answer here : How to draw a BufferedImage with a color tint (1 answer) Closed 4 years ago . How would I tint the icon that is passed through here to be a different color? Say I wanted to take a white image and make it a bit darker. I have looked into BufferedImages and such but I can't seem to find anything that will fit into the setup that I am using. I should also note that I am drawing the images onto a JLabel if that makes a difference. Here is the source that

ImageIcon click and drag around the window

旧街凉风 提交于 2019-12-12 06:33:26
问题 I'm trying to make it so I can click and drag an ImageIcon (in this case a card image but I'd like to learn how to do it generally) around the window but I don't really know how. I would like to be able to click and hold the mouse botton, drag the ImageIcon, and have stay where it is whn I release the mouse botton. This is the code I have so far: import javax.swing.*; import java.awt.*; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseListener;

Object on Image does not move when Image moves

房东的猫 提交于 2019-12-12 05:36:53
问题 I have two classes. The first, JPanelImage , adds an Image to my JPanel . The second, myObjet , represents the object I want to add on my Image . The Image can move and can zoom. The problem is that when I move the image, the object remains fixed. Class JImagePanel : import java.awt.Dimension; import java.awt.Graphics; import java.awt.Image; import java.awt.MediaTracker; import java.awt.Panel; import java.awt.Toolkit; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent;

how set Image in jTable cell when click(Mouse Event) the row?

流过昼夜 提交于 2019-12-12 04:54:36
问题 How to set the Image in jTable cell when click(Mouse event) the row?If I select first row the image will display in that row.Then i click the second row, the image will show in the second row?how to do this using table cell renderer or prepare renderer? 回答1: If you just want the image to appear in the table cell, use the default renderer for ImageIcon and ensure that your TableModel returns ImageIcon.class for that column. If you want the image to appear in response to a click, consider using

ImageIcon lost after creating a runnable JAR file

耗尽温柔 提交于 2019-12-12 03:44:29
问题 The project runs fine when I click play in Eclipse but after I created the runnable JAR file , The ImageIcon for the button is gone. The images are stored within the src folder, uder a subfolder images. I created the image icon as Icon playIcon = (Icon) new ImageIcon("src/images/play.png"); Although I am using a relative path, the button does not display images, How do I get the images even in the JAR file? Update after Nikolay Kuznetsov's answer I ended up creating a very unstructured

Android App iCon configuration issue - black & white

大憨熊 提交于 2019-12-12 03:38:23
问题 I'm trying to setup icon for android app but when I click the iCon setup and select Launcher Icons, selected image, even ic_launcher.png is showing as black & white. Am I missing any setting here? 回答1: Posting the solution or issue causing this problem. I was using Android Studio Preview and that was the issue. Preview is not ready for production app, it's like beta version. I reverted to the stable version of the app and it's working perfectly for icons. Attached is sample image for Android

After adding ImageIcons to JButtons, buttons no longer work

蹲街弑〆低调 提交于 2019-12-12 03:28:16
问题 I finished a project early, so with the remaining time I had before submitting it, I wanted to experiment. The entire program works great, and the JButtons did exactly as they were programmed to do. Something went awry after adding ImageIcon(s) to my JButtons. I'll show a few of the JButton initializations and show the original in a single comment above each block: /** * create child components */ private void initComponents() { //normalSetupButton = new JButton("Normal Setup"); ImageIcon