Swing/AWT/SWT :: Simple Image Display

Aug 8, 2014

I am fairly new to Java. I am trying to learn some image manipulation basics. I have searched the web endlessly and made numerous attempts but I cannot seem to get a darn image to display. This code is my latest attempt in Eclipse. The file I am using is chairangle.jpg which is is the src folder of the package I am working in in Eclipse. I am on Windows 8.

import java.awt.*;
import javax.swing.*;
import javax.swing.ImageIcon;
public class otherimg extends JFrame
{
public static void main(String args[]){
JFrame f = new JFrame();
ImageIcon image = new ImageIcon("image/chairangle.jpg");
JLabel label = new JLabel("", image, JLabel.CENTER);
JPanel panel = new JPanel(new BorderLayout());
panel.add( label, BorderLayout.CENTER );
f.pack();
f.setVisible(true);
}
}

View Replies


ADVERTISEMENT

Swing/AWT/SWT :: Doesn't Display Image

Mar 28, 2015

why this code, doesn't display the image?

import java.awt.Graphics;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

[code]...

View Replies View Related

Swing/AWT/SWT :: Display Image On Game

Jan 19, 2014

I have a class that retrieves an image, and a class that is a game. I want to put my image onto the game to use it as the main figure. As of right now in eclipse, the game class runs, so the game works, but the image doesn't do anything. Need to put the image into the game? Here is my image class:

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.*;

[code]....

View Replies View Related

Swing - Display Image On JFrame?

Jan 16, 2014

How to display an image on a JFrame. If you can, pany example code.

View Replies View Related

Retrieve Image From MySQL DB And Display In Jtable If Image Type Is Medium Blob Using Swings And Hibernate

Jan 5, 2015

I stored an image into MySQL database using swings and hibernate but I am struggling to retrieve that image from MySQL database and display same image in the jTable cell and same as on jLabel whatever I retrieve from the database using swings and hibernate .

View Replies View Related

Cannot Get Simple Image To Load In Jpanel

Aug 7, 2014

I cannot get an image to display. The code here is my latest attempt. I have tried ImageIcon, applets using getImage() among many other things. I do not know if it is a file path problem. The file I am using is in the src folder of the package I am using on Eclipse. I am on Windows 8. Here is the code.

import java.awt.*;
import javax.swing.*;
import javax.swing.ImageIcon;

[Code].....

View Replies View Related

Swing/AWT/SWT :: Image Manipulation - Create Application Where Image Is Displayed On One Label

Apr 7, 2014

Sir, I'am new to Swing Programming. I have to create an application where an image is displayed on one Label. The same image has to be split in parts and stored in database pert wise. Later the user has to retrieve the entire image by viewing a small part of the image. I have already displayed the full image on the Label, now i don't know how to split the image and store it part wise in the database.

View Replies View Related

How To Get Image To Display On JFrame

Nov 13, 2014

