imageicon

Java image scaling without loading the whole image into memory

女生的网名这么多〃 提交于 2021-02-07 20:54:59
问题 We have some very large jpgs which are used when print on A0 printers. The problem is that we need to convert this large image down to a thumbnail for use in a few java UIs. Is there any way to convert the image (with Java) without loading the whole image into memory? Currently we get out of memory exceptions when we try to load the images. Is there anything in the standard code or is my best bet to use jmagick? A pure java implementation would be best for our deployment. Thanks 回答1: I

Java: ImageIcon - image file updating but image icon in Java frame not

十年热恋 提交于 2021-02-05 09:24:12
问题 I have got a ImageIcon in a Jlabel in a JFrame (Java GUI). The ImageIcon should get updated based on pressing a Calculate button (i.e. calcButton.addActionListener(new ActionListener() ) with part of the code in the method: icon2 = new ImageIcon("M:\\Repos\\rtrans\\radTransPlot.png"); Plot1.setIcon(icon2); frame.add(Plot1,gc); frame.setVisible(true); The initial ImageIcon (icon1) is blank: public class RadTransGui { private ImageIcon icon1 = new ImageIcon("M:\\Repos\\rtrans\\radTransPlotEmpty

Add image to JCheckBoxMenuItem

眉间皱痕 提交于 2021-01-28 06:09:50
问题 I have been given an assignment in which i need to a use JCheckBoxMenuItem and add an image to it on the right side I've used the setIcon() method. Created a custom panel and added image to it and then adding the panel to checkbox. Tried to add panel like below. JCheckBoxMenuItem item = new JCheckBoxMenuItem(); item.setText("Option1"); JPanel panel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JLabel label = new JLabel(new ImageIcon( "C:\\Users\\abcd\\Desktop\\facebook.jpg")); panel.add

Java swing JButton/JLabel: icons are not displayed in their original size

帅比萌擦擦* 提交于 2021-01-11 02:54:12
问题 I have png icons and use them as icons in JButton / JLabel . The problem is that the image displayed at runtime is larger than the original icon, and because of this resizing, it's super ugly. Here is an example: Original icon (left) and how it's rendered in the JButton (right) The source code for this minimal example is simply: public class Main { public static void main(String... args) { JFrame frame = new JFrame("Test"); frame.setBounds(0, 0, 120, 80); frame.setDefaultCloseOperation(JFrame

getResources() for ImageIcon - java

。_饼干妹妹 提交于 2020-06-23 07:32:24
问题 my very first question: I've been trying to figure this out for a couple of days, but I got to the point I lost my patience. The following are some code and my project structure. QUESTION: how can I get getResources() to work in eclipse and after being imported to jar? Thanks for the help. public enum Icons { XXX("src/resoruces/icons/xyz.png"); private ImageIcon icon; Icons(String path) { try { // will fail miserably in eclipse and after exporting to jar URL imageURL = getClass()

getResources() for ImageIcon - java

我与影子孤独终老i 提交于 2020-06-23 07:31:30
问题 my very first question: I've been trying to figure this out for a couple of days, but I got to the point I lost my patience. The following are some code and my project structure. QUESTION: how can I get getResources() to work in eclipse and after being imported to jar? Thanks for the help. public enum Icons { XXX("src/resoruces/icons/xyz.png"); private ImageIcon icon; Icons(String path) { try { // will fail miserably in eclipse and after exporting to jar URL imageURL = getClass()

getResources() for ImageIcon - java

房东的猫 提交于 2020-06-23 07:31:13
问题 my very first question: I've been trying to figure this out for a couple of days, but I got to the point I lost my patience. The following are some code and my project structure. QUESTION: how can I get getResources() to work in eclipse and after being imported to jar? Thanks for the help. public enum Icons { XXX("src/resoruces/icons/xyz.png"); private ImageIcon icon; Icons(String path) { try { // will fail miserably in eclipse and after exporting to jar URL imageURL = getClass()

Error loading background image into JPanel in a JFrame

青春壹個敷衍的年華 提交于 2020-06-09 03:27:31
问题 I have a JFrame in which I want to occupy it entirely with a JPanel and put a background image in the JPanel . Code: public class InicioSesion extends javax.swing.JFrame{ private Image imagenFondo; private URL fondo; public InicioSesion(){ initComponents(); try{ fondo = this.getClass().getResource("fondo.jpg"); imagenFondo = ImageIO.read(fondo); }catch(IOException ex){ ex.printStackTrace(); System.out.print("Image dont load"); //Dont load the message. } Container c = getContentPane(); c.add

Error loading background image into JPanel in a JFrame

亡梦爱人 提交于 2020-06-09 03:26:07
问题 I have a JFrame in which I want to occupy it entirely with a JPanel and put a background image in the JPanel . Code: public class InicioSesion extends javax.swing.JFrame{ private Image imagenFondo; private URL fondo; public InicioSesion(){ initComponents(); try{ fondo = this.getClass().getResource("fondo.jpg"); imagenFondo = ImageIO.read(fondo); }catch(IOException ex){ ex.printStackTrace(); System.out.print("Image dont load"); //Dont load the message. } Container c = getContentPane(); c.add