How to make the swing drawings to appear in a specific jPanel?

hi,
I have a frame which I divided in two panels - one for the jComboBoxes/buttons and the other one for showing graphics. but the paint(Graphics g) overpaints it all =(
how should my code look like if I want some rectangles (depending on the combo choices and on button click which means update) to appear in the second panel?
the code's structure is like :
import *;
public class NewJFrame extends javax.swing.JFrame {
     private JPanel jPanel1;
public static void main(String[] args) {
          NewJFrame inst = new NewJFrame();
          inst.setVisible(true);
     public NewJFrame() {
          super();
          initGUI();          
     public void paint(Graphics g) {
          g.fillRect (x, y, w, z)
     private void initGUI() {
          jPanel1 = new JPanel();
               // combo boxes and buttons
               // action listeners for them
          jPanel2 = new JPanel();
               // the place where the rectangles should be shown
               // and updated if combos are changed and button clicked
}now, I wonder if anyone could possibly give me a hint how to make it correctly, because I'm really a total newb in Java and I can't find any good examples from www which I've search through for the solution.
P.S. is there a plug-in for eclipse for visual programming of the graphics? =)
thank You for the kindest help!
J.M.

You should not be mixing AWT and Swing component in
a Swing application, so don't use a Canvas.
If you need some custom painting then you should
override the paintComponent() method of JComponent or
JPanel and then add this component to the GUIwhat does mean the override the paintComponent() method of JComponent or JPanel?
how can I add that component to the GUI?
=)
can you give a short code example, please! the code structure would be more than enough.
J.

Similar Messages

  • How to make the contact picture should appear on the upper right corner with thumb picture when some one calling instead showing the entire screen

    How to make the contact picture should appear on the upper right corner with thumb picture when some one calling instead showing the entire screen

    See deggie's response in this post... https://discussions.apple.com/message/8531821#8531821

  • How to make the inputs appear in Playback

    Hi,
    I would like to know how to make the inputs (line-in, mic, SPDIF-in) appear in playback of windows's mixer ?
    Im running XP pro sp3 with XFI Extreme Audio PCI-Express.
    I dont know why but there is no inputs in playback that making me unable to hear it while its being recorded.
    <img border="0" height="405" width="640" src="http://img70.imageshack.us/img70/672/mixergq0.png">
    <img border="0" height="542" width="640" src="http://img399.imageshack.us/img399/486/allmysettingsmq2.png">
    Message Edited by Nuja on 0-06-2009 2:07 [email protected]

    - I've read a little more and come to these conclusions:
    . The instructions presume that a CD is included with the card for the purpose of installing the software. A CD/DVD reader is a requirement for this reason.
    2. The card uses Intel HD Audio. This changes enough of what I know about CL's card that I really don't know that the lack of external inputs in the playback mixer is not intentional and uni'versal. A recording application could let you listen to what is being recorded by having an option of playing back what's being recorded.
    I have enough uncertainty now that I don't think it's useful for me to continue commenting. If someone who has a? PCI Express X-Fi Xtreme Audio that came with the software CD and hard-copy documentation wishes to share whether or not they have line-in, etc. in the playback mixer, it could be useful.
    -Dave
    ?[email protected]

  • How to make the diagonal line in the swing table cell?

    Hi all,
    How to make the diagonal line in the swing table cell just like the link below?
    http://61.132.17.188/webber/table.gif

    One improvement.. To get a line that is neat, use a bit of Graphics2D
        public void paintComponent(java.awt.Graphics g)
            int w = getSize().width;
            int h = getSize().height;
            // draw a line between (0,0) and (w,h)  
            g.setColor(getForeground());
            if (strTop == null)
                strTop = "  ";
            if (strBottom == null)
                strBottom = "  ";
                java.awt.Graphics2D g2 = (java.awt.Graphics2D)g;
              g2.setRenderingHint(java.awt.RenderingHints.KEY_ANTIALIASING,java.awt.RenderingHints.VALUE_ANTIALIAS_ON);
              //g2.setStroke(new java.awt.BasicStroke(14.0f));
            g.drawLine(0, 0, w, h);
            //the following lines will draw the two strings,
            //one above the top of the line and the above below it.     
            g2.drawString(strTop, (w/2)+2, (h/2)-2);
            g2.drawString(strBottom, 2, (h / 2) + 2);
            //the x,y for drawString are only based on assumption.   //do necessary changes to suit ur needs.
        }Then create a TableCellRenderer and set it to the Table Header for ur table's 1st row.....
    Cheers

  • How to make the zoom in/out scale appear in the media browser ?

    How to make the zoom in/out scale appear in the media browser ? My videos only appear as a file list (only the names) and the zoom in/out device is currently not in the media browser...

    I meant that there is no "Icon mode" button or "List mode" button in my media browser. How to make them appear ?

  • The Header in my home page is truncated. My home page Header is cut off. The header appears in Internet Explorer, but not in Mozilla Firefox 3.6.13. How to make the header display in Firefox?

    The Header in my home page is truncated. My home page Header is cut off. The header appears in Internet Explorer, but not in Mozilla Firefox 3.6.13. How do make the header display?

    (Images or animations do not show) worked well.

  • I just installed photoshop cc, how to make the english UI available in preferences, as it doesn´t appear! Please help??

    I just installed photoshop cc, how to make the english UI available in preferences, as it doesn´t appear! Help please??

    Hi George,
    Kindly try the below mentioned steps.
    Sign in, Sign out | Creative Cloud desktop app
    Click on download on Digital photography software | Download free Adobe Photoshop Lightroom CC trial
    Please share the results once done.
    Thanks,
    Atul Saini

  • How to simply make the new ipod touch appear on itunes when it have been working in the previous computer (mac)

    how to simply make the new ipod touch appear on itunes when it have been working in the previous computer (mac)

    If the new computer is a PC see:
    iPhone, iPad, or iPod touch: Device not recognized in iTunes for Windows
    If a Mac:
    iPhone, iPad, iPod touch: Device not recognized in iTunes for Mac OS X
    Mac OS X v10.6 or later: iOS device not recognized in iTunes after restart

  • In firefox 4 RC, some addons installed suddenly disappear, but checking the profile, some of the missing addons related files are still here, how to make the addons back?

    I use firefox 4 form beta 9 to RC (zh) now and there are also firefox 3.6 installed in computer. One day when I open Fx 4 RC, some (actually a lot but not all) of the adoons just disappear. When I check on about:addons page, some addons installed do not appear in the list.
    The addons '''REMAINED''' including:
    * addons I already used in Fx 3.6 (like webmail notifie , xmarks)
    * ''addons only can use in Fx 4'' (like Open Web Apps for Firefox).
    The addons '''DISAPPEARED''' including:
    * addons I already used in Fx 3.6 (like yoono)
    * '' addons installed when using Fx 4'' (like updatescanner, Thumbnail Zoom).
    But when I check the profile(by Help > Troubleshooting Information>Open Containing Folder) , some (not sure is it all) of the missing addons related files are still here [lucky], so any one know how to make the missing addons back?
    Some more details:
    * This happened when i use RC for already a few days and keep on even i restart Fx and windows.
    * The bookmarks, history, search engine and even themes and icon setting are still here. [ I only sync bookmarks but not history for both xmarks and firefox sync.]
    * This addons are really '''disappeared''' but not disable only!
    * This number of addons missed, as i remember, at least 30, should be more than that number bacause some of them are installed but in disable mode.
    * I try to install back one of the addons - Stylish, the installed code are still here.
    * It is nearly an impossible mission to install every missing addons again, as it really kill my time.

    Delete the files extensions.* (extensions.rdf, extensions.cache, extensions.ini, extensions.sqlite) and compatibility.ini in the Firefox [[Profiles|profile folder]] to reset the extensions registry. New files will be created when required.
    See "Corrupt extension files": http://kb.mozillazine.org/Unable_to_install_themes_or_extensions
    If you see disabled, not compatible, extensions in "Tools > Add-ons > Extensions" then click the Tools button at the left side of the Search Bar to do a compatibility check.

  • How to make the dblink and what is the use of this

    plz any body tell me "how to make the dblink and what is the use of this"
    sujit

    Do you understand how to make the Slider work using code to read its value?  You will need to look into that in order to do this.
    What you can do is have the yello rectangle be a movieclip that sits over the red rectangle and use the Slider to control the yellow rectangle's alpha property from 0 to 1.  That way the yellow will gradually fade as you slide.
    What you will then need  to do is figure out how to make the number of dots that appear reduce from 15 to 8 over the same range of the slider.  You need to use the fractional value from the slider to decide how many dots either appear or do not appear.
    You should not start new postings for the same topics that you arlready have postings for.  Doing so in the future might result in them being removed.

  • After clicking on an open tab, how to make the focus automatically go to the body of page?

    After clicking on an open tab, how to make the focus automatically go to the body of page?
    Right now, clicking in an open tab and using arrow keys now moves through the open tabs. I liked the old versions where right after clicking in a tab you could directly go to navigate the page with the arrow keys.
    Is there a something I can change in about:config to change this behavior?
    Thanks in advanced.

    Firefox should still set the focus the the browser area if you click a tab.<br />
    Only with very old browser versions you could set the focus to a tab by clicking a tab.
    This behavior is likely caused by an extension.
    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance).
    *Do NOT click the Reset button on the Safe mode start window or otherwise make changes.
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes

  • How to make the Sourcelist checkbox in Material MasterPurch view- Mandatory

    Hi All,
    Can anyone please let me know how to make the Source list checkbox mandatory in Material Master.
    Ie for example if i am creating and ERSA Material, i want to make the source list option mandatory by default whenever i create an ERSA Material. I know the option to make the Source List mandatory at Plant Level.
    But i want to make source list mandatory at material. By default..it has to appear mandatory on the Material. I want to do this
    specially based on Material Type. Ie i want this to be mandatory only for specific material types i chose.
    Please suggest me the possible ways.
    Thanks
    Sridevi

    Hi, Get Source List Field sel. group from OMSR which is 16 by default change it to new field say 210, then goto OMS9 enter Field sel. group 210,  Check for field 'MARC-KORDB' & change it to mandatory for Field reference ERSA, if you cannot find there you need to create new field reference & assign it to ERSA in OMS2 &

  • How to make the option none in the payment information from app store

    how to make the none option in payment information in app store??????using iphone
    i made a purchase from my card then after i tried to make another purchase that is free but while doing this a massege appears "review your payment information" then it goes back to app store.tell me how to make none option in apple account payment information using iphone??????

    surendramandia wrote:
    i don't want to creat a new account i want  none payment option in my existing account
    This has been suggested by other Users, but have not tried it myself...
    ' ... Get an iTunes gift card & redeem that in iTunes using your existing Apple ID.
    Then the option for none, regarding a credit card should appear...'

  • How to make the  buttons same size on the toolbar

    Hi All,
    Can anyone please tell me how to make the size of buttons on the toolbar to be same .
    And i also want to add combo box at the right side of my menubar with prefered size.
    Please send me the solution if anyone knows . Thanks in advance.
    Regards,
    Shankar.

    how to make the size of buttons on the toolbar to be same Create a panel with a GridLayout. Add the buttons to the panel then add the panel to the menubar.
    add combo box at the right side of my menubar Read this section from the Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/components/menu.html]How to Use Menu Bars for an example.

  • How to make the last line of the textarea visible all the time?

    Hello,
    I am making an online chat application in JSP and XHTML. The chat log and online users� names textareas are refreshed every 5 seconds. When it comes to many messages in the chat log textarea, the scrollbar appears. Then, every time the chat log textarea is refreshed, I need to move the scrollbar down to see the last line of the textarea.
    Are there any ideas how to make the last line of the textarea visible all the time without moving the scrollbar?
    Thanks in advance.
    Dan

    I put the below code on the page, but it didn't work.
    Are there any ideas? Thanks.
    <table border="0" cellspacing="1">
    <tr>
    <th>Chat Log</th>
    <th>Users now online</th>
    </tr>
    <tr>
    <td><textarea rows="20" cols="60" name = "messages" readonly = "readonly"><%= texts %></textarea></td>
    <td><textarea rows="20" cols="20" name = "names" readonly = "readonly"><%= names %></textarea></td>
    </tr>
    </table>
    <script type="text/javascript">
    <!--
    document.messages.scrollIntoView(false);
    //-->
    </script>

