Adding .jpg image to the JFrame

I want to add an image in the JFrame
My code is as follows:
import java.awt.*;
import javax.swing.*;
public class test extends JPanel
     JProgressBar pb1 = new JProgressBar(JProgressBar.HORIZONTAL,0,100);
public test(String image)
ImageIcon imgIco = new ImageIcon(image);
JLabel imgLbl = new JLabel(imgIco);
imgLbl.setPreferredSize(new Dimension(500,500));
JPanel p1 = new JPanel();
p1.add(pb1);
setLayout(new GridLayout(1,1));
add(imgLbl);
add(p1);
public void salman()
          int i=0;
          while(i<=100)
               try
                    pb1.setValue(i);
                    pb1.setForeground(Color.lightGray);
                    pb1.setBackground(Color.blue);
                    pb1.setBorderPainted(true);
                    pb1.setStringPainted(true);
                    Thread.sleep(55);
               catch(Exception e)
                    System.out.println("Exception Occured!!!");
               i++;     
public static void main(String[] args)
JFrame f = new JFrame();
test img = new test("pills.jpg");
f.getContentPane().add(img);
f.setSize(450,470);
f.setVisible(true);
img.salman();
Thanks for you co-operation.
Regards
Salman Pirzada

you use
test img = new test("pills.jpg");where it finds pills.jpg????
try something like this:
String imageName = "pills.jpg";
img = Toolkit.getDefaultToolkit().getImage(Test.class.getResource(imageName));And make sure, pills.jpg is in the same directory where Test class is

