Set Background image to JScrollPane --- Need Help!!
Hi all;
How can i set a Background Image to this JScrollPane?
JLabel imageLabel;
JScrollPane jsp = new JScrollPane(imageLabel);
Pls need your sugessions...
Thanking in advance
Madumm
I included a complete code listing of a functional example. The main problem with wha tI shared earlier was that I did it quickly in Groovy, where everything is an object. When I called layeredPane.add(xxx, 4) - the number 4 was an object - whereas in Java it is not - this called the wrong function so that the label would not appear... ok - here is the code... run this with your own image and then modify it to do what you need...
import java.awt.Dimension;
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JLayeredPane;
import javax.swing.JScrollPane;
public class BackgroundImageExample {
public static void main(String[] args) {
try {
//Load Image
String filename = "/home/dlpinto/Desktop/Screenshot.png";
BufferedImage image = ImageIO.read(new File(filename));
//Create Image Label
JLabel label = new JLabel(new ImageIcon(image));
label.setBounds(0, 0, image.getWidth(), image.getHeight());
//Create Layered Pane
JLayeredPane layeredPane = new JLayeredPane();
layeredPane.setLayout(null);
layeredPane.setPreferredSize(new Dimension(image.getWidth(), image.getHeight()));
//Create Desired Components
JLabel messageLabel = new JLabel("Hello World");
messageLabel.setOpaque(true);
messageLabel.setBounds(50, 50, 100, 100);
//Populate Layered Pane
layeredPane.add(label, new Integer(JLayeredPane.DEFAULT_LAYER-1));
layeredPane.add(messageLabel, JLayeredPane.DEFAULT_LAYER);
//Create ScrollPane
JScrollPane sp = new JScrollPane(layeredPane);
//Create & Display Frame
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(800, 600);
frame.add(sp);
frame.setVisible(true);
System.out.println(layeredPane.getLayer(messageLabel));
System.out.println(layeredPane.getLayer(label));
} catch (Exception e) {
e.printStackTrace();
}
Similar Messages
-
I need to set background image in interactive forms. How it is possible ple
Hi,
I need to set background image in interactive forms. How it is possible please explain it step by step.
Regards,
Gurprit BhatiaHey Gurprit,
All you need to do is:
1. drag and drop the Image object from the Library -> Standard tab
2. select the image you want to use
3. position the image on the form where you want
4. right click the image and say "Send to Back"
That should be it!!
Cheers,
Kevin -
Setting background image for repeating frame in .pdf report
Is it possible to set a background image for a repeating frame, and more specifically for a repeating frame rendered in .pdf?
I do not see any standard property in the navigator for images of any sort and the documentation touches only on setting background images for graphs, which is not the intent in my case. I -did- add an HTML table property background="myimage.jpg" but the report is ultimately generated in .pdf format and I was not surprised to see that the image was not rendered.
Does anyone know if setting a background image as described is even possible, and if so, how? A second but less optimum solution would be setting the image as the background for all report pages, again in .pdf.
Many thanks.Hi Raj,
Yes you can have an image in the background. Thats possible if you are using XML forms as an iview or ivew dev in WebDynpro...
Also check this [link|regarding background color change in iview]
Regards,
Piyush
Reward points if this helps!!! -
How to set background image in a cell?
I am trying somethign that seems tricky to me...
The image I am using I faded to a solid color on the bottom
half. I set the background image to to left and NO REPEAT but when
the cell grows with content and it stretched beyond the image it
goes blank underneath. How do I set a background color without
going over the background image?
I need them both to be background because I want to use text
over both.
Any ideaS?Color goes UNDER the background image. Just set it.
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com
- Template Triage!
http://www.projectseven.com/go
- DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs,
Tutorials & Resources
http://www.macromedia.com/support/search/
- Macromedia (MM) Technotes
==================
"StarPilot06" <[email protected]> wrote in
message
news:eqqve6$341$[email protected]..
>I am trying somethign that seems tricky to me...
>
> The image I am using I faded to a solid color on the
bottom half. I set
> the
> background image to to left and NO REPEAT but when the
cell grows with
> content
> and it stretched beyond the image it goes blank
underneath. How do I set
> a
> background color without going over the background
image?
>
> I need them both to be background because I want to use
text over both.
>
> Any ideaS?
> -
Flex4 How to set background image in Vgroup..?
Hi.,
I have using v flex 4 vgroup to set background image., but image was not display.. any change my code.,
<fx:Style>
.backgroundImage
color:#808080;
fontWeight:bold;
fontSize:18;
fontStyle:italic;
contentBackgroundColor : #FFFFFF ;
backgroundImage:Embed("assets/Green Apple.jpeg");
</fx:Style>
<s:VGroup paddingBottom="10" width="100%" height="600" paddingTop="10" styleName="backgroundImage">
<s:Label text="hai hai hai">
</s:Label>
</s:VGroup>
any solution to solve this....
With Regards.,
LinFlex-@Peter
Yes! This works well now. Now I can get repeating background images directly in the code as well as in my CSS style sheets. This looks good and helps me a lot as there are lots of occasions for me using this. I've gotten used to having repeating image backgrounds in HTML and missed that in Flex 3. This feature alone makes moving to Flex 4 worthwhile.
This works fine for me:
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<!--make a background for the whole page -->
<s:BorderContainer width="100%" height="100%"
backgroundImage="@Embed('images/bkg/grey_grid.gif')"
backgroundImageFillMode="repeat" >
<!--make an inner area with a graphic background -->
<s:BitmapImage id="legalPad"
source="@Embed('images/bkg/legalPad.gif')"
fillMode="repeat"
left="40" top="100"
width="825" height="200" />
</s:BorderContainer>
</s:Application>
Here are the images I used:
grey_grid.gif
legalPad.gif -
How to set background image in Dynamic Shell Layout
Experts,
Using dynamic shell layout, how can we create a skin like this http://www.2shared.com/photo/OqXfb5jq/layoutissue.html
Issues :
1)Need to set the background to the page - How to set it in dynamic shell layout.
2)Panel box color to be changed
please advice
thnks
jdev 11.1.2.1Color goes UNDER the background image. Just set it.
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com
- Template Triage!
http://www.projectseven.com/go
- DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs,
Tutorials & Resources
http://www.macromedia.com/support/search/
- Macromedia (MM) Technotes
==================
"StarPilot06" <[email protected]> wrote in
message
news:eqqve6$341$[email protected]..
>I am trying somethign that seems tricky to me...
>
> The image I am using I faded to a solid color on the
bottom half. I set
> the
> background image to to left and NO REPEAT but when the
cell grows with
> content
> and it stretched beyond the image it goes blank
underneath. How do I set
> a
> background color without going over the background
image?
>
> I need them both to be background because I want to use
text over both.
>
> Any ideaS?
> -
Flex 4 Mdi canvass, how to set background image..?
Hi.,
Now i try to use mdi canvass background image,how to set background image in mdi canvass in flex 4..
With Regards
LinFlex-In the past flex 3 version, there is an attribute call <flexlib:MDICanvas backgroundImage="@Embed(source='/imgFolder/imgFile.png')/>
to set it. However it has problem in Flex 4 because of 'halo' and 'spark' theme library changed.
The following is my post that still haven't found the answer.
Dear all,
We have a project that doing migration from flex 3 to flex 4. We use flexlib the latest version of
flexlib - 2.5 - flex4.zip.
However we confronted problems that several of attributes that flex 4 doesn't support:
Constraints are listed as follows:
1) <flexlib:MDICanvas backgroundImage="@Embed(source='/imgFolder/imgFile.png')/>
2) <flexlib:MDICanvas backgroundSize="auto"/>
3) <mx:ApplicationControlBar barColor="#000000">
original error message:
====================================================
Description Resource Path Location Type
The style 'backgroundImage' is only supported by type 'flexlib.mdi.containers.MDICanvas' with the theme(s) 'halo'. MainView.mxml /osss/flex_src/hk/gov/labour/osss/view line 242 Flex Problem
Description Resource Path Location Type
The style 'backgroundSize' is only supported by type 'flexlib.mdi.containers.MDICanvas' with the theme(s) 'halo'. MainView.mxml /osss/flex_src/hk/gov/labour/osss/view line 242 Flex Problem
Description Resource Path Location Type
The style 'barColor' is only supported by type 'mx.containers.ApplicationControlBar' with the theme(s) 'halo'. MainView.mxml /osss/flex_src/hk/gov/labour/osss/view line 227 Flex Problem
Regards,
Man Pak Hong, Dave
manpakhong
[email protected] -
Hi,
i am new Developer in iphone,i want to ask very basic Question, i install iphone SDK 3.1 and using snow leopard 10.6
how to set Background image in iphone sdk 3.1,Sure, search the forum, this question has been asked and answered weekly. Keywords like "background image" taken from your subject line would be a good place to start. So its really not that difficult to think up search words now is it.
-
I would like to remove a short gray edge from two images. I need help in that I am not yet able to use PhotoShop. Could somebody kindly help me with this?
I doubt it Doc Maik, but I am certainly happy to learn The image is this one (and a similar one). They would be beautiful portraits if not for the "extra mouth". The grey edge that I would like to remove is the excess of (grey) mouth that is actually my horse's chin, but that in the pictures looks like a wider, looping mouth. Practically, looking at the picture, the "extra mouth" to the left. What I would love it to be able correct that to look like a normal mouth, which means that half of the protruding edge should be removed. I am not sure I was able to explain myself, but here is one of the two pictures. I thank you for you kindness in being available to advise me.
-
SETTING BACKGROUND IMAGE IN SAPSCRIPT
HI,
CAN U TELL ME HOW TO SET BACKGROUND IMAGE IN SAPSCRIPT.
REGARDS,
SANJAY.Hi Sanjay,
You can use transaction SE78 to inmport graphics to SAP.In the form painter, you can either include directly to the form using
Edit->Graphic->Create or using the INCLUDE statement in a window.
To use an INCLUDE stanment, goto the window script editor and use menu Include->Graphic. The include can look like this for a bitmap:
/: BITMAP MYLOGO OBJECT GRAPHICS ID BMAP TYPE BMON -
Setting background image in JFrame
Witam,
Jak mozna ustawic tlo w postaci grafiki (png, jpg, ...) dla jFrame? Znalalem juz kilka sposobow ale one uzywaja jPanel, ktorego ja NIE moge uzyc ... niestety. Jesli nie ma takiej mozliwosci dla jFrame to moze tez byc dla jScrollPane, JComponent, Scene albo LayerWidget;)
Hi,
Is it possoble to use image as a background for jFrame? I know that it is possible to use jPanel and ser background image for jPanel, but in my project I cannot use it. Instead I can use jFrame, jScrollPane, Scene or LayerWidget.:)In the future, Swing related questions should be posted in the Swing forum.
But there is already no need to post in the Swing forum because you already know the answer:
I know that it is possible to use jPanel and ser background image for jPanel,
If you need further help then you need to create a "Short, Self Contained, Compilable and Executable, Example Program (SSCCE)", that demonstrates the incorrect behaviour.
http://homepage1.nifty.com/algafield/sscce.html
Don't forget to use the "Code Formatting Tags", so the posted code retains its original formatting.
http://forum.java.sun.com/help.jspa?sec=formatting -
Problem in setting background Image to TabedPane.
Hi Pals,
I created a JFrame which consist of some components. The structure of the added components are given below.
1) I added a JPanel (MainPanel) with background image in a JFrame.
2) I added a JTabbedPane with 7 tabs in the previous JPanel (MainPanel).
3) Each tabs in the JTabbedPane having JPanel with Background Image.
This is my Frame Structure. but i haven't problem to run in JDK1.6,1.5. It is working perfect. But when am run in lower version like 1.3 or 1.4. The design is looking bad. The JTabbedPane overlap the (MainPanel). The background image of the (MainPanel) was hided. I set setOpaque(false) for the JTabbedPane. But it also not working. How can i solve this problem.
By,
MohanYour problems appear to stem from your choice of layout manager(s). To get better help sooner, post a [_Short, Self Contained, Compilable and Executable, Example Program (SSCCE)_|http://mindprod.com/jgloss/sscce.html] that clearly demonstrates your problem.
To post code, use the code tags -- [code]Your Code[/code] will display asYour CodeOr use the code button above the editing area and paste your code between the {code}{code} tags it generates.
db -
Set background image in the Interface builder
Hi,
Is there a way to set a background image for a View controller through the Interface builder? I'm using story boards.
If not please tell me how to do that programatically. I need to set this background image for all my UIs.
ThanksRemember that the client is running from a browser. You need to have the file be available to the browser and that means having it be served by the web server. Place the image file in a directory available to the web server and map that directory to a virtual web server directory and specify it with a url relative to the web server root: /images/your_image.gif
-
CSS in tables - background and paragraphs [was: need help]
Hi there,
I'm using Dreamweaver CS3 and i'm trying to add a background image to a cell. I'm using CSS which works, but that also adds parts of the background to other cells. The only way i can do it sucessfully is by going "properties" then "bg", but i would rather use CSS because i want my page valid with W3C. Is there an easy way to do this?
I also have a problem with paragraph spacing. If i align text to the top of a cell with paragraphs, the area above the whole text moves down one line in a broswer, if i have no paragraphs then it will look exactly the same as in dreamweaver. Is this normal or is there anyway to prevent it happening?.
Any help is much appreciated, thanks.Paragraphs have a default top margin. You need to remove or adjust the margin with your CSS:
td p {
margin-top: 0;
Awesome! Worked right away, this has been driving me nuts for ages, thanks a lot.
In code view, you can use CSS to style a single table cell like so.
HTML:
<table>
<tr>
<td style="background: url(some_image.jpg) no-repeat">
styled table cell here here </td>
<td>unstyled table cell here </td>
</tr>
</table>
I'm not too sure where to place this code, what does "styled and unstyled table cell" mean?
I'm not that great when it comes to codes, any help would be grealty appreciated, thanks. -
How to set background image in jlist
Hi all
is there a way for setting an image as jlist 's background?
I need that this image is trasparent.
Any idea or usefull link?
RegardsSwing related questions should be posted in the Swing forum, but there is no need to repost since all the information is available to you in the forum or the API.
First, read the JList API and follow the link to the Swing tutorial on "How to Use Lists". It will show you how to create a custom renderer. You will need by make your renderer non-opaque to see the background image.
Next you can search the Swing forum for examples of how to add an image as a background image. Most of the examples are for a JPanel, but the concept is the same.
Maybe you are looking for
-
Why is the install button different?
HI, recently I uninstalled an app and wanted to reinstall it. When I went to the App Store on my iPhone, that app did not have the 'Free' button which u click to download it, but rather a small button with a picture of acloud on it. What does this me
-
Hello, Am researching a way for validating SQL expressions. Say I have expressions substr(<tname.coumn_name>,1,2), I want to parse this expression for completeness, meaning whether the expression can be used in a case, decode or a normal select state
-
Hi- I'm stressing with AS3, I found an awesome tutorial to create a blur button but I can't figure out how to make it go to and play consistantly. Can anyone help? Here is the link. A sample code would be ideal. Thanks in advance. http://flashexplain
-
Unable to view in external monitor...
...tried "REFRESH AV DEVICES" and "VIEW> ALL FRAMES" and monitor set to AV in but no images from timeline, all connections are checked okay. Video is standard dv 16:9. Anybody have ideas?. Thanks
-
Hi, I need to call a servlet directly without getting authenticated. The reason I need the session is because I'm using profile APIs. The method I'm trying out is using login and goto. In the user servlets, I get a session exception ( Invalid Service