imageicon

Java resize an image

徘徊边缘 提交于 2019-12-11 11:14:57
问题 I would like to display an image in an area in my Jframe but the image takes up much space. I would like to take it fair precise dimensions. How can I do this in Java This is my simple code : I am open to any proposal if I did not use the right method or the right class to instantiate the image. import java.awt.*; import javax.swing.*; public class ExempleDeplace extends JFrame{ private JLabel myLabel; public ExempleDeplace(){ setLayout(new FlowLayout()); setTitle("Fenetre, modele Duchi");

Refresh Image in JLabel with Timer

倾然丶 夕夏残阳落幕 提交于 2019-12-11 10:02:07
问题 I´m currently working on a little programm witch displays pictures from a website in a little Swing GUI. The Problem is, that every time the picture changes a new frame pops up instead of refreshing the JLable. I have no idea how to realize this after trying a few attempts with different methods. It would be nice if you could give me a little hint. import java.awt.BorderLayout; import java.awt.Image; import java.io.*; import java.net.MalformedURLException; import java.net.URL; import javax

How to change description image in JList java

痴心易碎 提交于 2019-12-11 09:46:27
问题 Below is my code that displays images in a JList . I want to edit the description by each of the images shown in the JList . I don't know how to do it & need help. Thanks... import java.util.*; import javax.imageio.ImageIO; import javax.swing.*; import javax.swing.border.Border; import java.awt.*; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.Transferable; import java.awt.datatransfer.UnsupportedFlavorException; import java.awt.image.BufferedImage; import java.io.File;

Cannot instantiate the type Image java?

只愿长相守 提交于 2019-12-11 00:25:11
问题 public Image images[] = new Image[20]; for(i=0; i<10; i++){ images[i]=new Image(getClass().getResource("/images/"+i+".jpg")); } I am trying to add images to array but it gives the error Cannot instantiate the type Image j What can be the reason? 回答1: Abstract classes cant be instantiated directly. You could use ImageIO.read which returns BufferedImage , a sub-class of Image void loadImages() throws IOException { for (int i = 0; i < 10; i++) { images[i] = ImageIO.read(getClass().getResource("

Displaying Image in JTable

旧巷老猫 提交于 2019-12-10 19:59:15
问题 I'm trying to display an Image into column No 25 of a JTable :- For that i wrote the below code :- jTable1.getColumnModel().getColumn(25).setCellRenderer(jTable1.getDefaultRenderer(ImageIcon.class)); String query = "SELECT name,type,supplier, department, manufacturer, model, serial_no, description, location, broker, dop, installation_date, expiring_date, retiring_date,warranty_info, icost, rcost, aarea, voltage, wattage, amperage, eline, capacity, plink, notes, adding_date, modification_date

ImageIcon Loading in Java

南笙酒味 提交于 2019-12-10 11:34:30
问题 I have searched Google, SE, and Oracle's documentation for information on how to do this, but I can't seem to make it work. I have found several posts regarding whether to use getResource() or getResourceAsStream() and how to format the file name, but none that I can apply to my situation. My directory structure looks like this (with some extra levels in the resource folder): Root Folder | |_____ bin (compiled .class files go here) | |_____ src | | | |_____ packageA | | | | | |_____ packageAa

How to make drawn images transparent in Java

隐身守侯 提交于 2019-12-10 10:28:37
问题 I got the animation to work in my Snake Clone Game. But the problem based on the picture is that the images do not have transparency(notice the white background of the circle pictures. Programming-wise, is there a fix to be able to include transparency to these drawn images? Here's a picture containing my code and the output of the program. P.S. On a side note, I decided to paste the direct link instead of the IMG code because I cannot seem to get it to display on StackOverFlow. I put an

How to change the brightness of an Image

走远了吗. 提交于 2019-12-09 04:50:36
问题 My Question: I want to be able to change the brightness of a resource image and have three instances of it as ImageIcons. One at 50% brightness (so darker), another at 75% brightness (a little brighter), and finally another at 100% brightness (the same as the original image). I also want to preserve transparency. What I've tried: I've searched around and it looks like the best solution is using RescaleOp, but I just can't figure it out. I don't know what the scaleFactor and the offset is all

Refreshing a JLabel icon image

偶尔善良 提交于 2019-12-09 00:39:26
问题 I'm displaying an image in a JFrame using a JLabel and setting it's icon. It works the first time, but whenever I go to change the image, it remains what I set it the first time, so I've tried this and still the same result. contentPane.remove(lblPlaceholder); lblPlaceholder = null; lblPlaceholder = new JLabel(""); lblPlaceholder.setBounds(10, 322, 125, 32); contentPane.add(lblPlaceholder); lblPlaceholder.setIcon(new ImageIcon("tempimage.png")); How can I get it to change it's image? I've

ImageIcon Loading in Java

ぃ、小莉子 提交于 2019-12-08 06:24:17
I have searched Google, SE, and Oracle's documentation for information on how to do this, but I can't seem to make it work. I have found several posts regarding whether to use getResource() or getResourceAsStream() and how to format the file name, but none that I can apply to my situation. My directory structure looks like this (with some extra levels in the resource folder): Root Folder | |_____ bin (compiled .class files go here) | |_____ src | | | |_____ packageA | | | | | |_____ packageAa | | | | | |_____ images.java | | | | | |_____ resources | | | | | |_____ icon1.gif | | | |_____