Problem removing components not a problem of revalidate

ello everybody i'm trying to make a chart made of buttons in which every button press removes the pressed button, adds a TextField saves the string that was entered and than adding it as a label of a new Button instead of the one removed. the problem with the code is when i a button it removes the last button that was added
from the bottom right corner
import javax.swing.JButton;
import java.awt.GridLayout;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JFrame;
public class SudokoChart{
                private JFrame frm;
                private JButton btn;
     private TextField txt;
     private String label = null;
     private static final int DIMENSION = 9;
     private GridLayout chart;
  public class InnerHandler implements ActionListener{
        public void actionPerformed(ActionEvent e){
                if (e.getSource() instanceof JButton) {
                     btn = (JButton)e.getSource();
                                                     frm.list();
                    //chart.removeLayoutComponent(btn);
                    frm.remove(btn);
                    frm.validate();
                    txt  = new TextField();
                     frm.add(txt);
                     frm.pack();
                     frm.setVisible(true);
                     txt.addKeyListener(new KeyListener(){
                          public void keyPressed(KeyEvent e) {
                               if(e.getKeyChar() == KeyEvent.VK_ENTER){
                               label  = txt.getText();
                               txt.setText("");
                               frm.remove(txt);
                               frm.validate();
                               btn.setText(label);
                               frm.add(btn);
                               frm.validate();
                               frm.pack();
                               frm.setVisible(true);
                               public void keyReleased(KeyEvent arg0) {}
                               public void keyTyped(KeyEvent arg0) {}
     public SudokoChart(){
          frm = new JFrame("Sudoko Solver");
          chart = new GridLayout(DIMENSION,DIMENSION);
          frm.setLayout(chart);
     public void launchFrame(){
             boolean cont = true;
       for(int row = 0; row < DIMENSION; row++){
            for(int col = 0; col < DIMENSION; col++){
                 //compare between the action button point to  array button point (not related to
                 //the code)
                 btn = new JButton("Push to Enter");
                 //       butpoint[index] = btn; 
                cont = frm.add(btn).contains(btn.getLocation());
                System.out.println(cont);
                //butpoint[index].setLocation(btn.getLocation());
                // System.out.println(butpoint[index].getLocation());
                 //System.out.println(btn.getLocation());
                 //index++;
                //  butpoint[index] = btn;
                 //System.out.println(myButton.objCnt);
                 //frm.add(btn,chart,myButton.objCnt);
                 frm.pack();
                 frm.setVisible(true);
                 btn.addActionListener(new InnerHandler());                
     public static void main(String args[]){
          SudokoChart sc = new SudokoChart();
          sc.launchFrame();

It's an interesting way to go about this, but I'm not sure that I'd want to do it this way. Anyway, one way to possibly solve this problem is to use a 2D grid of JComponent that holds the JButtons, and then swap out your selected JButton for a JTextField, then remove all the JComponents from the container, and then re-add them using your GridLayout and your 2D array to add the components in the correct order.
Another way to do the same thing is to use a grid of a class that holds a JPanel that uses CardLayout that displays a JButton and on button press swaps this for a JTextField.
There are probably many ways to do what you want, and I'm not saying that either of my suggestions are best.
Edit: by the way, don't mix Swing and AWT components in the same app. Your TextFields should be JTextFields.
Edited by: Encephalopathic on Oct 16, 2009 2:39 PM

Similar Messages

  • Problem removing components from JLayeredPane

    Hi all,
    I have a problem showing and hiding components on a JLayeredPane. It goes Something like this:
    In my application I have a button. When this button is pressed I use getLayeredPane to get the frames layered pane. I then add a JPanel containing a number of labels and buttons onto that layered pane on the Popup layer. The panel displays and funcitons correctly.
    The problem comes when I try to remove the panel from the layered pane. The panel does not dissappear and I am no longer able to click on anything else in the frame!
    If anyone has any ideas how to get around this or what the problem might be I'd be very greatful to hear it. Sample code follows:
          * Called when the button on the frame is pressed:
          * @param e
         public void actionPerformed(ActionEvent e)
                    JLayeredPane mLayredPane = getLayeredPane();
              int x = 0, y = 0;
              Container c = this;
              while (true)
                   c = c.getParent();
                   if (c != null)
                        x += c.getLocation().x;
                        y += c.getLocation().y;
                        if (c instanceof JRootPane)
                             break;
                   else
                        break;
              mPanel.setBounds(x, y, 235, 200);
              mLayredPane.add(mPanel, JLayeredPane.POPUP_LAYER);
    //And when a listener fires from the panel I use
    mLayredPane.remove(mPanel);
    //To remove it from the layered pane and in theory return the
    //app to the state it was before the panel was displayedThanks again...

    The problem is you only removed it within the program, without actually removing it from the display. If that makes any sense, or whether thats your problem at all.
    If you are only using this line.
    mLayredPane.remove(mPanel);
    I think if you tell it to repaint and revalidate it should work, though i have never used LayeredPane.
    mLayredPane.repaint();
    mLayredPane.revalidate();

  • How do I sync iphone4s to Bluetooth in car, having problems. Did not have problems with iPhone 3G?, How do I sync iphone4s to Bluetooth in car, having problems. Did not have problems with iPhone 3G?

    I am having trouble syncing my new iphone4s to the Bluetooth in my car. The iPhone 3G had no problems? Can anyone assist with this problem? Thanks

    This means you chose to transfer the backup for the other iPhone to your second iPhone the first time you connected the second iPhone to iTunes on the computer being used to sync with the other iPhone.
    This did exactly as you selected. Photos/videos in the Camera Roll are not touched when syncing and are not touched the first time a new iPhone is connected to iTunes and choosing to set up the iPhone as a new iPhone. When choosing to transfer the backup for another iPhone to the new iPhone, the Camera Roll contents for the other iPhone replace the Camera Roll contents on the new iPhone.
    Unless you imported the photos from the Camera Roll as designed and intended, the photos are gone.

  • E66 problem - wont call (not slider problem)

    For three days now i have a new nokia e66, at times it wont initiate a call, no matter what i do and where, both "log" and "contacts" are unresponsive to either pushing the call button or choosing call from the menu. A restart helps.
    Any solutions?

    I think a wait for a software update would be a better solution than to take it to the shop. Repair shop will do squat. I've had exactly the same problem with the E65, solving it with regular software updates, since it was re-occuring every few months. Until the update is published, re-start is the interim solution

  • Menu Bar hangs in FF3.6.8 for Linux Mint 8. Delays of 1 minute plus after clicking on any element. Right click completely disfunctional. This happens in Safe Mode too. Even a complete remove/reinstall of FF did not cure problem.

    This is a persistent repeat problem. I had this problem a week ago. A Linux savvy friend could not solve it, so we deleted and removed FF. That was a drastic solution, but solved the problem.
    I had Ad Block and No Script add ons. I thought No Script might be the problem. Problem remained after disabling NS. I later even removed No Script but that still did not solve the problem.
    Running FF in safe mode from terminal does not stop problem. If I try to right click at all, anywhere on page FF slows to a glacial crawl. It also requires that I force quit.

    This is a persistent repeat problem. I had this problem a week ago. A Linux savvy friend could not solve it, so we deleted and removed FF. That was a drastic solution, but solved the problem.
    I had Ad Block and No Script add ons. I thought No Script might be the problem. Problem remained after disabling NS. I later even removed No Script but that still did not solve the problem.
    Running FF in safe mode from terminal does not stop problem. If I try to right click at all, anywhere on page FF slows to a glacial crawl. It also requires that I force quit.

  • Problem. Does not refresh language change in ADF components

    I have three recource bundles designated to change the language in a user interface.. The problem is that not all elements get refreshed.. Where could be the problem?

    I use af:selectOneChoice component to choose the language. If i choose a language I must click a submit button which instantaneously executes a submit action which reloads the page. Problem is when browsing other pages (after changing the language) not all the elements contain chosen lang. some of them still show previous one.. the only way to cope with it is to log off or restart the application... then everything is ok.. until I change the language actually... Can this be a problem with rendering or smth? Any ideas?

  • Conductor Engine not online problem

    Hi all,
    I've got a problem after I ported my web-workflow application into the
    training environment. It was ok in the development environment. (Both
    environment actually running same platform, which is NT 4 server and Win95
    client)
    After ported to the training environment, all components were able
    compiled. I am able to start the application as well. But when it comes to
    the point where the web interface call to the conductor interface to obtain
    a conductor session, it raised an error message back to the HTML client
    saying that "myengine.myenvironment" is not online. But if I check the
    conductor console, it always shows that "myengine" conductor engine is
    online.
    Throughout many testing, changing the conductor engine server to another NT
    machine did not help edle. Furthemore, no detail error message can be
    captured from the log file. By the way, conductor libraries provide very
    minimal exception class to handle any conductor specific errors.
    By writing some debug code into the conductor interface, it seems that the
    error always occured during the conductor OpenSession method with the
    engine.
    If anyone of you encounter this weird problem before please contact me
    ASAP. Appreciate your reply in advance.
    Regards,
    CP
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/forte>

    CP,
    Yes I have had the problem. The notes below are from working through the
    issue with Forte Tech support...
    > ... ...this > error is symptomatic of having
    > more than one copy of a DLL somewhere in your
    path. As
    > such, I would like for you to do an
    > exhaustive search on all of the disk drives on
    your system
    > for each of the following files:
    >
    > libofcus.dll
    > libwfacc.dll
    > wfclie0.dll
    > libwfcli.dll
    > libwfcus.dll
    > libwfenv.dll
    >
    > If one of these lives in more than one place, that
    is most
    > likely the problem. The only
    > place these should live is in their respective
    userapp
    > directory, and those directories
    > should be specified in your path.
    >
    In our case we had two of the dll's in the winNT\System32 directory. Once
    they were removed we could once again create sessions with the engine.
    Hope this helps.
    Roger
    -----Original Message-----
    From: CP Wong [mailto:[email protected]]
    Sent: Wednesday, July 21, 1999 4:15 AM
    To: [email protected]
    Subject: Conductor Engine not online problem
    Hi all,
    I've got a problem after I ported my web-workflow
    application into the
    training environment. It was ok in the development
    environment. (Both
    environment actually running same platform, which is NT 4
    server and Win95
    client)
    After ported to the training environment, all components
    were able
    compiled. I am able to start the application as well. But
    when it comes to
    the point where the web interface call to the conductor
    interface to obtain
    a conductor session, it raised an error message back to the
    HTML client
    saying that "myengine.myenvironment" is not online. But if I
    check the
    conductor console, it always shows that "myengine" conductor
    engine is
    online.
    Throughout many testing, changing the conductor engine
    server to another NT
    machine did not help edle. Furthemore, no detail error
    message can be
    captured from the log file. By the way, conductor libraries
    provide very
    minimal exception class to handle any conductor specific
    errors.
    By writing some debug code into the conductor interface, it
    seems that the
    error always occured during the conductor OpenSession method
    with the
    engine.
    If anyone of you encounter this weird problem before please
    contact me
    ASAP. Appreciate your reply in advance.
    Regards,
    CP
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive
    <URL:http://pinehurst.sageit.com/listarchive/forte>
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/forte>

  • HT204416 My Safari is no longer working with many sites.  However Chrome and Firefox work fine.  I would like to re-install Safari in an effort to clear up the problem I can not resolve.

    My Safari is no longer working with many sites.  However Chrome and Firefox work fine.  I would like to re-install Safari in an effort to clear up the problem I can not resolve.

    1. From the Safari menu bar, select
              Safari ▹ Preferences... ▹ Extensions
    Turn all extensions OFF and test. If the problem is resolved, turn extensions back ON and then disable them one or a few at a time until you find the culprit.
    2. Select
              Safari ▹ Preferences... ▹ Privacy ▹ Remove All Website Data...
    and confirm. Test.
    3. If the above steps don't resolve the problem, please describe it in more detail.

  • No task bar/menu bar or icons appear when I login into my main account, however this is not a problem with my guest accout

    So was trying to use install disk ! to solve the problem but did not want to reinstall the system because I have not backed up many of my photographs.  Then the disk got stuck and would not come out so when I shut down and restarted I could not get past the gray screen.  Well I was able to solve the problem and remove the disk, and finally it would load to the login screen, although it took some time to get there.  Then when I log in to my main account the desktop will load but the task bar and icons will not its completely blank except for the wall paper.  When I login into my guest account there is not a problem everything is there and functional. I've been researching but have had no luck on a solution.  Thank you for your help.

    Hello,
    Could be many things, we should start with this...
    "Try Disk Utility
    1. Insert the Mac OS X Install disc, then restart the computer while holding the C key.
    2. When your computer finishes starting up from the disc, choose Disk Utility from the Installer menu at top of the screen. (In Mac OS X 10.4 or later, you must select your language first.)
    *Important: Do not click Continue in the first screen of the Installer. If you do, you must restart from the disc again to access Disk Utility.*
    3. Click the First Aid tab.
    4. Select your Mac OS X volume.
    5. Click Repair Disk, (not Repair Permissions). Disk Utility checks and repairs the disk."
    http://docs.info.apple.com/article.html?artnum=106214
    Then try a Safe Boot, (holding Shift key down at bootup), run Disk Utility in Applications>Utilities, then highlight your drive, click on Repair Permissions, reboot when it completes.
    (Safe boot may stay on the gray radian for a long time, let it go, it's trying to repair the Hard Drive & clear caches.)
    If perchance you can't find your install Disc, at least try it from the Safe Boot part onward.

  • Not printing text-only graphics on Canon. Not printer problem-print ok on Brother and another network Apple prints ok on Canon. Believe a computer setting was inadvertently reset. What setting and how do I reset?

    Not printing text only on Canon--grahics print ok.  Not printer problem.  Prints ok on a Brother and another network Apple prints ok on Canon.  Believe a computer setting was inadvertently reset.  What setting and how do I reset?

    Without your printer model numbers, readers can only give you vague general directions.
    System Preferences > Print&Fax > ...
    ... shows a list of all set-up printers.
    If you are having serious problems, it makes sense to "Reset the Printing System" (which also removes all printer set-ups) and add back each printer. It only takes a few minutes.
    Mac OS X 10.6 Help: Resetting the printing system

  • Problem removing Objects from the stage in Flash CS4 (AS3.0)

    I have a problem with this code:
    this.addEventListener(Event.ENTER_FRAME, vanish);
    function vanish(event:Event):void{
         if(character_mc.hitTestObject(vanish_mc)){
              vanish_mc.parent.removeChild(vanish_mc);
    There are two overlapping objects on my stage: character_mc and vanish_mc.
    As soon as i start the scene[Ctrl+Enter] vanish_mc is VISUALLY removed. But the code still sees a collision somehow. How can i Entirely remove the object vanish_mc?
    Thank you for help and advice.

    Ah I think the problem is what my problem not which I proposed, my bad I was trying to keep it simple.
    the remove code in my problem actually looks like this:
    if(character_mc.hitTestObject(this["dollar_mc_"+String(i)])){
         removeChild(this["dollar_mc_"+String(i)]);
    I wanted it to be that way so I could add infinite "dollar_mc_" ' s without writing myself to death with code and or getting confused.
    Imagine it like a game where a character it picking up dollars, which would disappear once they intersect.
    And that exactly is what gives me that argument.
    Do you know a way i could write this code, or do you suggest to leave it that way...because it does run and work im just getting this argument while debugging.
    Thank you for all the help~

  • Problem removing a Exchange Federation Trust

    Hi, 
    I'm having a problem removing a Federation Trust.  I have removed the Organisation Relationship successfully. However when I go to remove the trust by Powershell  I get the following error
    [PS] C:\Windows\system32>remove-federationtrust "Microsoft Federation Gateway"
    Can't remove federation trust "Microsoft Federation Gateway". It's in use by the following organization(s): CN=Federation,CN=XXXXXX,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=XXXXX,DC=local
        + CategoryInfo          : InvalidOperation: (Microsoft Federation Gateway:ADObjectId) [Remove-FederationTrust], Or
       gsStillUsingThisTrustException
        + FullyQualifiedErrorId : A17E4A11,Microsoft.Exchange.Management.SystemConfigurationTasks.RemoveFederationTrusts
    I cant seem to make other changes to it either, I cant add a domain, remove domain.  I have seen references to delete the object in the Schema but dont really want to do that unless I know it wont cause other problems as I need to recreate this.
    Ian

    There are few things you need to make sure before you remove the federation, like permissions, TXT records etc.
    http://technet.microsoft.com/en-us/library/jj657500(v=exchg.150).aspx
    http://technet.microsoft.com/en-us/library/dd297972(v=exchg.141).aspx
    http://www.c7solutions.com/2012/03/fix-federation-trust-issues-after-html
    Cheers,
    Gulab Prasad
    Technology Consultant
    Blog:
    http://www.exchangeranger.com    Twitter:
      LinkedIn:
       Check out CodeTwo’s tools for Exchange admins
    Note: Posts are provided “AS IS” without warranty of any kind, either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.

  • Problem removing files with CVS (JDeveloper 10.1.3 Preview)

    Hello,
    I've got a problem removing files from CVS :
    - I right-click on the file I want to remove -> Versioning -> Remove
    - The file is removed from local directory, and it appears in "Pending changes" view, on "Outgoing" tab. Its status is "scheduled for removal".
    - When I commit the file in the "Pending Changes" view, and click OK, then nothing happens. The file stay with "scheduled for removal" status, and it is not deleted on CVS server.
    I tried to commit the package or the project, but it's the same thing.
    Files additions and modifications work correctly.
    I'm using JDeveloper 10.1.3 Preview version.
    Is this a bug ? Or do I do something wrong ? Is there an other way to solve my problem ?
    Thanks.

    Here is the message displayed in the log window when I remove file (in Versioning menu) :
    C:\J2EE\Projets\budgetapptest\src\test\swm>
    $ <internal cvs client> remove -l Test_suppr_1.java
    cvs remove: scheduling `Test_suppr_1.java' for removal
    cvs remove: use 'cvs commit' to remove this file permanently
    Here is the message displayed in the log window when I COMMIT the "scheduled for removal" file :
    C:\J2EE\Projets\budgetapptest\src\test\swm>
    $ <internal cvs client> commit -F C:\DOCUME~1\19363~1.WIN\LOCALS~1\Temp\.jdevcvs_cmt22356.tmp Test_suppr_1.java
    cvs commit: Examining .
    Thanks.
    Message was edited by:
    user444728

  • Problem removing focused object from a table

    Hi.
    I have a problem removing a component that is focused from a table. The
    whole row is removed except a single component (JSpinner) in one row.
    My table has three columns, the first two are String fields
    (not editable) and the last is a JSpinner. Since there is no
    Default cell renderer or cell editor for JSpinner I had to
    create them.
    So, if no element of the row is focused then calling the function:
    public void clearTable() {
    setVisible(false);
    dataVector.removeAllElements(); // clear data vector
    setVisible(true);
    works just fine
    but if a spinner in a row is focused them that spinner is left alone "floating" on an otherwise empty table.
    Questions:
    1) Any one has an ideia of what might be the problem?
    2) Do I have to play with Focus to solve this? (hate the idea,
    since always been told to avoid messing with focus, because
    of the problems it normally brings)
    Thanks in advance for the help,
    Rgds,
    Jorge

    The problem is that you need to properly stop the editing operation first.if( myTable.isEditing() ) {
        // If you want to throw away any edits use...
        myTable.getCellEditor().cancelCellEditing();
        // If you want to apply any edits, then end use...
        myTable.getCellEditor().stopCellEditing();

  • Problem removing Listener Service in Clusterware 11g

    It appears that I already have a listener service as shown below, and I am having problem removing this service so that I can create another. I know that I can just add a new listener service for each node, though if anyone would share some insight on how I can remove this listener service ofr Oracle 11g Clusterware with two node cluster, I would appreciate your insight. Thanks
    rac1.respecti.com>./crs_resources.sh
    HA Resource Target State
    ora.rac1.gsd ONLINE ONLINE on rac1
    ora.rac1.ons ONLINE ONLINE on rac1
    ora.rac1.rac1.lsnr ONLINE ONLINE on rac1
    ora.rac1.vip ONLINE ONLINE on rac1
    ora.rac2.gsd ONLINE ONLINE on rac2
    ora.rac2.ons ONLINE ONLINE on rac2
    ora.rac2.rac2.lsnr ONLINE ONLINE on rac2
    ora.rac2.vip ONLINE ONLINE on rac2
    rac1.respecti.com>srvctl remove listener -n rac1 -l rac1
    PRKO-2203 : Listener is running on node: rac1
    rac1.respecti.com>srvctl stop listener -n rac1
    CRS-0210: Could not find resource 'ora.rac1.LISTENER_RAC1.lsnr'.
    rac1.respecti.com>

    Hi, Is there any tnslsnr process running on the node. To understand the problem better, enable the debug trace for the .lsnr resource. You can enable trace by executing the following command as root.
    crsctl debug log res "ora.rac1.LISTENER_RAC1.lsnr:5"
    crsctl debug log crs "CRSRTI:1,CRSCOMM:2,OCRSRV:4"
    Try to stop the listener.
    Examine the log files under CRS_HOME/log/$HOST/crsd/* and CRS_HOME/log/$HOST/racg/*
    Thanks & Regards
    -Harish Kalra

Maybe you are looking for

  • How can i tell if my iphone 4 has been hacked into?

    Here is the situation.....a friend of mine is in a bad marriage. She found out her husband bugged her laptop and her phone and is finding out all of her conversations. The other day, we were all at a buffet restaurant and he was sitting at the table

  • Getting Error while using ebMS

    Hi , I am getting the below exception while sending a message using ebMS. Transport error: [IPT_HttpSendError] HTTP encounters send error :405 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <html dir=ltr> <head> <style> a:link               

  • Volume keyboard shortcut not working (since upgrade to Snow Leopard)

    The following keyboard shortcut commands, when I have upgraded to OS 10.6 a couple of months ago, have stopped working: Command-Up Arrow Command-Down Arrow (They control the volume of the iTunes application itself) Apparently they still exist accordi

  • Add sales view in Material number

    Hi, We have a material, which don't have Sales View. How can we add sales view in it. But this should be done for only 1 Material. because through oms2 transaction, we can extend according to material type.. Plz. guide...

  • SSRS version 8 bug?

    I am trying to create a vertical bar chart. When specify the horizontal axis properties Axis Option to be Scalar (X axis is by dates), then a single bar spans over three dates. I can working around this by making horizontal axis  option to be Categor