imageicon

java rmi passing ImageIcon objects

一个人想着一个人 提交于 2019-12-02 15:21:32
问题 I m making an rmi client server based program which is suppose to pass Image object through remote object interfaces . The Client receives an Image from the Server . Following is my code.... At Client public class ImageReceiver { public static ImageIcon imageicon; public static void main(String Data[]) { imageicon = new ImageIcon(url); imageicon=remoteObject.getImageFromServer(); } } // The Details regarding the binding of remote objects are excluded since they are worling fine... sendImage

Add a picture to a JFrame

孤者浪人 提交于 2019-12-02 13:45:07
All I am trying to do is add a picture to a JFrame . I am really confused and don't really understand... I have looked up every possible question on this site, looked on other java stuff, such as forums. I tried my best and now I must ask guys for help. I hope the code is clean and easy to read. Thanks for the help. package zeus; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.ImageIcon; public class Main extends JFrame{ public static final int WIDTH = 800; public static final int HEIGHT = 600; public static final int SCALE = 1; public static void Launch(){ JFrame xF =

Java getClass().getResource on a png returning Null Pointer

瘦欲@ 提交于 2019-12-02 13:18:20
I am not sure if I am referring to the right location with this code, the images I am trying to access are titled Flower0.png etc. They are located in the same directory as the rest of my code for this project. This class is in a src folder called hangman.ui and the .png files are located in a directory folder called Resources . Perhaps getClass().getResource is not right? This is my first time trying to put images into a GUI. Help is much appreciated! public WiltingFlowerRendererRemix(HangmanLogic logic) { panel = new JPanel(); panel.setLayout(new BorderLayout()); imageLabel = new JLabel();

My jar file won't load images

社会主义新天地 提交于 2019-12-02 12:43:14
问题 I am currently writing a program that I need to send to a friend as a jar. The program has images that need to be loaded for the program to work properly and I want it all to be contained in the one jar. Currently it doesn't work from the executable jar or when I run it through command line. It works in netbeans however. Here's the code I'm using: To load the image I'm using: protected ImageIcon createImageIcon(String path, String description) { java.net.URL imgURL = getClass().getClassLoader

java rmi passing ImageIcon objects

橙三吉。 提交于 2019-12-02 09:58:24
I m making an rmi client server based program which is suppose to pass Image object through remote object interfaces . The Client receives an Image from the Server . Following is my code.... At Client public class ImageReceiver { public static ImageIcon imageicon; public static void main(String Data[]) { imageicon = new ImageIcon(url); imageicon=remoteObject.getImageFromServer(); } } // The Details regarding the binding of remote objects are excluded since they are worling fine... sendImage is an interfacing method implemented... public ImageIcon getImageFromServer() throws RemoteException; At

Using an image for the background of a JPanel and JButton

拜拜、爱过 提交于 2019-12-02 08:37:00
I am trying to use an image I made in photoshop as the background for my GUI. How do I do that? also I made some images I want to display in the button backgrounds after the action is performed... For the JButton, use this: JButton button = new JButton("Button Name", new ImageIcon("foo.png"); The Panel is a bit more interesting. This is a good method, though: ImagePanel panel = new ImagePanel(new ImageIcon("foo.png").getImage()); 来源: https://stackoverflow.com/questions/8373006/using-an-image-for-the-background-of-a-jpanel-and-jbutton

Change photo when you click a button

家住魔仙堡 提交于 2019-12-02 08:29:30
import javax.swing.Icon; import javax.swing.ImageIcon; public class Stage1 extends javax.swing.JFrame { int score = 0; int iter = 1; public Stage1() { initComponents(); setDefaultCloseOperation(EXIT_ON_CLOSE); setTitle("Stage 1"); Icon ic = new ImageIcon("a"+ iter + ".jpg"); pic.setIcon(ic); } private void submitActionPerformed(java.awt.event.ActionEvent evt) { if(answer.getText().equals("input")) { score++; iter++; answer.setText(""); String sc = Integer.toString(score); jLabel1.setText(sc); jLabel2.setText(Integer.toString(iter)); } else { iter++; Icon ic = new ImageIcon("a"+ iter +".jpg");

ImageIcon method not working for all images

大憨熊 提交于 2019-12-02 08:10:30
问题 I'm trying to get a jpeg to display on a JFrame and I'm noticing that some image files work while others do not. I'm using Eclipse and all of my images are in the project's root dir. When I run the Debugger and it hits my breakpoint it reports the imageheight and imagewidth as -1 on the images that will not display. It reports the correct values on the images that do display. at first I thought it had something to do with the image sizes but after playing with resolutions in mspaint I've

Where have I to put an image to use it to create a new Swing ImageIcon object?

时间秒杀一切 提交于 2019-12-02 06:35:12
I am studying Java Swing library and I have a problem. In an example program it create an ImageIcon object by this line: ImageIcon icon = new ImageIcon(getClass().getResource("exit.png")); Whe I execute my program I obtain the following error caused by the fact that in the project the exit.png is missing: Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at javax.swing.ImageIcon.<init>(ImageIcon.java:205) at com.andrea.second.SimpleMenu.initUI(SimpleMenu.java:23) at com.andrea.second.SimpleMenu.<init>(SimpleMenu.java:17) at com.andrea.second.SimpleMenu$2.run(SimpleMenu.java

How can I drag images with the mouse cursor in Java GUI?

大憨熊 提交于 2019-12-02 04:42:56
问题 // my code that calls upon n images in a directory to be placed on the JPanel public void imageAdder(int n, String name){ BufferedImage myPic = null; for (int i = 0; i <= n; i++){ try { myPic = ImageIO.read(new File("Images/" + name + i + ".jpg")); } catch (Exception e){ System.out.println("no file man cmon"); } JLabel picLabel = new JLabel(new ImageIcon(myPic)); // picLabel.setBounds(mouseX, mouseY, 100, 50); // picLabel.addMouseMotionListener(this); // picLabel.addMouseListener(this);