Painting JComponents with CellRendererPane

I wrote a class that paints arbitrary JComponent that way it looks like itself but without any specific behavior. For example I paint JButton. It looks like JButton but it is not highlighted when mouse moves over it. It ignores clicks on it etc. Its just an Image of JButton!
I use CellRendererPane (package javax.swing) for this effect. Here is my wrapper class for drawing arbitrary JComponents (not full version):
public class DesignerModeComponentRenderer extends JPanel
protected JComponent representedComponent;
private CellRendererPane pane;
public DesignerModeComponentRenderer(JComponent representedComponent)
this.representedComponent = representedComponent;
pane = new CellRendererPane();
Dimension d = representedComponent.getPreferredSize();
setPreferredSize(new Dimension(d.width, d.height));
public void paint(Graphics g)
Dimension d = representedComponent.getPreferredSize();
pane.paintComponent(g, representedComponent, this.getParent(), 0, 0, d.width, d.height, true);
}As you can see it's just a JPanel with overriden paint(Graphics g) method where CellRendererPane draws representedComponent.
When I wrap JLabel, JButton, JTextField, JCheckBox with this class I reach desired effect. But when I use this class to draw JComboBox it is painted incorrectly. There is only Selected Option without arrow button that opens popup menu with options. And when I try to wrap JPanel with internal content elements I get just JPanel without any sign of its child components.
What's wrong? I'm sure that I'm on right way. But something losed in my method.
It seems that CellRendererPane must call paintChildren() method of representedComponent. But it does not for some reason.
Any suggestions?

I've solved the problem!
I reviewed JList class to learn how it uses CellRendererPane. Then I've made some changes in my wrapper class (DesignerModeComponentRenderer posted above). I tryed to make use CellRendererPane identic to JList use. After some changes my wrapper class start to draw JComboBox correctly. Here is result wrapper class code:
public class DesignerModeComponentRenderer extends JPanel
protected JComponent representedComponent;
private CellRendererPane pane;
public DesignerModeComponentRenderer(JComponent representedComponent)
this.representedComponent = representedComponent;
pane = new CellRendererPane();
pane.add(representedComponent);
add(pane);
Dimension d = representedComponent.getPreferredSize();
setPreferredSize(new Dimension(d.width, d.height));
public void paint(Graphics g)
Dimension d = representedComponent.getPreferredSize();
pane.paintComponent(g, representedComponent, this, 0, 0, d.width, d.height, true);
}Now 'representedComponent' being added to 'pane', 'pane' added to DesignerModeComponentRenderer and in method pane.paintComponent() container parameter is 'this' (instead of 'this.getParent()' as in previous version).
I think that the roblem was with not punctual parent-child Component structure in my wrapper class.

