No success in placing background image in JComboBox drop-down!
Hi All! I have an urgent proble, which I was not able to resolve a full day and a half long!!! I want to place a background image in the dropdown (JPopupMenu) of a JComboBox. Not behind the Menu Items (I know how to do that), but behind the popup itself (the items will have a transparent background). I was surprised to find out that I cannot achieve this via UI delegates (seems paint takes place in JComponent), nor with simply subclassing JPopupMenu (because after I draw the image it is overwritten by a background rectangle). I beleive this is not an easy thing to acheive, but I would accept a complicated solution as well.
Can anyone help me?
Thanks, in advance!
Try this for ideas. Change the filename to a valid image file on your machine.import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.InputEvent;
import java.awt.event.MouseEvent;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.DefaultListCellRenderer;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.SwingUtilities;
import javax.swing.plaf.basic.BasicComboPopup;
import javax.swing.plaf.basic.ComboPopup;
import javax.swing.plaf.metal.MetalComboBoxUI;
public class PictureCombo {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
new PictureCombo().makeUI();
public void makeUI() {
Object[] data = {"One", "Two", "Three", "Four", "Five"};
JComboBox comboBox = new JComboBox(data);
comboBox.setUI(new PictureComboBoxUI());
comboBox.setRenderer(new PictureListCellRenderer());
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(comboBox);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
class PictureComboBoxUI extends MetalComboBoxUI {
@Override
protected ComboPopup createPopup() {
return new PictureComboPopup(comboBox);
class PictureComboPopup extends BasicComboPopup {
Image image;
public PictureComboPopup(JComboBox comboBox) {
super(comboBox);
try {
image = ImageIO.read(new File("E:/Java/test.jpg"));
} catch (IOException ex) {
ex.printStackTrace();
@Override
protected JList createList() {
JList retVal = new JList(comboBox.getModel()) {
@Override
public void processMouseEvent(MouseEvent e) {
if (e.isControlDown()) {
e = new MouseEvent((Component) e.getSource(), e.getID(), e.
getWhen(),
e.getModifiers() ^ InputEvent.CTRL_MASK,
e.getX(), e.getY(),
e.getXOnScreen(), e.getYOnScreen(),
e.getClickCount(),
e.isPopupTrigger(),
MouseEvent.NOBUTTON);
super.processMouseEvent(e);
@Override
protected void paintComponent(Graphics g) {
if (image != null) {
g.drawImage(image, 0, 0, comboBox);
super.paintComponent(g);
retVal.setOpaque(false);
return retVal;
class PictureListCellRenderer extends DefaultListCellRenderer {
@Override
public Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected,
cellHasFocus);
Color selBgColor = list.getSelectionBackground();
selBgColor = new Color(selBgColor.getRGB() & 0xA0FFFFFF, true);
setBackground(selBgColor);
setOpaque(isSelected);
return this;
}db
Similar Messages
-
Displaying something other than a list in a JComboBox drop down section
Dear all,
i'd like to be able to put a JTree into a JComboBox drop down section, or at least appear to have done this. has anyone done this or have an idea how this might be achieved?
Cheers,
MattSounds like a job for a custom renderer. The JTree tutorial shows an example of one.
-
JComboBox drop down list border color
When we click arrow button of JComboBox we get drop down list with black colored border.
But I want to set border of dropdown list to grey color.
How to do that?The required border size and color is mentioned in javax.swing.plaf.basic.BasicComboPopup instantiated in javax.swing.plaf.basic.BasicComboBoxUI; and unfortunately that is not directly accessible.
One of the approach would be:
1. subclass BasicComboPopup - here you'll simply set the derived class's border to desired one.
2. subclass BasicComboBoxUI - here you'll override createPopup (to return derived BasicComboPopup object) and createUI (to return derived BasicComboBoxUI object)
3. make a call to target JComboBox's setUI to set new instance of derived BasicComboBoxUI object.
Caution:
1. This approach will be implementation specific, for more generalized result try creating your own look and feel.
2. May need to tweek some more code to get final output. -
How do I put a different image in my drop down menu for my current page?
Is there a way to put different images or color for each
buttons in my menubar? And is there a way to have a color to
identify the current page in my bar?
Thanks for your time and have a nice day!quote:
Originally posted by:
JM1978
khfinity
We are looking for "how to do it" answers, instead of "how it
looks like". You have been posting the same link multiple times on
this forum to others, however, it does not answer any of their
questions.
If you do not bother to post something useful, the don't
waste our time to see your posts!
Actually what I posted came after searching for an easy
"how to do it". The closest I found to a tutorial was this:
http://www.adobe.com/devnet/dreamweaver/articles/spryte_menu.html
The author designs and implements a spry menu with Fire Works
graphics. The last section describes how to modify the existing CSS
for multiple levels. Yet I found the sample page provided above,
easier to follow than the tutorial.
I'm sorry if you feel my post was not
"something useful", and I hope you find the mentioned
tutorial useful. -
Using a different background for the drop down options in a spry menu bar
Hi all,
I am trying to set just a background color in the drop down menu, I have a background image repeated along the x asis at the top but this has come down into the sub menu bar how can I change just the lower drop down menu to just a solid color??
I have tryed google and youtube to try to find a answer but have had no luck in finding the solution to this problem.Give a man a fish, you feed him for a day. Teach a man to fish, he eats every day…
winabe23, you joined this month—probably because you were having trouble with CSS and HTML and you have certainly come to the right place.
I'm going to send you to several places I have found helpful in understanding how you can make drop-down menus in CSS without the need for JavaScript—though JS may be necessary for certain older browsers that do not understand pseudo classes and may be necessary for the blind or keyboard navigation.
CSS Wizardry has a great tutorial here.
Line25 has one here.
For those who don't want to have to wrangle code, here is a menu generator from PureCSSMenu.
Here's a page by Eric Meyer who describes how the concept works.
And here is a video tutorial by "zorro30mum." It's in two parts, but there is a link to Part 2 below Part 1.
The reason why I am posting all of these links in my answer is because you're using Spry. And Spry has been found wanting by Adobe and they are deprecating and abandoning it.
The Spry framework is an open source Ajax framework that Adobe developed. Ajax stands for Asynchronous JavaScript And XML. On August 29th 2012, Adobe handed over Spry to github. If you want to help github develop Spry, there is a site for that, but I'm thinking you're not a JavaScript developer.
I would recommend you pay a little more attention and time to Ajax, which is not deprecated and not discontinued. It allows you to do client-side triggers for server-side code. But that's if you want to do work in JavaScript, XML and a server-side language, like Cold Fusion, php or ASP.
But in the meantime, the tutorials above will get you into understanding how this whole menuing stuff is done in CSS and give you the understanding necessary to do simple stuff, like changing the color of a background for a drop-down.
I hope this helps you make great websites!
-Mark -
Problem placing buttons on top of a background image
My knowledge of Java isn't the greatest and I am currently having problems placing buttons on top of a background image within a JApplet (this is also my first encounter with Applets).
I'm using a Card Layout in order to display a series of different screens upon request.
The first card is used as a Splash Screen which is displayed for 5 seconds before changing to the Main Menu card.
When the Main Menu card is called the background image is not shown but the button is.
While the Applet is running no errors are shown in the console.
Full source code can be seen below;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.net.*;
// First extend JApplet
public class WOT extends JApplet {
//--------------- Variables are declared here -----------------
private CardLayout contentCardLayout = new CardLayout(); // declare CardLayout
private Container contentContain; // declare content Container
private JPanel contentCard, splashScreen, mainMenu, menuImage; // declare content Panels
private JLabel splash, menu, map; // declare image labels
private ImageIcon mapBtn; // declare ImageIcons
private JButton mapOption; // declare option Buttons
private Timer timer; // declare Timer
private ActionListener actionListener, mapOptionListener; // declare ActionListener
//--------------- Initialise Applet -----------------
public void init() {
//--------------- Set-up Card Layout -----------------
contentCard = new JPanel(contentCardLayout); // assign card panels to CardLayout
//--------------- Splash Screen -----------------
splashScreen = new JPanel();
splash = new JLabel(new ImageIcon(getClass().getResource("img/bg.gif")));
splashScreen.add(splash);
splashScreen.setSize(600,800);
splashScreen.setLocation(0,0);
//--------------- "View Map" Option Button -----------------
mapBtn = new ImageIcon(getClass().getResource("img/map.gif"));
mapOption = new JButton(mapBtn);
mapOption.setBorder(null);
mapOption.setContentAreaFilled(false);
mapOption.setSize(150,66);
mapOption.setLocation(150,450);
mapOption.setOpaque(false);
mapOption.setVisible(true);
//--------------- Main Menu Screen -----------------
//menuImage = new JPanel(null);
//menuImage.add(mainMenu);
//menuImage.setLocation(0,0);
mainMenu = new JPanel(null);
menu = new JLabel(new ImageIcon(getClass().getResource("img/menu.gif")));
menu.setLocation(0,0);
mainMenu.add(menu);
//mainMenu.setBackground(Color.WHITE);
mainMenu.setLocation(0,0);
mainMenu.setOpaque(false);
//mainMenu.setSize(150,66);
mainMenu.add(mapOption);
//--------------- Map Image Screen -----------------
map = new JLabel(new ImageIcon(getClass().getResource("img/map.gif")));
//--------------- Add Cards to CardLayout Panel -----------------
contentCard.add(splashScreen, "Splash Screen");
contentCard.add(mainMenu, "Main Menu");
contentCard.add(map, "Map Image");
//--------------- Set-up container -----------------
contentContain = getContentPane(); // set container as content pane
contentContain.setBackground(Color.WHITE); // set container background colour
contentContain.setLocation(0,0);
contentContain.setSize(600,800);
contentContain.setLayout(new FlowLayout()); // set container layout
contentContain.add(contentCard); // cards added
//--------------- Timer Action Listener -----------------
actionListener = new ActionListener()
public void actionPerformed(ActionEvent actionEvent)
//--------------- Show Main Menu Card -----------------
contentCardLayout.show(contentCard, "Main Menu");
//--------------- Map Option Button Action Listener -----------------
mapOptionListener = new ActionListener()
public void actionPerformed(ActionEvent actionEvent)
//--------------- Show Main Menu Card -----------------
contentCardLayout.show(contentCard, "Map Image");
//--------------- Timer -----------------
timer = new Timer(5000, actionListener);
timer.start();
timer.setRepeats(false);
}Any help would be much appreciated!
Edited by: bex1984 on May 18, 2008 6:31 AM1) When posting here, please use fewer comments. The comments that you have don't help folks who know Java read and understand your program and in fact hinder this ability, which makes it less likely that someone will in fact read your code and help you -- something you definitely don't want to have happen! Instead, strive to make your variable and method names as logical and self-commenting as possible, and use comments judiciously and a bit more sparingly.
2) Try to use more methods and even classes to "divide and conquer".
3) To create a panel with a background image that can hold buttons and such, you should create an object that overrides JPanel and has a paintComponent override method within it that draws your image using the graphics object's drawImage(...) method
For instance:
an image jpanel:
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import javax.imageio.ImageIO;
import javax.swing.JButton;
import javax.swing.JPanel;
public class BackgroundImage
// **** this will have to be changed for your program:
private static final String IMAGE_PATH = "../../m02/a/images/Forest.jpg";
private BufferedImage myImage = null;
private JPanel imagePanel = new JPanel()
@Override
protected void paintComponent(Graphics g)
{ // *** here is where I draw my image
super.paintComponent(g); // **** don't forget this!
if (myImage != null)
g.drawImage(myImage, 0, 0, this);
public BackgroundImage()
imagePanel.setPreferredSize(new Dimension(600, 450));
imagePanel.add(new JButton("Foobars Rule!"));
try
myImage = createImage(IMAGE_PATH);
catch (IOException e)
e.printStackTrace();
catch (URISyntaxException e)
e.printStackTrace();
private BufferedImage createImage(String path) throws IOException,
URISyntaxException
URL imageURL = getClass().getResource(path);
if (imageURL != null)
return ImageIO.read(new File(imageURL.toURI()));
else
return null;
public JPanel getImagePanel()
return imagePanel;
}and an applet that uses it:
import java.lang.reflect.InvocationTargetException;
import javax.swing.JApplet;
import javax.swing.SwingUtilities;
public class BackgrndImageApplet extends JApplet
@Override
public void init()
try
SwingUtilities.invokeAndWait(new Runnable()
@Override
public void run()
getContentPane().add(new BackgroundImage().getImagePanel());
catch (InterruptedException e)
e.printStackTrace();
catch (InvocationTargetException e)
e.printStackTrace();
} -
Placing a background image in fluid grid layout
I am having trouble building a fluid grid layout I am not sure why but when I shrink the layout it doesn't seem to work correctly
I need to do 2 things.
1) make the background image shrink as it is suppossd to. when you scale down the images doesn't shirink to tablet size and isn't there for the phone size (although I think I want a new image for phone with just one side of the (page image). on it so I assume I just link that in there under that section in in the css
2)It doesn't seem to want to align the writing so that it is only over the page section of the background image on each side (the rightcontent and left content boxes-ie they should look like text on a page)
also I want to take the page here when it is finished and make it a template for further pages (just changing the text) is that done the same as usual for the fluid grids?
Thank you in advance for the help
Here is the link that the site has been temp posted on for detail editing.
http://approvalsite.info/Kind of makes sense.
I am not sure how to make the div tag layouts relative to the background image.
please advise.
also, I have been playing with it and it seems to be working better now.
But the issue I have with it now is that the image on the right side of the page keeps showing at the bottom of the page instead of on the top of the page directly next to the wording on the left.
does anyone know why?
I am sure it is just a simple coding issue.
help
approvalsite.info
CSS:
@charset "utf-8";
/* Simple fluid media
Note: Fluid media requires that you remove the media's height and width attributes from the HTML
http://www.alistapart.com/articles/fluid-images/
img, object, embed, video {
max-width: 100%;
/* IE 6 does not support max-width so default to width 100% */
.ie6 img {
width: 100%;
Dreamweaver Fluid Grid Properties
dw-num-cols-mobile: 5;
dw-num-cols-tablet: 8;
dw-num-cols-desktop: 12;
dw-gutter-percentage: 25;
Inspiration from "Responsive Web Design" by Ethan Marcotte
http://www.alistapart.com/articles/responsive-web-design
and Golden Grid System by Joni Korpi
http://goldengridsystem.com/
/* Mobile Layout: 480px and below. */
.gridContainer {
width: 85%;
padding-left: 1.82%;
padding-right: 1.82%;
background: url(../images/DSC_0014.jpg) center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
-background-size: cover;
#LayoutDiv1 {
clear: both;
float: left;
margin-left: 0;
width: 100%;
display: block;
#header {
clear: both;
float: left;
margin-left: 0;
width: 100%;
display: block;
#menubar {
clear: both;
float: left;
margin-left: 0;
width: 100%;
display: block;
#leftcontent {
clear: both;
float: left;
margin-left: 0;
width: 100%;
display: block;
height:auto;
#rightcontent {
clear: both;
float: right;
margin-left: 0;
width: 100%;
display: block;
height:auto;
#footer {
clear: both;
float: left;
margin-left: 0;
width: 100%;
display: block;
/* Tablet Layout: 481px to 768px. Inherits styles from: Mobile Layout. */
@media only screen and (min-width: 481px) {
.gridContainer {
width: 90.675%;
padding-left: 1.1625%;
padding-right: 1.1625%;
background: url(../images/DSC_0013.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
-background-size: cover;
#LayoutDiv1 {
clear: both;
float: left;
margin-left: 0;
width: 100%;
display: block;
#header {
clear: both;
float: left;
margin-left: 0;
width: 100%;
display: block;
#menubar {
clear: both;
float: left;
margin-left: 0;
width: 100%;
display: block;
#leftcontent {
clear: both;
float: left;
margin-left: 0;
width: 100%;
display: block;
#rightcontent {
clear: both;
float: right;
margin-left: 0;
width: 100%;
display: block;
#footer {
clear: both;
float: left;
margin-left: 0;
width: 100%;
display: block;
/* Desktop Layout: 769px to a max of 1232px. Inherits styles from: Mobile Layout and Tablet Layout. */
@media only screen and (min-width: 769px) {
.gridContainer {
width: 90%;
max-width: 1232px;
padding-left: 0.75%;
padding-right: 0.75%;
margin: auto;
background: url(../images/DSC_0013.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
-background-size: cover;
#LayoutDiv1 {
clear: both;
float: left;
margin-left: 0;
width: 100%;
display: block;
#header {
clear: both;
float: left;
margin-left: 5%;
width: 100%;
display: block;
#menubar {
clear: both;
float: left;
margin-left: 0;
width: 100%;
display: block;
#leftcontent {
clear: both;
float: left;
margin-left: 15%;
width: 30%;
display: block;
padding-right: 2%;
#rightcontent {
clear: none;
float: right;
margin-left: 1%;
width: 49%;
display: block;
margin-right: 8%;
#footer {
clear: both;
float: left;
margin-left: 0;
width: 100%;
display: block;
HTML
<!doctype html>
<!--[if lt IE 7]> <html class="ie6 oldie"> <![endif]-->
<!--[if IE 7]> <html class="ie7 oldie"> <![endif]-->
<!--[if IE 8]> <html class="ie8 oldie"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="">
<!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Untitled Document</title>
<link href="boilerplate.css" rel="stylesheet" type="text/css">
<link href="_css/layout.css" rel="stylesheet" type="text/css">
<!--
To learn more about the conditional comments around the html tags at the top of the file:
paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/
Do the following if you're using your customized build of modernizr (http://www.modernizr.com/):
* insert the link to your js here
* remove the link below to the html5shiv
* add the "no-js" class to the html tags at the top
* you can also remove the link to respond.min.js if you included the MQ Polyfill in your modernizr build
-->
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<script src="respond.min.js"></script>
<!-- Start css3menu.com HEAD section -->
<link rel="stylesheet" href="index_files/css3menu1/style.css" type="text/css" />
<!-- End css3menu.com HEAD section -->
</head>
<body>
<div class="gridContainer clearfix">
<div id="header"><h1>Jan Kardy's Literary Agency</h1></div>
<div id="menubar">
<!-- Start css3menu.com BODY section id=1 -->
<ul id="css3menu1" class="topmenu">
<li class="topfirst"><a href="../index.html" style="height:18px;line-height:18px;">Home</a></li>
<li class="topmenu"><a href="../about_jankardys.html" style="height:18px;line-height:18px;">About Jan Kardys</a></li>
<li class="topmenu"><a href="#" style="height:18px;line-height:18px;"><span>Resources</span></a>
<ul>
<li><a href="../Education_connection.html">Education Connection</a></li>
<li><a href="../submission_guidelines.html">Submission Guidelines</a></li>
<li><a href="#"><span>Blogs</span></a>
<ul>
<li><a href="http://unicornwritersconferencect.blogspot.com/">Unicorn Writers Conference</a></li>
<li><a href="http://advancenetworkingunicorn.blogspot.com/">Advanced Networking Blogs</a></li>
</ul></li>
<li><a href="../first_steps_to_publishing.html">First Steps to Publishing</a></li>
<li><a href="../library_publish_events.html">Library & Publishing Events</a></li>
<li><a href="#">Art Gallery</a></li>
</ul></li>
<li class="topmenu"><a href="#" style="height:18px;line-height:18px;">Clients</a></li>
<li class="toplast"><a href="#" style="height:18px;line-height:18px;">Contact Jan Kardys</a></li>
</ul>
<p style="display:none"><a href="http://css3menu.com/">Horizontal Menu Using CSS Css3Menu.com</a></p>
<!-- End css3menu.com BODY section -->
</div>
<div id="leftcontent">
<p>Jan Kardys, President of Black Hawk Literary Agency, has thirty years of diversified publishing experience for nine major publishing corporations. Black Hawk Literary Agency LLC represents a broad spectrum of authors and illustrators, with a focus on new nonfiction and fiction. <br />
</p>
<p>Jan was Director of Contracts for Warner Books/Little, Brown & Company, Director of Contracts at Macmillan Publishing Company, Charles Scribner's Sons, and Contracts Director at Prentice Hall/Simon & Schuster. Ms. Kardys has worked at Harcourt Brace Jovanovich, Doubleday, Scholastic, Lippincott & Crowell, Publishers, St. Martin's Press, Conde Nast Publications, and Google. Beginning a career in editorial, Jan also worked in art and production in School publishing. Jan held various executive positions in subsidiary rights, licensing, database design, imaging, royalty conversions, contracts, copyrights & permissions departments.<br />
</p>
<p></p>
</div>
<div id="rightcontent"><p><strong><center>Jan Kardys, Literary Agent<br />
Black Hawk Literary Agency, LLC. <br />
17 Church Hill Road,<br />Redding, CT 06896</center></strong></p>
<p><strong><center>
<p><img src="images/jankardys.jpg" alt="jankardys_headshot" /></p>
<p>Blog: <a title="http://bookpublishingteacher.blogspot.com" onkeypress="window.open(this.href); return false;" onclick="window.open(this.href); return false;" href="http://bookpublishingteacher.blogspot.com">http: bookpublishingteacher.blogspot.com</a><br />
</p>
<p>Email: <a href="mailto:[email protected]" title="mailto:[email protected]">[email protected]</a> <br />
</p>
<p>Phone: 203-938-7405</p>
</center></strong></p>
</div>
<div id="footer"><h6>Webpage designed by Technomage Web Design</h6></div>
</div>
</body>
</html> -
LinkListExplorer iview BackGround Image path not working
HI All ,
As i am using Layout set LinkListExplorer for few external links , when i am giving image name for eg growth.jpg in background image path, which is placed at /etc/public/mimes/images it is not showing anything , the same is working for NewsBrowser Layout set . I have tried many thing all possiblities but no success .
Pls help me in this regard.
Shwetang saxenaHi Vedant,
APEX only replaces the #WORKSPACE_IMAGES# variable within APEX itself. This is quite logical, because what you see in the APEX developer space is generated by PL/SQL from the database, so APEX can change what it wants. APEX can't access the files however, that's logical to because APEX would need premissions on the server and an Oracle directoryto start doing changes to files.
So if you want to point to the image directory in the CSS file you need to provide the full path.
Regards,
Joni -
Problem with Background image and JFrame
Hi there!
I've the following problem:
I created a JFrame with an integrated JPanel. In this JFrame I display a background image. Therefore I've used my own contentPane:
public class MContentPane extends JComponent{
private Image backgroundImage = null;
public MContentPane() {
super();
* Returns the background image
* @return Background image
public Image getBackgroundImage() {
return backgroundImage;
* Sets the background image
* @param backgroundImage Background image
public void setBackgroundImage(Image backgroundImage) {
this.backgroundImage = backgroundImage;
* Overrides the painting to display a background image
protected void paintComponent(Graphics g) {
if (isOpaque()) {
g.setColor(getBackground());
g.fillRect(0, 0, getWidth(), getHeight());
if (backgroundImage != null) {
g.drawImage(backgroundImage,0,0,this);
super.paintComponent(g);
Now the background image displays correct. But as soon as I click on some combobox that is placed within the integrated JPanel I see fractals of the opened combobox on the background. When I minimize
the Frame they disappear. Sometimes though I get also some fractals when resizing the JFrame.
It seems there is some problem with the redrawing of the background e.g. it doesn't get redrawn as often as it should be!?
Could anyone give me some hint, on how to achieve a clear background after clicking some combobox?
Thx in advanceI still prefer using a border to draw a background image:
import java.awt.*;
import java.awt.image.*;
import javax.swing.border.*;
public class CentredBackgroundBorder implements Border {
private final BufferedImage image;
public CentredBackgroundBorder(BufferedImage image) {
this.image = image;
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
int x0 = x + (width-image.getWidth())/2;
int y0 = y + (height-image.getHeight())/2;
g. drawImage(image, x0, y0, null);
public Insets getBorderInsets(Component c) {
return new Insets(0,0,0,0);
public boolean isBorderOpaque() {
return true;
}And here is a demo where I load the background image asynchronously, so that I can launch the GUI before the image is done loading. Warning: you may find the image disturbing...
import java.awt.*;
import java.io.*;
import java.net.URL;
import javax.imageio.*;
import javax.swing.*;
import javax.swing.border.*;
public class BackgroundBorderExample {
public static void main(String[] args) throws IOException {
JFrame.setDefaultLookAndFeelDecorated(true);
JFrame f = new JFrame("BackgroundBorderExample");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JTextArea area = new JTextArea(24,80);
area.setForeground(Color.WHITE);
area.setOpaque(false);
area.read(new FileReader(new File("BackgroundBorderExample.java")), null);
final JScrollPane sp = new JScrollPane(area);
sp.setBackground(Color.BLACK);
sp.getViewport().setOpaque(false);
f.getContentPane().add(sp);
f.setSize(600,400);
f.setLocationRelativeTo(null);
f.setVisible(true);
String url = "http://today.java.net/jag/bio/JagHeadshot.jpg";
final Border bkgrnd = new CentredBackgroundBorder(ImageIO.read(new URL(url)));
Runnable r = new Runnable() {
public void run() {
sp.setViewportBorder(bkgrnd);
sp.repaint();
SwingUtilities.invokeLater(r);
} -
How can I change the coding of a background image?
I am close to successfully uploading my first website. My one remaining issue: one of my pages isn't showing properly. When I called my hosting service, they tell me that there is an error in the coding of the background image.
It is currently:
http://cashmerepersonalconcierge.com/ContactUs__files/backgroundimage1.png
There is an extra underscore between "Us_files". It should be:
http://cashmerepersonalconcierge.com/ContactUs_files/backgroundimage1.png
but I have no idea how to change the coding in iWeb. Any ideas?
Here's the full URL for the page: http://cashmerepersonalconcierge.com/ContactUs.htmlThanks! That worked and was a fairly simple pick. Thanks for saving me hours!
I almost have it fixed. One small remaining problem:
My link to the "Contact Us" page isn't working from the top Nav bar. That's the one that is in the iWeb template I used. It's linking to:
http://www.cashmerepersonalconcierge.com/ContactUs.html
which doesn't exist.
The nav bar at the bottom link to:
http://www.cashmerepersonalconcierge.com/Contact_Us.html
which works.
Once again I see the extra space/underscore is the problem, but I can't figure out how to get to it. I resaved my folders and re-uploaed the "Contact_Us.html" page as well as all my other html pages to troubleshoot.
Thanks!! -
Hello all, I hope you can help.
In Photoshop I have a problem to overcome and have delved into the world of scripting..
If there is a quick way to produce the following could someone help me with some pointers?
Here is my situation..
I need to produce a photograph proof card, these are for a double image option so cause me a headache compared to just creating an action..
This proof card really is just a set of two different photographs placed onto a background image.
I would produce two different images of the same person and name them exactly the same except they are suffixed with an A or B to keep them together, these would be in a folder with approx 500 other images for example (250 x two of each person)
My preference for the process would be done in the following sequence:
1/ Open the background file jpg (which is sized at 2400 x 1800 pixels @ 300dpi)
2/ Load the first image from the batch file and place this.
3/ Get the filename of the first image and create it as a text layer and write it below the image at 10 point text size.
4/ Create another copy of this layer and change the font to 3of9barcode font, however the font needs an asterisk before the text then again after it. e.g. *filenameA*
Only the first image has the need for a barcode as they are for the same person. This is at 18 point.
5/ Load the next sequential image from the batch file and place this.
6/ Get the filename for the second image and as Item 3/ create a text layer below at 10 point text size.
7/ Place a png overlay with my copyright information over the images (I need to do this twice, once for each image)
8/ Flatten the images and save the file in a new folder with the same filename as the first image.
I can do this in Lightroom with the exception of putting the barcoded text, and the filenaming, this is because the background image is used as the identity plate and the filename is not based on the data from either photograph..
Can anyone shed some light on where to go from here?
Kind regards
BryanPhotoshop Scripting-wise this seems fairly "easy".
But I would recommend creating a template file (that already combines background image, png overlay and the Type Layers).
Maybe data driven graphics would also be an option …
Photoshop Help | Creating data-driven graphics -
Why am I having issues with the background image here?
body {
text-align:left;
font-family:Tahoma, Geneva, Helvetica, Arial, sans-serif;
font-size:11px;
line-height:17px;
color:#8a8683;
margin:0;
padding:0;
* html body {
overflow:hidden;
* html div#content {
height:100%;
overflow:auto;
div#colBg2 {
width:519px;
height:100%;
margin:0 0 0 449px;
background:url(/images/colBg2.png) repeat-y top;
z-index:600;
table#colText {
height:100%;
width:433px;
text-align:left;
z-index:700;
<div id="colBg2">
<div id="colText">
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum.</p>
</div>
</div>
What this is supposed to do is show background image colBg2.png as a column extending from the top of the viewport to the bottom, whether there's enough text to fill it or not. If it doesn't, then it shouldn't produce a scrollbar. It uses 100% vertical height hacks, as demonstrated in the code above.
When there's more text than the viewport can handle, there's a scrollbar, and the colBg2 successfully scrolls along with the text contained in colText. HOWEVER... when that background scrolls upwards so we can go down the page, it stops tiling. It stops wherever the viewport ends.
If I stretch the window to reveal more of the column, no problem. It tiles just fine, and extends all the way to the end of the screen. But not if I scroll down.
Anyone know if I'm doing anything wrong with this code, or if there's an obvious fix that isn't occuring to me?I was just about to prepare that for you guys when I had a quick flash to try applying the background image directly to the table instead
of a containing div. I'm sure there was a reason I used a containing div to begin with, but can't for the life of me remember why right now. I'm sure it'll hit me at some point and I'll probably be back here when it does, but so far eliminating the containing div altogether has produced the desired effect. =) -
Adding .flv or .swf in dreamweaver on top of background image
Hi,
I added an image background 1900 x 1200 in dreamweaver, which will serve as my background image for my web site. I would like to incorporate my .flv or .swf on top of my background image. Although, when doing so, the .flv or .swf gets placed under the background image and not on top. How do I place the .flv or .swf file on top of my background image in Dreamweaver CS5.
ThanksHi
This sounds as though you are not actually using a background-image but just placing an image on the page. To get any help people will have to see your page and the code, can you provide a link to a live page?
BTW: Your background-image size is way to big for most users monitors, just thought you should know.
PZ -
Spry Horizontal Menu Bar background image IE8 not visible.
I have a slight problem with a horizontal menu bar that I have placed on my site and am hoping someone can help me. It views fine in Firefox, however in IE8 the top menu background image is white instead of the image I specified. Firefox image is below.
Below is IE8 image lacking top menu background:
I am a novice and this is driving me nuts. How can something view fine in Firefox and loose the image in IE explorer? I must have a code incorrect, I know it. Any help is greatly appreciated.
Thank you,At the bottom of SpryMenuBarHorizontal.css, you will find
@media screen, projection
ul.MenuBarHorizontal li.MenuBarItemIE
display: inline;
f\loat: left;
background-color: #FFF;
Change the background colour to transparent and all is well. -
I looked around but didn't find a post on this or, missed it,
if it's posted. My situation is this. When I open my site in every
other browser (ie., firefox, opera, safari, camino, and flock) the
background image shows up correctly. When I open it in IE 7 it
looks darker and rough. I tried placing it as jpeg and png. They
both look the same. Everything else works fine, links, text. Any
thoughts.
Thanks...I see. Huh? 8)
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go
- DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs,
Tutorials & Resources
==================
"RedSamurai" <[email protected]> wrote in
message
news:g14bqa$h7d$[email protected]..
>
quote:
Originally posted by:
Newsgroup User
> Why is there so much empty space at the bottom of the
content?
>
> --
> Murray --- ICQ 71997575
> Adobe Community Expert
> (If you *MUST* email me, don't LAUGH when you do so!)
> ==================
>
http://www.projectseven.com/go
- DW FAQs, Tutorials & Resources
>
http://www.dwfaq.com - DW FAQs,
Tutorials & Resources
> ==================
>
>
> "RedSamurai" <[email protected]> wrote
in message
> news:g143og$8ou$[email protected]..
> >I apologize. A duh moment. Here's the address
> >
> >
http://www.garza-design.com
> >
> > Thanks...
>
>
>
>
>
Maybe you are looking for
-
I have noticed a lot of this going on this group - with no definitive answers but here goes... This is my set-up - 2 Alteon Load Balancers (configured as per docs) 2 Apache 2.0.39 with relevant Apache Bridge 2
-
please help.
-
when i start I tunes i get this message , The registry settings used by Itunes drivers for importing and burning CD'S and DVD's are missing please reinstall..ive reinstalled 5 times ,all 5 clean installs ...still dont work with Iphone 3 ..
-
Is there any solution for this, as i have iPhone 4 8GB. Any apps to clear temp files killing my space ?
-
Hi, I have updated numbers for the new version (Dec, 4th release) and the same worksheet I used to work got very slow, almost impossible to work with. I was wondering if someone else got the same issue.