Can't show J components on JPanel

Because I'm a begineer, I'm not sure I can explain my problem correctly.
The problem is quite simple.
I'd like to show some J components on JPanel but I can't.
I made a JFrame which has 5 JPanels.
Each JPanel has some components and calls paint method to draw some lines.
public void paint(Graphics g){
     g.setColor(Color.black );
     drawDisplay(g);
When I put AWT componts such as Label, Button etc, there's no problem.
But when I put J components like JLabel, JButton,
I cannot see the components. Sometimes I can click JCombo box....
Interestingly, when I remove the paint method, J components show up on interface.
Anybody understand this situation?
Do I have to know something for this?
Thank-you.

I second camickr's recommendation for you to study the tutorials. A few specifics:
public void paint(Graphics g){
   g.setColor(Color.black );
   drawDisplay(g);
}* Don't override the paint method of a JPanel, override the paintComponent method.
* You will need to call super.paintComponent(g) within your paintComponent override. This may need to be the first line in fact.
* As noted by camickr, do not place AWT components on a Swing component (JPanel).

Similar Messages

  • How can we add components to JPanel so that they can be resizeable

    Is it possible to add components to JPanel so that we can resize them or drag them.

    You could try searching the forums, but I'll save you the trouble. tjacobs has oft posted code which does what you want, both dragging and resizing.
    You can find an example here or here.

  • ScrollBars not showing up for the JPanel [urgent]

    Hi,
    I have a frame in which i have two nested split panes i.e one horizontal splitpane and in that i am having one more split pane on the right side and a JTree on the left side.In the second split pane (which is a vertical split) ,as a top component , i am setting a JScrollPane in which i am trying to display a JPanel which is having a lot of swing components in it.I want to see the scroll bars for this panel so that i can see all the components.Do i have to implement Scrollable interface for this panel to scroll in the ScrollPane.I don't know how to implement Scrollable interface.Can some body help me in resolving this?This is some what urgent.Any help will be highly appreciated.
    Thanks in advance.
    Ashok

    Thank you all for your replies.I added the scroll bar policy.The scroll bars are showing up but the components inside the Panel are not moving.I want the components to move when i am scrolling.Here is my code.In the code SeriesDescPanel, SeriesDescMapPanel are sub classes of JPanel.I am using null layout to add the components to these panels.
    public class MainWindow extends JFrame implements TreeExpansionListener
    public MainWindow()
    throws RemoteException
    // This code is automatically generated by Visual Cafe when you add
              // components to the visual environment. It instantiates and initializes
              // the components. To modify the code, only use code syntax that matches
              // what Visual Cafe can generate, or Visual Cafe may be unable to back
              // parse your Java file into its visual environment.
              //{{INIT_CONTROLS
              setJMenuBar(menuBar);
              setTitle("Series Maintenance");
              getContentPane().setLayout(new BorderLayout(0,0));
              setSize(667,478);
              setVisible(false);
              JSplitPane1.setDividerSize(1);
              JSplitPane1.setOneTouchExpandable(true);
              getContentPane().add(BorderLayout.CENTER, JSplitPane1);
              seriesMenu.setText("Series");
              seriesMenu.setActionCommand("Series");
              menuBar.add(seriesMenu);
              newSeriesGroupMenuItem.setText("New Series Group");
              newSeriesGroupMenuItem.setActionCommand("New Series Group");
              seriesMenu.add(newSeriesGroupMenuItem);
              newSeriesMenuItem.setText("New Series");
              newSeriesMenuItem.setActionCommand("New Series");
              seriesMenu.add(newSeriesMenuItem);
              seriesMenu.add(JSeparator1);
              serachMenuItem.setText("Search");
              serachMenuItem.setActionCommand("Search");
              seriesMenu.add(serachMenuItem);
              seriesMenu.add(JSeparator2);
              saveMenuItem.setText("Save");
              saveMenuItem.setActionCommand("Save");
              seriesMenu.add(saveMenuItem);
              seriesMenu.add(JSeparator3);
              exitMenuItem.setText("Exit");
              exitMenuItem.setActionCommand("Exit");
              seriesMenu.add(exitMenuItem);
              adminMenu.setText("Administration");
              adminMenu.setActionCommand("Administration");
              menuBar.add(adminMenu);
              bulkLoadMenuItem.setText("Bulk Load");
              bulkLoadMenuItem.setActionCommand("Bulk Load");
              adminMenu.add(bulkLoadMenuItem);
              drsMenuItem.setText("DRS override");
              drsMenuItem.setActionCommand("DRS override");
              adminMenu.add(drsMenuItem);
              helpMenu.setText("Help");
              helpMenu.setActionCommand("Help");
              menuBar.add(helpMenu);
              tutorialMenuItem.setText("Tutorial");
              tutorialMenuItem.setActionCommand("Tutorial");
              helpMenu.add(tutorialMenuItem);
              bulkLoadFormatMenuItem.setText("Bulk Load Format");
              bulkLoadFormatMenuItem.setActionCommand("Bulk Load Format");
              helpMenu.add(bulkLoadFormatMenuItem);
              aboutMenuItem.setText("About");
              aboutMenuItem.setActionCommand("About");
              helpMenu.add(aboutMenuItem);
    JSplitPane2 = new javax.swing.JSplitPane();
    upperPanel = new SeriesDescPanel();
    JScrollPane2 = new javax.swing.JScrollPane(upperPanel,
    ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
    ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    JScrollPane3 = new javax.swing.JScrollPane();
    JSplitPane2.setOrientation(0);
    JSplitPane2.setDividerSize(1);
    JSplitPane2.setOneTouchExpandable(true);
    JSplitPane1.setRightComponent(JSplitPane2);
    JSplitPane1.setLeftComponent(viewPane);
    viewPane.add(alphabeticPane);
    viewPane.add(searchDataPane);
    viewPane.setTitleAt(0,"All");
              viewPane.setTitleAt(1,"search");
    //JScrollPane1.setMinimumSize(new Dimension(126, 478));
    JSplitPane2.setTopComponent(JScrollPane2);
    //JScrollPane2.setMinimumSize(new Dimension(426, 409));
    JSplitPane2.setBottomComponent(JScrollPane3);
    lowerPanel = new SeriesDescMapPanel();
    seriesTreeModel = new SeriesTreeModel(SeriesMaintenanceUI.getSeriesGroupInfo());
    tickersTree.setModel(seriesTreeModel);
    alphabeticPane.getViewport().setView(tickersTree);
    //JScrollPane2.getViewport().setView(upperPanel);
    //JScrollPane2.setViewportView(upperPanel);
    //upperPanel.scrollRectToVisible(new Rectangle(upperPanel.getWidth(),
    //upperPanel.getHeight(),1,1));
    JScrollPane3.getViewport().setView(lowerPanel);
    //JSplitPane2.setPreferredSize(new Dimension(426,200));
    SeriesDescPanel upperPanel;
    SeriesDescMapPanel lowerPanel;
    SeriesTreeModel seriesTreeModel;
    SeriesTreeModel searchTreeModel;
    javax.swing.JSplitPane JSplitPane2;
    javax.swing.JScrollPane JScrollPane2;
    javax.swing.JScrollPane JScrollPane3;
    javax.swing.JTree tickersTree = new javax.swing.JTree();
    javax.swing.JTree searchTree = new javax.swing.JTree();
    javax.swing.JScrollPane alphabeticPane = new javax.swing.JScrollPane();
    javax.swing.JTabbedPane viewPane = new JTabbedPane(SwingConstants.BOTTOM);
    javax.swing.JScrollPane searchDataPane = new javax.swing.JScrollPane();
    //{{DECLARE_CONTROLS
         javax.swing.JSplitPane JSplitPane1 = new javax.swing.JSplitPane();
         javax.swing.JMenuBar menuBar = new javax.swing.JMenuBar();
         javax.swing.JMenu seriesMenu = new javax.swing.JMenu();
         javax.swing.JMenuItem newSeriesGroupMenuItem = new javax.swing.JMenuItem();
         javax.swing.JMenuItem newSeriesMenuItem = new javax.swing.JMenuItem();
         javax.swing.JSeparator JSeparator1 = new javax.swing.JSeparator();
         javax.swing.JMenuItem serachMenuItem = new javax.swing.JMenuItem();
         javax.swing.JSeparator JSeparator2 = new javax.swing.JSeparator();
         javax.swing.JMenuItem saveMenuItem = new javax.swing.JMenuItem();
         javax.swing.JSeparator JSeparator3 = new javax.swing.JSeparator();
         javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
         javax.swing.JMenu adminMenu = new javax.swing.JMenu();
         javax.swing.JMenuItem bulkLoadMenuItem = new javax.swing.JMenuItem();
         javax.swing.JMenuItem drsMenuItem = new javax.swing.JMenuItem();
         javax.swing.JMenu helpMenu = new javax.swing.JMenu();
         javax.swing.JMenuItem tutorialMenuItem = new javax.swing.JMenuItem();
         javax.swing.JMenuItem bulkLoadFormatMenuItem = new javax.swing.JMenuItem();
         javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();
    Pl. help me in resolving this.
    Ashok

  • Sticking components in JPanel to GridLayout

    Could please anyone help in the following.
    I have an application where some JPanel with several Swing components
    positioned with help of GridLayout. What I need is to
    remove and place components during runtime,
    but the problem is that when I remove component placed somewhere
    inbetween with use of the method remove() of the class JPanel,
    all components are shifted so that the empty space is filled and
    even one can see that the initial GridLayout is destroyed.
    How can I stick all components to the initial grid cells of GridLayout?
    I mean I do not want components to shift anywhere from their original
    cells.
    Thank you in advance.

    Well, that solution is what I came to also.
    I mean I replacing removed compenent with some other invisible component.
    But is this indeed the only way?
    I tryied the method removeLayoutComponent() in the class GridLayout, but
    I have not understood how it works and what it is for.
    When I tryied it instead of remove() (of JPanel) it did not remove anything,
    but it looks like something relevant to my situation.
    PS The second line of my orginal poster should be read
    "I have an application where some JPanel is created with several Swing components
    positioned with help of GridLayout in it".
    Sorry...

  • Design View showing collapsed components.

    Ever since I add tomahawk Menu component in my project, all other components are not shown properly in the design view of jdeveloper. I added the menu component to one file and all the files in the project are now showing collapsed view (Only parent component is shown that too in a box). I tried restarting jdeveloper but the problem still remains. I cannot add/edit any components in design view now because of the above reason. How do I go about now?

    Hi,
    it appears that there is a problem with the WYSIWYG editor and 3rd party components not rendering properly. The outline view is a fallback that JDeveloper uses when it can't show the WYSIWYG (its the outline view). Not sure if you have a support contract inwhich case you could file this as a bug? If not, I'll put that down on my list of issues to track and follow up on.
    thanks
    Frank

  • Can you show slideshow within Lightroom 4.4 in Adobe RGB color space?

    Can you show slideshow within Lightroom 4.4 (not export out from LR) in Adobe RGB color space provided that you are using a wide gamut monitor which is capable and hardware calibrated & profiled to show such color space?
    If this is possible, what is required to do so in Windows 8 and i7-4770 & HD Graphics 4600 platform or does LR take care of it automatically?
    This is very basic question, however, I could not find a clear answer/info from LR documentation, so wish that someone can advice.

    Those settings are probably stored in a plist somewhere in ~/Library/Preferences. If you can locate the appropriate file, you should be able to copy it to all the network user folders.

  • How can we show data in rows when it is in Columns........

    I have strucked with a simple but a complex problem.
    I have a Report with data in vertical rows..need of the hour is how can we show that data into column structure.
    here is the table sample which i have in Database..
    Location      chrg_type    Effective_date
    xxxxxxx        xxxx          xx-xx
    thhis is the structure in effective date we have several months in it in a single column i want show the effective date or effective month in various columns instead of a single column.
    my required table is....
                                Effective_date     Effective_date
    Location      chrg_type     xx-xx              xx-xx
    xxxxxxx        xxxx          xx-xx
    any tough heads?????

    Hi Sunil,
    Your 1st problem is that you are going to need one more field to accomplish you goal. What type of data do want under your new date columns?
    Anyway, once you have that you need to move on to how to move the data out into columns based on date.
    Try something like this.
    0_Date = IF DATEPART('m',{tbl.Effective_date}) = DATEPART('m',CurrentDate) AND
    DATEPART('yyyy',{tbl.Effective_date}) = DATEPART('yyyy',CurrentDate)
    THEN {tbl.DataField}
    1_Date = IF DATEPART('m',{tbl.Effective_date}) = DATEPART('m',DATEADD('m', -1, CurrentDate)) AND
    DATEPART('yyyy',{tbl.Effective_date}) = DATEPART('yyyy',DATEADD('m', -1, CurrentDate))
    THEN {tbl.DataField}
    2_Date = IF DATEPART('m',{tbl.Effective_date}) = DATEPART('m',DATEADD('m', -2, CurrentDate)) AND
    DATEPART('yyyy',{tbl.Effective_date}) = DATEPART('yyyy',DATEADD('m', -2, CurrentDate))
    THEN {tbl.DataField}
    ... Repeat this process until you have all of the columns you need, following this format.
    Hope this works for you,
    Jason

  • My Samsung TV has a USB port. I connect the cable from the iPad to the TV to view a video on the TV. The video shows on the iPad but on the TV I can only get the pictures and music available on the iPad. Why is this and can I show videos from the IPad on

    My Samsung TV has a USB port. When I connect the cable from the iPad to the TV I can only show Pictures and Music. Why does the videos not appear and how can I show videos on the TV.

    This article should help you with that:
         http://www.ehow.com/how_7211806_display-iphone-tv.html
    Take care

  • Forms 6.0-- How can I show records in a block in different colours.

    In a multi record block, how can I show few records in one colour and few more in a different colour depending on a condition.

    Use DISPLAY_ITEM.
    This will change the visual attribute of the item in the current(!) record,
    set_item_property changes the attributes of the item in all(!) records.

  • HOw can i show a table(name given in parameters) in a report program

    I made a report in which there is a paremeter asking for a table name ....
    PARAMETERS TBLLE_NAME(10) OBLIGATORY.
    Now when I enter the table namke then how can i show its values....
    HINT:- We have to use fiels symbols....AND THE USER CAN ENTER ANY DDIC TABLE NAME having some records ...........

    You can display the contents of the DB table inputted using ALV.
    Pass the Structure name as the DB table name inputted.
    Use CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE to create the dynamic table of the same structure as the DB table passed.
    Once the above steps are done, the internal table with data can be displayed using ALV.
    Reward points for all helpful answers.
    Thanks,
    Balaji

  • How can I show album art in the mini player when playing songs from a plugged in iPhone?

    How can I show album art in the mini player when playing songs from a plugged in iPhone?
    When I play from my phone and switch to the mini player it's always showing the music notes in the thumbnaill. It'd be nice if it could get album art off of the phone.
    I'm on iTunes version 11.0.4.4

    He @mracole,
    it is very nice that you post a solution to complete the library with artwork for album's that do not have an artwork. Your solution perfectly addresses the problem for assigning artwork, BUT this thread is about CHANGING artwork for albums already uploaded into iTunes Match. Just try to replace for example a blue artwork cover for an album with a red one. If you made it in a simple way (without deleting the album from iTunes Match and local changes on the files with an external ID3-Application or 2 or more iTunes libraries on different Mac's) this is the right place to give a solution. I really tried for hours to change the artwork to make them visible in landscape cover flow mode on my iPhone5. In rare cases I made it, but then the covers sometimes where restored to the old onces - exacly how it is mentioned by Starhawk
    As long as there is no simple way to change the cover of an iTunes Match stored album (you can change title, artist and so on without hitting "update iTunes Match" over all distributed Library on different devices - this date will be synchronized almost instantly) I considered the behaviour from iTunes as BUGGY! For me the local artwork cache (and if there is any iCloud artwork cache - I don't know) do not interfere with iCloud. Even when I delete the whole local cache (album artwork music - everything) I do not manage to change the artwork.
    Regards from Munich, Germany

  • Can I show a data label for only one point in a series?

    Forgive a newbie question from an Excel convert, but can I show a value label for only one point in a data series? If yes, how?
    There are a number of graphs where I only want to value of either an extreme value or the ending value to show. Having all the labels in a series makes the chart too busy. This is pretty easy to do in Excel.
    If this can't be done, I guess that adding a text box over those points would work.
    Thanks

    Hi W-T,
    Welcome to Apple Discussions and the Numbers '09 forum.
    wahoo_tiger wrote:
    Forgive a newbie question from an Excel convert, but can I show a value label for only one point in a data series? If yes, how?
    Sure. Here's and example labeling only the MIN and MAX points.
    Column B contains the data charted with the blue line.
    Column C extracts the MIN and MAX values using the formula below. Those two values are charted as a separate series, using the green data point markers, and are labeled with their values. The intervening empty string values appear to have doused the lines connecting the two data points.
    Formula: =IF(OR(B=MAX(B),B=MIN(B)),B,"")
    Regards,
    Barry

  • When opening a new tab how can I show previoius history in the window?

    When opening a new tab, can I show the previous history in the new window?

    You can try middle-clicking (scroll wheel) the Back button which will open a new tab with the same History.

  • How can i show Bcc in my outgoing emails for Mac Lion 10.7.2

    How can i show Bcc in my outgoing email for Mac Lion 10.7.2  Bcc does not highlite in View.
    Noomee

    Reset the SMC: http://support.apple.com/kb/ht3964
    Should fix just this sort of thing.

  • How can I show a 0% range in the data value label on a bar chart thanks?

    How can I show a 0% range in the data value label on a bar chart thanks?

    I'm not sure what the question is. 
    I know that if you have a bar chart and one of the categories (X-axis) has bar (Y value) equal to 0%, no bar is plotted for that category. Even the addition of a stroke (line) around the bars doesn't make one appear for 0%.  The only automatic way I know of to make it look like there is data in that category is to add the value labels to the bars. Inspector/Chart/Series, select one of the bars on the chart, click on "value labels". Another method that is a workaround is to fudge the number a little in your table so that instead of 0% it is a very small %.  This will get you a thin line on the chart.
    But if your question is about the value labels (the numbers that display on or in the bars) and you are not getting one for a bar that is supposed to be 0%, it probably means your table doesn't actually have a 0% in the corresponding cell. A blank cell in the table will not get a value label.

Maybe you are looking for

  • Variable Name Makes App Crash

    I have an embedded bitmap resource, one of many in my program, which is an AIR app.  There's nothing unusual about it; in fact, I can replace the file to be embedded with a blank white file of the same size, or another (working) bitmap from the same

  • Adding CRM WebUI transactions to the Transactions tab in SOLAR01

    Hello, does somebody know if there is a possibility to add direct links to CRM WebUI transactions on the transactions tab in TA SOLAR01. Means, is it possible to link direct to the specific component on the WebUI, like it is possible to open transact

  • 10.6.5, then Error -36 on external HD : How to solve now?

    It's probably just a coincidence, but a day after upgrading to 10.6.5 I started getting Error -36's on one of my external drives (the one that has my iTunes library on it.) The drive is one of those LaCie Mini hubs, 250 GB. What I've tried so far: -

  • TS3694 error code 2324

    I get an error code 2324 and don't seem to be able to find a solution to clear this. I am trying to install the latest version of iTunes.

  • Left Hand/Right Hand Separation in Music Notation

    I'm new to GarageBand and am wondering if there is anyway to separate the right hand from the left hand part in music notation. I recorded some piano music into GarageBand using a midi keyboard but the right and left hand parts are sometimes combined