Maybe you are looking for

  • LMS 3.2 device updates failing?

    Have upgraded from LMS 3.1 to 3.2 then applied all the software updates ok. Now applying device updates - they are failing but can't see a clear reason. The Activity Log > Event Log doesn't really provide any clues. I'm guessing the relevant log file

  • Firefox on Win 7 64 bit is a big memory hogger; on Win 8.1 32 bit, it's not

    As above; I have several PCs, on two of which I use FF regularly. One PC has Win 7 64-bit as OS while the other has Win 8.1 32-bit as OS. I noticed that Firefox on Win 7 64-bit is a big memory hogger, sometimes eating up more than 2GB of RAM and obvi

  • Error in installing sap 4.7ee,os 2000

    hi to all when i am installing sap 4.7ee. when i npress the log view.i am gettin an error that is Error 2007-12-31 06:21:25 FJS-00012 Error when executing Script Error 2007-12-31 06:21:25 FJS-00012 Error when executing Script my os is win2000.HDD.160

  • How to stop 12 flv files all loading at once

    Hi Guys, Ive just created a page with 12 FLV players, all to play audio, problem is, when you click open the page, all the tracks seem to be loading into the players. Can some one please tell me how to stop this, Im a flash newbie so please leave me

  • License agreement

    I've used Adobe Reader successfully for years.  Now, when I try to open a document with it, there is a message that says that I must accept the license agreement.  However, I cannot find a window tha shows the license agreement to accept.  I've reins