SetPreferredSize() & setSize() of JPanel don't work as expected.

http://myhome.cari.com.my/attachment/201002/1/195233_1265032535pmPA.jpg
Above link show what i want to do,but it doesn't show as expected after i run the code below.
//-----------START-----------
import javax.swing.*;
import java.awt.*;
public class Testing extends JPanel
public Testing()
{   setLayout(new GridLayout(1,2));
JPanel leftPanel=new JPanel();
leftPanel.setPreferredSize(new Dimension(224,768));
leftPanel.setBorder(BorderFactory.createLineBorder(Color.black));
JPanel rightTopPanel=new JPanel();
rightTopPanel.setPreferredSize(new Dimension(800,576));
rightTopPanel.setBorder(BorderFactory.createLineBorder(Color.blue));
JPanel rightBottomPanel=new JPanel();
rightBottomPanel.setPreferredSize(new Dimension(800,192));
rightBottomPanel.setBorder(BorderFactory.createLineBorder(Color.red));
JPanel rightPanel=new JPanel(new GridLayout(2,1));
rightPanel.setPreferredSize(new Dimension(800,768));
rightPanel.setBorder(BorderFactory.createLineBorder(Color.yellow));
rightPanel.add(rightTopPanel);
rightPanel.add(rightBottomPanel);
add(leftPanel);
add(rightPanel);
public static void main(String[] args)
{   JFrame frame=new JFrame("Testing!!");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setResizable(false);
frame.setContentPane(new Testing());
frame.getContentPane().setPreferredSize(new Dimension(1440,800));
frame.pack();
frame.setVisible(true);
//--------------END-------------------
Edited by: ImMax on Feb 2, 2010 3:56 PM
Edited by: ImMax on Feb 2, 2010 3:57 PM

Use code tags to post codes -- [code]CODE[/code] will display asCODEOr click the CODE button and paste your code between the {code} tags that appear.
db

Similar Messages

  • PageMargins don't work as expected

    Hi,
    I'm printing a report with the following code:
    document.PrintOptions.ApplyPageMargins(new PageMargins(1440, 0, 0, 0));
    document.PrintOptions.PrinterName = dialog.PrinterSettings.PrinterName;
    document.PrintToPrinter(dialog.PrinterSettings.Copies, dialog.PrinterSettings.Collate, dialog.PrinterSettings.FromPage, dialog.PrinterSettings.ToPage);
    However, the margins don't work as expected. If you set thr right or bottom margin, everything is fine. However, if you set left or top, you'll get completely unexpected results.
    See this illustration:
    http://i33.tinypic.com/2dl8xsi.png
    Arrows indicate where whitespace occurs after the margins have been set.
    The only margin I want is a margin at the left, but as you can see from my illustration, it's not possible.
    Setup: CR2008 SP2, VS2005, C#/.NET 2.0
    Regards,
    Florian

    Thanks, that seems to work much better (even faster).
    Here's the code that worked for me:
    if (dialog.ShowDialog(this) == DialogResult.OK)
        document.ReportClientDocument.PrintOutputController.ModifyPaperOrientation(pageSettings.Landscape ? ReportDefModel.CrPaperOrientationEnum.crPaperOrientationLandscape : ReportDefModel.CrPaperOrientationEnum.crPaperOrientationPortrait);
        document.ReportClientDocument.PrintOutputController.ModifyPrinterName(dialog.PrinterSettings.PrinterName);
        document.ReportClientDocument.PrintOutputController.ModifyPageMargins(1,1,1,1);
        try
            PrintReportOptions options = new PrintReportOptions();
            switch (dialog.PrinterSettings.PrintRange)
                case PrintRange.CurrentPage:
                    options.AddPrinterPageRange(this.GetCurrentPageNumber(), this.GetCurrentPageNumber());
                    break;
                case PrintRange.AllPages:
                    options.AddPrinterPageRange(1, totalPages);
                    break;
                case PrintRange.SomePages:
                    options.AddPrinterPageRange(dialog.PrinterSettings.FromPage, dialog.PrinterSettings.ToPage);
                    break;
            options.Collated = dialog.PrinterSettings.Collate;
            options.NumberOfCopies = dialog.PrinterSettings.Copies;
            options.PrinterName = dialog.PrinterSettings.PrinterName;
            document.ReportClientDocument.PrintOutputController.PrintReport(options);

  • Second Level Subdomains | wildcard domains on Azure don't work as expected

    Hi,
    We're having issues with the Custom Domain functionality of Azure Websites.
    In short, a wildcard CNAME record has been set up to point to the Azure Website instance:
    *.mydomain.com -> mydomain.azurewebsites.com
    In Azure portal, in the custom domains section, the wildcard is also set up with a valid entry
    e.g. *.mydomain.com (record in custom domains section).
    Problem:
    visiting www.level2.mydomain.com results in a 404 error from Azure 'Error 404 - Web Site not found!' etc.
    Every other single-level subdomain gets through fine e.g. level1.mydomain.com is fine.
    Question:
    Are we doing something unsupported here?
    Thanks in advance,
    H

    Hi Petr,
    Many thanks for your response!
    With the knowledge that double wildcard certificates are not supported with Azure Websites, I set up a simple test to see if second-level subdomains would work on Azure Websites
    without SSL.
    Test:
    - a template MVC5 app, no SSL endpoint binding and a single custom domain *.mydomain.com.
    - Home controller index action with a simple redirect to another site
    - published to a Shared Azure Website instance
    - DNS entry from *.mydomain.com to <azurewebsitename>.azurewebsites.net
    - wait for everything to propogate
    Result:
    - 'Error 404 - Web Site not found!' on Azure when navigating to www.secondlevel.mydomain.com
    - Successful redirect when navigating to random.mydomain.com (where random is
    not an explicitly mapped subdomain in the DNS service: therefore, wildcard catchall is working as expected for single-level wildcard subdomains)
    Assessment:
    The non-support of second-level subdomains is not restricted to the fact that Azure Websites don't support double wildcard certificates? The issue extends to Azure Website's non-support of double wildcard Custom Domains?
    Thanks,
    H

  • Http cache don't work as expected in an applet

    Hi, everyone!
    I write an applet which dynamic connect a http server and fetch content from it. I wish the content could be cached in browser's cache system.
    Here is my code, it's work well in MS JVM, but when I turn to sun plugin, the cache system don't work. Every time I get a Response code 200 ( wish to be 304)
    ==================My code================================
    URLConnection conn=(URLConnection)url.openConnection();
    conn.setUseCaches(true);
    conn.setAllowUserInteraction(false);
    conn.connect();
    java.io.ObjectInputStream ois=null;
    Object o=null;
    try
    ois=new ObjectInputStream
    (new java.util.zip.InflaterInputStream(conn.getInputStream()));
    return ois.readObject();
    finally
    if(ois != null)
    ois.close();
    ==================My code================================
    I tested on sun JDK 1.42 and IE6.
    My Http Server is Jetty ,and I do have add a last_modified tag in http response.
    I look into the Java plugin control panel ,only the jar file is cached.

    Sorry for the confusion, of course you are right and it seems to be a bug.
    I ment that the method name setUseCaches itself might be confusing because it does not force caching, it just allows it when available.
    There are several bugs about the plugin caching (4912903, 5109018, 6253678, 4845728, ...) even if they might not fit 100% to your problem they show that plugin caching is an issue which sun really should improve.
    You might have a look at them and vote for them or submit a new bug.

  • FLV Playback controls don't work as expected

    Hi
    I have a FLVPlayback component that I feed with flv through
    the url paramterer.
    The movie loads and play fine, but I the controls do not work
    as expected.
    Eg. If the movie has ended I can not rewind and play it again
    (without reloading the host page)
    Does anyone know whats wrong here?
    Thanks in advance
    T

    Hi
    I have a FLVPlayback component that I feed with flv through
    the url paramterer.
    The movie loads and play fine, but I the controls do not work
    as expected.
    Eg. If the movie has ended I can not rewind and play it again
    (without reloading the host page)
    Does anyone know whats wrong here?
    Thanks in advance
    T

  • TS3048 "Mouse buttons don't work as expected"

    When I consulted the troubleshooting page, the fix was identical to the fix listed for tracking problems, and that won't fix my problem.. Probably won't fix other peoples problems either
    When my Magic mouse is connected, it acts like the left button is constantly being held (selecting, dragging, and not allowing left click), except it's not.
    I have checked that the button hasn't warped for some reason, and also done a peliminary scan of other internet forums. There was a similar problem with the trackpad, but that occured after a firmware update, and was fixed by a firmware update.
    Could anybody help?

    Hello n:
    Just a bit of information from someone who has been using Apple products for well over 15 years (including a couple of warranty issues).  Also, as an aside, the little purple dots indicate that I have helped a lot of people here in the past. 
    1.  I suggest you follow my original suggestion.  As far as I know, there is no "deep-seated" problem with Apple mice.  Extrapolating from what you read in these forums and deciding there are big problems is roughly akin to visiting a hospital and deciding everyone in the world is sick.  If you are near an Apple store and it is convenient, take the mouse in for replacement.  If not, call Applecare for a warranty replacement.  Be sure you specify that you feel the mouse has failed.
    2.  This post is completely idiotic:
    It doesn't make sense to me to call this into Apple Care... since even if they do send you a new one, they'd also have to request that not only do you send yours back in to them, but they would STILL have to charge you a holding fee. And if the r-depot finds out that there is nothing wrong with the mouse you returned (as far as they can see), then that's even more lost $$$.
    If you call Applecare and they send you a replacement mouse, you do return the failed one within 14 days.  Apple pays the shipping cost both ways.  There is NO SUCH THING as a "holding fee." The so-called r-depot (there is no such thing) certainly does not waste time trying to debug a failed mouse.  The mouse goes to, I am sure, recycling.
    My original post was to keep your from wasting time debugging a problem that is not debuggable.
    Barry
    P.S.  In the years I have been using Apple products, I had two warranty issues.  One was an iMac that was DOA.  That was replaced (through Applecare) at no cost to me.  The other was a keyboard that was acting oddly.  Applecare replaced the keyboard and paid shipping both ways.  I do not work for Apple, but I can attest to the fact that their warranty service is first class.
    Message was edited by: Barry Hemphill

  • Albums don't work as expected

    New to itunes and am importing my CDs...
    1) An album like Actually where the artist is always Pet Shop Boys groups as one album as expected.
    2) An album like Into The Woods, various artists, does not group at all (all individual songs are not in same album).
    3) Some albums with various artists do group together under the same album correctly (not many).
    Question 1) Particularly for #2 above, how do you get albums to group together correctly?
    Questions 2) What does the 2nd column (after the art work) mean? It has a number in it, and for albums that group correctly, it makes sense, track 1, 2 etc. For for albums that don't droop, I will have a long song that says 15 for that number. There is a number column for track #. Additionally, the 2nd column cannot be hidden.
    Thanks!
    bob

    See this: Why aren't songs with the same album art grouped together? http://support.apple.com/kb/TS1468

  • Prelude Ingest don't work as expected with P2 material.

    Hi!
    I try to ingest my footage from P2 card and this is what's happening.
    If I just use Ingest dialog windows with P2 mode like just clicking the card, it shows only less than half of the footage as you can see in 2 images of below.
    Ok. So tryed to solve the problem and got to the "folder mode" and marking all clip parts and ofcourse check "stitch clips together mark" and choose Transcode to h264. After that, Media Encoder tells me multiple errors. It shows error box "One or more errors occured during ingest.Please check the..." And event window tells "Transcode task failed. Reason: AME unknown error!" and "Concatenate task failed. Reason: AME unknown error!". Adobe mediaencoder errorlog tells "
      - Encoding Time: 00:00:15
    02/06/2014 06:50:36 PM : Encoding Failed
    Export Error
    Error compiling movie.
    Unknown error.
    So... what can I try next or forget the using Prelude?
    Sami

    Hi,
    Thank you for your post.
    The two images you posted represent the different views of Prelude interprets P2 clips. On the 'File Directory" view, it shows much more footages than the 1st image under the same folder, because there are spanned clips for the two shots. When a shot or take is recorded requiring more than the file size limit of a medium, a file-based camcorder starts another file, and continues recording the shot to that file without interruption.
    So, you could do the ingest from either view. For P2 clip, prelude imports all of the spanned clips within a single shot or take as a single clip. No need to transcode.
    To import a group of spanned clips, select one of them to import all of them. If you select more than one spanned clip, you will import duplicates of the whole group of spanned clips as duplicate clips in the Project panel.
    Hope this helps.
    Best regards,
    Ada

  • Safe Margins - how come they don't work as expected ?

    Hello everyone,
    Ok, so I have put a title on the lower left area of my footage, and have my "safe margins" ON. I placed the text title right up against the outer safe margin border.
    When I export this to .vobs and play it on the TV, the logo is not anywhere near the bottom corner of my TV screen, but up and to the right of the bottom corner, and this is not good, and it's very puzzling why it is doing this.
    Does anyone have any suggestions ?
    Thanks,
    Dave.

    David,
    Depending on the design of your logo, you might consider some "bleed" in the graphic itself, just like in printing to get the graphic to end beyond the page perimeter. If you've got a bug, then a graphic field behind it (say a rectangle with Opacity to 20% maybe even with a gradient from 20% to 0% to the right of the bug), that bleeds off of the screen, even beyond the Action Safe Area, will insure that the whole graphic is about where you want it, and then place the bug inside the Title Safe Area. Visually, it will appear that the logo does go off screen, but your bug will be where you placed it.
    Hunt

  • I am running SSH in Terminal window and my function keys don't work.

    Hi all,
    The company I am working in is using mainly Windows and they are running a database on Putty.exe
    I managed to set up the SSH in Terminal on Mac OSX and I can see the database well and fine. Certain "commands" within the database are executed by numbers 1, 2, 3 etc while other "commands" are executed by function keys F1, F2 - F16 etc. However, when I press the F1 - F12 keys on my keyboard, they don't work as expected.
    If any one has any expert advice, I would greatly appreciate it, thanks!

    FInd out from your database administrator what terminal type the database application supports. Examples of terminal types are vt100 and ansi. Now go back to the Mac's Terminal Preferences and set the terminal to the matching type.

  • Macbook pro 13inch,mid2010 qwertyu keys don't work after upgrade os x Yosemite

    macbook pro 13inch,mid2010 qwertyu keys don't work after I upgrade os x 10.10 Yosemite. but it works on keyboard viewer. I'm not sure if it's hardware or software problem, how can I fix it?

    Hello there, kipolo.
    Great job using the Keyboard viewer to troubleshoot your issue so far. The following Knowledge Base article provides a great checklists of steps to pinpoint the issue a bit further:
    One or more keys on the keyboard do not respond - Apple Support
    Some keys don't work as expected
    From the Apple menu, choose System Preferences.
    From the View menu, choose Speech.
    Click the Text to Speech tab.
    If "Speak selected text when the key is pressed" is enabled, the key or key combination set to speak text cannot be used for other purposes or used to type text--click Set Key and change it to a less-commonly used key combination (try to use modifier keys such as Shift, Command, Option, and Control). Or, disable the "Speak selected text when the key is pressed" option.
    Click the Accessibilty or Universal Access pane in System Preferences, then click the Keyboard tab.
    Make sure that Slow Keys is turned off. With Slow Keys on, you need to press a key for a longer period of time for it to be recognized.
    In the Accessibilty or Universal Access pane, click the Mouse tab, and make sure Mouse Keys is turned off. With Mouse Keys enabled, you cannot use the Numeric Keypad to enter numbers--instead the keypad moves the pointer (cursor). (There is an option to enable Mouse Keys with five presses of the Option key; you may want to turn that option off to avoid accidentally enabling it.) If Mouse Keys is enabled and you are using a keyboard with no numeric keypad or Num Lock function, see Unable to type while Mouse Keys is enabled in Mac OS X.
    If the function keys on the top row of the keyboard are not working as expected, see Mac OS X: How to change the behavior of function keys.
    If the issue persists, use Keyboard Viewer to help isolate the issue:
    Click the Language & Text pane (Mac OS X v10.6) or International pane (Mac OS X v10.5.8 or earlier) in System Preferences.
    Click the Input Sources tab (or Input Menu tab in Mac OS X 10.5.8 or earlier).
    Click the Keyboard & Character Viewer "On" checkbox to select it (click the Keyboard Viewer "On" checkbox in Mac OS X 10.5.8 or earlier).
    From the Input (flag) menu, choose Show Keyboard Viewer.
    If the keyboard is connected and detected by OS X, the keys you type will highlight in the Keyboard Viewer window. Open TextEdit (or any text application), and try to type something using the keys that were previously not responding to see if they highlight in Keyboard Viewer.
    Start from the Mac OS X Install Disc, choose Terminal from the Utilities menu and test the keys which were previously not working.  If the keys work while started from the Install disc, then the keyboard itself is working correctly.  Use How to troubleshoot a software issue to isolate the software issue that may be causing the keys to not respond.
    Thanks for reaching out to Apple Support Communities.
    Cheers,
    Pedro.

  • Keyboard not working as expected

    I woke up this morning and suddenly found a few problems with my keyboard:
    The caps lock light is reversed so that the caps is off when the light is on and vice versa
    The placement of some of the symbols are moved around. The @ is to the right of the P button and Shift-2 produces a ". Shift-9 is ), shift-8 is ( and many other switched like this.
    Resetting PRAM or the computer doesnt fix this

    Hello there, morris152.
    The following Knowlede Base article provides some great information for troubleshooting your issue with the keyboard:
    One or more keys on the keyboard do not respond
    http://support.apple.com/kb/ts1381
    Particularly:
    Some keys don't work as expected
    From the Apple menu, choose System Preferences.
    From the View menu, choose Speech.
    Click the Text to Speech tab.
    If "Speak selected text when the key is pressed" is enabled, the key or key combination set to speak text cannot be used for other purposes or used to type text--click Set Key and change it to a less-commonly used key combination (try to use modifier keys such as Shift, Command, Option, and Control). Or, disable the "Speak selected text when the key is pressed" option.
    Click the Accessibilty or Universal Access pane in System Preferences, then click the Keyboard tab.
    Make sure that Slow Keys is turned off. With Slow Keys on, you need to press a key for a longer period of time for it to be recognized.
    In the Accessibilty or Universal Access pane, click the Mouse tab, and make sure Mouse Keys is turned off. With Mouse Keys enabled, you cannot use the Numeric Keypad to enter numbers--instead the keypad moves the pointer (cursor). (There is an option to enable Mouse Keys with five presses of the Option key; you may want to turn that option off to avoid accidentally enabling it.) If Mouse Keys is enabled and you are using a keyboard with no numeric keypad or Num Lock function, see Unable to type while Mouse Keys is enabled in Mac OS X.
    If the function keys on the top row of the keyboard are not working as expected, see Mac OS X: How to change the behavior of function keys.
    If the issue persists, use Keyboard Viewer to help isolate the issue:
    Click the Language & Text pane (Mac OS X v10.6) or International pane (Mac OS X v10.5.8 or earlier) in System Preferences.
    Click the Input Sources tab (or Input Menu tab in Mac OS X 10.5.8 or earlier).
    Click the Keyboard & Character Viewer "On" checkbox to select it (click the Keyboard Viewer "On" checkbox in Mac OS X 10.5.8 or earlier).
    From the Input (flag) menu, choose Show Keyboard Viewer.
    If the keyboard is connected and detected by OS X, the keys you type will highlight in the Keyboard Viewer window. Open TextEdit (or any text application), and try to type something using the keys that were previously not responding to see if they highlight in Keyboard Viewer.
    Start from the Mac OS X Install Disc, choose Terminal from the Utilities menu and test the keys which were previously not working.  If the keys work while started from the Install disc, then the keyboard itself is working correctly.  Use How to troubleshoot a software issue to isolate the software issue that may be causing the keys to not respond.
    Thanks for reaching out to Apple Support Communities.
    Cheers,
    Pedro.

  • JComboBox don't work here

    I have a code like below, it complile fine, but the JComboBox don't work. If I resize the GUI manaually to very small height, these JComboBox start work. I don't understand why this happens. Any idea is high appreciated. Please email me at [email protected] Many thanks.
    import javax.swing.*;
    import java.awt.HeadlessException;
    import java.awt.*;
    public class testComboBox extends JFrame {
    String[] _tmp={"XY PLOT", "AREA", "PIE", "BAR", "CANDLE"};
    JComboBox cb1= new JComboBox(tmp);
    String[] _tmp1={"Top", "Bottom"};
    JComboBox cb2=new JComboBox(tmp1);
    String[] _tmp2={"SOUTH","EAST"};
    JComboBox cb3=new JComboBox(tmp2);
    public testComboBox() throws HeadlessException {
    this.setSize(new Dimension(200, 180));
    JPanel _jp=new JPanel();
    _jp.setSize(new Dimension(200, 160));
    _jp.setLayout(new GridBagLayout());
    GridBagConstraints _myBag= new GridBagConstraints();
    _myBag.insets=new Insets(2,2,2,2);
    _myBag.weightx=1.0;
    _myBag.weighty=1.0;
    _myBag.gridx=0;
    _myBag.gridy=0;
    jp.add(cb1, _myBag);
    _myBag.gridx=0;
    _myBag.gridy=1;
    jp.add(cb2, _myBag);
    _myBag.gridx=0;
    _myBag.gridy=2;
    jp.add(cb3, _myBag);
    this.getRootPane().setLayout(new GridBagLayout());
    GridBagConstraints _myBag1= new GridBagConstraints();
    _myBag1.insets=new Insets(2,2,2,2);
    _myBag1.weightx=1.0;
    _myBag1.weighty=1.0;
    _myBag1.gridx=0;
    _myBag1.gridy=0;
    this.getRootPane().add(_jp, _myBag1);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.setVisible(true);
    public static void main(String[] args) throws HeadlessException {
    testComboBox testComboBox1 = new testComboBox();
    testComboBox1.show();

    try adding testComboBox1.pack() before the show()
    honestly, you'll get a better answer posing a link to this in the swing forum (do not X-post, just put in a link to this)

  • Component.setSize() doesn't seem to work.

    I've been having trouble making a JFrame that holds a JTable in a JScrollPane, where I set the size of the JTable to be close to the size of the JFrame. Basically, I thought I would be able to listen for the event of resizing, get the new height and width and set the table to that width and that height, minus a little bit for an okay button on the bottom of the panel. However, while I am able to find the size of the window as it resizes, it simply seems that setSize and the assoicated methods do not have the intended effect on my JTable. I've tried a number of things, but it just resizes it to the incorrect number. That is, I can table.setSize(x, y) and then table.getSize() returns values different from the x and y I just found!!
    I've written a really simple program that demonstrates the problem. It does occur in this code, but it isn't nearly as severe:
    package src;
    import java.awt.Component;
    import java.awt.Container;
    import java.awt.Dimension;
    import java.awt.GridBagConstraints;
    import java.awt.GridBagLayout;
    import java.awt.Insets;
    import java.awt.event.ComponentEvent;
    import javax.swing.JFrame;
    import javax.swing.JTable;
    public class Test extends JFrame {
        public static void main(String args[]) {
            new Test();
        private Container c;
        private GridBagConstraints constraints = new GridBagConstraints();
        private GridBagLayout layout = new GridBagLayout();
        private JTable table;
        public Test() {
            setSize(300, 400);
            constraints.insets = new Insets(4, 4, 4, 4);
            constraints.fill = GridBagConstraints.BOTH;
            c = getContentPane();
            c.setLayout(layout);
            setTitle("table.setSize() does not work as expected. Resize this window to see.");
            table = new JTable();
            addComponentListener(new java.awt.event.ComponentAdapter() {
                public void componentResized(ComponentEvent event) {
                    System.out.println("Window resized to " + getWidth() + " , " + getHeight());
                    Dimension size = new Dimension(getWidth() - 20, getHeight() / 2);
                    //table.setMaximumSize(size);
                    //table.setPreferredSize(size);
                    //table.setMinimumSize(size);
                    table.setSize(size);  //toggle some of these on and off to get closer to having it do what it should.
                    validate();
                    System.out.println("Tried to set to " + size + " but is now " + table.getSize());
            addComponent(table, 0, 0, 4, 3);
            pack();
            show();
        private void addComponent(Component component, int row, int column, int width, int height) {
            constraints.gridx = column;
            constraints.gridy = row;
            constraints.gridwidth = width;
            constraints.gridheight = height;
            layout.setConstraints(component, constraints);
            c.add(component);
    }Thanks in advance!
    Andy

    @james91 : setSize has two different signature
    - setSize(int width, int height)
    - setSize(Dimension size)
    @OP : You are using a LayoutManager for your contentPane. Calling setSize on your JTable is useless as you call validate afterwards. validate() will cause the LayoutManager to call layoutContainer(...). In the layoutContainer() method, table.setBounds(...) is called so setting the table's size is completely useless.
    If you really want to use a GridBagLayout, you'll have to use :
    constraints.weightx = 1.0;
    constraints.weighty = 1.0;
    Don't forget to add your table to a JScrollPane if you want the header to appear.

  • Buttons don't work

    I am working on a small application.
    My main frame is a public class that defines two buttons in its constructor one for input and the other for feedback.
    The input screen and the feedback screens are defined as inner listener classes of the main class.
    The code compiles fine but the buttons don't work.Please take a look at my code and make suggestions for what I am doing wrong
    Thanks
    import java.awt.*;
    import java.awt.event.*;
    public class project1 extends Frame {
    static Object source;
    static Button input, feedback, apply;
    public project1(){ 
    super("Project Development Coordination System");     
    setSize(500,500);
    setLayout(new BorderLayout());
    //Build and add 1st Panel of project1
    Panel p1 = new Panel(new BorderLayout());
    TextField Title = new TextField();
    Title.setFont(new Font("Sansserif", Font.BOLD, 48));
    Title.setText("HORNSONIC");
    Title.setEditable(false);
    TextField Name = new TextField();
    Name.setFont(new Font("Sansserif", Font.BOLD, 30));
    Name.setText("Hera International, Inc.");
    Name.setEditable(false);
    p1.add(Title, BorderLayout.NORTH);
    p1.add(Name, BorderLayout.CENTER);
    add(p1, BorderLayout.NORTH);
    //Build and add 2nd Panel
    Panel PDCS = new Panel();
    TextField pdcs = new TextField();
    pdcs.setFont(new Font("Sanserif", Font.BOLD, 22));
    pdcs.setText("Project Development Coordination System");
    pdcs.setEditable(false);
    PDCS.add(pdcs);
    add(PDCS, BorderLayout.CENTER);
    //Build and add 3rd Panel
    Panel buttons = new Panel();
    Button input = new Button("INPUT");
    buttons.add(input);
    Button feedback = new Button("FEEDBACK");
    buttons.add(feedback);
    input.addActionListener( new Input());
    feedback.addActionListener(new Feedback());
    add(buttons, BorderLayout.SOUTH);
    addWindowListener(new WindowAdapter(){
    public void windowClosing(WindowEvent event){
         System.exit(0);
    //end of project1()
    //Input class     
    static class Input extends Frame implements ActionListener {
              Input(){
    super("Input");
    setSize(500,500);
    //Build and add FirstPanel of the Frame
    Panel FP = new Panel(new BorderLayout());
    //Build and add northpanel of FP
    Panel np = new Panel(new BorderLayout());
    //Build and add subpanel1 of np
    Panel subpanel1= new Panel();
    Label L1 = new Label("Sample#");
    TextField T1 = new TextField(10);
    T1.setEditable(true);
    Label L12 = new Label("Customer:");
    TextField ctf = new TextField(10);
    ctf.setBackground(Color.gray);
    ctf.setForeground(Color.black);
    ctf.setEditable(true);
    subpanel1.add(L1);
    subpanel1.add(T1);
    subpanel1.add(L12);
    subpanel1.add(ctf);
    //Build and add subpanel2 of np
    Panel subpanel2 = new Panel();
    TextField sub1t = new TextField(10);
    sub1t.setBackground(Color.gray);
    sub1t.setForeground(Color.black);
    sub1t.setEditable(true);
    subpanel2.add(sub1t);
    Label sublabel = new Label("Model#");
    subpanel2.add(sublabel);
    TextField sub2t = new TextField(10);
    sub2t.setBackground(Color.gray);
    sub2t.setForeground(Color.black);
    sub2t.setEditable(true);
    subpanel2.add(sub2t);
    np.add(subpanel1, BorderLayout.NORTH);
    np.add(subpanel2, BorderLayout.CENTER);
    FP.add(np, BorderLayout.NORTH);
    //Build and add centerpanel of FP
    Panel cp = new Panel(new BorderLayout());
    //Build and add subcenter1 of centerpanel
    Panel subcenter1 = new Panel(new BorderLayout());
    Panel NP = new Panel();
    Label Project = new Label("Project Scope");
    NP.add(Project);
    TextField PS = new TextField(10);
    PS.setBackground(Color.gray);
    PS.setForeground(Color.black);
    PS.setEditable(true);
    NP.add(PS);
    Label Appl = new Label("Application:");
    NP.add(Appl);
    TextField Price1 = new TextField(10);
    Price1.setBackground(Color.gray);
    Price1.setForeground(Color.black);
    Price1.setEditable(true);
    NP.add(Price1);
    subcenter1.add(NP, BorderLayout.NORTH);
    Panel CP = new Panel();
    Label TP = new Label("Target Price-");
    CP.add(TP);
    TextField appl = new TextField(10);
    appl.setBackground(Color.gray);
    appl.setForeground(Color.black);
    appl.setEditable(true);
    CP.add(appl);
    Label quote = new Label("Quoted Price-");
    CP.add(quote);
    TextField Q = new TextField(10);
    Q.setBackground(Color.gray);
    Q.setForeground(Color.black);
    Q.setEditable(true);
    CP.add(Q);
    subcenter1.add(CP, BorderLayout.CENTER);
    cp.add(subcenter1, BorderLayout.NORTH);
    //Build subcenter panel of cp
    Panel subcenter = new Panel(new GridLayout(1,3));
    List list = new List (3,true);
    list.addItem("Woofer:");
    list.addItem("Mid:");
    list.addItem("Tweeter");
    subcenter.add(list);
    TextArea inches = new TextArea(3,5);
    inches.setBackground(Color.gray);
    inches.setForeground(Color.black);
    inches.setEditable(true);
    subcenter.add(inches);
    List list1 = new List(3, true);
    list1.addItem("Count-");
    list1.addItem("Count-");
    list1.addItem("Count-");
    subcenter.add(list1);
    TextArea count = new TextArea(3,5);
    count.setBackground(Color.gray);
    count.setForeground(Color.black);
    count.setEditable(true);
    subcenter.add(count);
    List list2 = new List(3, true);
    list2.addItem("Materials:");
    list2.addItem("Materials:");
    list2.addItem("Materials:");
    subcenter.add(list2);
    TextArea materials = new TextArea(3,5);
    materials.setBackground(Color.gray);
    materials.setForeground(Color.black);
    materials.setEditable(true);
    subcenter.add(materials);
    cp.add(subcenter, BorderLayout.CENTER);
    FP.add(cp, BorderLayout.CENTER);
    //Build and add southpanel of FP
    Panel sp = new Panel();
    TextArea comments = new TextArea("Comments:", 3,30);
    sp.add(comments);
    FP.add(sp, BorderLayout.SOUTH);
    add(FP, BorderLayout.NORTH);
    //Build and add SouthPanel of Frame
    Panel SP = new Panel();
    List l1 = new List(8,true);
    l1.addItem("Quote Requested:");
    l1.addItem("Quote to be completed by:");
    l1.addItem("Sample Requested:");
    l1.addItem("STd sent to Factory:");
    l1.addItem("Factory estimated ETD:");
    l1.addItem("Revised ETD#1:");
    l1.addItem("Revised ETD#2:");
    l1.addItem("Revised ETD#3:");
    SP.add(l1);
    TextArea dates1 = new TextArea(8,8);
    dates1.setBackground(Color.gray);
    dates1.setForeground(Color.black);
    dates1.setEditable(true);
    SP.add(dates1);
    List l2 = new List(8, true);
    l2.addItem("Days Quote overdue:");
    l2.addItem("Date Quote Received:");
    l2.addItem("Actual ETD:");
    l2.addItem("Sample Arrival Date:");
    l2.addItem("Days Sample overdue:");
    l2.addItem("Days in Development:");
    l2.addItem("Date sent to customer:");
    l2.addItem("Actual Days to customer:");
    SP.add(l2);
    TextArea dates2 = new TextArea(8,8);
    dates2.setBackground(Color.gray);
    dates2.setForeground(Color.black);
    dates2.setEditable(true);
    SP.add(dates2);
    add(SP, BorderLayout.SOUTH);
    //Build and add CenterPanel of Frame
    Panel TD = new Panel();
    TextField td = new TextField("TIME IN DEVELOPMENT");
    TD.add(td);
    add(TD, BorderLayout.CENTER);
              addWindowListener(new WindowAdapter(){
    public void windowClosing(WindowEvent event){
         System.exit(0);
    }// end of input()
    public void actionPerformed(ActionEvent Event)
    Object source = Event.getSource();
    if (source == input){
                   new Input();
                   setVisible(true);
    }//end of input if
              }//end of actionPerformed.
         }//end of class input
    //Feedback class
    static class Feedback extends Frame implements ActionListener{
    Feedback(){
    super("Feedback");
    setSize(500,500);
    //Build and add panel 1.
    Panel p1 = new Panel(new BorderLayout());;
    //Build and subpanel off panel 1
    Panel subpanel1= new Panel();
    Label L1 = new Label("Sample#");
    TextField T1 = new TextField(10);
    T1.setEditable(true);
    Label L12 = new Label("Customer:");
    TextField ctf = new TextField(10);
    ctf.setBackground(Color.gray);
    ctf.setForeground(Color.black);
    ctf.setEditable(true);
    subpanel1.add(L1);
    subpanel1.add(T1);
    subpanel1.add(L12);
    subpanel1.add(ctf);
    Panel subpanel2 = new Panel();
    TextField sub1t = new TextField(10);
    sub1t.setBackground(Color.gray);
    sub1t.setForeground(Color.black);
    sub1t.setEditable(true);
    subpanel2.add(sub1t);
    Label sublabel = new Label("Model#");
    subpanel2.add(sublabel);
    TextField sub2t = new TextField(10);
    sub2t.setBackground(Color.gray);
    sub2t.setForeground(Color.black);
    sub2t.setEditable(true);
    subpanel2.add(sub2t);
    p1.add(subpanel1, BorderLayout.NORTH);
    p1.add(subpanel2, BorderLayout.CENTER);
    add(p1, BorderLayout.NORTH);
    //Build and add Panel 2
    Panel p2 = new Panel(new BorderLayout());
    //Build and add subcenter1 of Panel 2.
    Panel subcenter1 = new Panel(new BorderLayout());
    //Build subpanels of subcenter 1.
    Panel NP = new Panel();
    Label Project = new Label("Project Scope");
    NP.add(Project);
    TextField PS = new TextField(10);
    PS.setBackground(Color.gray);
    PS.setForeground(Color.black);
    PS.setEditable(true);
    NP.add(PS);
    Label Appl = new Label("Application:");
    NP.add(Appl);
    TextField Price1 = new TextField(10);
    Price1.setBackground(Color.gray);
    Price1.setForeground(Color.black);
    Price1.setEditable(true);
    NP.add(Price1);
    subcenter1.add(NP, BorderLayout.NORTH);
    Panel CP = new Panel();
    Label TP = new Label("Target Price-");
    CP.add(TP);
    TextField appl = new TextField(10);
    appl.setBackground(Color.gray);
    appl.setForeground(Color.black);
    appl.setEditable(true);
    CP.add(appl);
    Label quote = new Label("Quoted Price-");
    CP.add(quote);
    TextField Q = new TextField(10);
    Q.setBackground(Color.gray);
    Q.setForeground(Color.black);
    Q.setEditable(true);
    CP.add(Q);
    subcenter1.add(CP, BorderLayout.CENTER);
    p2.add(subcenter1, BorderLayout.NORTH);
    //BUILD and add subcenter to Panel 2);
    Panel subcenter = new Panel();
    List list = new List (3,true);
    list.addItem("Woofer:");
    list.addItem("Mid:");
    list.addItem("Tweeter");
    subcenter.add(list);
    TextArea inches = new TextArea(3,5);
    inches.setBackground(Color.gray);
    inches.setForeground(Color.black);
    inches.setEditable(true);
    subcenter.add(inches);
    List list1 = new List(3, true);
    list1.addItem("Count-");
    list1.addItem("Count-");
    list1.addItem("Count-");
    subcenter.add(list1);
    TextArea count = new TextArea(3,5);
    count.setBackground(Color.gray);
    count.setForeground(Color.black);
    count.setEditable(true);
    subcenter.add(count);
    List list2 = new List(3, true);
    list2.addItem("Materials:");
    list2.addItem("Materials:");
    list2.addItem("Materials:");
    subcenter.add(list2);
    TextArea materials = new TextArea(3,5);
    materials.setBackground(Color.gray);
    materials.setForeground(Color.black);
    materials.setEditable(true);
    subcenter.add(materials);
    p2.add(subcenter, BorderLayout.CENTER);
    //Build and add south subpanel of Panel 2
    Panel subpanel = new Panel();
    Label L2 = new Label("Sample Disposition:");
    subpanel.add(L2);
    TextField T2 = new TextField(10);
    T2.setEditable(true);
    subpanel.add(T2);
    Label l2 = new Label("Date:");
    subpanel.add(l2);
    TextField t2 = new TextField(10);
    t2.setEditable(true);
    subpanel.add(t2);
    TextArea TF = new TextArea("Feedback:",3,30);
    TF.setEditable(true);
    subpanel.add(TF);
    p2.add(subpanel, BorderLayout.SOUTH);
    add(p2, BorderLayout.CENTER);
    //Build and add Panel 3.
    Panel p3 = new Panel();
    Label L3 = new Label("Project Continued on Revision#:");
    TextField T3 = new TextField(10);
    T3.setEditable(true);
    Label l3 = new Label("Order Placed:");
    TextField t3 = new TextField(10);
    t3.setEditable(true);
    p3.add(L3);
    p3.add(T3);
    p3.add(l3);
    p3.add(t3);
    add(p3, BorderLayout.SOUTH);
    setVisible(true);
    addWindowListener(new WindowAdapter(){
    public void windowClosing(WindowEvent event){
         System.exit(0);
    }//end of Feedback()
    public void actionPerformed(ActionEvent AE){
    if (AE.getSource() == feedback){
    new Feedback();
         setVisible(true);
    }//end of feedback if
    }//end of actionPerformed
    }//end of class Feedback
    public static void main (String args[]){
         project1 window = new project1();
         window.setVisible(true);
         //end of main
    }//end.

    I compiled and did run your code....
    it seems you are trying to implement a Frame with two buttons... each time the user click on a button, the main frame displays the equivalent panel with a set of components .. isn�t it ?
    well... some tips:
    1 - Why don�t you use a JTabbedPane ? a much better container than a simple Frame....
    2 - If you really need to use a Frame as a container of multiple forms.. then you should take a look in the java.awt.CardLayout
    other tip: don�t use the Frame component as the same class as the ActionListener.. divie these comopnents in two classes...

Maybe you are looking for

  • Transaction KSB1(cost line items)  - Tables or FM's to get data?

    Hi, For a current report, I need to obtain the data stored in transaction KSB1 - Actual Cost Line items for cost centers. What tables contain this data? Are there any standard function modules available to obtain the data? Please help. Thanks, John

  • More than 100 mb xml file , giving out of memory error in BIP 10.1.3.4

    We are running outofmemory error, java heap space error, if we run a report which has more than 100mb xml, with two or more grouping in RTF template. How to configure it to work with better performance for bigger XML files ? Any particular setup , po

  • New report for Cash Position (TC - FF7A)

    Hi I want to draw cash position (FF7A) report in following format:- 1) Receipt                AR Collection                Other                Total Receipt 2) Disbursements                Payroll                Bonus 3) Accounts Payable            

  • Netbeans UTF-8 cannot read arabic characters

    Hi I wondering how to deal with arabic in netbeans my platform is Vista with Nebeans5.5 and the locale is Arabic I try this : Properties pi = System.getProperties(); pi.put("file.encoding", "UTF-8"); System.setProperties(pi);         System.out.print

  • Error 2 when starting LabVIEW from ELVIS Instrument Launcher

    I have a WinXP Pro SP2 box that's running LabVIEW 7.1 (academic license) and NI ELVIS 2.0.1. When I perform the following steps, 1) Log on to the WinXP machine as a user who does not have Power User or Administrator privileges. 2) Click on Start > Al