Showing image in JPanel
Ok I'm trying to put an image in a full screen JPanel, why isn't it working?
package game;
import gui.FullScreenDisplay;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.lang.Runnable;
import java.lang.Thread;
public class Runner implements Runnable
private static final long serialVersionUID = 1L;
private FullScreenDisplay display;
public static void main(String args[])
Thread t = new Thread(new Runner());
t.start();
public Runner()
makeGui();
private void makeGui()
display = new FullScreenDisplay(this);
public void run()
try {
Thread.sleep(1000);
} catch (InterruptedException e) {/*Nothing to do*/}
run();
public void quit()
System.exit(0);
package gui;
import game.Runner;
import java.awt.GraphicsEnvironment;
import java.awt.event.KeyEvent;
import javax.swing.KeyStroke;
import javax.swing.AbstractAction;
import java.awt.event.ActionEvent;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.Graphics;
import java.awt.Image;
import javax.imageio.ImageIO;
import java.io.File;
import java.io.IOException;
public class FullScreenDisplay extends JFrame {
private static final long serialVersionUID = 1L;
private Runner master;
private JPanel mainPanel;
private Image tempImage;
public FullScreenDisplay(Runner master)
super();
//Remove this eventually.
try {
tempImage = ImageIO.read(new File("test_image.jpg"));
} catch (IOException e) {
System.out.println("image get error");
e.printStackTrace();
this.master = master;
makeFrame();
makePanel();
makeKeyBindings();
//setFullScreen(chooseBufferStrategy());
setFullScreen();
requestFocus();
setVisible(true);
//Remove this eventually.
Graphics g = tempImage.getGraphics();
mainPanel.paint(g);
this.update(g);
private void makeFrame()
setUndecorated(true);
setResizable(false);
setFocusable(true);
private void makePanel()
mainPanel = new JPanel(){
public void paintComponent(Graphics g) {
if(tempImage == null){
System.out.println("Balls");
g.drawRect(10, 10, 10, 10);
g.drawImage(tempImage,0,0,null);
super.paintComponent(g);
System.out.println("Did it work");
add(mainPanel);
private void makeKeyBindings()
mainPanel.setFocusable(true);
//Key bindings... don't like using a string to index, find out if there's a better way.
mainPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "exit");
mainPanel.getActionMap().put("exit", new AbstractAction(){
public void actionPerformed(ActionEvent e)
master.quit();
/*private void chooseBufferSrategy()
private void setFullScreen()
GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().setFullScreenWindow(this);
}
eggguns wrote:
Ok I'm trying to put an image in a full screen JPanel, why isn't it working?This is not the Swing forum. Please repost your question into the Swing forum.
And this is probably too much code as well.
Similar Messages
-
CapturingCanvas3d not showing Image in JPanel
Hello guys
I m having problem showing image on a panel which has capturingCanvas3d in it. If I add this canvas to a JFrame then it shows otherwise it displays just blank.
I hope you people to solve my problem.
Regards
Qasim Alieggguns wrote:
Ok I'm trying to put an image in a full screen JPanel, why isn't it working?This is not the Swing forum. Please repost your question into the Swing forum.
And this is probably too much code as well. -
Problem of showing image in opera
hi,
I have used following code for for showing image with jsp:
<img src="<%=image%>"> height="100" width="100">When i open this with Internet Explorer then it can show image. But whwn open it in Opera then it cannot show images. What's the problem of my code? What will be solution of this problem? IS there anybody can help me? PLese give me a solution
With regards
BinaDid you bother to override getPreferredSize(), getMinimumSize() and getMaximumSize() to return sizes appropriate for the image you're drawing? If you didn't and you're not adding anything to the JPanel it's just going to act like an empty JPanel.
-
Having trouble displaying image in JPanel
I want to display an image in jpanel making it to scale to the size of the panel.
And later i should be able to draw on that image , i am really new to all this , but i have to finish it soon.
This is the code i am compiling and getting error
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class LocaterClient extends JFrame
JPanel panel;
public LocaterClient()
super("LocaterClient");
panel = new JPanel();
panel.setSize(374,378);
panel.setOpaque(false);
panel.setVisible(true);
getContentPane().add(panel);
/*JFrame f = new JFrame();
f.setSize(374,378);
f.getContentPane().add(panel);*/
public void paintComponent(Graphics g)
super.paintComponent(g);
ImageIcon img = new ImageIcon("World_MER.jpg");
ImageIcon fillImage = new ImageIcon(img.getImage().getScaledInstance
(getWidth(), getHeight(),Image.SCALE_REPLICATE));
g.drawImage(fillImage.getImage(), 0,0, this);
public static void main(String args[])
LocaterClient lc = new LocaterClient();
lc.setDefaultCloseOperation( EXIT_ON_CLOSE );
lc.pack();
lc.setVisible(true);
This is the error i am getting
LocaterClient.java:24: cannot resolve symbol
symbol : method paintComponent (java.awt.Graphics)
location: class javax.swing.JFrame
super.paintComponent(g);
^
1 error
If i remove super.paintComponent(g); line it compiles and runs but i get a tiny panel without the image.
PLease help me , i am not evn sure is this is the procedure should i follow , because i should be able to draw on that image later on .
Please provide me with some sample code.import javax.swing.*;
import java.awt.*;
public class ImagePainter extends JPanel{
private Image img;
public ImagePainter(){
img = Toolkit.getDefaultToolkit().getImage("MyImage.gif");
public void paintComponent(Graphics g){
g.drawImage(img,0,0,getSize().width,getSize().height);
public static void main(String[]args){
JFrame frame = new JFrame();
frame.getContentPane.add(new ImagePainter());
frame.setSize(500,500);
frame.show(); -
Pop up a window to show images
Hi, I am trying to show images when the user rolls the mouse
over the image but I want to show them as a pop up window only when
the user is on the image.
Any ideas how can I handle this? I will have variety of
images and want the same behavior for all of them.mouseOver and mouseOut event functions for the images.
-
My mac will not show images when on the internet?
My mac will not show images when on the internet? I think I have inadvertently changed some settings but nor sure which one.
I am going to assume you are using Safari here. If so then go to the Apple menu bar and hit Safari-> Preferences. Under the Apperance tab there is a check box that is called "Display images when the page opens". Check if that is unticked.
-
How can i show images from different folders in image gallery
Hi All,
i have downloaded and executed photo viewer image gallery application.
in that we r showing images sequentially what we have defined in xml file.
but i want show images randomly or i want show images from different gallary.
Can any one help me.
thanks
Raghu.WaqarLFC7 wrote:
On Windows:
Ctrl + click on the songs you want to group - then right click and click get info and it will ask you if you want to get info for multiple items click YES then under album name it whatever you want and them songs will be grouped into 1 album.
Mac:
Same procedure but hit SHIFT instead of CTRL.
Actually, it's right click or ctrl click, same as windows. -
My iphone 4 only shows image to connect to itunes. It will not come up in itunes and does not appear to be connecting to my computer. I have attempted to restart my phone numerous times but it just keeps going back to this same screen. Please help.
Did you make a backup because you can't recover what's on our phone. Follow these steps to resotre your phone (the phone has to be plugged into your computer):
1) On your phone, press your sleep button for 2 seconds
2) After the two seconds, don't release the sleep and press the home button for 10 seconds
3) Release the sleep button and keep the home buttton pressed untill your computer detects your phone.
4) A window should pop up and you should have the restore button. Press it. -
CRS 10.1 with Endeca 3.1.1 -home page doesn't show image and promo products
Thanks to this forum and especially cmore I'm close to setting up my local dev environment, but still have something to resolve.
I have ATG 10.1.2 + CRS + Endeca 3.1.1. I installed BCC with Staging and Production (switchable) stores.
The problem is with Production CRS - both US Store and Home Store don't show image and promoted products on Home page.
What I see below Top Category pane is empty square. Unlike Production, home page on Stage works fine - I see homepage_promo_storeSiteUS_en_anonymous.png and promoted products.
I think the problem is not related to Endeca, as I currently connect both Stage and Prod to the same Endeca CRS, I also believe that issue is not related to configuration - I tried to run production with Stage configuration, and it changed nothing. I believe the issue is somewhere in data (DB) - but I did full deployment for Prod and it didn't help. I verified targeters and slots on Prod through ACC, and they looks fine. So don't know at this point what to do next.
While doing full deploy I see some errors in the log which might be related to the issue, But the same errors I see on Stage as well and still Stage works without issues:
10:17:41,805 ERROR [nucleusNamespace.] Invalid attempt to resolve component /atg/registry/Slots/HomeTheme in scope global. It is defined in scope request
10:17:41,811 ERROR [nucleusNamespace.] Invalid attempt to resolve component /atg/registry/Slots/PromotedProduct1 in scope global. It is defined in scope request
10:17:41,816 ERROR [nucleusNamespace.] Invalid attempt to resolve component /atg/registry/Slots/PromotedProduct2 in scope global. It is defined in scope request
10:17:41,819 ERROR [nucleusNamespace.] Invalid attempt to resolve component /atg/registry/Slots/PromotedProduct3 in scope global. It is defined in scope request
10:17:41,822 ERROR [nucleusNamespace.] Invalid attempt to resolve component /atg/registry/Slots/FeaturedProduct2 in scope global. It is defined in scope request
10:17:41,826 ERROR [nucleusNamespace.] Invalid attempt to resolve component /atg/registry/Slots/FeaturedProduct3 in scope global. It is defined in scope request
10:17:41,829 ERROR [nucleusNamespace.] Invalid attempt to resolve component /atg/registry/Slots/FeaturedProduct4 in scope global. It is defined in scope request
10:17:41,832 ERROR [nucleusNamespace.] Invalid attempt to resolve component /atg/registry/Slots/FeaturedProduct5 in scope global. It is defined in scope request
10:17:41,836 ERROR [nucleusNamespace.] Invalid attempt to resolve component /atg/registry/Slots/FeaturedProduct1 in scope global. It is defined in scope request
10:17:41,839 ERROR [nucleusNamespace.] Invalid attempt to resolve component /atg/registry/Slots/CategoryPromotionContent2 in scope global. It is defined in scope request
10:17:41,842 ERROR [nucleusNamespace.] Invalid attempt to resolve component /atg/registry/Slots/CategoryPromotionContent1 in scope global. It is defined in scope request
Last update: I compared Stage and Prod home pages HTML code, and notice that the first difference between two pages is absence of endeca-slot Div, the below code present on Stage, and is Not present on Prod:
It is the first difference only , there are a bunch more.
<div class="endeca-slot" zone="/content/Shared/Global Search Configuration/Search Box">
<script type="text/javascript">
if(Endeca.Site) {
Endeca.Site.Audit.contents["/content/Shared/Global Search Configuration/Search Box"] = [{"@type":"SearchBox","endeca.internal.created.by":"admin","rule.msg":"Fired","endeca.internal.last.modified.by":"admin","rule.msgcode":"13","rule.state":"fired","endeca.internal.resource.path":"\/sites-live\/NYCoCRS\/content\/Shared\/Global Search Configuration\/Search Box\/Search Box","endeca.internal.workflow.state":"ACTIVE","type":"DGraph.MerchDebug","Title":"Search Box","rule.id":"1","endeca.internal.last.modified":"2013-03-20T11:43","endeca.internal.date.created":"2013-03-20T11:43","Zone":"\/content\/Shared\/Global Search Configuration\/Search Box"}
</script>
Edited by: PKU on Apr 1, 2013 8:32 AM
Edited by: PKU on Apr 1, 2013 8:35 AMAfter some analysis and experiments:
Most likely the issue is with Scenarios. HomeTheme Slot is populated by Theme scenario.
For some reason the slot remains empty on "bad" environment. On "good" environment the slot contain promo content item after the first call of the slot. I checked respective targeter and promo content item, and they look OK, so I believe something wrong with Scenarios. -
How to show image in oracle adf if i have data in byte[] ?
For first time I am using <af:inputFile> to get file of image type from any location on my system and convert the data in "byte[]" and store it in database...
When i visit page again i need to show uploaded file which is coming to me "byte[ ] ".
To show image i am using <af:image> component.
Help will be appreciated.Check this blog post: http://tompeez.wordpress.com/2011/12/16/jdev11-1-2-1-0-handling-imagesfiles-in-adf-part-3/
Dario -
How to show image in a Transperent form ?? screen shots attached
Hi
Help me in making Images appearing as Transperent . Screen shots attached
I am having a TextInput and a Search Button (The Functionality is that user can enter something in this TextInput and makes a Search Operation by pressing Search Button .)
At the Initail screen display i need to show Some Image in transperent Inside this TextInput , when Mouse is focused on this TextInput , the Image will be completely Invisible .
Now the question i want to ask is , how to show image in a Transperent form ??
Please find the screen shots attached with this Thread .Thanks for specifying the alpha property of an Image .
-
Apache: showing images in ascending order by name
hi:
i have several detail pages where i show images contained in
a folder:
$folder = dir($path);
while ($folderEntry = $folder->read()){
if ($folderEntry <> "." && $folderEntry
<> ".." &&
substr($folderEntry, -6, 2) <> "00") {
echo '<li><img src="'.$path.$folderEntry.'"
/></li>';
$folder->close();
in the local server they appear in the way i want, in
ascending order by
name (img_01.jpg, img_02.jpg, img_03.jpg, ...) but in the
remote server
they appear in, apparently, random order
i activated FancyIndexing in the httpd.conf file but it
doesn't solved
the problem:
# Directives controlling the display of server-generated
directory
listings.
# FancyIndexing is whether you want fancy directory indexing
or
standard
IndexOptions FancyIndexing
# End of indexing directives.
i know i can store the filenames names in an array an sort it
but i
prefer to control it in the server
local (OS X 10.4.10)
Apache/1.3.33 (Darwin) PHP/5.1.6
remote (Red Hat Linux 2.6.9-34.ELsmp)
Apache/2.0.52
tia,
jdoeTempleton's suggestion is best if needing help with Microsoft Entourage. Since I know the answer is "not possible" I can at least steer you toward an AppleScript that will give you a workaround. Have a look here <http://www.barryw.net/weblog/files/category-5.html>.
Further questions about this script should be directed either to its author or to Microsoft's Entourage newsgroup <http://groups.google.com/group/microsoft.public.mac.office.entourage>.
Hope this helps! bill
1 GHz Powerbook G4 Mac OS X (10.4.9) -
Showing Image Stored In DataBase
Hello Friends,
I have images stored in MySQL database. In a blob field. In a desktop application i have used
blob b=rs.getBlob("Picture");
byte[] buf=b.getBytes((long)1,(int)b.length());
ImageIcon imgIcon= new ImageIcon(buf);
Image img=imgIcon.getImage();
Graphics g=image.getGraphics();
g.drawImage(img,0,0,320,240,image);
the thing worked fine. But now i have to show images over web. I am not able to uderstand that how to show images. As i m unable to get Graphics from any of the component.
Help Me,
Its urgent,
thanking u all
Abhilash JainThe common method to include binary information (image, PDF, document, etc) is to Base64 encode the file and store the resulting character string in the XML. It would be up to the receiving system to handle the encoded information in the XML.
-
How to make mouseover effect text show image in popup window or tooltip?
I am trying to display a popup image in a new window when the mouse moves over some text. Or perhaps, the image could display in a tooltip when the mouse moves over some text.
However, I have achieved the functionality of an image appearing above the text when the mouse moves over some text. This is how I did this:
I put this code into the Page HTML Header:
<script type="text/javascript">
<!--
function setFirstChildImgDisplay(el,vis) {
if(!el || !el.getElementsByTagName) return;
el.getElementsByTagName('img')[0].style.display=vis;
// -->
</script>
I created a region and put this in the Region's Title field:
{div onmouseover="setFirstChildImgDisplay(this,'inline')" onmouseout="setFirstChildImgDisplay(this,'none')">Check out Page 1 here <img src="#WORKSPACE_IMAGES#DGNR Preview Page 1.bmp" alt="Page 1 Preview" style="display:none;">{/div}
I am thinking that I should not have all of this code in the Region's Title field. But, I don't know where else to put it in APEX.
So my questions are:
1. how to get an image to display in a popup window or as a tooltip when the mouse is moved over some text?
2. where should the {div} content be placed in APEX, if not in the Title field?
Please note that I used '{' & '}' instead of '<' & '>' just so the div would display in this post.
Also, I would like to give credit to this website because this is where I found out how to do what I have provided above.
http://forums.devshed.com/web-design-help-2/mouseover-effect-text-shows-image-321876.html
Thank you in advance,
MaggieIt's just an image map. Play with the settings. Here's a shape layer making a hole in the water and adding a bit of color.
-
Hi
I want to show image in table based on the result i have a field status which contains the 01 / 02 / 03 values and now i want to show 3 images insted of value I have created one value attribute of string type and assigned the path of the image to it but its taking the image of last record only so can any one tell me what i have to do for this bellow is the code i am using
wdContext.currentContextElement().setImgXiStatus("");
if(xistatus.equals("01"))
wdContext.currentContextElement().setImgXiStatus("green.bmp");
else if(xistatus.equals("02"))
wdContext.currentContextElement().setImgXiStatus("yellow.bmp");
else if(xistatus.equals("03"))
wdContext.currentContextElement().setImgXiStatus("red.bmp");
else
wdContext.currentContextElement().setImgXiStatus("");
Thanks
Ninad1 - NODE_MY_TRNAS
1.1---NODEoutput
1.1.1---NODEetData
1.1.1.1---NODEimageNodeHelper
1.1.1.1.1---icon
Set singleton = false for node "NODEimageNodeHelper" and selection(NODEimageNodeHelper) = 1:1.
Assuming card(NODEetData) =0:N, you can set the icon for row number i as follows:
INODEetDataElement e = wdContext.nodeNODEetData().getNODEetDataElementAt(i);
e.nodeNODEimageNodeHelper().currentNODEimageNodeHelperElement().setIcon("icon.gif");
For naming nodes, the following rule is useful: Name in camel-case, first letter uppercase, for cardinality =0:N, use plural name.
Example:
Node "Books" (node, card=0:N) leads to IBooksNode, IBooksElement interfaces.
Armin
Maybe you are looking for
-
Not able to view data in Aria People search Org Chart
Hi, I have uploaded my data into aria_tmp_people, aria_people_a & aria_people_b. While doing the search from Aria poeple, the uploaded data is not displaying in org chart. Your help is highly appreciated. Thanks Aneesh
-
I am receiving this error with the following code, which counts the number of work days between two parameters and I don't see the problem. Please help. Public Function GetDateCount(ByVal StartDate AS DateTime, ByVal EndDate AS DateTime) AS Integer
-
Addition of new field in the qa32 transaction
HI, I have to add a new field in qa32 transaction.which is AFNAM in the alv output,for a given purchase document i have to display the requested by field,could any body tell me how to do it. Regards Abhinay
-
This html code only plays midi file in IE, not Safari - why?
<html> <title>New York</title> <bgsound src="http://home.earthlink.net/~maugustine2/daydream/bachair.mid" loop="0"> <body bgcolor="#CCCC98"> </html> With this code, the midi file: bachair.mid will only play with IE 5.2/mac, not Safari 2.0.1 / 10.4.2
-
Moving Wrong Offerings and Classes to the correct Catalogues
The user have spend the whole day entering Catalogues, Offerings, and Classes. Unfortunately most of the Offerings and Classes were entered under the wrong Catalogue. (Don't ask me how they did it, but they did...lol). Now the user wants to copy/move