Similar Messages

  • [svn] 4673: Adding preview images to the theme directories.

    Revision: 4673
    Author: [email protected]
    Date: 2009-01-26 12:46:51 -0800 (Mon, 26 Jan 2009)
    Log Message:
    Adding preview images to the theme directories.
    QE Notes: None
    Doc Notes: None
    Bugs: SDK-17735, SDK-16429
    Reviewer: None
    Ticket Links:
    http://bugs.adobe.com/jira/browse/SDK-17735
    http://bugs.adobe.com/jira/browse/SDK-16429
    Added Paths:
    flex/sdk/trunk/frameworks/themes/Ice/preview.jpg
    flex/sdk/trunk/frameworks/themes/Institutional/preview.jpg
    flex/sdk/trunk/frameworks/themes/Smoke/preview.jpg
    flex/sdk/trunk/frameworks/themes/Spark/
    flex/sdk/trunk/frameworks/themes/Spark/preview.jpg
    flex/sdk/trunk/frameworks/themes/Wooden/preview.jpg

    yes the first bit of code is netbeans generated.
    the second piece of code is an fx file that updates the content of the grid based on the users selection.
    so i cannot add the image to the grid in composer as its a dynamically generated grid. but ill try and see if i can just to test for now
    thanks...

  • Why can't I resize jpg images in the applet?

    I used this code to display images in an html page. One applet for one image. But out of the 8 images I loaded, 6 adjusted themselves to 320x240 automatically, 1 randomly jumps around to certain parts of the image every 250millisecs, and 1 just cuts the top left hand part of 320x240. How can .jpg files give 3 different situations? I tried using the resize() method in the code but it doesn't do anything! How can I size those .jpg images to the size I want?
    /**This video stream applet loads a new image every 250ms
    import java.applet.*;
    import java.awt.*;
    import java.net.*;
    import java.io.*;
    import java.awt.event.*;
    public class Video extends Applet implements Runnable{
    private Image img,buffer;
    private Thread video = null;
    private URL url;
    private MediaTracker tracker;
    public synchronized void init(){
    tracker = new MediaTracker(this);
    try{url = new URL(getCodeBase(),"Camera1.jpg");}
    catch(MalformedURLException e){}
    img = getImage(url);
    tracker.addImage(img, 0);
    buffer = createImage(320,240);
    resize(320,240);
    if(video!=null)return;
    video = new Thread(this,"VideoStream");
    video.start();
    public synchronized void destroy(){
    if(video!=null)video=null;
    public void run(){
    while(!Thread.interrupted()){
    // Load new image.
    try{tracker.waitForID(0);}
    catch(InterruptedException e){}
    // Draw new Image.
    repaint();
    // Remove old image & add new one.
    tracker.removeImage(img,0);
    img.flush();
    tracker.addImage(img,0);
    // Sleep
    try{Thread.sleep(250);}
    catch(InterruptedException e){}
    public synchronized void update(Graphics g){
    Graphics bufGraph = buffer.getGraphics();
    bufGraph.drawImage(img,0,0,this);
    paint(bufGraph);
    g.drawImage(buffer,0,0,this);
    public void paint(Graphics g){
    g.drawImage(buffer,0,0,this);
    Also how can I add more than 1 .jpg in an applet since the applet tag for html is
    <applet code = Video.class width =... height = ...>
    <param name = "buffer" value = "Camera1.jpg"> ...and I can only put
    </applet> one file for "value
    Thanks a lot for ur help!

    you may try the function getScaledInstance(int,int,int) in Class Image.
    the first and second parameters are the width and height you want,the third parameter is hints-flags to indicate the type of algorithm to use for image resampling.

  • Resizing JFrame on button click to show an image on the JFrame

    Dear All,
    I have a JFrame which has an empty label. On button click I want to set an icon for the label and want the JFrame to be resized to show that icon. I am using frame.pack() and I am not using any other sizing function. The code that I have right now, prints the image on the panel, but does not resize the frame to show the image. Pleae could someone help.package gui;
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.Font;
    import java.awt.Toolkit;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.ItemEvent;
    import java.awt.event.ItemListener;
    import java.awt.event.KeyEvent;
    import java.awt.event.KeyListener;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import javax.swing.ImageIcon;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTextArea;
    public class ComponentDemo extends JPanel implements ActionListener,
    ItemListener, MouseListener, KeyListener {
         private JTextArea textarea;
         private JButton button;
         private final static String newline = "\n";
         private JLabel imageIcon;
         public ComponentDemo() {
              button = new JButton("JButton welcomes you  to CO2001");
              button.addActionListener(this);
              add(button);
              textarea = new JTextArea(10, 50);
              textarea.setEditable(false);
              addMouseListener(this);
              textarea.addKeyListener(this);
              JScrollPane scrollPane = new JScrollPane(textarea);
              add(scrollPane);
              imageIcon = new JLabel();
              add(imageIcon);
              setBackground(Color.pink);
              new JScrollPane(this);
          * Create the GUI and show it. For thread safety, this method should be
          * invoked from the event-dispatching thread.
         private static void createAndShowGUI() {
              // Create and set up the window.
              JFrame frame = new JFrame("Simple FrameDemo");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
              frame.setLocation(700, 200);
              // get the content pane and set the background colour;
              frame.add(new ComponentDemo());
         //     frame.setSize(screenSize);
              // frame.getContentPane().setBackground(Color.cyan);
              // Display the window.
              frame.pack();
              frame.setVisible(true);
              frame.setResizable(true);
         public static void main(String[] args) {
              // Schedule a job for the event-dispatching thread:
              // creating and showing this application's GUI.
              javax.swing.SwingUtilities.invokeLater(new Runnable() {
                   public void run() {
                        createAndShowGUI();
         @Override
         public void actionPerformed(ActionEvent e) {
              // TODO Auto-generated method stub
              if (e.getSource() instanceof JButton) {
                   // System.out.println(e.getSource());
                   String text = ((JButton) e.getSource()).getText();
                   textarea.append(text + newline);
                   textarea.setBackground(Color.cyan);
                   textarea.setForeground(Color.BLUE);
                   textarea.setCaretPosition(textarea.getDocument().getLength());
                   imageIcon.setIcon(createImageIcon("SwingingDuke.png",
                   "Image to be displayed"));
         @Override
         public void itemStateChanged(ItemEvent arg0) {
              // TODO Auto-generated method stub
         @Override
         public void mouseClicked(MouseEvent arg0) {
              textarea.append("A Mouse click welcomes you to CO2001" + newline);
              textarea.setBackground(Color.green);
              textarea.setCaretPosition(textarea.getDocument().getLength());
         @Override
         public void mouseEntered(MouseEvent arg0) {
              // TODO Auto-generated method stub
         @Override
         public void mouseExited(MouseEvent arg0) {
              // TODO Auto-generated method stub
         @Override
         public void mousePressed(MouseEvent arg0) {
              // TODO Auto-generated method stub
         @Override
         public void mouseReleased(MouseEvent arg0) {
              // TODO Auto-generated method stub
         @Override
         public void keyPressed(KeyEvent e) {
              System.out.println(e.getKeyChar());
              textarea.append("The key " + e.getKeyChar()
                        + " click welcomes you to CO2001" + newline);
              textarea.setBackground(Color.YELLOW);
              textarea.setFont(new Font("Arial", Font.ITALIC, 16));
              textarea.setCaretPosition(textarea.getDocument().getLength());
         @Override
         public void keyReleased(KeyEvent e) {
              System.out.println(e.getKeyChar());
              // textarea.append("The key "+
              // e.getKeyChar()+" click welcomes you to CO2001" + newline);
              // textarea.setBackground(Color.green);
              // textarea.setCaretPosition(textarea.getDocument().getLength());
         @Override
         public void keyTyped(KeyEvent e) {
              // TODO Auto-generated method stub
              System.out.println(e.getKeyChar());
              // textarea.append("The key "+
              // e.getKeyChar()+" click welcomes you to CO2001" + newline);
              // textarea.setBackground(Color.blue);
              // textarea.setCaretPosition(textarea.getDocument().getLength());
         /** Returns an ImageIcon, or null if the path was invalid. */
         protected ImageIcon createImageIcon(String path, String description) {
              java.net.URL imgURL = getClass().getResource(path);
              if (imgURL != null) {
                   System.out.println("found");
                   return new ImageIcon(imgURL, description);
              } else {
                   System.err.println("Couldn't find file: " + path);
                   return null;
    }

    myJPanel.setPerferredSize(new Dimension(new_width, new_hight));
    myJFrame.pack();

  • Signing a PDF/A with a JPG image, invalidates the compliance

    I am trying to sign a PDF/A document.
    I can't do it with Adobe Acrobat without invalidating the PDF/A compliance. So I am using our tool to sign the file.
    When I use a BMP as the graphical represenation of the signature, the file remains compliant, if we use a JPG image the compatibility fails.
    The only difference between the two PDF/A files (compliant and incompliant) is the XObject that is different (one is simple neat bmp object, the other is a JPG, with Fileter /DCTDecode etc.).
    I would like to know if there is any way I can make the JPG image to work without invalidating the PDF/A compliance, or is it inevitable, as a JPG object has attributes that contradict basic concepts of PDF/A.
    Thanks
    Tal

    Thanks.
    what you say about PDF/A being a final version makes a lot of sense, but not when you are talking about digital signatures of course.
    if you first sign and then convert the file to be PDF/A compliant you automatically invalidate the signatures.
    long term electronic archiving and digital signatures is a perfect match, and people still ike to see their hand written signature, even on an electronic document, and it is exactly where the problem begins.
    the pre flight is very cheap with information.
    it gives me a general note on the XObject that it should start with stream and then CR LF, and must end with an endstream preceeded by EOL. as far as I can tell my object complies with these requirements

  • How to save a new jpg image from the clipboard

    It seems like it should be simple but I can't find anywhere this has been documented.
    I have an image on the clipboard and simply want to save it as a new image.
    I've been using Image Events and I can get a file saved but it's always empty.
    Can someone please post some sample code to do this?

    I'm sure there's a more elegant way to script this, but here is a script I just wrote real quick that should at least give you a start to an alternate way of dealing with clipboard data without having to launch Preview...
    <pre style="width:630px;height:auto;overflow-x:auto;overflow-y:hidden;"
    title="Copy this code and paste it into your Script Editor application.">--see if clipboard is a file
    set filePath to ""
    try
    set clipPath to the clipboard as «class furl»
    set filePath to clipPath as alias
    end try
    if filePath is not "" then
    set newFile to getFileName("copied")
    do shell script "cp " & quoted form of POSIX path of filePath & ¬
    space & quoted form of POSIX path of newFile
    return --end
    end if
    --see if clipboard is image data
    set jpegDATA to ""
    try
    set jpegDATA to the clipboard as JPEG picture
    end try
    if jpegDATA is not "" then
    set newFile to getFileName("new")
    set theFile to open for access newFile with write permission
    write jpegDATA to theFile
    close access theFile
    return --end
    end if
    beep 1
    display dialog ¬
    "No file or image data found on the clipboard." with icon ¬
    note buttons {"Whatever"} default button 1
    on getFileName(type)
    choose file name with prompt ¬
    "Select a name and location for the " & type & ¬
    " jpeg:" default location (path to desktop) default name ¬
    type & ".jpg"
    end getFileName</pre>
    Hope this helps...

  • How can i display a JPG image in a JFrame ?

    sample code would be appreciated
    marvinrouge

    Thanks both : it helped
    here is the code given to all jana-net-guys
    it displays from 1.jpg to 12.jpg
    how can i improve it to displays all .jpg and .gif even if their names ARE NOT like <number>.jpg ???
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.io.*;
    public class PhotoDisplayer extends JFrame implements ActionListener {
         JPanel cp = new JPanel();
         public PhotoDisplayer() {
              getContentPane().setLayout(new BorderLayout());
              setImage(1);
                   cp.add(first);
                   first.addActionListener(this);
                   cp.add(prev);
                   prev.addActionListener(this);
                   cp.add(next);
                   next.addActionListener(this);
                   cp.add(last);
                   last.addActionListener(this);
                   cp.add(exit);
                   exit.addActionListener(this);
              getContentPane().add(cp, BorderLayout.SOUTH);
              pack();
              show();
         public void setImage(String image) {
              ImageIcon ii = new ImageIcon(image);
              if (ii.getIconHeight()>height)
                   height = ii.getIconHeight();
              if (ii.getIconWidth()>width)
                   width = ii.getIconWidth();
              JLabel img = new JLabel(ii);
              JScrollPane sp = new JScrollPane(img);
              getContentPane().removeAll();
              getContentPane().add(sp, BorderLayout.CENTER);
              getContentPane().add(cp, BorderLayout.SOUTH);
              setTitle(image);
              pack();
         public void setImage(int img) {
              setImage("" + img + ".jpg");
         public int image = 1;
         public void moveImage(int dec) {
              if (image+dec>=1 && image+dec<=12) {
                   image += dec;
                   setImage(image);
         public void actionPerformed(ActionEvent event) {
              if (event.getSource()==first)
                   setImage(1);
              if (event.getSource()==prev)
                   moveImage(-1);
              if (event.getSource()==next)
                   moveImage(1);
              if (event.getSource()==last)
                   setImage(12);
              if (event.getSource()==exit)
                   System.exit(0);
         int width = 320;
         int height = 200;
         JButton first = new JButton("First");
         JButton prev = new JButton("Prev");
         JButton next = new JButton("Next");
         JButton last = new JButton("Last");
         JButton exit = new JButton("Exit");
         public static void main(String[] args) {
              new PhotoDisplayer();
         public Dimension getPreferredSize() {
              return new Dimension(width, height);
    }

  • Adding an image to the Static Button Widget

    Hi all
    I managed to convince my client to let me do my own navigation instead of using the by default navigation bar and its limitations. I finally will be able to do branching and customised feedback on several slides! Great. BUT. There is a but. I need to make the new buttons look like the current ones: Pause/Play, previous, next, TOC and Exit.
    I was happy to discover that I could use a static button widget on my master to deal with my previous and next buttons for all my standard slides. But when I try to add an image of my button the way I want it to look, it looks like that:
    If I resize the button the picture remains at the same size:
    I don't get the Image feature here at all and I wonder if it's possible to customise the button with our own pictures...
    Any success anybody?

    Alright thanks for your suggestions. Yes I am publishing to a slightly different location and I pasted the picture at the root of the published folder. The pic is found but it appears tiny:
    It should replace the button by default but it is added to the button actually, by its side.
    Cheers
    Helene

  • Problem adding an image to the display list

    I'm trying to create a component to add images to a Panel (id=hbox). I seem to be loading the images successfully (because the trace statement works), but can't add them to the display.
    I'm using the following line of code, but getting an error:
    hbox.addChild(event.currentTarget)
    What am I doing wrong?
    Thank you!
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" backgroundAlpha=".5"   backgroundColor="0xffffff" creationComplete="init()"  >
        <mx:Script>
        <![CDATA[
        public function placeAnimals():void{
            for(var i:int=0; i<12;i++){
                var imageLoader:Loader = new Loader();
                var url:String = "images/animal"+i+".png";
                var urlReq:URLRequest = new URLRequest(url);
                imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
                imageLoader.x=50*i
                imageLoader.load(urlReq);       
                function imageLoaded(event:Event):void {
                    trace("Success="+event.currentTarget.url)
                   //hbox.addChild(event.currentTarget)
             public function init():void {
                 placeAnimals()
        ]]>
        </mx:Script>
        <mx:Panel  id="hbox"  height="200"   backgroundImage="images/smallWhitePanel.png"  borderStyle="none" />
    </mx:Canvas>

    You cannot add an image directly like that... why not dot the following
    var img:Image = new Image();
    img.source = url;
    this.addChild(img);
    hpefully it should work.. i'v neva seen image being added to the hbox like that... it will work only if you embed it / put it in source element..
    the following link should help you
    http://livedocs.adobe.com/flex/3/html/help.html?content=controls_16.html

  • Adding an image from the web to the report in the header with other Text

    I am attempting to fix a Crystal Report where I have a Logo positioned in the upper left corner of the Report Header.  The Report Header also includes 2 text fields.  One is fixed data and the other is a date.  I have mastered the img src but I cannot get the two text fields to display to the right of the image.  They will always push to the line below.  I have tried putting them in different sections and underlying the next section, and all other settings that I can think of.  What I must have would be similar to this:
    |                . "UPDATE"
    Image
    |                . "DATE"
    I have even tried suppressing all headers and using multiple detail sections to no avail.  I am using Crystal Reports 2008

    I have found the answer or should I say the cause of my problem.  It is that Microsoft in their infinite wisdom have changed the way (or engine) their Outlook (post version 2003) handles html.  They now use the "engine" from their 'Word' program which cannot handle most compound formatting.  To handle this program, you have to build it all on one level.  To solve my Header problem, I was forced to recreate my graphic to include the Header text, place that graphic on the top of the page and build my form below,  an entire line at a time.  Multiple objects on the same line would look great in Outlook prior to '2007' but may be in any order or grouping in '2007' and after See this explanation...
    [http://blogs.sitepoint.com/2007/01/10/microsoft-breaks-html-email-rendering-in-outlook/]

  • When adding an image to the composition. Ae CC crashes what should i do?

    Please someone help?

    We need to know a lot more to help you. Please provide answers to the questions listed here: "FAQ: What information should I provide when asking a question on this forum?"

  • Adding background image to JFrame

    This is the code I have now. I want to add a background image to the JFrame, and it needs to be where i type the file name of the image into the program code and it loads it from my computer.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    class GUIFrame extends JFrame implements ActionListener, KeyListener
         Display myDisplay;
         Button guess;
         Button solve;
         TextField input;
         JTextArea guessedLetters;
         MenuBar myBar;
         Menu fileMenu;
         MenuItem fileNewGame;
         MenuItem fileQuit;
         * constructor sets title of GUI window
         GUIFrame()
              super("Hangman");
              setSize(1000,600);
              guess = new Button("Guess");     
              guess.setFocusable(false);
              solve = new Button("Solve");     
              solve.setFocusable(false);
              input = new TextField(20);
              guessedLetters=new JTextArea(10,10);
              guessedLetters.setEditable(false);
              myBar=new MenuBar();
              fileMenu=new Menu("File");
              fileNewGame=new MenuItem("New Game");
              fileQuit=new MenuItem("Quit");
              myDisplay = new Display();     //make an instance of the window
              setLayout(new FlowLayout());     //How things are added to our Frame
              add(myDisplay);
              add(guess);
              add(solve);
              add(input);
              add(guessedLetters);
              setMenuBar(myBar);
              myBar.add(fileMenu);
              fileMenu.add(fileNewGame);
              fileMenu.add(fileQuit);
              addKeyListener(this);
              guess.addActionListener(this);
              solve.addActionListener(this);
              setVisible(true);     //make the frame visible
         * exectues when user presses a button.
         public void actionPerformed(ActionEvent e)
         public void keyPressed(KeyEvent e)
         public void keyReleased(KeyEvent e)
         public void keyTyped(KeyEvent e)
    }

    Look in the API under JFileChooser and Scanner to see how to get the file name. One you have it, you can load the file easily using several different methods...
    This is even easier, you can paint and image onto anything you like with this method:
    g.drawImage(image, 0, 0, null); //where g is the graphics context from the object you want to paint.
    Simple as that.
    The biggest problem you'll have with painting images onto other objects is making sure the image is loaded before you try to draw it; use ImageIO to load or add your image to a MediaTrakker after your load statement like this:
    Image im = (Image)ImageIO.read(new File("c:/myImages/myImage.jgp"));
    or
    BufferedImage bi = ImageIO.read(new File("c:/myImages/myImage.jgp"));
    or
    Image image = Toolkit.getDefaultToolkit().getImage("c:/myImages/myImage.jgp");
    MediaTracker mediaTracker = new MediaTracker(jf);
    mediaTracker.addImage(image, 0);
    mediaTracker.waitForID(0);
    BTW: what this means it that you can paint right onto the graphics content of the JFrame and not have to worry about any other containers if you want.
    If you expect the image to last more than just a flash, then you also need to override your paintComponents(Grahics) method to paint your graphics to your screen.

  • How to create multi-level style pulling in a .jpg image as a bullet?

    From within RoboHelp 8 HTML, when creating/editing a 3-tier multi-level style, I want to use a .jpg image for the bullet(s).  I can not find a way to point to the image while in Edit mode.  My only choices are predefined bullets for the List Style.
    When searching for an answer within the forum, I noticed mention of a Baggage folder in RoboHelp.  I do not have a Baggage folder.  I do have links to websites accessible from within the web-based Help file I've created beneath the URLs folder in the Project Manager.
    Thank you for any help you can provide.

    Hi there
    I never really played much with adding images to the oddly formatted Multi-list styles.
    The Project Manager has two views. Sounds like you are using the new "global" view. In that view you don't see a special area labeled Baggage Files. In this view the files are simply listed among the other content. If you change the view to Classic (I think it's the first icon on the left of the pod toolbar) you will then see the Baggage Files folder.
    Cheers... Rick
    Helpful and Handy Links
    RoboHelp Wish Form/Bug Reporting Form
    Begin learning RoboHelp HTML 7 or 8 within the day - $24.95!
    Adobe Certified RoboHelp HTML Training
    SorcerStone Blog
    RoboHelp eBooks

  • CS6 / Mac : I want to placate hand writen words on a jpg image.

    CS6 / Mac : I want to placate hand writen words on a jpg image. The words are to be extracted from a letter I photographed on jpg. I guessed that was asked before, if anyone can redirect me to an appropriate tuto I didn't find yet. Thx.

    Plonk, what I gave you was a very quick and easy way to achieve your goal, but it was, perhaps, simplistic.  But without seeing the underlying image, or the scanned letter.  My method relied on the text being black, and the paper it was written on being as near white as possible.  It also need the underlying image to have no large areas of very dark tones, or obviously the black text will not show against it.
    So to make it a decent test, I found this crumpled letter with a very off white background:
    Adding a Levels Adjustment layer, and setting it thus:
    I can move all those off white tones (as indicated by the right side of the histogram) to full white, like this
    Notice the red arrow on the Levels Properties.  Clicking on that icon clips it to the letter layer beneath it, so that it _only_ operates on that layer and no others.  This is important. Incidentally, you should also set the levels layer's Blend mode to Luminosity - this prevents colour artifacts creeping in.
    Placing the scanned letter layer, with its clipped Levels adjustment layer, we get the following.  On the left the Letter layer Blend mode is set to Multiply.  You could also use Darken (I bet you can workout why that would work) but Multiply gives a more solid black.  The second example has the Blend mode set to Divide.  This is a useful trick because it still gives contrast over dark tones, but the text would start to get thin where it overlays very light tones.  The third example is the original letter with no Levels layer.
    If you work in layout, you'll know that editors chose their images with overlaid type in mind.  It would be fairly trivial to make the type black over light tones and white over dark tones by using layer masks with two type layers.  You select either the dark or light area, and add a layer mask to the appropriate type layer.  Then copy the mask to the other type layer and invert it.  That ensures a perfect transition from one to the other.

  • Loading a jpg image into my java 3d scene

    public class Example3D extends JApplet {
        public BranchGroup createSceneGraph() {
         // creating the universe
         BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0);
         BranchGroup objRoot = new BranchGroup();
         TransformGroup mainTG = new TransformGroup();          
         mainTG.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
         mainTG.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
         // Now you can add new elements to the mainTG
         ColorCube c2 = new ColorCube(.1);
         mainTG.addChild(c2);
         objRoot.addChild(mainTG);
         // Create the rotate behavior node
         MouseRotate behavior = new MouseRotate();
         behavior.setTransformGroup(mainTG);
         objRoot.addChild(behavior);
         behavior.setSchedulingBounds(bounds);
         // Create the zoom behavior node
         MouseZoom behavior2 = new MouseZoom();
         behavior2.setTransformGroup(mainTG);
         objRoot.addChild(behavior2);
         behavior2.setSchedulingBounds(bounds);
         // Create the translate behavior node
          MouseTranslate behavior3 = new MouseTranslate();
         behavior3.setTransformGroup(mainTG);
         objRoot.addChild(behavior3);
         behavior3.setSchedulingBounds(bounds);
         objRoot.compile();
         return objRoot;
        public Example3D() {
         Container cp = getContentPane();
         cp.setLayout(new BorderLayout());
         Canvas3D c = new Canvas3D(SimpleUniverse.
                          getPreferredConfiguration() );
         cp.add("Center", c);
         BranchGroup scene = createSceneGraph();
         SimpleUniverse u = new SimpleUniverse(c);
         u.getViewingPlatform().setNominalViewingTransform();
         u.addBranchGraph(scene);
        public static void main(String[] args) {       
         new MainFrame(new Example3D(), 512, 512);
    }as a test, i added a cube into the scene and it works fine. but i also want to add a 2d jpg image into the scene too, its called flatTable.jpg
    i hope someone can help me, thanks guys.

    Check out this link:
    http://java3d.j3d.org/tutorials/raw_j3d/chapter1/textures.html
    It should give you enough information about loading textures with java3d.

Maybe you are looking for