Painting jcombobox onto g2

Hi
I am trying to paint several types of swing components onto the g2 of a jpanel. I have been able to do this satisfactorily with most types of jcomponent, however, i am struggling to get a suitable result for jcomboboxs. I cant get it to paint the drop down arrow, it just paints the box with the text in. Below is the code i am using
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.UIManager;
public class NewJFrame extends JFrame {
     public static void main(String args[]){
          try {
               UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() );
          }catch (Exception e) {
               e.printStackTrace();
          new NewJFrame();
     public NewJFrame(){
          JPanel panel = new MyPanel();
          getContentPane().add(panel);
          setSize(300,300);
          setVisible(true);
     class MyPanel extends JPanel{
          public void paintComponent(Graphics g){
               super.paintComponent(g);
               Graphics2D g2 = (Graphics2D)g;
               g2.translate(10,10);
               JComboBox box = new JComboBox(new String[]{"First"});
               box.setSize(100,20);
               box.paint(g2);
               g2.translate(-10,10);
I would really appreciate any help anyone can give me on sorting this out. Thanks.

OK, firstly thanks for the replies. Perhaps I should
have explained what I am trying to achieve. What I
am trying to build is basically something tantermount
to a GUI builder, whereby the user can select a
widget from a tool bar, and place it on a canvas,
they can then select any components they've dragged
out and drag them around the page, resize them,
change thier properties, etc. To do this i have
decided i want to render the components directly to
the g2 of the JPanel. What I am not trying to do is
create a bog standard GUI that you would indeed use a
layout manager(s) for. I have done a pretty
commendable amount of googleing for this, and the
closest thing i can come up with is the Draw app
here, and this is loosely what Ive based my app on.
http://java.sun.com/products/javawebstart/demos.html
I have my program up and running for most of the
e basic widgets, except JComboBoxs. So I will ask
again can anyone
a) Please answer my original question and tell me how
i can render the JComboBox with its arrow.
Or perhaps even more usefully,
b) Point me to a sample app where what I am trying to
achieve is done already
Thanks in advance,Then why not use absolute layout and implement listeners to move the items around when the user drags. The other thing I would look at is creating a single version of each widget to use. You could then use that one widget to paint it in a number of different places in the same manner a JTable does, I'm sure that'd be far more efficient.

Similar Messages

  • Painting Shapes onto JPanels

    hi, I'm currently trying to draw shapes in java for the first time. I've been looking at the tutorials and examples for java.sun but I'm having a few problems.
    At the moment I have code as follows:
    public class drawShape{
    public void paintComponent(Graphics g) {
    g.drawRect(2,2,2,2);
    I want to draw the rectangle onto a form called mainCanvas which is just a normal JPanel. I've been trying but am unsure how to get this working. I've tried mainCanvas.drawRect but that won't work. and in all the examples given on java.sun I can't see what Graphics g is supposed to be?
    Hope u can help

    The Graphics object gets passed to you. e.g.:
    public class MyPanel extends JPanel {
        // overriding paintComponent
        public void paintComponent(Graphics g) {
            g.drawRect(2,2,2,2);
    }Then when you add a MyPanel to a frame and make it visible, Swing's rendering system will make sure your paintComponent method gets called.

  • 3d painting issue - why is my selected value showing up different then the actual color I'm picking?

    Love the CS5's 3d painting features but I'm running into a really frustrating issue:
    When I select a value from the 3d object and try to paint with that value, it's showing up as a different value altogether (the image hopefully illustrates this much better than words).
    Not sure if it's got something to do the the lights setup or something else but I cannot figure it out.  Anyone else running into this or have a solution?
    Thanks!!!

    Ok, let me try to be explain the issue in more detail.
    Note: 
    All 3D layer settings are default.  No lights, ambient color setting, etc have been tweaked.
    Description:
    In order to paint out texture seams on a 3d character model, I have imported an .obj of the model into PS CS5 and applied a texture map to it which I have previously painted.
    Using the eye dropper I have selected a color value from the sides of the seam and have attempted to paint that value over the seam to remove it.
    Results:
    The color value picked from a texture applied to a 3d model which is 161,161,173, is not the same color value when painted directly back onto the model. It has now mysteriously turned into 152,152,177.
    Expected results:
    When a color value is picked from a texture applied to a 3d model (161,161,173) and painted back onto the textured model it should remain exactly the same (161,161,173)
    I hope lighting/shading is not figured in when color picking.  That would make your results completely unpredictable.  It could possibly be what is happening but is there a way turn this off or work around it?
    Thanks for the help.

  • Paint program - layers

    Hi i am in the process of making a paint program and have decided to go through the (hopefully not) long process of using layers.
    at the moment all shapes, when drawn, are stored in a vector and then painted onto the graphics of a class extending JPanel.
    what i want to do is store them in separate images, all the size of the JPanel canvas (so they can be positioned at (0, 0)) and anyt area of the image that isnt part of the shape should be transparent.
    i have tried creating a new graphics object for each shape and then painting them onto an ARGB buffered image then storing all the images in a new vector and finally painting them onto the canvas however this isnt working.
    is there an easier way to do this, or does anybody know what has happened?
    thanks

    If they're in a vector, they're basically already in a kind of layered system, of course.
    If what you want is to have all the shapes live in their own coordinate system, and then be able to assign relative positions to draw their system in a larger coordinate system...well, I thought that Java2D already handled that. But if it doesn't, then rather than drawing in images, another thing you can do is create a class that represents a coordinate system. Basically, all it would have to do is have two state elements: a reference to a shape, and a reference to an (x,y) pair where you want to anchor that shape for drawing. Then your vector could hold these objects.
    It wouldn't have to be much more than:
    class Layer {
      private Shape shape;
      private Point location;
      // constructor that sets these; shape could be final, but location probably shouldn't be
      public void paint(Graphics g) {
        // maybe use AffineTransform to move the shape to the given location, then
        // paint it?
    }You should probably check on a forum that does more with GUIs though.
    But, if you want to, you can also make each layer just be an image. You'd gain some of the operations of images (like Graphics knowing how to scale them) but might lose image quality. There are a bunch of tutorials about double buffering that will tell you how to create an intermediate image; you could apply that to make multiple images, if you wanted to.

  • Live Paint - Selecting the Fills made with live paint

    hi
    A few questions about live paint.....
    1) How do you select the fills you make with live paint by color? so you can change their properties ie, transparency, color?
    2) How do you put the Live Painted Fills onto separate layers so you can turn them off/on easily and change their properties?
    thanks

    Expand the LivePaint object. Then ungroup as necessary for what you are trying to do.
    JET

  • Ignore AWT paint messages?

    Hi,
    I'm have a grid of buttons 20x20 and I want to update 20 of these buttons by changing the picture on them, and I will do it in a 'For Loop'.
    But on really slow systems there is slight flicker, is there anyway to ignore these paint messages until the end of the loop, and then stop ignoring them again ?
    I tried setIgnoreRepaint(false) but the buttons still update during the loop. I presume that this is because this procedure only stops OS paint messages.
    Is there anyway to do what I'm after ?
    Thanks for your help.

    yea there is. This is howd Id do it. Make a new class that extends Button. Then make the two functions, public void paint(Graphics g) and public void update(Graphics g). now you control wats painted. You can have an Image field in your class, which stores the temporary picture, painting it onto g whenever somebody calls repaint(). So have a getGraphics() function which returns image.getGraphics() and paint onto that. Then just call repaint() when you want it painted.

  • Underlying JTabbedPane paints through

    I have a problem where i'm updating some Components on a tab and when that tab is not the currently selected tab the components paint through onto whatever tab is selected. I've tried setting the visibility of the JPanels that are changing to false and then true when that tab is selected but that doesn't seem to work. Any ideas?

    The tab where I'm updating the components is made up of 3 Jpanels, each one is updated with a chart component (the chart is removed, a new one is created and then added to the JPanel). I am using absolute positioning (I calculate the x,y coords based on the chart size and center it in the JPanel). It only occurs when the charts are being updated and a different tab is selected and as soon as I switch to a diferent tab everything redraws fine.

  • Why doesn't paintComponent paint my damn Component??!

    Hello Folks, please help me with this *1@&%' thing.
    Basically I have a class SeatPanel, that extends JPanel and is used for drawing a SeatPlan.
    So, I override
    public void paintComponent(Graphics g)
    someObject.doStuff(g);
    }and that function looks like
    public void doStuff(Graphics g)
    dolotsOfDatabaseQueries();
    while(ResultSet.next())
    doSomeThings();
    g.fillRect(x, y, 10, 10); // Paint some Seats
    }Ok, it works like that, it takes some time and then there appears the Plan on my JPanel.
    What i have to do is letting this function run in a Thread, so this Thread does the DB-Queries and paints the rectangles.
    So I tried to do the Method like this:
    public void doStuff(final Graphics g)
    new Thread(new Runnable()
    public void run()
    dolotsOfDatabaseQueries();
    while(ResultSet.next())
    doSomeThings();
    g.fillRect(x, y, 10, 10); // Paint some Seats
    }}).start();
    }But then there's nothing painted. The Thread does the Queries, but the Painting-Methods do not paint anymore onto my Panel, so it stays blank.
    Can you please tell me why and how to fix that?
    Thank you!

    There are a few problems with the second version of this method.
    Firstly. the new thread is a local field, (local to doStuff(Graphics)) so after the method returns, it will be erased.
    Secondly, even if this Thread was global, it would be re-initialised each time the component is refreshed, which is an unpredictable occurance. To fix this, you would need to place it in a static part of the method.
    I think that you need to re-think the concurrency of this component totally.
    Bamkin.

  • FAQ: What are the known issues so far in Photoshop CS6 Beta

    APPLICATION  COEXISTENCE
    Lightroom 4 Beta + Photoshop CS6 beta -- Editing the same video file simultanously in both applications may result in an error, crash, or blank (transparent) frames. You might see this Photoshop error: "Could not complete the Render Video command because of a problem with Adobe Media Encoder".
    This will only be an issue with Lightroom 4 beta and Photoshop CS6 beta on the same system, editing the same video. The released versions will not have this issue.
    Workaround: Upgrade to LR Release version (even if it's just the trial), or don't open the same file in both apps at the same time.
    CS5 Help fails to launch after install of CS6
    Workaround: Launch the stand alone "Adobe Help" application or reinstall CS5
    CROP
    Crop action shows wrong crop box.Playing an action with a crop step that has dialogs turned on results in a crop box that covers the entire canvas instead of the expected area.
                    Workaround: Ensure that the Crop Tool is selected before running the action or disable dialogs for the action.
    FILTERS
    (32bit OS only) Initial "Merge to HDR Pro" image display and result is black until settings are changed
    Workaround: It will remain black until droplist in the "mode" line is selected, changed and activated, then action appears to be normal.
    Bokeh color is different from preview after render at certain zoom levels on particular image patterns
    Workaround: View image at 100%
    Lighting effects bump map generates artifacts if an alpha channel bump map is used. The resulting preview and final image is artifacted across the gradiated areas of the alpha channel.
                   Workaround: Do not use a gradiated alpha channel as a bump map
    Liquify will perform the filter and save to just part of the photo if you click cancel while it is "finishing processing" a large file.
    LAYERS
    If a vector layer has a center-aligned stroke combined with an inside-aligned layer style stroke, then that vector layer's stroke may not display correctly -- part of the vector layer stroke will disappear as the layer is moved around the image.
    Workaround: Use the "Path Selection Tool" to move your vector around -- alternatively, Change the stroke alignment or remove underlying layers.
    Dragging a selection box while layer filters are applied stops marquee selection from following cursor movement
    Workaround: Even though the graphic of the selection marquee stops, the selection still happens. OR Turn off layer filtering before targeting the layers using a selection box
    TYPE
    Editing text attributes in the Character panel when the layer is locked can result in a crash
    Workaround: Unlock your text layer prior to attribute adjustments in the Character panel
    Setting the menu type>font>preview size to "huge" after opening a saved file caused photoshop to crash
    Workaround: Uncheck Background save in Photoshop CS6
    Style by example or definition not working as expected:
    If any attribute in the Paragraph Panel is set and you create a new Paragraph Style, the new style is based on the default and the override is not cleared.
    DRAWING AND PAINTING
    Paint is offset with Grip Pen- if you select the Soft Low Density Airbrush Preset with Grip Pen paint with swicth facing right with a high tilt towards you the cursor shows the spray should be going up, but it sprays down.
    3-D
    Creating a video timeline and rendering video from two 3D layers may not include ground plane reflections
    Workaround: Use mesh for ground plane instead of 3D engines construct, or duplicate the file and remove the keyframes
    Creating a New background texture after changing lighting presets results in crash
    Workaround: Create the New background texture prior to adjusting lighting presets
    Unable to create a constraint on extruded object with Pillow Inflate setting applied. Further actions may result in Photoshop instability or crash.
    Photoshop may crash when trying to align/distribute constraints from selections of two 3-D extruded objects
    Photoshop may not always save a texture when you paint directly onto the 3d object using Paint on Target Texture setting.
    Photoshop may crash when selecting a different panel filter after the focus has been on 2 fields in the environment flyout with IBL map present
    Photoshop may crash after embedding a 3D layer into a layer group, creating a new 3d object in the group, and then closing the document.
    When changing the color of the lines or points in the 3D scene cross section from the Properties panel, side b color overwrites the color in side A.
    Program Error when adjusting fill value in Layers panel while in Lighting Effects workspace.
    Workaround:You will have to use opacity slider instead of fill slider to pull back the lighting effect
    PLUGINS
    DUPLICATE PLUGINS CAUSE ISSUES ON MAC:
    If you install duplicate plugins or point the additional plugins folder preferences to a duplicate set of plugins (such as, to an older version of Photoshop), then it is possible for odd Photoshop behavior, such as an inappropriate file extension to appear when saving files.
    (example: while performing a "save as"  to JPEG file type, the file format appears to change to .dcm)
    In this case, there may be a duplicate "file formats" plugin that's populating the Save As file types list with duplicates of the same options.
    If there are duplicate file format plugins installed, the Mac OS will remove the duplicates from the list, but you may still see the odd saving behavior.
    Solution:
    Remove the duplicate plugins.
    If you are not sure if you have this issue, but are seeing odd behavior, you can check for duplicates by looking through the plugins listed in the Help > System Info dialog.
    Bridge
    Unable to Copy and Paste in File info in Bridge
    Workaround: Typing info in Manually works, or copy and paste work in Photoshop's File Info dialog
    Install
    Adobe Setup Utility may quit, or error during install. You may see error: "Exit Code: 15"
    Workaround: Create a folder named 'Templates' at "<Windows drive>:\Users\<current user login id>\AppData\Roaming\Micorsoft\Windows\"
    Message saying trial of PS CS6 beta expired,Content coming soon, stay tuned.
    Workaround: re-launch photoshop CS6 beta. This issue should not happen anymore

    1. You can get full support for your camera by upgrading to Lightroom 4. But personally, I would wait for Lightroom 5 since it will be released shortly, probably within the next month. Lightroom 5 will work with Photoshop CS5. The only difference is that Lightroom will need to create a TIF or PSD file that contains all the changes you have made in Lightroom. That's not a big deal, in my opinion. That file has to be created at some point anyway whenever you use Photoshop.
    2. Yes, Lightroom 4 will pass images back and forth between it and Photoshop.
    3.  The upgrade would not break Lightroom 3. It would essentially work the same as it does with your current setup.
    4. If you purchase CS6 it is my understanding you will be allowed to use it indefinitely. This is not true of the Creative Cloud version. Support and updating for additional cameras will cease for CS6. Adobe has announced that they will make Camera Raw 8.1 so that it can be usable with CS6 as far as reading Lightroom adjustments. But any new controls will not be accessible.
    5. So far, Adobe has indicated that they have no plans to making Lightroom a subscription-only offering.
    You are asking your questions as though you are addressing Adobe directly. This is a User-to-user forum. I don't work for nor do I speak for Adobe. I am only giving you the information as I understand it. It seems to me that upgrading to Photoshop CS6 and Lightroom 5 is a "safe" choice. None of us, not even Adobe, really knows what the future will bring. Technology changes so quickly anymore that everything we are doing right now could be obsolete in a matter of a very short period of time. As Adobe changes their marketing strategies I think it will probably motivate some people to look elsewhere. I have Photoshop CS6 and I'm going to upgrade to Lightroom 5. Then I will have to wait and see what develops after that. At any rate, I have tools that I can use for the foreseeable future. If I have to change at some point then I will do so.

  • Photoshop CS4 3D Engine

    For the first time i have finally got around to actually using Photoshop's new 3D engine to paint directly to a model exported as OBJ from Maya 2009. First off, well done to Adobe because it is pretty damn good, but i seem to be having a problem with it of some sort.
    I was working on a model, and i saved it out as a PSD (i assume that is the best format for Photoshop's 3D work as well as 2D work, yes?). When i reopened it later in the day, i found it was streched in the Y axis (Up, which may also be Z in some programs but i can't remeber what photoshop sees it as). The probelm was, was that the model was at a slant just ranomly placed on the screen when i saved it. So when it was streched length-ways, i  couldnt get it back exactly where it was so now the model isn't the same as it's orginal, which it needed to be for what i need it for. Does anyone else get this problem?
    Just to add, although i know it's not very useful posting it here, but if i might make a few suggestions....
    The shadow color, whould be able to be changed so we can see what we are painting in the shadows. I was painting white onto green, and all i could see was black in the shadows, but i chnaged the render settings to not have shadows and show the wireframe with solid colours instead.
    Also, something seems off about the navigation, but i can't make out what it is. This is compairing it to Maya, 3DS Max and ZBrush. It seems to slow to navigate around somehow. Also, shouldnt the manipulator to move around always be shown when using a 3d model, so you dont have to change tools to rotate quick, then brush to paint, then rotate quick and so on. Also, can i ask why there is the option to scale the model in only 1 axis at a time, right next to the move and rotate handles on the navigator? Why would you strech it intentially? You should reall only need to scale it all equally up and down to see what you are doing, but not change the model given to it literally like that in my opinion. (Note that the model was not streched before saving it obviously).

    MDenver wrote:
    ...Place yourself in my position... And I didn't insult her, I just pointed out my personal observations.
    Perhaps you forgot that you said that I acted like a smartass and offered a childish comment.
    It is true that I missed that you were referring to the default objects within Photoshop. I should read more carefully. But knowing how you insult people that attempt to offer help, I won't bother reading your further posts so we won't run into this problem again.
    As Mylenium noted, if you are to replace the default templates with your own models, you'll need to use your modeller found in another true 3D program.
    Place yourself in the position of the few here that desire to help. You'll win more assistance with honey. Dump the vinegar.

  • How to turn a pdf file into excel document and keep original format

    I Have an excel bid form that i use all the time ,then i convert it into a PDF  And once in a while i need to add something to it  I paid for acrobat but when i try to turn the PDF back into an excel document the format is changed , the columns are in the wrong places And it does not look at all like the original excell form is there any thing i can do to  fix this If not this will be useless to me  any help appreciated

    A PDF does not contain any spreadsheet, word processing or page layout file format information.
    No "format", columns, rows, etc.
    "When you create a PDF, you’re painting a picture. Your paintbrush is the is the result of a combination of the software used to create the source document and the software you’ve chosen to convert your source document into the universal electronic document format we all know as PDF.
    Like the painter’s brushstrokes, each character, each line and each image is fundamentally independent, but they can interact with each other to produce particular visual effects. On the PDF page, objects are connected by a coordinate system and not a lot else. There’s no logical, semantic connection between the letters comprising a word; characters simply happen at a series of locations on the rendered page.
    As originally designed, PDF is fundamentally a system for painting objects onto a page, plus a whole lot of other features we aren’t talking about right now! There’s no innate concept of words, sentences, paragraphs, columns, headings, images, tables, lists, footnotes – any of the semantic structures that distinguish a “document” from a meaningless heap of letters, shapes and colors. PDF is fundamentally about how the document appears on the page, not how it looks when abstracted from the page."
    Duff Johnson, Each PDF Page Is a Painting
    http://talkingpdf.org/each-pdf-page-is-a-painting/ 
    Be well...

  • How to create a loop for my problem? Please read for more detail.

    Hi guys,
    I am doing my project and currently i faced one problem and that is more towards looping i guess. My project is about embedding and I had done all the embeding stuffs already but I am only able to embed my barcode into image at starting at coordinate 0,0.
    What i want to know is how do i had to structure my loop so that i can embed my barcode even when i start at x=20 and y=30 for example?
    currently i used nested for loop which is why i can only start at 0,0.
    I wanted to make it something like this:
    for<lets make it x=20>
    for<lets make it y=30>
    <my code retrieve pixel at x=20 y=30>
    <my code retrieve pixel of barcode at x=0 y=1>
    end
    end
    end
    I wanted to have something like above where i can start at 20,30 but at that certain cooridnate i will starting retrieve barcode pixel at 0,0.

    So just say what you don't know how to do, because what I showed is exactly what you need.
    So please answer the following:
    1.) I have an image of my barcode and I don't know how to paint it onto another image.
    or is it
    2.) I have a routine that draws a barcode at a fixed location and I don't know how to get it to draw anyplace I tell it.
    or
    3.) I don't have anything yet, and I want someone to code this for me.
    or it is
    4.) Les you don't have any idea what I want to do, so here is what I need (pay more attention):
    but in any case (well except #3), you'll be better off if you can give us some code to look at and explain what you are specifically trying to do and where you are having problems.

  • Problems with Image scale

    hi,
    I have an Image instance that I want to manipulate by increasing and decreasing its visible size
    I've used many algorithms
    but most of it throws an out of memory error when enlarging for a couple of times.
    such as getScaledInstance(),or so;
    another thing,
    does any one know how to get a BufferedImage reference out of Image reference without casting?
    I hope any one can help.
    thanks in advance

    Maybe the code underneath helps to solve your bufferedImage/Image problem. scaledImage is the Image in that case. your other problem, in fact is, that u are running out of memory, because the Image repaints itself on and on again wihout being cleared out of the memory. in that case i would have to know about what u woild like to do with the program, so that maybe i can be of help for u. hope that helps...
    if (image != null)
    //Create BufferedImage as base
    BufferedImage sub = new BufferedImage
    Width,Height,BufferedImage.TYPE_INT_RGB);
    //Initialize painting area
    Graphics2D g = sub.createGraphics();
    //Paint scaledImage onto painting area
    g.drawImage(scaledImage, (int) -Sx, (int) -Sy, null);
    g.dispose();
    }

  • PDEXGroup to set the Page Group ColorSpace

    Hello,
    I'm currently trying to add an Image into a PDF (that's the only content) but as I read on previous threads I'm trying to get a correct rendering when there is an alpha (channel/mask) in my image.
    To do so I first create an Image (PDEImageCreate) then I create the Alpha mask and apply it to the first image (using PDEImageSetSMask).
    The problem is now my image is too dark in "Acrobat Reader" and is correct in Evince. So I guess my problem is Acrobat try to blend in CMYK but my source image is in RGB.
    But I don't really understand how I should/could specify that ? I tried in the Resources of the Page, and then I tried the PDEXGroup, but how can I add my XObject to the PDEXGroup ?
    Am I on the wrong track trying to set the Page ColorSpace ?
    Thanks in advance.

    Following your indication I re-read the paragraph relating to Transparency group. starting with the 11.4.7.
    All of the elements painted directly onto a page—both top-level groups and top-level objects that are not part of any group—shall be treated as if they were contained in a transparency group P
    My main question here is how do I get access to this "group P" ?
    Because I didn't found how, I searched "how to specify a blending" which leads me to paragrap 11.6.3
    11.6.3    Specifying Blending Colour Space and Blend Mode The blending colour space shall be an attribute of the transparency group within which an object is painted; its specification is described in 11.6.6, "Transparency Group XObjects."
    Ok so how to define a Transparency group is in 11.6.6 (still my original question)
    Summarized : a transparency group is a specialized form XObject with a Group entry in its dictionnary. (Group with subtype "/S /Transparency")  Also a Page may have a Group entry (some entries in this dictionnary may be  interpreted differently when in a Page group).
    So (again) I looked at the right paragraph to make a Group 8.10.3, "Group XObjects".
    This paragraph finally describe what the CosObj should look like  I expect it to be something like :
    6 0 obj                                % Form XObject
       << /Type /XObject
          /Subtype /Form
          /FormType 1
          /BBox [ 0 0 1000 1000 ]
          /Group <>      /Matrix [ 1 0 0 1 0 0 ]
          /Resources << /ProcSet [ /PDF ] >>      /Length 58
        >>stream   
    endstream
    endobj
    But alas my main concern is still here, how do I add a PDEImage in a PDEGroup or PDEForm or CosObj and then overwrite the Page content with this new content in order to change the default Blending ColorSpace ?
    You said to use the Cos API but what the Cos Object should look likes when the Color Blend Space is correctly set ?
    Below there is some code sample that I used to get this working.
      1 void func()
      2 {
      3         PDDoc       document;
      4         PDPage      page;
      5         ASFixedRect mediabox;
      6         PDEContent  content;
      7
      8         /* Some or most informations are skipped below for readability but important
      9          * call remains
    10          */
    11
    12         document = PDDocCreate();
    13
    14         page     = PDDocCreatePage(document, PDBeforeFirstPage, mediabox);
    15         content  = PDPageAcquirePDEContent(page, NULL);
    16
    17         /* setup arguments PDEImage */
    18         image    = PDEImageCreate(....);
    19         /* setup arguments for Image mask / alpha channel */
    20         mask     = PDEImageCreate(....);
    21
    22         PDEImageSetMatteArray(mask, ...);
    23         PDEImageSetSMask(image, mask);
    24
    25         CosDoc documentCos = PDDocGetCosDoc(document);
    26         CosObj xobjForm  = CosNewNull();
    27         CosObj resources = CosNewNull();
    28
    29         /*
    30          * Here is the naive version I first tried which as you explained should be
    31          * done using Cos_Layer functions
    32          */
    33 #if defined NAIVE_VERSION
    34
    35         /*
    36          * Doesn't work
    37          */
    38
    39         CosObj imgCos;
    40         PDEImageGetCosObj(img, &imgCos);
    41         PDEXGroup grp_image = PDEXGroupCreateFromCosObj(&imgCos);
    42         PDEXGroupSetColorSpace(grp_image, PDEColorSpaceCreateFromName(ASAtomFromString("DeviceRGB")));
    43
    44         PDEContentAddElem(content, kPDEAfterLast, image);
    45         PDPageSetPDEContent(page, content);
    46
    47 #elif defined SECOND_VERSION
    48
    49         /*
    50          * Doesn't work
    51          */
    52
    53
    54         PDEContentAddElem(content, kPDEAfterLast, image);
    55
    56         PDEForm myf = NULL;
    57
    58         PDEContentAttrs  pdeContentAttrs;
    59         memset(&pdeContentAttrs, 0,  sizeof pdeContentAttrs);
    60         PDEContentGetAttrs(content, &pdeContentAttrs,  sizeof pdeContentAttrs);
    61
    62         PDEContentToCosObj(content, kPDEContentToForm, &pdeContentAttrs,
    63                 sizeof pdeContentAttrs, documentCos, NULL, &xobjForm, &resources);
    64
    65         if (!CosObjEqual(xobjForm, CosNewNull()) && !CosObjEqual(resources,  CosNewNull())) {
    66             /* success retrieving form & resources */
    67
    68             // Put resources into the Form XObject stream dictionary
    69             CosDictPutKeyString(xobjForm, "Resources" , resources);
    70
    71             // Set BBox key for the Form XObject according to the image page
    72             ASFixedRect rectOrigPage;
    73             PDPageGetMediaBox(page, &rectOrigPage);
    74
    75             CosObj BBoxArray = CosNewArray(documentCos, 4,  false);
    76             CosArrayPut(BBoxArray, 0, CosNewInteger(documentCos, false, ASFixedRoundToInt16(rectOrigPage.left)));
    77             CosArrayPut(BBoxArray, 1, CosNewInteger(documentCos, false, ASFixedRoundToInt16(rectOrigPage.bottom)));
    78             CosArrayPut(BBoxArray, 2, CosNewInteger(documentCos, false, ASFixedRoundToInt16(rectOrigPage.right)));
    79             CosArrayPut(BBoxArray, 3, CosNewInteger(documentCos, false, ASFixedRoundToInt16(rectOrigPage.top)));
    80
    81             CosDictPutKeyString(xobjForm,  "BBox" , BBoxArray);
    82
    83             // Set matrix key for the Form XObject
    84             ASFixedMatrix  defaultMatrix;
    85             PDPageGetDefaultMatrix(page, &defaultMatrix);
    86
    87             myf = PDEFormCreateFromCosObj(&xobjForm, &resources, &defaultMatrix);
    88
    89             PDEXGroup trpgroup = PDEXGroupCreate(documentCos, kPDEXGroupTypeTransparency);
    90             PDEXGroupSetColorSpace(trpgroup, PDEColorSpaceCreateFromName(ASAtomFromString("DeviceRGB")));
    91
    92             PDEFormSetXGroup(myf, trpgroup);
    93             PDEContentAddElem(content, kPDEBeforeFirst, (PDEElement) myf);
    94
    95             PDPageSetPDEContent(page, (ASExtension) PDEFormGetContent(myf));
    96         }
    97
    98 #else
    99
    100         /*
    101          * Doesn't work
    102          */
    103
    104         CosObj xobjForm  = (CosObj) CosNewDict(documentCos, false, 1);
    105         CosObj resources = (CosObj) CosNewDict(documentCos, false, 1);
    106
    107         CosDictPutKeyString(xobjForm,  "Type", CosNewName(documentCos, false, ASAtomFromString("XObject")));
    108         CosDictPutKeyString(xobjForm,  "Subtype", CosNewName(documentCos, false, ASAtomFromString("Form")));
    109         CosDictPutKeyString(xobjForm,  "FormType", CosNewInteger(documentCos, false, 1));
    110
    111         CosObj array_bbox = CosNewArray(documentCos, false, 4);
    112         CosArrayPut(array_bbox, 0, CosNewInteger(documentCos, false, 0));
    113         CosArrayPut(array_bbox, 1, CosNewInteger(documentCos, false, 0));
    114         CosArrayPut(array_bbox, 2, CosNewInteger(documentCos, false, width));
    115         CosArrayPut(array_bbox, 3, CosNewInteger(documentCos, false, height));
    116
    117         CosDictPutKeyString(xobjForm,  "BBox", array_bbox);
    118
    119         ASFixedMatrix frmMatrix;
    120         frmMatrix.a = FloatToASFixed(1);
    121         frmMatrix.d = FloatToASFixed(1);
    122         frmMatrix.b = frmMatrix.c = frmMatrix.h = frmMatrix.v = fixedZero;
    123
    124 #endif
    125
    126         PDDocSave(document, ....);
    127
    128 }
    Thanks again for your help.

  • Reuse ImageIcon across multiple applets

    I have 5 applets and a gif image that all reside in the same JAR file. I have a common class that loads up the gif and then paints it onto a JPanel in each of the applets. When I run the different applets, using Java Plug-in 1.3.1 (IE 5.0), the image displays fine in the first applet i run, but all subsequent applets fail to load it. I'm loading it each time the applet launches using the following method:
    animatedGif = new ImageIcon(
    Toolkit.getDefaultToolkit().getImage(getClass().getResource(imageFileName)));
    Anyone have any idea why it only displays in the first applet launched? Thanks.

    I tried cloning the image, but did not solve the problem. I added code to check the load status of the image, and found that MediaTracker is reporting an ERRORED load status on the second, and subsequent loads. Is there any way to get more specific info on the reason MediaTracker errored? It's not throwing any exceptions.
    animatedGif = new ImageIcon(
              Toolkit.getDefaultToolkit().getImage(getClass().getResource(imageFileName)), "Loading image");
    System.out.println("******** animated GIF=" + animatedGif);
    int err = animatedGif.getImageLoadStatus();
    if (err == MediaTracker.ERRORED) {
         System.out.println("******MediaTracker ERROR");
    } else if (err == MediaTracker.COMPLETE) {
         System.out.println("******MediaTracker COMPLETE");
         }