Similar Messages

  • How to transfer Painter 12 with my custom brushes from old iMac to a new iMac both running Mavericks

    Hi,
    I just purchased a new iMac. Have Painter 12 on my older iMac and want to be able to transfer Painter 12, with my custom brushes to my new iMac. Tried Airdrop but got a message that it was damaged and that I should trash it. Does any know how to get  Painter 12 with all my custom brushes to my new machine? Both are running Mavericks.
    Thank you,
    Jim

    etresoft,
    Thank you for your response. I did try to use Migration Assistant and I got as far as the two machines trying to communicate with each other. So I guess the answer to your question would be I tried, I failed and it worked until a certain point. I understand that there are other ways to connect the machines, I would have to see if I have the proper cables to do so. Airdrop did get data to my new machine and that tells me that they do see each other on the network. I do not know why they did not see each other via Migration Assistant. I assume that I could go to Corel's site and download Painter 12 to my new machine, ( my new machine does not have a disk drive ), but I will not have my custom brushes etc. and would have to totally make them up in the fresh install version and I am trying to avoid that.
    You are probably correct in saying that Painter 12 probably needs a full reinstallation to work properly. Am I to assume that Migration Assistant will do a full reinstallation, including my custom brushes? I guess I am a little confused here.
    Jim

  • Error GR493 report painter/writer with special ledger

    Hi ,
    I am trying to create a report painter using a table of a special ledger. The table is the one for 'real item'. The following error appears:
    'Table ZIFRSA is not installed in Report Writer.
    Message no. GR493
    Diagnosis
    The Report Writer can only report on tables if the attributes of these tables that are relevant for reporting are defined in control tables. This is not the case for table ZIFRSA.'
    We are not using intercompany transaction. My question is if it possible to make report in report painter/writer with this table.
    I can make report with the total table of special ledger, but not with the one for real item.
    Thanks,
    Cecilia.

    Hi Cecilia,
    I guess the tables created through SPL should look as follows:
    1. ZIFRST - Totals Table
    2. ZIFRSA  - Actual Line Item Table ( I guess this is what you are calling real item)
    3. ZIFRSP  - Plan Line Items Table
    Bear in mind that, the report is not created off table ZIFRSA but rather ZIFRST.  Please create the report writer or report painter using table ZIFRST.
    If the above suggestion did not work,  then check the solution provided in OSS note 3761.
    Elias

  • Publishing a screen painter form with full code

    Hi Dear;
    could you publish a sample of screen painter form with the coding that you use in it please?
    bets regards;

    Hi,
    Take a look at the following sample provided by SAP in the following path C:\Program Files\SAP\SAP Business One SDK\Samples\COM UI\VB.NET\04.WorkingWithXML\2003.
    In the above sample a form designed in Screen painter (MySimpleForm.xml) is used with the code. U can open the MySimpleForm.xml in screen painter.
    Vasu Natari.

  • Report painter errror with key fie

    hello,
    we have a tdoce called ZUSO_PEN , when excuting this report the error is
    Library ZA6: Key figure ZUS_CS_PEN_ACCR in set 0000COL_PEN_TIEOUT is not allowed
    Procedure
    If you need the key figure ZUS_CS_PEN_ACCR, you must check off the corresponding entry in the library ZA6.
    Action: Maintain library
    please help out with this.
    thanks very much.

    Hi Sachin,
    I reviewed RPA0 transaction and both users are the same properties.
    I just created a new user ZZZ with copy of YYY, executed the report painter and it shows the amounts in correct currency, this is strange.
    Thanks for your help.
    José Luis

  • Report painter report with two header rows

    Experts,
    I have managed the variable values in report painter but in display output i am unable to recognize the
    value displayed for march / April is actual or planned
    Please find attached screen shot for the same...
    Is there any way to have both the information on header row?
    Thanks
    Sagar C'kar

    Hi Sagar...
    Please change the short, medium and long text as you wish (please have all the description in the long text), by default system displays with the medium text, but no need to worry, when you keep the cursor on the head column of the text (where medium text is maintained), system displays with long text also. By this you can see the long text. This option we may use for adding additional text there, maintain some text at medium text and maintain additional text at long text option, so when you keep the cursor at head of the column with medium text, you see long text in addition.
    If you want to have the long text instead of short or medium text make changes like this..
    By this you make the text length at maximum i.e. 21 digits I suppose and then.....
    By the above you select "long text" as default
    Regards..
    Jose

  • Report painter issue with displaing a month budget

    Hi,
    I have a problem with making report in report painter.
    I want to display a month budget of cost element for the one particular cost center.
    For example: Iu2019ve putted two characteristics in one row, a set (which contains cost element number) and cost center. In column Iu2019ve placed these characteristics : period, value type and fiscal year.
    The main issue is that the report displays only u201C0u201D even when there are some assets on that cost element for that cost center.
    Of course when I remove characteristic u201CCost Centeru201D from a row, I will see some non u201C0u201D values in my report. I used CCSS table in my report and KSTAR field in the set.
    How can I make report showing assets for cost elements for a particular cost centers? Of course I would like to have more than one such u201Ccost elementu201D-u201Ccost centeru201D pair in my report.
    Regards,

    Solved

  • Report Painter problem with empty selection variant

    Hello,
    I use the cost center selection variant for the column definition in Report Painter as characteristic value. This selection variant get only the cost centers which are valid from 1.1.2003 to 31.12.2004. The column of the report created by Report Painter which uses this selection variant display value without taking into account limitations follow from this selection variant. I expect value zero for year fiscal year 2007 in this column, because the cost centers are invalid in 2007 year but the report displays different value. The problem appeared after upgrade from 4.6C to ECC 6.0.
    Best Regards
    ZD

    My problem with Report Painter occurred when I was creating my own report based on 1VK library.
    In my example I used in the column definition characteristic Cost
    Center, which is determined by selection variant, and Basic Key Figure
    equal SWKG-Costs. For system date (18.07.2007) there are no valid
    master data for the characteristic Cost Center but when I execute
    report for fiscal year 2007 the column display no-zero value without
    taking into account value of Characteristic Cost Center. I expected
    zero value in this column because there are no postings for Cost
    Centers (no valid cost centers were selected) in financial year 2007.
    Could you help me with this problem ?

  • Need to call a Report Painter Report with filtered selection criteria

    Hello All,
    I have created a Report through which I am calling a Report Painter Program 'Z443'  as I have to first filter out the selections and then pass it to the Report Painter Report.
    I tried the following two ways and found these problems :
    1. Submit (program) with selection-table ..... and Return.
      The output had many entries i.e the parameters were not passed correctly to the Report Painter Report.
    2. Tried using the FM ' CRIF_RW_WEB_CALL_REPORT '.
      The transaction for the Report Painter is opening but selections from the first Report is not being transferred.
    Please help if you have worked on any similar requirements .
    Thanks!

    hi
    thanx for ur reply.
    i think the select-options is the best way to get more then one currency values.
    but i need to know what code i have to write for display of this day.
    in the standard report MCTA there he is using only one currency. similarly i need to add 2 more columns for each currency in that same report o/p.
    how to do that can any body help me
    regards,
    maqsood

  • Report Painter - Problem with Currency Display

    Hi Gurus,
    I created a Report Painter (Tx: GRR1, Library: 9P1) using Basic key figure SWKG (Currency: USD)
    When I executed the report using a user XXX, this shows amounts in correct currency: USD. However, when I executed the report using a user YYY, this shows amounts in incorrect currency.
    I reviewed SUIM transaction and compared both users and no have difference.  Next I reviewed SU01 transaction and in Parameters there were some differences, y added parameter one bye one from XXX to YYY user, I executed the report again but the error persist.
    Is there other user configuration that I can see?
    Thanks in advance.
    José Luis

    Hi Sachin,
    I reviewed RPA0 transaction and both users are the same properties.
    I just created a new user ZZZ with copy of YYY, executed the report painter and it shows the amounts in correct currency, this is strange.
    Thanks for your help.
    José Luis

  • How to make a paint stroke with leaves write on smooth?

    I have a paint stroke line "write on" across the screen with leaves (leaves03.mov) as the brush source.
    How do I make the leaves write on as a fade in rather than appear one after the other? Like smoother?
    Thanks

    Mark, I did everything stated. Except set sequence to "From". Their was not a "From" under Traversal.
    The leaves are still appearing with the write on behavior. I would like as each leaf is "written on" to fade in, not just appear. The sequence paint behavior fades in the row after the leafs appear.
    Also what is IIRC?
    Thanks (and sorry if I am missing anything.)

  • Cant open PC Paint files with Appleworks paint program

    I have been using the very simple Paint program that comes with windows. I have finally made the move and ditched the PC for something more stable.
    When I try to import my .bmp pictures I used to work on into Appleworks it insists on opeing the Drawing program that has no "fill" etc. Even when I open the Paint program and then "force" it to open a .bmp only part of the picture is shown. I thought that a .bmp is pretty basic and common file type.
    Does anyone know if Appleworks can handle .bmp files and if not what are other options. I didn't really feel the need to have a $170 paint program for what I am doing.
    Hope you can help.
    Michael

    Dale,
    Thanks for your reply.
    The problem is that I need to use the "fill" in the paint program.
    I have actually just been able to get the file to load into Appleworks paint after reading about using the .pict save. All looked good untill I tried to fill. What happens now is that the fill is very chunky and does not bleed thru at all. This makes it pretty useless at the moment.
    Same problem, with a twist now.
    Looking forward to any further ideas.
    Michael

  • Painting issue with swing titlebar

    Hi,
    I had already posted this but no body replied so I am posting it again hoping somebody might reply to this now.
    In my swing application I wanted a custom titlebar, so I created my own RootPaneUI by taking most of the code from MetalRootPaneUI to get what I wanted.
    In order to make my titlebar visible I had to call:
    frame.setUndecorated(true);
    frame.getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
    The major issue I am facing now which sounds very weird to me is with the painting of the window. When I start the application sometimes (not always), I see the frame being stuck to the top left corner of the monitor, when I move the mouse over the toolbar/menubar, the frame starts painting the icons of underlying IDE like eclipse or IntelliJ over my application. It seems like a painting issue which is really a very strange behaviour.
    This issue does not happen with windowslookandfeel and also works fine for MetalLookAndFeel when the JFrame is decorated to show window decorations(windows titlebar) not the look and feel one(custom titlebar).
    I wanted to know if its me who is doing something wrong or is it a swing bug. Is there a way to fix this issue. I searched a number of forums but couldn't find an answer to it.
    Thanks in advance.

    Hello @Andre_Uhres:
    In my application, I am using swing application framework (JSR 296) and I have a splash screen(JFrame) which loads some configuration data and then shows a modal login dialog on top of it. On successful login the login dialog and splash is disposed and the main application frame shows up.
    The job of showing splash screen and logging in the application was being done in the main/initial thread. I apolgoize for not being able to provide a sample runnable code because the issue is seen only with my application and not with any other demo programs and it was not quite possible for me to put that huge code here.
    public static void main(String args[])
    SplashFrame.start();
    //Launch the main application
    Application.launch(ApplicationMain.class); // swing application framework would launch the frame in the invokeLater method.
    class SplashFrame
       public void start()
            // create a splash and show it
           // load the configurations
           // show login dialog
           // on successful login dispose splash and login
    }I eventually moved this code into SwingUtilities.invokeLater() but even this didn't help me. I still see the same issue.
    public static void main(String args[])
    // or use invokeAndWait
    SwingUtilities.invokeLater(new Runnable(){
    SplashFrame.start();
    //Launch the main application
    Application.launch(ApplicationMain.class); // swing application framework would launch the frame in the invokeLater method.
    }I also tried doing this:
      RepaintManager.setCurrentManager(new RepaintManager()); as I read in some forums that sometimes RepaintManager might need to be overwritten to resolve some painting issues.
    FYI: I am using JDK 1.6.0_17
    In spite all these, I still see the same issue. Any help much appreciated.
    Thanks

  • Painting problems with cwgraph in multiple document interface (mdi).

    Has anyone else seen weird behavior when using a cwgraph on an MDI child form in .NET. Whenever I open a new child window (containing a cwgraph) it gets painted once in the correct location and again offest about 50 pixels away and the old original location doesn't get invalided properly.
    The only workaround I've found is to contain the cwgraph in a panel or groupbox and the problem seems to go away entirely.

    Do you only see this problem with the graph, or do you see it with other Measurement Studio controls as well? Do you have any other ActiveX control on an MDI child and if so, what is the behavior of those controls? Could you please post a small test project that reproduces the problem? Thanks.
    - Elton

  • Painting problems with JTable

    i am using JTable inside an JApplet , if i change the table model by adding a row , and attach it to table i can't see the new added row , but if i resize the applet then i could be able to see the new added row. why is this beviour?
    is it someting to do with JApplet painting event.
    In JApplet i am using some AWT components.. other than JTable , is it happening because of this?
    thanx in advance,
    Abhijit Choudhary,

    Hi,
    that cannot be said, if you do not specify which TableModel you use - is it a DefaultTableModel or is it an own class that you use as TableModel?- What does the method, that adds a row?- Does this method notify all TableModelListeners of the changes done?- Guess, that is the point, the TableModelListeners are not notified about that, that a new row has been added - so a listener (JTable is one of them) is unable to update its display until a resize forces it to ask the TableModel for its size (row, column and so on) and update its display this way.
    That is the behavior you see ... so it should be a missing TableModelEvent when adding a row.
    greetings Marsian

Maybe you are looking for