I have been trying to make a game lately, but I can't seem to work out how to get an image to display on my JFrame. I have tried everything, copied different codes of the internet, but nothing works. Here is my code of the GUI:

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class GUI extends JFrame implements Runnable, ActionListener {
JButton start = new JButton("Start nieuw spel");
JButton instellingen = new JButton("Instellingen");
public GUI() {

[Code]...

View Replies View Related

JavaFX Will Not Display Image

Oct 21, 2014

I've been on this for a while and for some reason I just can't seem to get this to work. I know my code is solid, but it won't display my image. I've tried swithcing the image to different directories and also using different image sizes and types. I even used Orcale's guide to display your image, but still no go! All I get is a blank canvas? There are no errors. I'm also running NetbeansIDE 8 that supports JavaFX and I made sure the project is a JavaFX Application project.

All I get is a blank new window, but no images.

Here's my code:

package javafxapplication3;
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.image.Image;

[code]....

The homework called for me to display it three times - the first one regular, second resized, and the last one rotated. I even deleted the extra images in hope at least one appears.

View Replies View Related

Display Image (GIF / JPG) On JPanel

Apr 12, 2014

I'm simply trying to make a gui for managing images for my purpose, but i fall at the first step: I'm actually not able to display an image, whether it would be a .gif or .jpg ....

//--------MY PANEL FOR VIEWING IMAGE---------
package graph2D;
 
import java.awt.Graphics;
import java.awt.Image;
import java.awt.MediaTracker;
import java.awt.Toolkit;
import javax.swing.JPanel;
class PannelloConImmagine extends JPanel {
private Image miaImmagine;
 
[Code] .....

it is supposed that i placed the image "pippo.gif" in my project "src" folder, isn't it? anyway I tried to add a new folder to my build Path, and place pippo.gif on it, but it doesn't work.

View Replies View Related

Cannot Display Image For Some Reason

Mar 27, 2014

I am using Netbeans. For some reason I cant display an image.

Java Code:

import java.applet.Applet;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Toolkit;
import java.net.URL;

public class ImageLoadingTutorial extends Applet{
private Image spiral = null;

[Code] ....

View Replies View Related

JSP :: Choose / Display Image Path

Mar 15, 2014

I want to do the followings:

-When i press "choose the Image Path" a window open like a picture 2.
-I want also satisfy the condition written in red.

View Replies View Related

ActionListener To Display Different Image Icons?

May 23, 2014

If you look at line 74 you will see my actionPerformed method where I want to switch the icon displayed on the JButton. I know I still have to add the images to the button however I am running into a few issues here.

In my next class it will be vital that I can decipher what each icon is display on the JButton.

Java Code: import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
public class Screen implements ActionListener

[code]....

View Replies View Related

Program That Will Have GUI Window And Display Image?

Jun 24, 2014

I am writing a program that will have a GUI window and displays an image when clicked on the image changes and clicked on again the image changes once more. Here is what i have.

package ButtonLab;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

[Code]....

The issue i am having is when i run it the window pops up but with no images. The images wont load, I have tried to use the c: path to the image also.

View Replies View Related

Software To Display Image On Screen Using Particular Library

Jul 30, 2014

I am writing a piece of software to display an image on the screen using a particular library. The library lets me create an Atlas out of texture file data, to fetch Textures out of the Atlas using the textures' names, and to draw the textures by calling Renderer.draw(texture). It doesn't make a great deal of sense to create more than one of an Atlas or Renderer. I previously designed my code as follows:

public class SystemAssets {
static Atlas atlas;
public static void initializeAtlas(String pathToTextureFiles) {
atlas = new Atlas(pathToTextureFiles);
}
public static Texture getTexture(String textureName) {
return atlas.getTexture(textureName);
}
}

Similarly, I made a TextureRenderer class whose sole purpose is to provide static access to a Renderer. But many people seem to say that opening up a class like this to global access is bad. I cannot think of any better alternative, however. My core update/draw logic currently works something like this:

public class Game extends AbstractGame {
public void init() {
Screen current = new FirstScreen();
TextureRenderer.initialize();

[code]...

Making a Renderer object belong to the Game or Screen class doesn't make much sense to me, as there doesn't seem to really be a 'has-a' relationship between them; it's more of a 'uses-a', so that seems to imply that it would be best to just call Renderer.draw(thing) from outside the class rather than making it a data member. This would make my main code essentially call the various methods in order to get or print some form of data, much like System.out.println(). And of course, making one of the classes a subclass of Renderer makes even less sense. But making data members static for the purpose of global access and using singletons are often cited as 'bad' programming practices. This problem also arises in a lot of other scenarios in my program, ie. when I want to serialize Thing data members like texture filenames; do I put the serializer as a static data member in a class for global access and call it like I would a function, or do I put it in a class? And it seems like the Renderer will have to be initialized at the start of the program, which would take place in the init() method in Game, then be used to draw Textures in the Screen, so it would have to be accessible from both locations.

edit: In case it's suggested to put these in the main class, that's unfortunately going to be difficult without using static variables; the library recommends having the main class creating an Application object, which is essentially a black box that actually does all the work of calling Game's init() and draw() methods (via a Game object passed into its constructor) and looping until the program exits. AbstractGame and Screen are classes supplied by the library, so it doesn't seem like I can easily give Game any data that AbstractGame doesn't specifically ask for.

View Replies View Related

JavaFX 2.0 :: Display Image In WebView From External Directory

Jun 18, 2014

I have a WebView and a Javascript that appends an <img> tag in a webview.
 
Like so:
 
function insertImg(src) {
   $("body").append("<img src='" + src + "'/>");
}
 
I call this function with the following code:
 
String path = "file://Users/rod/Desktop/123.gif";
webengine.executeScript("insertImg('" + path + "')");
 
However, this does not work and no image is displayed.
 
How can this be achieved?

View Replies View Related

Swing/AWT/SWT :: Simple Applet Won't Run

Mar 11, 2002

I coded up a simple applet and some html with an applet tag and it tested out OK using the applet viewer. But it doesn't do anything (except draw a grey empty box 100x200) when executed from the application server. For the applicaton server test, I put the applet tag in the HTML Body of the JSP page i.e.

<applet code=CatApplet.class height=100 width=200> </applet>

The applet class file is in the same directory as the JSP page. The source for it is:

import java.awt.*;import java.awt.event.*;import javax.swing.*;import java.io.*;import java.net.*;
import java.util.Date;public class CatApplet extends JApplet{public void init (){setBackground(Color.green);
resize (250,100);}public void paint (Graphics g){g.drawString ("lets get some cat gui going", 35, 15);}}

Why won't my applet run when the applet tags are in the JSP page?

View Replies View Related

Swing/AWT/SWT :: Simple Java GUI

Feb 4, 2015

I'm just starting to learn Java GUI. I'm trying to make a simple GUI that will update dynamically but having trouble ending the loop correctly.The Currently I've got the GUI updating and stopping, but the Test class method loop does not terminate correctly, it continues to count.

import java.awt.*; // Using AWT container and component classes
import java.awt.event.*; // Using AWT event classes and listener interfaces
import java.util.Timer;
import java.util.TimerTask;

[code]....

View Replies View Related

JSP :: Store A File / Image Into Oracle Database And Display On Browser?

Nov 2, 2014

I want to store an image/file into oracle database using jsp.

I have written code to store data when am running in my machine it is working fine, but not working in server throwing an error saying that "The system cannot find the file specified."

I am attaching the code what am written.

View Replies View Related

Display Image On JLabel Or JPanel With Respect Of Components Size?

Mar 27, 2015

i have very critical problem in my collage project i have try many code but still i cant solve this problem, i want to display image on jlabel or jpanel with respect of components size without use of drawimage method

View Replies View Related

Simple Calculator Swing Java

Dec 13, 2014

I am a beginner with Java. I have never used SWING before but I have to use it now and I am clueless. I don't know if what I am doing is right.I need to create a simple calculator. My problem is getting the buttons the user clicks to appear in a text field. I know I haven't added the =/*- buttons yet.

I have left actionPerformed practically blank, what to put in ?

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
/**
* Created by IntelliJ IDEA.
* Date: 11/12/2014
* Changing Face Program.
*/
public class Calc extends JFrame implements ActionListener

[code]...

View Replies View Related

Swing/AWT/SWT :: Use JComboBox With Simple ListCellRenderer

Aug 7, 2014

I am trying to use a JComboBox with a simple ListCellRenderer

public class EntscheidendeBehoerdeListRenderer extends JLabel implements ListCellRenderer<EntscheidendeBehoerde> {
private static final Color HIGHLIGHT_COLOR = new Color(0, 0, 128);
private static final long serialVersionUID = -4719965772580952993L;
public Component getListCellRendererComponent(
JList<? extends EntscheidendeBehoerde> list,
EntscheidendeBehoerde value, int index, boolean isSelected,
boolean cellHasFocus) {

[code].....

The JCombox shows and odd behavior, when I point to an item it moves up or down and an empty line appears under the cursor.

View Replies View Related

Swing/AWT/SWT :: Create A Simple JFrame Application

Jan 22, 2015

I installed Windowsbuilder in Eclipse as described in this video:URL....

To get starated I now want to create a simple JFrame application that works in the following way. On the opening screen I want to present 4 buttons. Based on the selection I want the JFrame to change layout and components so that the same JFrame behind the scenes contains 5 layouts but only one visible at any time. What is the best way to accomplish this? Or should I do this in another way using multiple JFrames or similar?

View Replies View Related

JavaFX 2.0 :: ImageView Image Created In Scene Builder 2.0 Doesn't Display In Running App

Sep 9, 2014

I'm using Scene Builder 2.0 and have added an ImageView to the parent AnchorPane.  I've added my PNG files for the app icon and the various buttons. I select the ImageView in Scene Builder and then crawl the filesystem to the project package folder and select the PNG for the Image.  The assigned image is displayed in the Imageview in Scene Builder in both design mode and Preview mode.
 
While everything else shows up properly when the app is executed, the image assigned to the ImageView does not display.
 
From the FXML file:

<ImageView fx:id="ivBRULogo" fitHeight="64.0" fitWidth="64.0" layoutX="14.0" layoutY="14.0" pickOnBounds="true" preserveRatio="true" AnchorPane.leftAnchor="14.0" AnchorPane.topAnchor="14.0">
         <image>
            <Image url="@BRU_PE_B_64.png" />
         </image>
      </ImageView>
 
What might be occurring between the compiled app and what Scene Builder generates?

View Replies View Related

Swing/AWT/SWT :: Simple GUI Task - Draw Pie Chart With Different Colors

Jan 31, 2014

Simple gui task. it meant to draw pie chart with different colors. i can't seem to find a mistake in it. It works if i put in g2g.draw(arc) i know arcs overlaps a bit due int conversion, but that's ok.

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
import java.awt.geom.Arc2D;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.Color;

[Code] ....

View Replies View Related

Swing/AWT/SWT :: How To Scroll Image

Sep 30, 2014

I have a java swing application.

1. The human user of my application asks it to fire up a scanner which scans a paper document. The document is a filled in form.
2. The application then displays the scanned image to the human user.The image is displayed in a JScrollPane since it may be larger than the scroll pane.
3. The human user needs to locate a certain item in the form, for example a social security number, and enter it into a field in a data entry screen.Note that the image and the field appear on the same screen.

Of-course the social security number always appears in the same location in the image. Also the image needs to be the appropriate magnification and resolution to allow the human user to easily read and understand the item he is searching for in the image.

What is the best way to present the scanned image to the user such that he immediately sees the item he requires and can enter it into the data entry field.

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved