JPanel do not  cover the indicated area

I do:
JFrame.getContentPane().add(aJPanel);
On the "aJPanel" i have previously applied a mixture of method calls, such as:
    jp.setSize(new Dimension(400, 400));
//or jp.setPreferredSize(new Dimension(400, 400));
    jp.setBorder(BorderFactory.createLineBorder (Color.blue, 2));
    jp.setBackground(Color.white);      
   jp.validate();
   jp.setVisible(true);However, NO method has a result, unless i add something like JLabel. Then the JPanel spreads just for the area of JLabel.
To be more specific, here is the code:
package strongconcomp;
import javax.swing.*;
import java.awt.*;
//import java.awt.image;
import java.awt.event.*;
import javax.swing.event.*;
import java.io.*;
public class MainPanel extends javax.swing.JApplet
    static JFrame frame;   
    public static int screenWidth=0;
    public static int screenHeight=0;
    private static void createGUI()
        JFrame.setDefaultLookAndFeelDecorated(true);       
        frame = new JFrame("Strongly Connected Components- DFS");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        screenWidth=screenSize.width;
        screenHeight=screenSize.height;
        System.out.println("width:"+" "+screenWidth+" "+"height:"+" "+screenHeight);       
        frame.setSize(screenWidth-2,screenHeight-2);       
        frame.validate();       
        frame.getContentPane().add(ControlPanel.designPanel(), BorderLayout.EAST);  
        GiraffePanel graph=GiraffePanel.designPanel();
        graph.addMouseMotionHandler();
        frame.getContentPane().add(graph,BorderLayout.WEST);    
        frame.setVisible(true);                       
    public static void main(String[] args)
        javax.swing.SwingUtilities.invokeLater(new Runnable()
                public void run()
                    createGUI();
class ControlPanel extends JPanel
    ControlPanel()
        new GridBagLayout();
    static ControlPanel designPanel()
        ControlPanel cp=new ControlPanel();
        cp.setBackground(Color.CYAN);
        cp.setBorder(BorderFactory.createLineBorder(Color.black));
        //cp.setSize(MainPanel.frame.getWidth()/4, MainPanel.frame.getHeight());
        cp.setSize(5,6);
        JLabel conTo= new JLabel("Connections To");
        JLabel conFrom= new JLabel("Connections From");
        cp.add(conTo);
        cp.add(conFrom);
        return cp;
    /*  wrapper class for ButtonGroup   */        
    class JButtonGroup extends JFrame
        JButtonGroup()
            new ButtonGroup();
//The background doesn't appear, in order to be able to click on it. The
//   only thing, that appears is an
//Oval with the arguments provided.
class GiraffePanel extends JPanel
    int xvalue=10;
    int yvalue=10;
    static GiraffePanel designPanel()
        GiraffePanel jp=new GiraffePanel();
        jp.setBackground(Color.RED);
        jp.setBorder(BorderFactory.createLineBorder(Color.black));
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        jp.setPreferredSize(new Dimension(400, 400));
        jp.setBorder(BorderFactory.createLineBorder (Color.blue, 2));
        jp.setBackground(Color.white);   
        jp.validate();
        jp.setVisible(true);
        return jp;
    public void paint(Graphics g)
        g.drawOval(xvalue, yvalue, 40,40);       
    public void addMouseMotionHandler()
        new MouseMotionAdapter()
            public void MouseClicked(MouseEvent e)
                xvalue=e.getX();
                yvalue=e.getY();               
                repaint();
        setVisible( true );       
}

Whats with all this "static" code in you panel classes?
Overriding the paint(..) method does nothing when your panel is created using a static method.
Here is a simple example of how to do some custom painting on a panel:
http://forum.java.sun.com/thread.jspa?forumID=57&threadID=594537

