Problem: Mulitple panels, one Graphics2d object?!?!

Help!
My application contains one main JPanel, called DrawingPanel. DrawingPanel contains many different Graphics2D objects that it periodically repaints and redraws. When a user clicks on one of these objects, the listener pops up a different JPanel (a list of these new Panels is a member variable of DrawingPanel). In this JPanel I want to draw some new Graphics2D objects. The problem is that when I call paint or paintComponent in the new JPanel (i've tried both) the Graphics2D object contains all the objects from DrawingPanel also. How do I get rid of this extra garbage? I've tried using the dispose function after painting the graphics in both places, but this doesn't work...ideas?
(sorry, for the cross post to java swing if anyone noticed...I'm desperate and figured that maybe I put this in the wrong forum originally...thanks)

your query is difficult to understand, if ur problem is related to painting to the specific panel try
painting
component.paintComponent()
or if ur panels are a differnet classes then try to override the paint method in each place.
and if u do not want a paint method at all
then create a graphics object with
component.getGraphics() method and dispose ur
graphics object inside finalize() method.

Similar Messages

  • Merging Two Graphics2D objects into one

    Is it possible to accomplish this:
    1) have a method in class A that returns a Graphics2D object
    2) have a method in class B that returns a Graphics2D object
    3) have class C call both class A's and class B's methods that return Graphics2D objects
    4) lay those two Graphics2D objects into a new Graphics2D object within a component's paint(Graphic g) method
    What I am trying to do is a lot like a Viso diagram, that is drag a graphic onto another graphic x numberof times and perform some kind of layering technique.
    Thanks

    Why don't you pass a graphics 2D into each method, and get method to draw onto that. Then it becomes very simple to combine each.
    MArk

  • Changing a Graphics2D object into a BufferedImage

    Well subject says it all really. At some point in my code I extract a Graphics2D object from another object, and I'd like to store it as a BufferedImage. The code below does almost what i want, but not quite.
    BufferedImage img;
    GraphicsConfiguration gc = this.getGraphicsConfiguration();
    this.img = gc.createCompatibleImage(getWidth(), getHeight(), BufferedImage.OPAQUE);
    Graphics2D g2d = img.createGraphics();
    This is the only hint I've been finding around the forums, and it works well if you just want to draw new drawings on a BufferedImage. However, I have a Graphics2D object that already contains alot of graphics, and I want to copy this into a BufferedImage. I can't seem to find a way to do this no matter where i look.
    Any help would be appreciated.

    reading through alot of code will be alot more work than a simple explanation of the problemA good SSCCE is many times easier to understand than a description.
    That said, if I understand what you are trying, I assume you have a paintComponent override in nr1 that has a drawImage statement, and you want to obtain a part of that image in nr2 which is in a different class, to a BufferedImage in the same class as nr2.
    If that's it, you can construct a BufferedImage of appropriate size and call the paintComponent method of nr1 with the Graphics reference of the BufferedImage, translated or otherwise transformed if necessary, to paint the panel's painting on the BufferedImage. Something like (in the class containing nr2)
    BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
    Graphics2D g = bi.createGraphics());
    g.translate(x, y); // optional
    g.setClip(x1, y1, w1, h1); // optional
    nr1.paintComponent(g);Note that you need a reference to panel nr1 in the class containing nr2.
    Now (even if this is not what you needed) which was easier to understand -- the description above or the code? So if that's not it, don't expect anything more without a SSCCE which only demonstrates the problem faced -- not 500 lines of code that have nothing to do with the problem.
    luck, db

  • Jpanel holding a Graphics2d object

    hi!
    Im trying to properly extend JPanel to display a Graphics2d Object that already exists. So what I have done is extended JPanel, and in the constructor, I send the graphics2d object that i would like displayed on the jpanel object.
    Then in paintComponent, I cast the graphics object to a graphics2d object and set the value equal to the graphics2d object already created.
    The problem is that when I use the component, all I get is a blank jpanel. I dont know what the problem is... code follows, please let me know what you think
    Thanks.
    public class JPanelGraphics2d extends JPanel{
         Graphics2D m_g2d;
         JPanelGraphics2d (Graphics2D g){
              m_g2d = g;
              setPreferredSize(new Dimension(450, 450));
         public void paintComponent(Graphics g) {
              super.paintComponent(g);
              Graphics2D g2 = (Graphics2D)g;
              g2 = m_g2d;
    }

    It looks a bit like you don't understand the nature of Java's method parameters.
    Setting g2 = m_g2d does nothing outside your paintComponent method - it simply changes the reference that g2 holds within your paintComponent.
    However, there's also something else wrong about your approach. A Graphics object is simply a toolkit and context for drawing graphics - it doesn't maintain any image of what's been drawn. An Image is what contains imagery and graphics - a Graphics is what's used to draw this.
    Therefore you're probably after creating an Image, passing that your your panel and drawing that in the paintComponent method.
    Hope this helps a bit.

  • Uix two view-objects on one entity-object synchronize

    Hi All
    I want to add some uix pages to an old project using ADF UIX and Business Components.
    I have an entity object to a table witch about 50 fields.
    Now I create two view objects due to a better performance. One witch seven attributes for the overwiew and one with all attributes for the detail page.
    They are related via a view link.
    I create the overview as a read-only-table and the detail-page as an input-form.
    The proplem is that the synchronization don't work. The detail page shows the first dataset ever.
    Has anyone a solution or a tip where I can found that?
    Is where a performance problem if I use one view-object for both pages?
    Thanks in advance
    Roger

    Use custom DataAction for the first page:
    package controller;
    import oracle.adf.controller.struts.actions.DataAction;
    import oracle.adf.controller.struts.actions.DataActionContext;
    public class Class1 extends DataAction
      protected void validateModelUpdates(DataActionContext actionContext)
         //super.validateModelUpdates(actionContext);
          // put you custom validation here
    }http://www.oracle.com/technology/products/jdev/collateral/papers/10g/ADFBindingPrimer/index.html#usingdataaction
    Message was edited by:
    Sasha
    Message was edited by:
    Sasha

  • Can i Bind more than one Model object to the Custom controller or not

    Hi All, I trying to bind more than one model object to the custom controller, Both the model objects contains same attribute name called ( output). Both model objects created on to top of the BAPI. So when i bind first model object to the custom controller will work fine. When i am trying to bind the second model object to the same controller. This second model object also having the same attribute name called "output" . So it is giving an error of "Duplicate context element "Detail". Rename or uncheck duplicate elements.
    can i assign more than one model object to the single controller or not?
    But in the reference document, it has given that , we can create model object with more than one bapi.So in this case if both the bapis contains any element with the same name will also be problem. Any body give me the solution.
    Initially we have created one custom controller for each model object. But later i realized that, why con't we use same controller for all the model object. Because, the custom controller context is the public context. this context shared across all the view controllers.
    The concept which I am trying to do is right or wrong?

    Hi Vishal,
    of course, you can bind one controler to many models. When the same name occours you can simply RENAME binded node in controler.
    Regards
    Bogdan

  • Possible?Multi-Entity View Object with one Entity Object that is Read-only.

    I know this sounds crazy, but I would like to create a multi-entity view object, where one entity object is based on a table in my application (we'll call it "Users", which basically stores the primary key for the person from the institutional people database), and the other table is a entity object based on a view of the institutional people database table (read only access), which we can call "People".
    I know that since no updates will be done to the People table, it really should be a read-only View Object, but I would lose the ability to sort on attributes like Last Name, Hire date, etc, since those would be transient attributes in my ViewObject for the Users. By having People as an entity object, I can then create a multi entity view object and have the ability to join Users to People and be able to sort on the above mentioned fields (like Last Name).
    The problem is that when I use the JDev (I'm currently using 10.1.2.1) AppModule BC4J tester, when I click on the multi-entity view object that I added to the AppModule it gives me an error:
    oracle.jbo.RowCreateException) JBO-25017: Error while creating a new entity row for People.
    ----- LEVEL 1: DETAIL 0 -----
    (java.lang.InstantiationException) null
    I have tried to change all the attributes to updateable in my entity object, but no create method, and I have tried to make them all read-only, but no effect, I get the same error (probably because the People view is read-only in my schema).
    Is there a way to change the entity object so that it will not try to create a new row when it runs the Tester? So that the multi entity view object behaves more like a view link, but gives me the added bonus of being able to sort on the Last Name column from the People table?
    Thanks for any help on this subject...at worst, I will have to use the view link method to get the job accomplished, but it would be "cooler" if this would work!
    Jeremy.

    Steve, thanks for your quick response to my question.
    To answer your questions, I was trying to create the Multi-entity View Object to give me more flexibility when working with my User table, and my People view. The flexibility I desired was that I would be able to sort my Users based on attributes in the People view. This is not possible when the there is only one Entity in my VO, and the People view data are all transient attributes, because they are not in the SQL statement.
    Ultimately, after working with one of my colleagues, we decided to use the approach that you mentioned by creating a read-only VO with the SQL query we want to display to the user (contains both User and People data fields), and then use a different ViewObject when performing other actions on the User Table (such as inserts/updates/deletes). By using the setWhereClauseParam() method in the handleLifeCycle() for the JSP page, we should be able to navigate between the different View Objects, so that the user does not see any difference.
    Thanks! Oh, and by the way, I have read your article you included before, and I have used it many times before to tune my View Objects! Thanks!

  • How to bind 2 ADF Select One Choice objects to work as a relation

    Greetings,
    im new to Jdeveloper, i got used to Microsoft Visual Studio (regarding bindings) and im lost here.
    So here what im trying to do:
    I have 2 tables in my database (Cities & States),
    i am creating 1 view object for each so i can link them to "select one choice" objects. The first object, should show ALL cities (that part is done),
    but when i choose a city from that object, the second object should show only the corresponding states of that city. I managed to do
    that, using ADF Form, simple by clicking navigation buttons, and what ever is on the city list, the correct states are shown in the second object.
    My goal here is, instead of navigating with buttons (for the city object), and then choose states from the second object as a list, i want also my city
    object to be a "select one choice" object, so both will be a drop down list, and not navigating to all cities until i find the one im searching for.
    I try that but when i choose a city from city object, the second object is not show the corresponding states but keep showing all the states that exists in my country.
    I don't want to use java beans for this but just adf bindings.
    Can you assist me please?

    My characters are greeklish (greek, using english characters, ill try to explain)
    http://prntscr.com/1cfvd0       (Data Control View)
    NomarxiaView3 (Cities)
    CodeNomoy (state's id)
    Perigrafy (city's name)
    PoleisView4 (States)
    CodeNomarxias(city's id)
    Perigrafy (state's name)
    http://prntscr.com/1cfwe4      (the page)    
    Perigrafy's settings      http://prntscr.com/1cfwku    
    CodeNomy's settings      http://prntscr.com/1cfwok    
    make not PoleisView4 inside of Nomarxia (cities), so thats the relationship i use for states.
    *A small update, im trying different combos for partialTrigger or in general anything so i can figure out my self whats the problem of not refreshing the 2nd object,
    and i noticed most of the cases im getting this warning "<FacesCtrlListBinding> <getInputValue> ADFv: Could not find selected item matching value 1 of type: java.lang.String in the list-of-values."
    looks like whatever i choose from the list of cities, it keep looking of value 1 (keep in mind value 1, do not have a state relation, only half of my list currently have states).
    That means the problem is not refreshing the 2nd object (atleast for now), but refreshing its own id

  • Error handling in CRM One Order Object

    We have done some enhancements in the CRM One Order Object standard process. We need to raise some custom error messages under certain error conditions from our code. For that, we are using the standard function module CRM_MESSAGE_COLLECT. The caller_name that we currently pass to it is a standard object (CONFIG) maintained in CRMC_OBJECTS table.
    Now, we also want to delete "our" error messages (and not the ones coming from the standard process) when a certain state has been reached. I found function module CRM_MESSAGES_DELETE which could be used for this purpose. But, the problem is that if we pass object 'CONFIG' to it, it would delete all the messages (even the ones that were not raised by our code) belonging to that object.
    I also tried passing a key (a random string) to CRM_MESSAGE_COLLECT's import parameter IV_LOGICAL_KEY and then using the same key while calling CRM_MESSAGES_DELETE but it did not work.
    One possible solution I see is that we add a custom object to CRMC_OBJECTS and then use that as a handle to "our" error messages. But I don't know what is the standard way of maintaing data in this table. It doesn't have a maintenance view for it and neither could I find any links to it in IMG.
    Can anyone help with a solution?
    Thanks in advance.

    Yes creating a new Object may not be a solution for you as it might have some downstream impact.
    Reading your problem again, if you want to delete only the custom messages, why don't you pass the message-id and message number you want to delete to the function module - CRM_MESSAGES_DELETE. I assume, since these messages are custom, so you might get a Z-message id along with the message number.
    Regards,
    Shyamak

  • Ps CS6 Problem: Transform applied to Smart Object cannot be repeated on another target

    Ps CS6
    OS X 10.6.8
    Problem: Transform applied to Smart Object cannot be repeated on another target.
    "Edit > Transform > Again" fails to transform any target after a Transform is applied to a Smart Object. The following message appears:

    When ever I have a problem in CS6 and I have many I always test priot releases like cs2 cs3 cs5.  I nevet nitice before you posted this problem the Photoshop has different favlors of Free Transform and that free transform for CS6 has been modified.  Adobe seems to be introducind new improvement matche with new bugs, 
    Investgating your bug using CS5 I see the following.  There are two types of free transform one type seems to be for smart Object layers and the other for other layer types.  In CS5 you should see a difference in the Option bar for Free transform.
    The option bar for layers other then smart object looklike this:
    Transform 9 anchor point icons  X: field Relative icon Y: filed  W: % Constrain icon H: %  Angle ° H: ° V: °
    The Option Bar for Smart Object layers look like this:
    Transform 9 anchor point icons  X: field Relative icon Y: filed  W: % Constrain icon H: %  Angle ° Check Box Anti Alias (grayed out)
    If I use the one for other then smart object layers Transform Again is not gratey out and I can use Transform Again on layers even smart object layers However the anchor point seems to be relative always to the first transformed layer's anchor point
    If I use free transform on the smart Object Layer and not have done any transform on a other then smart object layer in this Photoshop session not even in an other document the smart object layer will be tramsformed and Transform again menu item will be grayed out. If any had done a Transform on an layer other then smart object layer even in an other document Transform Again would not be grayed out and could be used on the smart object layer at hand.  The transform would not be the one just done on the smart object layer rather it be the one done to the other then smart object layer.  Seems a bit bazzar to me.  This may be how CS6 is also working.
    CS6 also added interpolation method to the other then Smart object layer transform and not the one for smart object layers. To be consuitant Adobe should have also put interpolation into the omart opject transform for Adobe transforms smart opject layer by first rendering the pixels for the smart opject then transforms them like a raster layer.  Adobe did manage to record the interpolation use into an action step.  However I do not know if the made it into Scripting  it did not make it into the photoshop javascript user guide. I will test the scriptlistener plugin to see if it records it for the action manager....
    Message was edited by: JJMack
    I have now tested the Scriptlistner Plugin it does record the interpolation for transform normal layers. Still the layer resize method in the Photoshop Javascript user guide has not been change for that support. In the past what I have done is scripting was to save the users default interpolation Photoshop prenerenvr changed the preference to what I wanted to use do the layer transform resize then restored the users interpolation preferance.  Adobe broke that in CS6 if the users defalt preference is what Adobe's defalt is "Bicubic Automatic" an internal Photoshop error occurs. Adobe did not add "Bicubic Autoimatic" to scripting when I try to save the preference scriping has the internal error. There is also no way to set the preference back to "Bicubic Automatic.  I'm also transform smart object layers so I would still have to use the save preference, change preference, transform, restore preferance method.  This works if the users preference is set to some preference other the "Bicubic Automatic"
    Message was edited by: JJMack
    So to me it look like CS5 and CS6 transform work basiclly the same.  There seems to have been some behavior changes made to CS6 I can not seem to put my finger on as well as the addition of the interpolation method in the option bar. I can't put my finger on it so it may be the same in CS5 and CS6.
    It may have to do with the bazar behavior of Free Transform  and Transform Again not being available on smart object layers if no free transform to a normal layer has been done in this Photoshop session  but are available if one was done in any doument. And thet you can start to do a transform on the smart object layer and see the Transform handle but then start using transform Again shortcut Ctrl+Shift+T and watch the old transform being done perhaps rotating some virtual anchor point and not around the acnchor point bing displayed in the Transform bounding box and control points.
    Message was edited by: JJMack
    Over in the Adobe Feedback site several issues were posted with CS6 Transform one was marked "Not a problem" by Adobe. One was marked "Solved" by Adobe and the others have no Adobe markings the may on not be a problem
    So I beleive there is a bug but I do not think it originated in CS6 the bazar things I see happing also seem to be in CS5.

  • Transport Problem  - flow from one DSO to another DSO.

    Hi all experts,
    I am loading one DSO from program.  And based on first DSO, I am loading second DSO.
    In other words, second DSO is getting loaded from first one.
    While transporting from dev to quality system do i need to activate and include info-source of first DSO in the request ?
    <b>or</b>
    mere activation of both DSOs and update rules will be sufficient ?
    Waiting for your reply..
    Regards
    Vinay

    Thanks Patric.
    I am facing one problem.
    In one single request I have included two DSOs. ( One DSO is loading second DSO. ) Also I have included Info-source (generated from first DSO, commn structure and transfer structure).
    I also activated the update rules. But transport is getting failed showing error as below
    Start of the after-import method RS_UPDR_AFTER_IMPORT for object type(s) UPDR (Activation Mode)
    Update rules {tech name of update rules} read in version M
    Error when activating update rule {tech name of update rules}
    Activation of the update rules for {second dso} { 8first dso }
    IC={second dso} IS={ 8first dso } error when checking the update rules
    Can you help in this issue ?
    Regards
    Vinay

  • Dragging more than one display object in flex3

    As per my knowledge, we can drag and drop only one display object at a time.... What should i do if i want to drag more than one display object together as a group.
    I am having a canvas and inside it i am having a box..... In that box I am having many Panels.... Now i can create a group of adjascent panels.... And i can drag that panel group to some other place in that box only....
    So how to drag a group of display objects together.

    You can use custom code for that.  Flex doesn't use the Flash Player's dragging API.  It monitors mouse activity instead.  There is an example in Panel.as.  You can extend it to move more than one panel.
    Alex Harui
    Flex SDK Developer
    Adobe Systems Inc.
    Blog: http://blogs.adobe.com/aharui

  • How can I stack Graphics2D objects

    How can I stack two or more Graphics2D objects on the same BufferedImage.

    I am trying to create layers. Here is an example I have started with. The problem is the remarked code. The effect is correct but it is applied to the complete image. I would like to separate the effect to only the shadow text. I would appreciate any help. I am new to Java so still fumbling around with concepts.
    import java.awt.*;
    import java.awt.font.*;
    import java.awt.image.*;
    import java.io.*;
    import javax.imageio.*;
    import java.awt.geom.*;
    import java.util.*;
    public class ShadowText {
    static Rectangle2D.Double Rectangle;
    static BufferedImage image;
    static Graphics graphics;
    static Graphics2D g2d;
    static TextLayout textLayout;
    public ShadowText() {
    public static void main(String[] args) {
    BufferedImage image = new BufferedImage(500,120,BufferedImage.TYPE_INT_RGB);
    Rectangle2D Rectangle = new Rectangle2D.Double(0,0,500,120);
    graphics = image.getGraphics();
    g2d = (Graphics2D) graphics;
    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
    g2d.setPaint(Color.white);
    g2d.fill(Rectangle);
    g2d.draw(Rectangle);
    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
    //g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, .5f));
    textLayout = new TextLayout("Shadow Text", new Font("Serif", Font.BOLD, 70), g2d.getFontRenderContext());
    g2d.setPaint(Color.black);
    textLayout.draw(g2d, 12, 102);
    //float ninth = 1.0f / 9.0f;
    //float[] kernel = {ninth, ninth, ninth, ninth, ninth, ninth, ninth, ninth, ninth};
    //biop = new ConvolveOp(new Kernel(3, 3, kernel));
    //op = (BufferedImageOp) biop;
    //image = op.filter(image,null);
    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
    textLayout = new TextLayout("Shadow Text", new Font("Serif", Font.BOLD, 70), g2d.getFontRenderContext());
    g2d.setPaint(Color.black);
    textLayout.draw(g2d, 10, 100);
    Write("C:/JavaTraining/Filters/images/ShadowText.jpg",image);
    public static void Write(String file, BufferedImage image){
    //Check for file exsist
    StringTokenizer tokens = new StringTokenizer(file,".");
    if(tokens.countTokens()>0){
    String filename = tokens.nextToken().trim();
    String type = tokens.nextToken().trim();
    try{
    if(type.equalsIgnoreCase("gif")) type = "png";
    ImageIO.write(image, type, new File(file));
    }catch (IOException e){
    System.out.println("Invalid file name or path! "+file);
    }else{
    System.out.println("Invalid file name! "+file);
    }

  • InDesign Problem Using Panels in Vista

    I have InDesign installed on two computers. The one with Windows XP runs InDesign just fine, no problems, but the one running Vista I am unable to use the selection tool without using the keyboard command and I am unable to use or select anything on any of the panels. The drop down menus are enabled but other than that I cannot select anything.
    I have reset the default preferences and even tried renaming them so that the system was forced to reset to the defaults.
    I have tried uninstalling and reinstalling the program. I can only be lead to believe that this is a Vista problem since it is working fine in XP.
    Help anyone?

    I don't have Aero as a Color Theme selection and I just changed the font to the default (96 dpi) as suggested in the Adobe link you sent. This seemed to enable me to use the panels now but everything is so small now, not just that program but everything and I'm not sure that I will be able to work with it this small.
    Thank you for the information. It's the first time I was able to use the InDesign in Vista. My problem is that I need to work back and forth between InDesign and Photoshop and I can't get Photoshop to cooperate with the Windows XP. It was working fine but then as of last week it now tells me that I need to enable GPU enhancements through Performance setting in the Preference Panel.
    Well, when I go into the Preference Panel then the system shuts down. Same thing if I try to open a photo. It opens then immediately shuts down.
    Any information on this?
    I've just started with the Adobe Forums and have been reading all of your responses so far. Thank God there are brilliant people out there for those of us less fortunate.

  • Can i open more than one Resultset object

    hi in my program i have to retrive data from three table and the data from three
    table i have to use in another one
    i wanna know that can we open more than one ResultSet object within one
    try{
    }catch{] block ( i means ResultSet rs = st.excuteQuery(query) more than one time for different -different tables)
    or there is any other way to do this

    You can only have one active result set per statement at a time.
    Depending on the driver you are using you might be able to have more than one active statement (and result set) on one connection. Or not.
    Try catch has nothing to do with that.
    If you are nesting result sets then it is likely you should be using a join (SQL) which would then only require one result set.

Maybe you are looking for

  • Agent Inbox Enhancement with Z fields in CRM 2007

    Hi All, I' m working in CRM 2007. i have a requirement to enhance the Agen inbox search criteria with the Z fields. i have enhanced the BOL structure with the z fields and did some design layer customizing to get the drop of this Z fields. now i need

  • Compressor never works for me

    I shot my friends music video with my Canon 7D, imported it straight into FCPX- edited it- sent it to compressor- chose 1080p HD Video sharing, and it never works. The compression fails everytime. I've tried other compression settings as well. Any he

  • How to modify the frequency of a pulse generator without stopping application

    I need to generate pulses on a counter output of a 6024 card. But I have to change the frequency while the programm is running between 1Hz to 800 Hz. If I do the initalization on each loop, the system becomes very slow and I can't reach 800Hz. Anyone

  • IPod touch says connected to Internet but won't open apps as says not connected to Internet!

    iPod is connected to wifi. It won't connected to iTunes or any app saying it needs Internet connection.... Have tried turning it all off etc which usually works but still not working. Any help please. Thanks

  • Data sources for 0PP_C02

    Hi Gurus, I need to develop report which should show Production : quantity & value of goods produced monthly for that i found 0PP_C02