Why does my login panel resize?

Hi,
This is probably a basic problem. So please bear with me.
I'm making an application and Applet, where the user needs to log in. I created a Frame, that scales to cover the whole screen.
     dimension = Toolkit.getDefaultToolkit().getScreenSize();
     setBounds (0, 0, dimension.width, dimension.height);After the Frame is created, I create a JPanel in it, where the user needs to enter username and password. And as users go, they will make errors, so I have to add functionality to check on
1. Are username and password filled in
2. Can username and password be used to authenticate
So I need to draw that JPanel a few times. And there it goes wrong. So my question is, can you help me with my JPanel.
   // Constructor
   public LogInPanel () {
      width = 450;
      height = 350;
      // Create error label and set its colour
      errorLabel = new JLabel ("Fill in both fields", SwingConstants.LEFT);
      errorLabel.setForeground(Color.RED);
      setLayout(new GridLayout (4, 2)); // 4 rows, 2 columns
      setUp();
   public void actionPerformed(ActionEvent event) {
          command = event.getActionCommand();
          if (OK.equals(command)) {
               //Process the user name and password.
               userName = userNameField.getText();
               password = passwordField.getPassword();
               isError = ((userName.length() == 0) || (password.length ==0));
          if (!isError) {
               // TODO: Authenticate with system
          else {
               // Error condition, either user name or error not filled in. Do setUp() again.
               setUp();
    private void setUp () {
        // Set the size and location of this panel
        setBounds (width, height, width, height);
         // User name label and text field
         add (unameLabel);
         add (userNameField);
         // Password label and text field
         add(passLabel);
         add(passwordField);
         // Create okButton and add it to the layout
         JComponent okButton = createButtonPanel();
         add(okButton);
         // An empty panel to fill up the empty spot after the button
         JPanel emptyPanel = new JPanel();
         emptyPanel.setBackground(Color.WHITE);
        if (isError) {
            add(errorLabel);
        setSize(dimension.width/3, dimension.height/3);
        setVisible (true);
    private JComponent createButtonPanel() {
        JPanel panel = new JPanel(new GridLayout(0,1));
        JButton okButton = new JButton("OK");
        okButton.setActionCommand(OK);
        okButton.addActionListener(this);
        panel.add(okButton);
        return panel;
    }When I run the code I get the following LoginPanel displayed
|Username: | "userNameField"       |
|Password: | "add(passwordField)"  |
|OKbutton  |emptyPanel             |
|Nothing yet                       |
------------------------------------And as I emulate a stupid user, I directly press the OK button. What happens now is that my LoginPanel moves up a few lines, and increases four times (2x in width, 2x in height), to something like:
|Username: | "userNameField"                                           |
|Password: | "add(passwordField)"                                      |
|OKbutton  |emptyPanel                                                 |
|No error message!                                                     |
|                                                                      |
|                                                                      |
|                                                                      |
|                                                                      |
|                                                                      |
------------------------------------------------------------------------And I can't find the reason for that behaviour. So hopefully you see it. And if so, do tell.
TIA,
Abel

without your code, I can't tell why you are having this behavior, however I can tell you that when I've done something like this, I've done it differently. For one, I don't recreate the JPanel but rather I show a JOptionPane.showMessage(....) error message over the panel, the erase the JPanel's fields and set focus where I want it after the JOptionPane has been dealt with. This is simpler than your current plan and thus less likely to blow-up.

Similar Messages

  • Why does my login screen when scrolling mouse over appear pixalated (has small squares wherver the mouse scrolls until the entire page has been scratched like a lotto ticket:) ?

    Why does my login screen when scrolling mouse over appear pixalated (has small squares wherver the mouse scrolls until the entire page has been scratched like a lotto ticket:) ?

    OS X Lion: Login window partially appears, cursor movement redraws screen

  • Why does my xfce4-panel taskbar look like this?

    Why does one task take up the whole bar? It's so ugly!!

    Ah, so this brings up another aesthetically displeasing trait: Now my panel changes size depending on how many tasks are in my taskbar because I have it set to normal width, rather than full width. Is there any way to force the whole panel to stay at one length?

  • Why does a Login Error occur: "AFP Client wants to use Keychain Login"?

    I have three people in my house with separate logins. We are currently using two desktop G4s which are networked via 1000 Base T. When the users login to one of the Macs, they must enter their passwords twice. Once for the AppleShare login and then a second time for the KeyChain Login.
    If I attempt to unify the passwords, which are exactly the same, I will get a login error: "AFP Client wants to use Keychain Login". At this point, a dialogue box will appear looking for a password, but not accepting any kind of text at all. All I can do is reset the Mac, go into my admin login and remove the login.keychain file from the local Library folder to get back into the User account.
    In my attempts to fix this, I have removed every preference file with the word "login" in it and re-logged in without success. I have also used the Keychain Access software to administer Keychain First Aid without success. Finally, I have deleted the keychain login in Keychain Access without success. I have done all of these separately and together without success.
    This is only happening on one Mac. The Mac that has no files on it. All working files are stored on the other Mac and it does not have the same problem at all.
    This is not a huge problem, but it is annoying. I would appreciate it if anybody knows anything about this and could shine some light on the situation.

    Sorry about the delay from your last reply. I have been busy with work and studying for a licensing exam.
    Anyway I tried the AppleJack Utility you suggested. It looked like it tidied up some things. But as for my particular issue, it did absolutely nothing.
    Interestingly enough, you know when you aren't looking for something and that something just happens by accident? When I logged in the other day, I typed in the first login. The second dialogue came up immediately and I hit the cancel button instead of the OK button. When I was passed on to the Finder, the second login dialogue came up again. I typed in the password this time and checked the checkbox. When I relogged in, the problem vanished. I only waited this long to let you know to make sure the problem is gone and it is. I wish I would have thought of selecting the cancel button before. Sometimes solutions are simple like this one.
    Thanks for your help.

  • Why does Fireworks CS5 keep resizing images when I paste them?

    I am having a problem in Fireworks CS5 where images that are copied and then pasted into a new document automatically re-size and become either very tiny or very large.
    I have taken some screenshots to show this more clearly: (this website only allows me to upload images of 450 pixels across so they are not too clear)
    Image 1: I have taken a large image and reduced its size to 100x100 pixels (highlighted in red).
    Image 2: I have created a new document which is 100x100 pixels in size.
    Image 3: I have copied the image from Image 1 (control + C) and then pasted it into Image 2 (control + V). The image was 100x100 and the new image was 100x100 yet when I paste the image it suddenly becomes 313x313 in size and is too large for the new image. Sometimes it becomes tiny when pasted and is too small for the document.
    Can anyone help with this matter? Perhaps I am missing something obvious, but I have tried searching for solutions and tried a range of methods (different kinds of copy and paste etc), but nothing seems to help. Please let me know what I am missing!
    Thank you for your help! As I said I am using Fireworks CS5. I am using Windows 7. If there is anything else you want to know just let me know.

    I don't know what could be causing the copy/paste resizing issue, but here are a couple of ideas that may help with your workflow:
    You can create a new document for animation by choosing File > Open..., selecting multiple images, and clicking the "Open as Animation" option. This will place each image file into its own State.
    Consider using commands from the States panel fly-out menu—e.g., Duplicate State, Copy to States, etc.—to move objects from one state to another.
    Other commands to copy objects within Fireworks include Edit > Duplicate and Edit > Clone. These do not involve the clipboard and may sidestep the resizing problem.
    Sometimes with bitmaps, I like to convert them to symbols, as it allows me to resize the bitmap freely without losing the original resolution. (This might introduce extra steps, but it could allow you to correct the image size after it's been pasted incorrectly.)
    It's a longshot, but I wonder if it would help to empty the clipboard contents once in a while, to clear out old data.

  • Why does my iPhone randomly resize images?

    Suddenly I'll have a string of photos that are only 640x480. The only thing I've down is download all of my images via Image Capture but it's random and does not resize all of them. Then I try to redownload them only to find they are small on my iphone too. I only use the apple camera to take these photos and they have not been sent, edited, or opened with any other app.
    I have an iPhone 4s but this has happened on my older phones as well.

    It could be that someone is using FaceTime to call you!  Open the phone application, click on "Recents" on the bottom, and see if that's the case.

  • Why does it login to another database spontanously?

    I got three databases created on the same machine under the single Ora9i.
    And when I do below, it goes as you see.
    And my question is, why it login me to PLM when I do 'connect /as sysdba'? I would expect to login GTP as well.
    is it normal or it is due to wrong configuration?
    Any opinions are welcomed!
    C:\Documents and Settings\e501967>sqlplus system/[email protected]
    SQL*Plus: Release 9.2.0.1.0 - Production on Thu Sep 24 11:49:03 2009
    Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.
    Connected to:
    Oracle9i Release 9.2.0.1.0 - Production
    JServer Release 9.2.0.1.0 - Production
    SQL> l
    SP2-0223: No lines in SQL buffer.
    SQL> select name from v$database;
    NAME
    GTP
    SQL> disconnect
    Disconnected from Oracle9i Release 9.2.0.1.0 - Production
    JServer Release 9.2.0.1.0 - Production
    SQL> connect /as sysdba
    Connected.
    SQL> l
      1* select name from v$database
    SQL> /
    NAME
    PLM
    SQL> disconnect
    Disconnected from Oracle9i Release 9.2.0.1.0 - Production
    JServer Release 9.2.0.1.0 - Production
    SQL> connect /@GTP.CORP.STATESTR.COM as sysdba
    Connected.
    SQL> l
      1* select name from v$database
    SQL> /
    NAME
    GTP
    SQL>

    Hi,
    connect /as sysdbaDid you meant that if you use above command to connect to database you always login to PLM and not GTP.
    If yes then its because your ORACLE_SID is set to PLM
    You can get as well as set the value of ORACLE_SID using
    set ORACLE_SID
    set ORACLE_SID=GTPIf this is not what you intend to meant, then can you please explain your query once again.
    Regards
    Anurag Tibrewal

  • Why does the program panel fail to match magnification of source panel?

    The magnification and resolution settings for both program & source panels are identical. However, the magnification on the program panel is much higher than the source. The rendered video, of course, is produced with the higher magnification thereby blocking out  a substantial % of the desired frame. What can I do to match the magnification of the source panel to the program panel? Thanks for your input in this regard!

    It sounds like your Sequence setting
    does not match your footage.
    Try this:
    Or, right-click a media file and select 'New Sequence From Clip".
    How do I choose the right sequence settings?
    http://www.video2brain.com/en/lessons/how-do-i-choose-the-right-sequence-settings

  • Why does Bridge Metadata Panel look like this...?

    I just updated to Photoshop CS6 from CS5.1 and trying to iron out a few issues. One is this...
    In Bridge CS 6 my Metadata Panel items are truncated for some reason. There is plenty of room in the panel width, so...? I have even pulled the width out further than shown below. There are no problems with the other panels.
    Below are pics of the same panel in my install of CS 6 and then the same panel in my installation of CS 5.1.  Thanks.
         CS 6                                                                                                CS 5.1

    You've made the headings column too narrow.
    Hover your cursor over the space between the 'e' in Fil...e and _IGP1220.DNG.  It will change to a resizing indicator, indicating there's a hidden division there.  Drag it to the right to make enough room for the headings.
    Here's what I see, by the way, when I reduce the UI color to the blackest I can get it in Bridge CS6...
    -Noel

  • Why does the reference panel not pop up in Dreamweaver CS6? Help!?

    Every time I go to Window --> Results  nothing pops up in Dreamweaver CS6 (non cloud member version). Is this not an option for those with a hard copy of the software???

    It's there.  On Windows, click F7.  If you don't see the Results Panel immediately, you may need to resize or close your Properties Panel tab group to make room for it.  See screenshot.
    Nancy O.

  • Why does ibooks author automatically resize all images of a gallery?

    The point here is, I have more than one graphic files (not pictures taken by a camera) to put into one gallery widget of an iBooks Author document. Unfortunately, not all figures have the same height/width aspect ratio. If I put them together in the gallery, some of them have cropped widths others have cropped heights. Impossible to losslessly fit all into the same gallery. If I scale alle figures to the same width, the result is acceptable for the figure with the highest heigth, all other figures are cropped again.
    Well in a first time, I was not that much concerned, but the iBooks Author Quality check refused to publish such eBooks, where some picutes appear cropped in the small view (not in the full-screen view).
    Now, why is the iBA software automatically sizing all images of a gallery w.r.t. the center of an image? It would be of much more help, to leave some white background boarders on images of un-equal height, as long as the width of all images is exactly the same. The crop-pan function would then be useful to individually place a smaller-than-the-rest image in that frame of its larger precedecor image.
    Can this autosize function be turned off? Am I really forced to paste smaller images into a white image of the maximum height/width of the galery's largest image?

    If you have differently shaped (height/width) images that you want to place in one gallery....
    The first image you place will determine the shape (max height and width) of your gallery mask, so choose it wisely.
    Before you add each image to the gallery go to photoshop and:
    1. Size the IMAGE to be at the max height OR width of your gallery mask -- do this if you want at least one dimension (height or width) to fit all the way across or up and down in the gallery mask.
    2. Size the CANVAS to the same height and width of your first image (the size of your gallery mask).
    I hope this makes sense and is helpful. Yes, it's ridiculous, but it's the only way I found to make images of different dimensions fit in a gallery.

  • Why does the layers panel in ID CS6 affect or override Articles Panel and reading order?

    In InDesign CS6 we arrange the order of content using the Articles panel and we expect that the reading order of the exported PDF will match what's in the Articles panel. In reality, we come to find that the layers panel in InDesign adversely affects the reading order. It completely ignores the articles panel which is counter to the purpose. Anyway, I've found that the reading order in the pdf ends up being the reverse order of what is in the InDesign documents layers panel. In terms of Accessibility, this is a problem and requires manual re-organization of the reading order. The Articles panel in InDesign was supposed to alleviate this process. Any ideas?

    In InDesign CS6 we arrange the order of content using the Articles panel and we expect that the reading order of the exported PDF will match what's in the Articles panel. In reality, we come to find that the layers panel in InDesign adversely affects the reading order. It completely ignores the articles panel which is counter to the purpose. Anyway, I've found that the reading order in the pdf ends up being the reverse order of what is in the InDesign documents layers panel. In terms of Accessibility, this is a problem and requires manual re-organization of the reading order. The Articles panel in InDesign was supposed to alleviate this process. Any ideas?

  • Why does my login screen act funny

    When I turn on my macbook pro it goes to the log on screen. When I getto the logon screen it is blank but when i move my mouse around it erases the blank screen like on some paint program. I am running Lion.

    OS X Lion: Login window partially appears, cursor movement redraws screen

  • Why does my Control Panel disappear?

    I have saved workspaces, and have tried preset workspaces – the Essential one makes my control panel disappear as if I have a second monitor. If I try another workspace, such as Layout, the control panel returns but some of the panels won't extend open. It's really strange. I've done all the basics - restarted, checked for updates, open and close tools, resetting workspaces. I think it's a glitch in the program. I've attached two screen shots. You will see in the first one the blacked out, smaller control panel (which I can't move), and in the second, the Brush Panel is nowhere to be seen even though it is checked (happens with anything I check). This is greatly interfering with my workflow so any help or a patch is much appreciated! Also, hitting (F) to change the view of the file window doesn't change anything for the control panels.
    Thanks!
    -Diana Terry

    It sounds like the app may be crashing. Here are some things to try.
    Go to Settings>Safari>Clear History, Cookies and Cache. Restart the iPad. Restart the iPad by holding down on the sleep button until the red slider appears and then slide to shut off. To power up hold the sleep button until the Apple logo appears and let go of the button
    Reset the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider - let go of the buttons.
    Quit Safari and restart. Go to the home screen first by tapping the home button. Quit Safari by double tapping the home button and the task bar will appear with all of you recent/open apps displayed at the bottom. Tap and hold down on the Safari app icon until it begins to wiggle. Tap the minus sign in the upper left corner to close the app. Restart the iPad. Restart the iPad by holding down on the sleep button until the red slider appears and then slide to shut off. To power up hold the sleep button until the Apple logo appears and let go of the button.

  • Why does iMessage open when I"m chatting in google?

    Why does the login to iMessage window open up when I'm chatting through gmail?

    Hi,
    By default the first thing the Messages app asks you to do is enter an Apple ID to use for the iMessages account.
    You can ignore this and use the set up to add other accounts (or use the System Preferences > Internet Accounts to enable them).
    If it is not already, I would go to Messages Menu > Preferences > Accounts and in the iMessages account untick the box for "Enable this Account" even if it does not have an Apple ID.
    9:22 pm      Monday; February 3, 2014
      iMac 2.5Ghz 5i 2011 (Mavericks 10.9)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
     Couple of iPhones and an iPad

Maybe you are looking for

  • Macbook won't turn on, won't charge either (no green/amber light)

    So I was cleaning my keyboard today (just with water and a towel) and after cleaning, the screen shut off but my macbook was still turned on (could hear the fans). It wouldn't respond to anything and I tried a hard shut down but this did not work eit

  • Can no longer use mic after ios 4

    Hello. Yesterday I tried using the earphones with mic that came with my iPod for the first time since upgrading to ios 4. The earphones still work, but the mic doesn't, if I hold down the home button it doesn't bring up voice control anymore, and if

  • I have a huge iphoto library and an HP simple save hard drive which has been mac formated.

    the discssion board states to close iphoto, go to folders, locate, click and drag library to new location (ie-my HP simple save which has been formated to mac)  When I look in my libraries, I have several for libraries, including some that say 6.  Wh

  • Network in Finder doesn't display available servers

    I have not seen this on the boards (exactly). When I choose the network icon in a finder window instead of seeing the other computers on the network, I see three folders: 1. Users, 2. Applications, 3. Library nothing is in any of them. I am on mac G5

  • FAQ Builder and Survey Builder Portlet

    I am currently using Oracle Portal Version: 9.0.2.2 and am not able to find the FAQ Builder and Survey Builder Portlet. Is this not shipped with this version? How can I go about adding these to my pages?