Sitemap

Amicuk Programming Answers

Two problems with displaying images in JPanel

2015-10-11   Views:0

Advertisement

Hi, I need to display some small rectangular images inside a JPanel. These images also need to be componenents as they will have listeners associated with them. I have never had any experience with images, so I might totally be down the wrong path. I

Hi,
I need to display some small rectangular images inside a JPanel. These images also need to be componenents as they will have listeners associated with them. I have never had any experience with images, so I might totally be down the wrong path. I was thinking of just creating a class which extends JComponent, and using the graphics drawImage method. However, I don't want each image component to have to know exactly where to draw the image associated with itself. Rather, I want the JPanel which holds all of the images to know how to lay them out.
Is there an easier way to use images?
Which brings me to my second problem. I want these images to overlap each other, so that only a small portion of each is showing (this way I can fit more on the screen), then when the user clicks on one, I can show more of it.
Unfortunately, I don't know of any layout managers which will allow me to overlap components. I could use the drawImage method mentioned above, but like I said, I would like to try to not have each image object try and figure out its location.
any help is greatly appreciated. Thanks!

The replay answer
Advertisement
Hi
there is a better way ; it is called a JLabel ;-)
JLabel myJLabel = new JLabel(new ImageIcon("img/myLogo.gif"));for your second problem, don't use any layout manager like in this code :
myJPanel.setLayout(null);
myJPanel.add(myJLabel);
myJLabel.setBounds(new Rectangle(x, y, width, height);hope it helps
Nico

Go to See the other 4 answers

Two problems with displaying images in JPanel

Category:DefaultRelease time:2015-10-11Views:130

Hi, I need to display some small rectangular images inside a JPanel. These images also need to be componenents as they will have listeners associated with them. I have never had any experience with images, so I might totally be down the wrong path. I[More]

Help Please, Problem in displaying same  JTables on two JPanels

Category:DefaultRelease time:-0001-11-30Views:130

Problem in displaying same JTables on two JPanels. In an application, I have a dynamic display of JTables on one JPanel. After a print preview button action, I have to bring same JTables on another JPanels, while taking this the previous JPanels cont[More]

Problem with display of JScrollPane

Category:DefaultRelease time:2015-10-11Views:130

I have made a small GUI. It has a JFrame and four JPanels are added to the frame. The placement is done by program and hence layout manager is set to null. Two of the panels contain JScrollPane. One scroll pane is associated with a JList. Another scr[More]

Need to display image on JPanel

Category:DefaultRelease time:-0001-11-30Views:130

Hello I am trying to implement a graphical version of the Knights Tour. I am done with the algorithm part of the problem itself. I am having problem with displaying the chess board. Although seemingly straightforward the images will not display on th[More]

Problem in displaying the TaxRate columns .

Category:DefaultRelease time:2015-10-11Views:130

Hi Experts,                         I am having a problem in displaying the 'TaxRate', in this Query there are some different Taxrate's columns  like-  ' 'Basic Excise Duty [email protected] %',  ' Education [email protected]% ' , 'Secondary Education Cess @1%',    etc.  [More]

Problem with displaying BLOB images on JSP page using a servlet

Category:DefaultRelease time:2015-10-11Views:130

hi. I have a big problem with displaying BLOB images using JSP. I have a servlet that connects to the oracle database, gets a BLOB image , reads it, and then displays it using a BinaryStream. The problem is , this works only when i directly call that[More]

Problem with display of Buttons in ADF

Category:DefaultRelease time:2015-10-11Views:130

Hi All, I had a strange problem in display of the ADF Page in one of the server.I had two buttons inside ToolBars, The UI was coming fine in the two WLS, But when I deployed the application in third WLS, I was seeing that Buttons are coming in the to[More]

Problem with display driver

Category:DefaultRelease time:2015-10-11Views:130

Hello, Im using Photoshop CC and when it starts up it sometimes gives me this error message: 'Problem with display driver and has temporary disabled enhancements which use graphics hardware.' What does this mean? Then it tells me to download the lats[More]

I have a early 2011 Macbook pro 13 inch, I'm running Lion 10.7.4, and i want to upgrade to 10.8 Mountain Lion. Is it safe for my computer or are people experiencing problems with displays and Battery life?

Category:DefaultRelease time:2015-10-11Views:130

I have a early 2011 Macbook pro 13 inch, I'm running Lion 10.7.4, and i want to upgrade to 10.8 Mountain Lion. Is it safe for my computer or are people experiencing problems with displays and Battery life? Do Not post stuff about how Airplay doesnt w[More]

Authorization problem when displaying icons in BW Report

Category:DefaultRelease time:2015-10-11Views:130

Hi All I have the following problem when display BW Report as iView: The report data itself is displayed perfectly but to display the icons (like DrillDown arrows, Hierarhy level open arrows) the Windows login message "Connect to <my BW server.com[More]

Problem to display a negative number in XML Publisher output in excel

Category:DefaultRelease time:2015-10-11Views:130

Hi All, I am facing problem in displaying a negative number in XML Publisher output in excel. My requirement is that I have to display a negative number in brackets when the output is taken in excel format. Eg: If the value is -123 then i have to dis[More]

Hot
Trying to install Itunes 10.5 update onto my netbook running windows xp and it keeps telling me it can't continue the update due to missing something from the windows installer package. My installer package is the latest I can find which is 4.5 from [More]
My iPad screen is green, this is the second time in two months. Do I need to take it back. I've had it 9 months?There is no need to bang or drop the iPad!!  Read this solution.  Read the whole thing. If your iPad is still under warranty, I have heard [More]
HI Experts, One of my employee could nt able to view his total compensation statement through ESS  portal.It is showing only blank. I have checked the integration PCOMP  SFTCS in T77S0 table and is with  ZHR_CM_TCS. What could be the reasons for  sho [More]
I'm running an applet in a side frame in Netscape 4.04 browser. When I kick the HTML page off with the browser closed, the applet appears to start twice, with both running concurrently. This causes it to fall over because both try to write to the sam [More]
Hello all... I seemed to have done something very bad to my iMac.  When I start it up 3 images flash repeatedly and there is no way for me to start any work on my computer.  The 3 images that flash are the apple logo, a prohibited symbol, and the fil [More]
Trying to convert PDF file and keep getting the error signPlease try updating the Reader. Go to Help -> check for updates. Regards, AnoopRead other 2 answers [More]
I've to send a big file (about 150 Mb) to a friend of mine abroad, I've a bradband and him too. What's the best way? It does exist a good program or another way? Thank you.Hi, Valerio - Here is a good, free way to send large files: http://www.yousend [More]
IPOD 5 Touch is not taking a charge.  It shows a picture of a lightning bolt and above that a picture of a battery at the end of the battery is a slim red line.  This was purchased in August 2013.  Could it be battery or ac charger adapter or usb cab [More]
Hi, I've recently rebuilt my old Mac Pro onto this new early 2008 Mac Pro. (By rebuild I mean, wipe, reinstall everything). I have a RAID 0 across two 500Gb drives. Lately I've noticed the irregular crashing of applications. Looking at the Console lo [More]
I backed up my iPad on my laptop with iTunes.  I want to remove and re-install  iTunes.  How do I preserve the backup for use after I re-install iTunes?The device backups and iTunes library should be unaffected by uninstalling and reinstalling iTunes [More]