Similar Messages

  • Payroll Error msg "The gross wages do not cover the negative offset that has been forwarded, therefore, no grossup is permitted".

    Hi Experts,
    I am getting the below error msg while running payroll for an US employee.
    "The gross wages do not cover the negative offset that has been forwarded; therefore, no grossup is permitted."
    I am getting this error msg just after USTAX function processing part of UTX0 subschema. I am highlighting below facts & findings for your reference.
    As per a client requirement,  I have configured a new gross up WT (ER benefit contribution) for a benefit plan (IT 0168) and the changes are in QAS system. The changes have to be reflected in period 20/2014 (4th May'14- 10th May'14) with retro effective 01/01/2014 as per the benefit plan record maintained from 01/01/2014.
    This error msg is coming only for few employees. In my example, when I am running payroll in period 20/2014 with forced retro as 01/01/2014, system is giving error in period 14/2014 (23rd Mar'14-29th Mar'14). When I checked the pay result of this employee for period 14/2014, I can see the /101 is in -ve value and there is claim generated for this period. So I think, eventhough, a value of $ 2.53 is getting added as per the IT 0168 record, its not helping to give a +ve gross value and thus tax is not able to recoved on the same.
    I hope you have come across this issue and can help me to assist to resolve the error msg.
    Regards,
    Prakash  

    If you have correctly configured payroll the system should automatically off set that and should create wage tyes /561 or /563 in RT.

  • Is there a way to make an audio clip not cover the whole project? I want to add audio clip or song and let it start at a certain point in the project. I'm working with iMovie on IPad!

    Is there a way to make an audio clip not cover the whole project in iMovie? I want to add audio clip or song and let it start at a certain point in the project. Whenever I add audio or song it covers the whole project. I'm working with iMovie on IPad!

    Thank you for your reply Karsten but unfortunately this didn't help me so far. Or maybe I'm missing something?
    First the link is a tutorial for iMovie on a Mac. I'm using iMovie on iPad so the steps are inapplicable.
    Second it is only possible for me to manipulate the end part of the sound clip to whichever duration I want. But I can't do the same with the 'beginning' of the sound clip.
    I simply want to place some photos in the beginning of my video with no sound in the background then after like 2 secs I want to start the music clip. For some reason that is not possible! Cause every time I drop the music clip unto my project timeline it automatically place it self along with the first frame in the project! And consequently the photos and music are forced to start together.
    Hope I'm making sense...

  • How do I extend my WiFi with Airport Express? I have Ethernet in the house and an Wifi that do not cover the whole house. I do not get it to work.

    I have Ethernet in the house and an Wifi that do not cover the whole house. I do not get it to work. I have tried to get it into my network and it get connected via the WiFi but not the Ethernet. Also when it gives a green light I cannot see that it is giving any signals to my devices (iPhone etc).

    You need to pay attention to something, while extending your network with the latest AirPort Express upgrade, your devices will be connected to it except your iPhone, you'll see your iPhone always connected to the capsule instead, even if you're at 1 foot from the AirPort Express.
    You need to change the radio settings from automatic to 802.11a - 802.11b/g on your capsule, then I put it back to the default settings...
    Now in the AirPort utility you should see your iPhone connected to the AirPort

  • I preordered an album but not all the songs are showing up. They say purchased but wont go into my itunes library or onto my iphone. Please help.

    They say purchased but wont go into my itunes library or onto my iphone. Please help.

    Hey there aussieboss123,
    It sounds like you are wanting to download an album that you pre ordered, not all the songs are downloading. First, use this section of the following article to see if the tracks download:
    Download a pre-ordered item
    When a pre-ordered item becomes available, you will receive an email letting you know that you can download your pre-order.
    If you enabled the option to automatically download prepurchased content in iTunes, then your pre-ordered content may already be in your library. If not, click the download link provided in your email notification, and your pre-ordered content will begin to download. You can also use the Check for Available Downloads feature in iTunes on your computer (choose Store > Check for Available Downloads) to begin downloading your pre-order.
    iTunes Store: About pre-orders
    http://support.apple.com/kb/ht5714
    If it does not, I would use the following article to report a problem with the purchase to the iTunes Store support directly:
    How to report an issue with your iTunes Store, App Store, Mac App Store, or iBooks Store purchase
    http://support.apple.com/kb/ht1933
    Thank you for using Apple Support Communities.
    Cheers,
    Sterling

  • Err. E:"TRANSPORTING NO FIELDS" will not fill the output area.

    Dear all,
    Below are my codes and i keep getting this error
    E:"TRANSPORTING NO FIELDS" will not fill the output area. The addition does not make sense here.
    Any idea how to fix this?
    The first bit...
    TABLES: /BI0/MWBS_ELEMT.
      DATA:   I_MWBS_ELEMT LIKE /BI0/MWBS_ELEMT OCCURS 0 WITH HEADER LINE.
      DATA:   W_MWBS_ELEMT LIKE LINE OF I_MWBS_ELEMT.
    Then second bit...
      READ TABLE I_MWBS_ELEMT WITH KEY WBS_ELEMT = SOURCE_FIELDS-POSID TRANSPORTING NO FIELDS INTO W_MWBS_ELEMT.
      IF SY-SUBRC IS INITIAL.
        RESULT = W_MWBS_ELEMT-RESP_CCTR.
        RETURNCODE = 0.
      ELSE.
        SELECT SINGLE * FROM /BI0/MWBS_ELEMT INTO W_MWBS_ELEMT
                        WHERE WBS_ELEMT = SOURCE_FIELDS-POSID
                        AND OBJVERS = 'A'.
        IF SY-SUBRC IS INITIAL.
          APPEND W_MWBS_ELEMT TO W_MWBS_ELEMT SORTED BY RESP_CCTR.
         RESULT = W_MWBS_ELEMT-RESP_CCTR.
        ELSE.
          CLEAR RESULT.
        ENDIF.
      ENDIF.

    Hi
    The error is here
    READ TABLE I_MWBS_ELEMT WITH KEY WBS_ELEMT = SOURCE_FIELDS-POSID TRANSPORTING NO FIELDS INTO W_MWBS_ELEMT.
    The addtion TRANSPORTING NO FIELDS is in conflit with addition INTO:
    TRANSPORTING NO FIELDS means not to fill the work are
    INTO mean fill a work area
    So or u need to fill a work area or u don't need to fill a work area, but (from the code you've pasted) it seems u need to fill the work area W_MWBS_ELEMT, so your code should be:
    READ TABLE I_MWBS_ELEMT INTO W_MWBS_ELEMT WITH KEY WBS_ELEMT = SOURCE_FIELDS-POSID.
      IF SY-SUBRC IS INITIAL.
        RESULT = W_MWBS_ELEMT-RESP_CCTR.
        RETURNCODE = 0.
      ELSE.
        SELECT SINGLE * FROM /BI0/MWBS_ELEMT INTO W_MWBS_ELEMT
                        WHERE WBS_ELEMT = SOURCE_FIELDS-POSID
                        AND OBJVERS = 'A'.
        IF SY-SUBRC IS INITIAL.
          APPEND W_MWBS_ELEMT TO W_MWBS_ELEMT SORTED BY RESP_CCTR.
         RESULT = W_MWBS_ELEMT-RESP_CCTR.
        ELSE.
          CLEAR RESULT.
        ENDIF.
      ENDIF.
    Max

  • I am new to Muse so I am following the tutorial for Katie's Cafe.  I downloaded the sample files.  The problem is not all the files are in the folder as are on the tutorial.  The colour sample for instance is not there.  The CC Getting Started Katies.muli

    I am new to Muse so I am following the tutorial for Katie's Cafe.  I downloaded the sample files.  The problem is not all the files are in the folder as are on the tutorial.  The colour sample for instance is not there.  The CC Getting Started Katies.mulib file is also not there so you cannot automatically download all the necessary library files.  Can anyone help?

    found it in another area
    Where do I find the cc getting started Katies.mulib File ?

  • Hello, i have a problem with my macbook air. When i try to open my iPhoto i should wait about 3mins to get opened it and also in it just appeared around 57000 photos! in which i have 2000. they are not mine, the photos are pics of other people or things

    hello, i have a problem with my macbook air. When i try to open my iPhoto i should wait about 3mins to get opened it and also in it just appeared around 57000 photos! in which i have 2000. they are not mine, the photos are pics of other people or things

    If you want help you’ll need to give us more information. There are 9 different versions of iPhoto and they run on 8 different versions of the Operating System. The tricks and tips for dealing with issues vary depending on the version of iPhoto and the version of the OS. So to get help you need to give as much information as you can. Include things like:
    - What version of iPhoto.
    - What version of the Operating System.
    - Details. As full a description of the problem as you can. For example, if you have a problem with exporting, then explain by describing how you are trying to export, and so on.
    - History: Is this going on long? Has anything been installed or deleted? - Are there error messages?
    - What steps have you tried already to solve the issue.
    - Anything unusual about your set up? Or how you use iPhoto?
    Anything else you can think of that might help someone understand the problem you have.

  • First, I've read the manual. This new Nano won't sync and won't charge. Itunes does recognize the device. When it's connected to a Windows PC, the battery indictor shows charged. When it's not connected, the indicator shows no charge. I've tried this on t

    First, I've read the manual. This new Nano won't sync and won't charge. Itunes does recognize the device. When it's connected to a Windows PC, the battery indictor shows charged. When it's not connected, the indicator shows no charge. I've tried this on two PCS without success.

    Maybe the Nano you got is defective. Have it replaced.

  • I have a page showing up when I run my Keynote presentation that does not belong there and is not in the navigation area-how do I remove it?

    I have a page showing up when I run my Keynote presentation that does not belong there. It's not in the navigation area so there is no obvious way to delete it—how do I remove it?

    Not sure if these will help... In the navigator view, is there a triangle next to the slide that appears before the slide that does not belong? If so, click it and you might find the extra slide in there. Or try View Menu:Light Table and see if you can find it in there.

  • Not cover the screen?

    There is a light gray spot on the center of the screen
    Agent says that the warranty does not cover the screen?

    The warranty covers defects in manufacture/assembly/design. It does not cover abuse, accidental damage or user caused damage. From you description I have no idea of the case of the spot.

  • Macbook pro default maximum screen size does not cover the bottom inch

    Kind of frustrated by my new macbook pro.
    At the bottom of the screen, there's the icon bar (icon dock), which is about inch height. I adjusted it to smaller size, about half inch. This is what I did, not sure if related to my problem.
    At the beginning, I thought it was Safari's problem. Later I found all programs has the problem. I'll use Safari as example to describe the problem though.
    When I open Safari, it does not expand to the bottom inch of the screen, as if the icon dock prevents it expanding to the icon bar area of original icon bar size (i.e., inch, not half inch I'm using), and as if there was a line at the bottom inch. I click the plus sign (maximum screen), it still leave the inch uncovered. However, if I use full screen modle, Safari would covers the whole screen.
    when not in full screen model, I can drag the bottom edge of Safari, but can only drag to the virtual icon bar line (at bottom inch position). When bottom edge is at the virtual line, the drag arrow is single direction pointing to up. However, I could move Safari to lower and cover the bottom inch area (with icon bar on the top), and then drag the top edge to make it cover all screen area.
    What makes more annoying is if a new tab automatically opens, Safari will goes to the size with the bottom inch uncovered. This problem does not happen if program runs in full screen model.
    I tried a few programs, all have such problem. Looks to me default maximum screen size excludes the bottom inch (because by default that area is supposed to be occupied by icon bar although I changed the size or just simply hide the icon bar).
    Anyone know why? How to solve the problem? TIA.

    called Apple, the solution is:
    1, turn on sound
    2, shutdown
    3, press and hold these four keys the same time: left option, left command, R, and P
    4, press and release power button to restart
    5, after first starting chime sound, continue hold those four keys
    6, after second starting chime sound, release keys
    this resets some settings --- not sure what is reset though.

  • 1px is missing from text, but not in the stage area

    So my issue is this. I have some text, static, arial. The letter "F" has the top bar missing so it almost looks like a t. But this only looks like this when I render. In the staging area while viewing actual pixels the F looks perfectly fine. Is there a way to fix this without making the text thicker? Whats worse is that when i do custom anti alias settings and thicken the font by 200(which is the max) it actually is thicker than some of the other texts but the to of the F is still missing....its practically bolder than the actual bold setting and its messed up....
    I tried to make sure that its positioning is not on a decimal point with no success(that includes any other layers that the text is in).
    Any suggestions on how to fix this?

    Hello everybody,
    PL 32 is taken back from the portal and the PL 31 is re-available. If you have had upgraded the PL, downgraded it back except you want the bug or error in the PL 32 still exists, just use it.
    PL 34 will be available within several days next. Adios amigo...Zorro.
    Rgds,

  • When I export a playlist and then open in excel, do whatever sorting I want, I then save the file and reimport into itunes but not all the songs are there. It appears to be from "comma's" in the song name. Any solutions?

    I see songs such as "Monday, Monday" or "Paint It, Black" or even the artist name such as "Fireballs, with Jimmy Gilmer" which have comma's in them, being a problem when I try to do the following:
    1. Export a playlist which contains songs which are all there and play fine, but some have comma's in the title such as listed above.
    2. I then open that file in Excel and bring it in as a Tab-delimited file.  Everything lays out fine, and all the songs are thing (including those with comma's).
    3. I then sort the varoius fields I want (which I can't do in i-tunes because i-tunes won't sort it properly), and resave the file as a newly named file, which is also a .txt file.
    4. I then import that playlist into my itunes. It is exactly the same songs that I just had exported but i-tunes says some of the songs can't be found.
    I have traced this problem to comma's in the file name of the song such as listed above.  There must be a solution to this either as the file is opened in excel or in how it's saved or some other solution short of having to rename song/artists without using comma's. 
    Thanks.

    The additional problem is the file name of the song itself.  Even if I were able to delete the commas or replace with a space for example, changing the file name would result in itunes not being able to find the file.  I would have to go through each file (out of about 15,000+ songs) to find any that have titles such as described in this thread and change not only the song and artist in the fields, but changing the mp3 file itself. 
    I fear that I am really pretty much going to have to start with a list of songs that have no comma and then do a file compare to find those songs with commas and then just physically moving them into a new playlist I'm trying to create, but this is a royal pain as I want to be able to create a variety of playlists based on these chart dates/peak positions. 
    I'm trying to sort the songs in this manner:  I use different fields in itunes so that I can put the "peak position" of each song based on Billboard charts, as well as the date the peak position was acheived. I use the "comment box" for that.  I use the "grouping" field for my peak position.
    So I end up with something like "10/14/1980" in the comment box as the peak position for a song which is in the grouping field, and so forth.  If I try to sort the comments column in itunes for example, it won't sort properly. If I sort the Grouping field, it will bring up all the "1's", but that's followed by "10", 11, ...19, then "2", etc.  This is why I want to export the playlist and sort it as I want, and then reimport the playlist into itunes. 
    What I'm ultimately trying to achieve is a year-by-year peak position playlist so that I end up with every #1 song (in this case) from, say, January 1st 1980 and then every #1 song in sequential order for the rest of the year falls in line.  I have chart position dates from 1955 through 1999.  I have entered in all the data from Billboard books I own so I can really create some amazing playlists, but these commas are problematic. Had I known this ahead of time I would have made "Monday, Monday" as "Monday Monday" and not included commas, but it's too late for that.
    Any suggestions?

  • Adobe Reader will not center the printable area on the page

    Hi there,
    I have posted a few times about this issue already but have still not gotten an answer so I'm trying again. Adobe Reader will not center PDF files on the page if the printable area is less than 8.5" X 11". I make sewing patterns for a living and have always drafted them on 7.5" X 10" artboards (printable areas)....the art boards are centered on the page when they are drafted. Up until a few months ago there has never been an issue for me or my customers to print the patterns in either landscape, portrait (depending on the particuar PDF's orientation) or autoportrait/landscape orientation. Then about 2 or so months ago I started getting complaints about the top left hand side of the page getting cut off. When I tried printing one of the PDF's myself that was drafted in landscape orientation, and I printed it in "landscape" orientation, the top left side of the pdf did indeed get cut off. When I printed in autoportrait/landscape orientation the pdf printed fine, and for many of my customers this seems to fix the problem. But for many of them it doesn't fix the problem and the pdf still prints with part of it getting cut off regardless of which box is checked for orientation. I've found that if I go to the "pages to print" box and click "other options" then select "current view" this often solves the problem...but then the user does not seem to be able to select which pages to print. This is becoming a major problem for my business (lots of complaints) and would really like to know if anyone has looked at this issue and if the problem will be solved anytime soon. It is not just me but many of my colleagues and 100's of customers. Help! Thank you:)

    iMac G4, Mac OS X (10.4.9)
    Make sure you have the latest Adobe Reader installed for your OS.
    http://www.adobe.com/support/downloads/product.jsp?platform=macintosh&product=10
    Did you try using Preview. If you control click on the PDF on your desktop you can use the "open with" option.

Maybe you are looking for