Maybe you are looking for

  • Forms demos problem / bigraph form unable to find javabean

    hi there, i've installed the developer suite 10g and the forms-demos with patches. i can call 127.0.0.1:8889/forms/formsdemos/demo.html, everything loads fine... beans, images (regering to the bigraph demo). but when i open the graph.fmb with forms d

  • Can anybody tell me what is the problem in the code below?

    package first; class A { A a; A(){} A(A aa){ this.a=aa; String name; void setname(String a){ this.name=a; void bar(){ dostuff(a); void dostuff(A a1){ a.setname("vahvah"); //a1=new A(); public static void main(String args[]){ A a2=new A(); A a1=new A(

  • How to start EM in Oracle Web Center?

    Please guide how to start EM in Oracle Web Center? as i am not getting emctl file in BIN Directory of Oracle Web Center Home... Please guide and help Thanks, Waheed.

  • Shared photostream disappeared

    Hi all! I have a serious problem with a shared photo stream. I have 9 shared photo streams in total, all have been working well except one for the last week. This particular stream is shared with about 8 people, and everyone is able to add pictures t

  • Deployment Error of VO w/ JBO-25058: PartyName879_PartyName not found

    Need additional help with an OAF deployment issue... I am attempting to deploy 5 OAF pages for E-business R12 using customizations: (order management) ImcHierarchyAddChild.xml ImcHierarchyCreate.xml ImcHierarchyView.xml ImcHierarchyAddParent.xml ImcH