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
This is my first mac and the **** hard drive crashed in only 2+ years and of course the waranty is expired.  Can I replace the hard drive with any 3.5" replacement or do I need something special.  And if I do where can I get it?  I didn't see anythin [More]
so i have my iphone4 (white one) just last month (8/31) well, the camera works fine until few days ago when i take pictures, the screen suddenly has a blue line on it, the line is like a really tiny blue line thats stay vertically, and its 1cm away f [More]
working on a new website .I want to cut and paste information from microsoft. firefox is not letting me.How is Firefox involved in "microsoft word to another application"?Read other 2 answers [More]
I need to define deadline for all interactive activities. However, I do not want to add due transitions or Connector to every interactive activity. How to set the activity deadline without due transitions? Or, I add a due transition / deadline to all [More]
My iPhone 4 has appearantly a glitch in hardware...??? I turn on bluetooth and it can search for devices till the battery runs out and that's it. I don't think that this is a software error, as there are plenty of iP4's amongst my friends who don't e [More]
Hi guys, I just submitted a bug report for an issue I have come across in the XI versions of Adobe Reader. The problem appears when a form is embedded in a webpage using either iframe or object tag. When the form is loaded the focus is set to the fir [More]
All I need is a manual for MS-6378. Can anyone please help. I tried to replace motherboard, but did not work properly. Now I need to jumper settings and where to plug power switch.MS-6378 Manual, drivers, BIOS, and any other downloads simply a click [More]
I have a Canon BJC-55 printer that is currently connected to my MacBook Pro running OS 10.5.1, I can print anything in black with the gutenprint driver supplied with the installation of Leopard. However, I am unable to get it to print any colors. Doe [More]
Hi all, We are not able to invoke ALSB proxy service from BPEL ? Please help me on this issue. Thanks & Regards, Bharathy.Can u make me clear , how to use business service in OSB pipeline ?http://download.oracle.com/docs/cd/E13159_01/osb/docs10gr3/co [More]
I bought a N97 in Hong Kong about 2 weeks ago. After one week the touch screen stopped to works. There is also a quite big white spot mark on the inside of the screen. After working with electronics and mechatronics (mechatronic) the last 30 years, a [More]