Keeping the components size fixed when the window is maximized

How to keep the Labels and text boxes same size when the window is maximized to fit the screen.Thank you in advance.
My code:package test;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class ShoWnd extends JFrame{
     Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
     JMenuBar menubar;
     JMenu menu;
     JMenuItem menuitem1,menuitem2;
     JLabel label1=new JLabel("Name:");
     JLabel label2;
     JTextField txtfld1;
     JTextField txtfld2;
     JButton btn;
     public ShoWnd(){
          menubar=new JMenuBar();
          menu=new JMenu("File");
          menuitem1=new JMenuItem("open");
          menuitem2=new JMenuItem("Exit");
          label1=new JLabel("Name:");
          txtfld1=new JTextField();
          label2=new JLabel("Name:");
          txtfld2=new JTextField();
          btn=new JButton("Click");
          menu.add(menuitem1);
          menu.add(menuitem2);
          menubar.add(menu);
          setJMenuBar(menubar);
          setLayout(new GridLayout(3,2));
          getContentPane().add(label1);
          getContentPane().add(txtfld1);
          getContentPane().add(label2);
          getContentPane().add(txtfld2);
          getContentPane().add(btn);
          setSize(100,100);
          setVisible(true);
     public static void main(String args[]){
          new ShoWnd();
}

How to keep the Labels and text boxes same size when the window is maximized to fit the screen.Either : By using a suitable LayoutManager other than GridLayout.
Or: Enclose each label and text box (what the heck is a text box?) in a container with a suitable layout manager and arrange those containers in a GridLayout (or any other layout).
The Java™ Tutorials: [Laying Out Components Within a Container|http://java.sun.com/docs/books/tutorial/uiswing/layout/index.html]
db

Similar Messages

  • Todays update! After todays update I can no longer send Safari or Spotify to the task bar without it cutting out (dropping audio in and out). Streams normally if I keep the window open on my desktop. This needs to be fixed immediately.

    Todays update! After todays update I can no longer send Safari or Spotify to the task bar without it cutting out (dropping audio in and out). Streams normally if I keep the window open on my desktop. This needs to be fixed immediately.

    Nevermind. I figured it out.

  • [svn:fx-trunk] 13276: Min/ Max size fixes for AIR Window and WindowedApplication.

    Revision: 13276
    Revision: 13276
    Author:   [email protected]
    Date:     2010-01-05 07:18:31 -0800 (Tue, 05 Jan 2010)
    Log Message:
    Min/Max size fixes for AIR Window and WindowedApplication.
    AIR won?\226?\128?\153t allow you to set the min width greater than the current max width (same is true for height). You also can?\226?\128?\153t set the max width less than the current min width (same is true for height). The code that sets nativeWindow.minSize and nativeWindow.maxSize has been modified to take this into account.
    QE notes: None.
    Doc notes: None.
    Bugs: SDK-24566
    Reviewer: Corey
    Tests run: checkintests, apollo/spark/components/Window.as, apollo/spark/components/WindowedApplication.as, apollo/Window, apollo/WindowedApplication
    Is noteworthy for integration: no
    Ticket Links:
        http://bugs.adobe.com/jira/browse/SDK-24566
    Modified Paths:
        flex/sdk/trunk/frameworks/projects/airframework/src/mx/core/Window.as
        flex/sdk/trunk/frameworks/projects/airframework/src/mx/core/WindowedApplication.as
        flex/sdk/trunk/frameworks/projects/airspark/src/spark/components/Window.as
        flex/sdk/trunk/frameworks/projects/airspark/src/spark/components/WindowedApplication.as

    THank you , Nancy. Appreciate the input.
    So instead of this:
    <a class="brand" href="index.html"><img src="../img/logo-ca.png"alt="Consumers Advocate Review"> </a>
    Would it be something like this?:
    <a class="brand" href="index.html"><img src="http://ConsumersAdvocate/img/logo-ca.png"alt="Consumers Advocate Review"> </a>
    And if I do that, is there a way to cope with that locally so that DW can still display the images?
    jeff

  • Locking the window after maximizing it

    Hi ,
    I am a Mac user for about 2 years and I like it a lot and I 'm happy with it.
    However , the only thing bothers me ,is that I can not lock the window after maximizing it like in PC Windows. So when I click on the window by inadvertence, it moves and I have to fit it to full frame manually each time.
    Is there any solution for this or maybe the OSX application is done like that and we have to use it as is?
    Any help would be much appreciated.

    There is no maximize in Mac OS X that is the same as in Windows (window takes over the screen). The little green button at the top left makes the window as large as possible, based on the content of the window and the size of your screen. If you move such a window, clicking it again will move it back into a fully viewable position.

  • How to keep objects centered and fixed when window resized

    Hi,
    Newbie here with a question about centering.  What I'm trying to do is center the content of a website and keep the content fixed in size, but what is happening is when I move the right side of the window toward the left side of the window (i.e. contract the window to a smaller size), the items that are centered,  keep moving.  For example, if I have a menu bar, I want the menu bar area to be fixed, and stay centered when a window is resized.  I've attached images of what I'm talking about to hopefully make this more understandable.
    Below is the link I used for information regarding centering:
    https://forums.adobe.com/thread/454036
    Thank you for your assistance

    May I suggest a bit more modern list style menu like the one way down the bottom of this page:
    http://www.peattiecapital.com/2014.php
    Here is the HTML code (classes on the a tag are optional)
    <ul>
       <li><a class="nl2014" href="2014.php">2014</a></li>
       <li><a class="nl2013" href="2013.php">2013</a></li>
       <li><a class="nl2012" href="2012.php">2012</a></li>
       <li><a class="nl2011" href="2011.php">2011</a></li>
       <li><a class="nl2010" href="2010.php">2010</a></li>
       <li><a class="nl2009" href="2009.php">2009</a></li>
       </ul>
    The CSS is here:
    http://www.peattiecapital.com/archive.css

  • The maximize/minimize and close and buttons are not shown correctly when FF windows is maximized.

    I have the same problem on all my computers, one running Windows 7 and two with Vista.
    The three buttons in the upper right corner of the FF windows are not shown correctly. They are soft of cut off in the middle when the FF window is maximized.

    It is possible that the screen is too wide or too high and that the scroll bars fall off.<br />
    Open the system menu via Alt+Space and see if you can resize that window.<br />
    If that works then close Firefox to save that setting.<br />
    See also:
    * http://kb.mozillazine.org/Resizing_oversize_window
    Window sizes and positions are stored in [http://kb.mozillazine.org/localstore.rdf localstore.rdf] in the [http://kb.mozillazine.org/Profile_folder_-_Firefox Profile Folder].
    See http://kb.mozillazine.org/Corrupt_localstore.rdf

  • Why does the flash video have much higher contrast when the window is maximized?

    When using Mozilla Firefox, any flash videos like those on youtube, when maximized, shows much higher contrast. The video becomes so dark that it is pretty difficult to view it. When zoomed out, everything looks normal.
    The work around I ended up using, was to maximize the window using ctrl++ option without using the "fullscreen" button. It is a hassle, but it works. Does anyone know why this happens?
    I use Mozilla FF 19.0.2. Btw, this doesn't happen on Chrome or IE.

    [HKEY_CURRENT_USER\Control Panel\Colors]
    "Window"="0 0 0"
    *http://superuser.com/questions/579227/getting-rid-of-white-flash-in-windows-8-high-contrast-mode

  • Could I reinstall OS X partition keeping the windows boot camp partition?

    II have a OS x partition that need reinstall. In the same hd I have a Windows Boot camp partition. The question is, could I reinstall OS X partition without affect the Windows partition?
    Thanks,
    Jorge.

    Sometimes it works, sometimes not.
    Of course you should backup both.
    Q: why do you think OS X needs to be reinstalled or something?
    Disk directory trouble?
    Because 3rd party disk utility can do better, as well as maybe clone Mac volume so you can boot and do more repairs.
    Or maybe the partition table is shot. Or bad sectors. And bad sectors can require a full format.
    In a perfect world, but disk drives and systems aren't

  • Window resizing and how to keep the window at that size.

    Having trouble with the applications window not staying the same size after I resize it. I know that dragging the corner will resize as well as the green button, but after I close it, it reverts back the small window and not to the resized window after I have done the above. Went to an apple store and no one there knew how to fix it or maybe I didn't explain myself very well.

    I assume you're opening the Applications folder in a separate window through an alias or a Dock icon... if so, just open it, move and resize it the way you want, then immediately close it again. That should do the trick.

  • How do i keep the window visible on top

    I'm watching videos and want them to stay 'on top' of all other windows as I switch between applications...like word to explorer to safari to google...I want to keep my video playing visible on 'top' of all other windows.

    Firefox itself does not have native features for this. However, you can download and install the PowerMenu application for Windows at [http://www.abstractpath.com/powermenu/]. It installs very quickly.
    When you want to watch your video, put it into its own Firefox window (you can do this by right-clicking the video tab and selecting "Move to new window". In this new window, right-click any one of the three Windows buttons at the top right corner (Minimize, Resize, Close). Click "Always On Top" from the menu. This window will now remain on top of all other windows until you uncheck "Always On Top".
    I hope that helps!

  • Stage.nativeWindow.alwaysInFront how to keep the window always in front

    Hi, I've just written and application that needs to always be in front of the other applications. I have set the application's nativeWindow.alwaysInFront property to true, but, after a few other air applications open the application will get pushed behind. It seems to work when the first application opens up, but after opening a second time it will no longer be on top. Any suggestions? Thanks.

    One way is to browse your iTunes Music Library in the Finder and open the video file with QuickTime instead of playing it in iTunes. Then you have always-on-top and also fixes the "full screen on 2nd monitor" problem. Maybe not ideal, but a workaround.

  • Tabs are not in the title bar even when the window is maximized on Windows

    if I'm right since FFX 4b9 tabs should be located in title bar when the ffx window is maximised on Windows OS. [[https://bugzilla.mozilla.org/show_bug.cgi?id=572160]]
    I'm on XP Pros
    This works fine on minefield for me.
    But under FFX 4b9 and 4b10... tabs are still under Firefox logo...

    Hello,
    I have same kind of issue, but for me it works only with maximized windows. On normal windows the tabs tags are still under firefox button. Like you can see on the images I uploaded.
    Is there any way to make it appear always like when maximized to fill the gap?
    Thank for your help

  • Need to install Linux keeping the windows 8 os .

    Hello,  I have a HP notebook laptop running windows 8 in it. My laptop is covered under warranty for another 18 months. I need to install another OS like Ubuntu in my PC in order to run some softwares as a part of my acads. But I also need Windows 8 for my general usage. I read somewhere that I will lose my HP warranty if I boot my system or try to install another OS than what came with the PC.  Is this true? Having warranty for my laptop is as important as having dual OS in my PC. Is there a way to install another OS on the current Windows without endangering my warranty? Also, I need Ubuntu only for this semester, so if I install it now will I be able to remove that later again keeping my warranty safe? I am unable to ask any of my friends or seniors regarding this because many of them know how install and uninstall OS but no one is assuring me regarding my warranty. Hope to find a solution here.

    again people respond with the wrong help info. You simply need the PARAGON NTFS DRIVER FOR MAC. gives you full read and write support from your mac side to your bootcsamp side. You will always be able to read your mac side contents from your bootcamp side and also copy from mac to bootcamp while in windows mode. But buy the paragon ntfs $20 driver and you will be fine. Ive had it for years without any problems. works perfectly and easily. It also allows you to verify and repair your bootcamp partition from within disk utility on your mac side.
    http://www.paragon-software.com/home/ntfs-mac/

  • Lxterminal --command: How can I keep the window open? [SOLVED]

    Hello,
    I am trying to create an application launcher that will let me connect to my vpn account at start up instead of having to manually type the openvpn command each time my machine boots. I need to use sudo, but lxterminal disappears the instant it opens. I tried adding the read command as suggested here:http://ubuntuforums.org/showthread.php?t=192427, but it just doesn't work.
    Any suggestions? Or alternatively, is there a way for me to start the vpn connection automatically at startup, preferably without even having to enter my password?
    Here's my .desktop file:
    [Desktop Entry]
    Encoding=UTF-8
    Name=OpenVPN
    Comment=Establish a secure connection
    Icon=vpn
    Exec=lxterminal --command="sudo openvpn --config /home/myhomefolder/.vpnkey/vpnfile.ovpn"
    Terminal=false
    Type=Application
    Thanks!
    Last edited by DavidR (2009-09-19 17:43:06)

    I tried adding it to /etc/rc.local, and according to the boot up messages it works, but the boot process just stops after OpenVPN opens the tunnel. OpenVPN doesn't terminate and I think that the startup process keeps waiting for bash to exit, but bash doesn't as it keeps waiting for the OpenVPN output. In other words, my machine stops booting.
    Here's what I have in rc.local:
    #!/bin/bash
    # /etc/rc.local: Local multi-user startup script.
    cd /home/homefolder/.vpnkey
    openvpn --config vpn.ovpn

  • Workbook doesn't fit the window when launched from Portal

    Hello SCNer's,
    When a workbook is launched from Portal it opens to the right side of the window and is minimized.
    It fits the window once maximized, are there any settings available which can defaultly set the workbook to fit the window.
    Thanks SCNer's.

    Hi,
    Do you mean by executing the Query in portal or executing the Workbook.
    Protal setting for the number of columns/rows are decided by 0ANALZER_PATTERN web template. Which is the default web template.
    Check the settings in the Default Web Template used.
    Thanks & Regards,
    Namrata

Maybe you are looking for

  • Removed from iTunes 10? Smart Playlist of all podcasts

    Hi all, I was able to create a smart playlist of all podcasts in iTunes 9, however I don't see the option in iTunes 10. Basically I'd like all my podcasts to add automatically to a smart playlist. See "Get smart playlists" here: http://www.apple.com/

  • Could i get some helps about the website?

    hi i'm a new user of flash and dreamweaver. so please sorry for this question. i used a template from flash and converted it into a swf. after i integrated that swf file into my dreamweaver template. everything does work in my local browser but it's

  • After upgrading to Acrobat X Pro, having problems editing text

    I just upgraded to Acrobat X Pro from Acrobat 8 Professional. I've opened a document (created in Acrobat 8) and when I try to edit the text, it all seems fine until I try to save it. Then the formatting goes awry. The spacing between paragraphs disap

  • User name - Migration Assistant

    Is there a way to change the user name from an old computer when using Migration Assistant to set up a new MBA? I want everything from the old computer, but want to change the user name.

  • Letters and numbers like on lcd-screen

    hi there, i want to do a frame, where you can see something like a lcd-display with such letters and numbers (like on many counters). how can i do this ? are there any (standard)fonts i can use, or do i have to use images therefore ? thanks in advanc