Problem refreshing when using GridBagLayout for a JPanel

Well, i have a JPanel which use the GridBagLayout to layout the components. If i remove a component everything it's ok, i mean it disappear from the panel, but the appears when i want to add a component. It doesn't show me the new component. Any sugestion?

Here is the all code:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Test {
     private JFrame f;
     private final JPanel detalii = new JPanel();
     private String[] sir1 = { "1820620160027", "Bradescu", "M", "Marius-Catalin", "Rovine bl. I29", "0745035150" };
     private String[] sir2 = { "1820620160031", "Bercea", "C", "Florin Bogdan", "Brazda bl. I29", "0745035150" };
     public Test(){
          f = new JFrame( "Test" );
          detalii.setLayout( new GridBagLayout() );
          detalii.setPreferredSize( new Dimension( 450, 400) );
          creazaDetaliiElev( sir2 );
          f.addMouseListener( new MouseAdapter(){
               public void mouseClicked( MouseEvent evt ){
                    if( evt.getButton() == 1){
                         creazaDetaliiElev( sir1 );
                         //detalii.invalidate();
                         f.repaint();
                    } else {
                         creazaDetaliiElev( sir2 );
                         //detalii.invalidate();
                         f.repaint();
          f.getContentPane().add( detalii );
          f.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
          f.pack();
          f.setVisible( true );
     protected void creazaDetaliiElev( String[] elev ){
          if( detalii.getComponentCount() == 0 ){                    
               GridBagConstraints c = new GridBagConstraints();
               c.fill = GridBagConstraints.VERTICAL;
               JLabel lblID = new JLabel( "CNP:");
               c.anchor = GridBagConstraints.WEST;
               c.insets = new Insets( 5, 5, 5, 5 );
               c.gridx = 0;
               c.gridy = 0;
               detalii.add( lblID, c );
               JLabel lblNume = new JLabel( "Nume:" );
               c.gridx = 0;
               c.gridy = 1;
               detalii.add( lblNume, c );
               JLabel lblInitiala = new JLabel( "Initiala:" );
               c.gridx = 0;
               c.gridy = 2;
               detalii.add( lblInitiala, c );
               JLabel lblPrenume = new JLabel( "Prenume:" );
               c.gridx = 0;
               c.gridy = 3;
               detalii.add( lblPrenume, c );
               JLabel lblAdresa = new JLabel( "Adresa" );
               c.gridx = 0;
               c.gridy = 4;
               detalii.add( lblAdresa, c );
               JLabel lblTelefon = new JLabel( "Telefon:" );
               c.gridx = 0;
               c.gridy = 5;
               detalii.add( lblTelefon, c );
               JTextField txtID = new JTextField( String.valueOf( elev[ 0 ] ) );
               txtID.setBackground( Color.WHITE );
               txtID.setHorizontalAlignment( JTextField.TRAILING );
               txtID.setEditable( false );
               c.gridx = 1;
               c.gridy = 0;
               detalii.add( txtID, c );
               JTextField txtNume = new JTextField( elev[ 1 ] );
               txtNume.setBackground( Color.WHITE );
               txtNume.setHorizontalAlignment( JTextField.LEADING );
               txtNume.setEditable( false );
               c.gridx = 1;
               c.gridy = 1;
               detalii.add( txtNume, c );
               JTextField txtInitiala = new JTextField( elev[ 2 ] );
               txtInitiala.setBackground( Color.WHITE );
               txtInitiala.setHorizontalAlignment( JTextField.CENTER );
               txtInitiala.setEditable( false );
               c.gridx = 1;
               c.gridy = 2;
               detalii.add( txtInitiala, c );
               JTextField txtPrenume = new JTextField( elev[ 3 ] );
               txtPrenume.setBackground( Color.WHITE );
               txtPrenume.setHorizontalAlignment( JTextField.LEADING );
               txtPrenume.setEditable( false );
               c.gridx = 1;
               c.gridy = 3;
               detalii.add( txtPrenume, c );
               JTextField txtAdresa = new JTextField( elev[ 4 ] );
               txtAdresa.setBackground( Color.WHITE );
               txtAdresa.setHorizontalAlignment( JTextField.LEADING );
               txtAdresa.setEditable( false );
               c.gridx = 1;
               c.gridy = 4;
               detalii.add( txtAdresa, c );
               JTextField txtTelefon = new JTextField( elev[ 5 ] );
               txtTelefon.setBackground( Color.WHITE );
               txtTelefon.setHorizontalAlignment( JTextField.TRAILING );
               txtTelefon.setEditable( false );
               c.gridx = 1;
               c.gridy = 5;
               detalii.add( txtTelefon, c );
          } else {
               detalii.removeAll();
     public static void main( String[] args ){
          new Test();
, but nothing, as you see i use invalidate() too.

Similar Messages

  • I am trying to cut and paste from a program, IEP DIRECT, and normally on my PC I have no problems; however, when using my MAC the formatting gets all mixed up

    i am trying to cut and paste from a program, IEP DIRECT, and normally on my PC I have no problems; however, when using my MAC the formatting gets all mixed up

    If you refer to this
    https://www.iepdirect.com/iepdotnet/hub/index.html
    then they have an issue with mac version.
    At a first glance, their website is optimized for Windows only, it displays badly in Safari, perhaps it would be better in Firefox or other browser.

  • Problems occured when using BAPI_INSPECTIONPLAN_CREATE

    hi,guys!
    please help!
    problems occurred when using BAPI_INSPECTIONPLAN_CREATE to create inspection plans.
    problems as belows:
    This inspection point completion is not possible for task list type Q;
    Consistency check not successful when creating operation;
    Inspection characteristic cannot be uniquely assigned to one operation.

    Hi Alex,
    There must be some data issue.
    Just try to create the Inspection plan without BAPI i.e. using the transaction for the data you have and see whats happening.
    Regards,
    Atish

  • HT4864 My outgoing email as stopped working when using Outlook for mac 2011. Any suggestions?

    My outgoing email as stopped working when using Outlook for mac 2011. I have deleted and reinstalled the account twice. I have 11 gig free on my iCloud account. The outgoing server is set at smtp.mail.me.com using port 587. If I was able to reinstall the account, I am positive I have the correct password. I can log into my iCloud accout using the same credentials.
    Any suggestions?

    I called Microsoft to fix my problem...for those maybe having the same issue, I was told by the Tech to use this outgoing server setting - p06-smtp.mail.me.com
    All is working fine since doing so.

  • Mac user, PS CC 2014 latest version. When using "Save for Web" I bring my 900 x600px @72 ppi in to SFW and the output becomes 300ppi. The only way it stays at 72ppi is if I check "none" for metadata. I know to should not matter much, but I would prefer to

    Mac user, PS CC 2014 latest version. When using "Save for Web" I bring my 900 x600px @72 ppi in to SFW and the output becomes 300ppi. The only way it stays at 72ppi is if I check "none" for metadata. I know to should not matter much, but I would prefer to keep all my web jpgs @ 72ppi. Any solutions?

    It opens up as 900x600 @300ppi
    Here's a screenshot-

  • How stop PS6 from removing the DPI value from an image when using "save for the web"?

    How stop PS6 from removing the DPI-value from an image when using "save for the web"?
    Example:
    - Open a tif image, that contains a dpi value (resolution).
    - Use the splice tool in PS6.
    - Export the slices with "Save for web", as gif-files.
    Then the dpi value is removed, the gif files has no dpi value (it's empty).
    How can we stop PS6 from removing the dpi value when using "save for web"?
    OR:
    When using the slice tool, how can we save the sliced pieces without PS removing the dpi value?

    you can make your art go a little bit over the bounds. or you can make sure your artboart and art edges align to pixels

  • Pages-when using template for envelopes can you import names/address from address book

    When using templates for envelopes can you import names/address from the address book?

    Drag the VCard from Address Book onto the open envelope template.
    If you want mutiple addresses make a Group of those in Address Book and drag the Group icon onto the Pages template.
    Peter

  • Is it possible to ignore "Rigid relationships between attributes cannot be changed" when using ProcessUpdate for Dimension?

    As per the title is it possible to ignore "Rigid relationships between attributes cannot be changed" when using ProcessUpdate for Dimension?
    We have a case where very rarely an item might have been miscategorised so the brand is manually changed.  We want this dimension to be rigid to speed up ProcessUpdate.
    We do a ProcessFull each night, so it will get corrected then, but during the hourly updates we would just like to ignore this error if possible?

    Hello,
    The rigid relationship should be defined when the members will not change over time. Here are some threads regarding rigid relationship for your reference, please see:
    Processing OLAP Cube: http://social.technet.microsoft.com/Forums/sqlserver/en-US/17a55593-9543-404e-a579-0a011965585d/processing-olap-cube?forum=sqlanalysisservices
    Flexible and rigid relationship: http://social.msdn.microsoft.com/Forums/sqlserver/en-US/2d8f5443-065d-4485-9385-6f0b5fa417da/flexible-and-rigid-relationship?forum=sqlanalysisservices
    If you have any feedback on our support, please click
    here.
    Regards,
    Elvis Long
    TechNet Community Support

  • What is a valid location for autorecovery files when using Word for MAC?

    What is a valid location for autorecovery files when using Word for MAC?

    Microsoft Word for Mac support forums is probably a better place to ask.

  • When using imovie for Ipad, how can I fast forward a project to cut the length down?

    When using imovie for Ipad, how can I fast forward a project to cut the length down to fit under the 15 minutes required for Youtube? My current project is 23 minutes, and need to cut it down below 15 minutes. I was hoping to speed up the video. The content would actually be better viewed in at a faster speed anyhow.

    Jon,
    It sounds like you did, just as you should, Save_As and Delete everything that is unwanted. If you did the Deletion from the Timeline, there should be nothing from the old Project, that should be included. A DVD is Transcoded and burned from the Timeline. If the Assets are not there, they will not included in the DVD, even if you did not Delete anything from the Project Panel.
    Tell us about the Clips now on your Timeline. Also, can you check the Timeline, by hitting the \ (Backslash key), and looking near the end of the Timeline. Do you have any "orphans" out there? Check all Video Tracks, even if you have to scroll to see them all. Does the Duration of the Timeline (viewed in the Program Monitor) match what you think that it should? If not, then you most likely have orphans, that you missed Deleteing.
    Good luck,
    Hunt

  • Is there anyway to stop the auto-refresh when using HsGetValue?

    Hi there
    I am just wondering if there is a way to stop the automatic refresh when opening a workbook that has HsGetValue functions? The issue I am having is that when you create a report in Smart View using the HsGetValue function, save it down, disconnect from Smart View then open it up again, it automatically tries to refresh the data. If you do not type your login, it just changes to #NEED REFRESH and you cant see the data anymore. This only happens when you have Smart View installed, if you are on a vanilla computer you can see the numbers no problems.
    The reason we dont want it to refresh is that we want to be able to view data at a point in time, instead of always refreshing to the latest data.
    I know that I can stop the refresh by changing Excel to Manual Calculation, instead of auto-calculation on formulas, but this isnt a viable solution as users arent used to manually pressing the Calculate button in Excel for their non Hyperion work.
    We are using 11.1.1.3 Planning and Essbase.
    Thanks!

    See this post Smart view first refresh
    Aside from turning auto-calculation off, you would need to copy the cells and paste them as values to get a static worksheet. This will eliminate any future refreshes.

  • Different screens shown when using BDC for Transaction XK03

    Hello Forum,
    Please provide a soultion for the below problem .
    When i open transaction XK03 (with 4 check boxes of general Data ticked )it is ok.
    When i call transaction XK03 from my program (by sending the check box parameters ticked)- the scren shown is different .
    (I used BDC to set the checkboxes)
    Sample code for testing that i write to call XK03 is -
    DATA: ls_bdc_comp  TYPE bdcdata,                   "workarea for BDC recording of XK03
            lt_bdc_comp  TYPE STANDARD TABLE OF bdcdata. "table for BDC recording of MK03
      CLEAR: ls_bdc_comp .
      REFRESH lt_bdc_comp.
      CLEAR ls_bdc_comp.
      ls_bdc_comp-program = 'SAPMF02K'.
      ls_bdc_comp-dynpro = '0101'.
      ls_bdc_comp-dynbegin = wc_x.
      APPEND ls_bdc_comp TO lt_bdc_comp.
      CLEAR ls_bdc_comp.
      ls_bdc_comp-fnam = 'BDC_OKCODE'.
      ls_bdc_comp-fval = '/00'.
      APPEND ls_bdc_comp TO lt_bdc_comp.
      CLEAR ls_bdc_comp.
      ls_bdc_comp-fnam = 'RF02K-LIFNR'.
      ls_bdc_comp-fval = 'S000819001'. "Vendor
      APPEND ls_bdc_comp TO lt_bdc_comp.
      CLEAR ls_bdc_comp.
      ls_bdc_comp-fnam = 'RF02K-D0110'.  "Address
      ls_bdc_comp-fval = 'X'.
      APPEND ls_bdc_comp TO lt_bdc_comp.
      CLEAR ls_bdc_comp.
      ls_bdc_comp-fnam = 'RF02K-D0120'. "Control
      ls_bdc_comp-fval = 'X'.
      APPEND ls_bdc_comp TO lt_bdc_comp.
      CLEAR ls_bdc_comp.
      ls_bdc_comp-fnam = 'RF02K-D0130'. "Payment transactions
      ls_bdc_comp-fval = 'X'.
      APPEND ls_bdc_comp TO lt_bdc_comp.
      CLEAR ls_bdc_comp.
      ls_bdc_comp-fnam = 'WRF02K-D0380'. "contact person
      ls_bdc_comp-fval = 'X'.
      APPEND ls_bdc_comp TO lt_bdc_comp.
      CALL TRANSACTION 'XK03'
           USING lt_bdc_comp.
           MODE 'E'.
    Regards
    Lovleen
    Moderator Message: Please use proper subject lines while posting your questions.
    Edited by: Suhas Saha on Jul 22, 2011 3:48 PM

    Hi,
    You can try with below code,
    DATA: ls_bdc_comp TYPE bdcdata, "workarea for BDC recording of XK03
    lt_bdc_comp TYPE STANDARD TABLE OF bdcdata. "table for BDC recording of MK03
    CLEAR: ls_bdc_comp .
    REFRESH lt_bdc_comp.
    CLEAR ls_bdc_comp.
    ls_bdc_comp-program = 'SAPMF02K'.
    ls_bdc_comp-dynpro = '0101'.
    ls_bdc_comp-dynbegin = 'X'.
    APPEND ls_bdc_comp TO lt_bdc_comp.
    CLEAR ls_bdc_comp.
    ls_bdc_comp-fnam = 'BDC_OKCODE'.
    ls_bdc_comp-fval = '/00'.
    APPEND ls_bdc_comp TO lt_bdc_comp.
    CLEAR ls_bdc_comp.
    ls_bdc_comp-fnam = 'RF02K-LIFNR'.
    ls_bdc_comp-fval = 'S000819001'. "Vendor
    APPEND ls_bdc_comp TO lt_bdc_comp.
    CLEAR ls_bdc_comp.
    ls_bdc_comp-fnam = 'RF02K-D0110'. "Address
    ls_bdc_comp-fval = 'X'.
    APPEND ls_bdc_comp TO lt_bdc_comp.
    CLEAR ls_bdc_comp.
    ls_bdc_comp-fnam = 'RF02K-D0120'. "Control
    ls_bdc_comp-fval = 'X'.
    APPEND ls_bdc_comp TO lt_bdc_comp.
    CLEAR ls_bdc_comp.
    ls_bdc_comp-fnam = 'RF02K-D0130'. "Payment transactions
    ls_bdc_comp-fval = 'X'.
    APPEND ls_bdc_comp TO lt_bdc_comp.
    CLEAR ls_bdc_comp.
    ls_bdc_comp-fnam = 'WRF02K-D0380'. "contact person
    ls_bdc_comp-fval = 'X'.
    APPEND ls_bdc_comp TO lt_bdc_comp.
    ls_bdc_comp-fnam = 'USE_ZAV'. "contact person
    ls_bdc_comp-fval = 'X'.
    APPEND ls_bdc_comp TO lt_bdc_comp.
    CALL TRANSACTION 'XK03'
    USING lt_bdc_comp
    MODE 'E'.
    It will also take you to some other screen but up to some extend you will able to see same kind of data.

  • An difficulty when using GridBagLayout.

    Hi everyone!
    Now, I'm in a Java Swing project and I'm get trouble in using GridBagLayout to layout 2 component. I want to put 2 JTextArea in only one line with the width of them is the same(I've used c.weightx=1 and c.fill=GridBagContraints.HORIZONTAL). But when I fill data into one of them, the width of both is not the same. It's ok to use Spring layout to resolve this problem. But I think GridBagLayout is very flexible, so please help me to resolve this problem using GridBagLayout.
    Thanks a lot.

    if you want both textarea to have the same width, then use a GridLayout.
    as for GridBagLayout, i stop using it, and use third party Layout manager...such as FormLayout, GridBagPlusLayout (awsome), TableLayout, etc..
    they are easier to use, more readiable, and as powerful as GridBagLayout

  • No sound when using Airplay for Movies on Apple TV

    For reasons unknow, when I try to stream full length movies (Lion King and Nemo bought from iTunes) from my iPhone or Macbook Pro using Airplay, there is no sound.  When I stream smaller movies, like Boundin' the Pixar Short, there is no problem.
    Side note 1: Why do purchased movies not show up like purchased TV shows on Apple TV?  I feel like I shouldn't have to use Airplay for movies if I don't need to use it for TV shows I buy.
    Side note 2: For some Netflix movies played directly from Apple TV there is no sound.  Other movies work fine and the movies that work or don't work seem to change day to day.
    Thanks for your help.

    Gldsndz wrote:
    Side note 1: Why do purchased movies not show up like purchased TV shows on Apple TV?  I feel like I shouldn't have to use Airplay for movies if I don't need to use it for TV shows I buy.
    Apple has not negotiated the rights to allow this is the assumed reason.
    We can't even play Purchased music or TV Shows from the cloud in UK.

  • Single Vertical Line When Using ADF for Scan or Copy on HP Officejet Pro 8600

    HP Officejet Pro 8600 Premium Printer (CN577A)
    OS: MS 7 64 bit
    When using the ADF for my CN577A HP Officejet Pro 8600 Premium printer, I get a single vertical line on the document that is produced. This occurs when copying or scanning, both in black and white, and in color. If I scan or copy using the glass, I don't get the vertical line.
    I already tried the troubleshooting.  I unplugged the printer, left it without power for several minutes; that didn't correct the problem.  Next, I cleaned the rollers and the glass; I still get the vertical line, but only when using the ADF.
    My firmware version used is current (CLP1CN1150CR).
    What should I check next?
    This question was solved.
    View Solution.

    The ADF uses its own glass area on the scanner bed, it is the narrow (about 1" wide) strip on the left.  Cleaning this area should resolve the issue.  A single small spot would cause the issue you are seeing.
    Bob Headrick,  HP Expert
    I am not an employee of HP, I am a volunteer posting here on my own time.
    If your problem is solved please click the "Accept as Solution" button ------------V
    If my answer was helpful please click the "Thumbs Up" to say "Thank You"--V

Maybe you are looking for

  • PDF's from the Web

    I am having trouble opening some PDF's on the web... My computer has Windows Vista with Acrobat 5 & Adobe Reader 9 installed. Adobe Reader is set as the default program to open PDF's. The following link opens successfully in Adobe Reader http://earth

  • How to retrieve Data from SAP BW to  SQL

    Hi All, i am looking for way to retrieve Data from SAP BW to SQL. Could you please give me some indcations or a document on how to implement it? Thanks in advance Cheers Gilo

  • UME search for users code problem

    Hello All , i am trying to develop an iview that contains a textbox that get a part of  a userName or User display name and search using UME api`s i wrote the following code: public void onSubmit (Event event)throws UMException        IPortalComponen

  • Connet to domino with notessql

    Hi, i've an odbc connection with a lotus notes database, using notessql driver, in a xp. I've oracle 10g and i'd like to recover data from notes with this odbc connection. Usually i use sql loader when i've to get data from external source like excel

  • BAPI or and FM to maintain MatMaster QM view fields

    Hello fellow abapers, I have been developing a program to create and update material masters.  Everything has been going well using FM BAPI_MATERIAL_SAVEDATA until I was asked to maintain the inspection data on th QM view.  I cannot seem to find wher