I have a window for used for searching a database with widgets used for selecting a subset of criteria and one of these widgets is a JComboBox. The same window also contains a button that will bring up a dialog used to define the whole set of search criteria. The dialog also includes a JComboBox widget that is linked to the same data as the first JComboBox I mentioned.
The problem is that when I change the value of the JComboBox in the dialog, it makes the first JComboBox drop down it's list. Subsequent changes to the JComboBox in the dialog can cause more lists to be shown in various places on the screen that don't go away even when the dialog is closed. I have tried to set the first JComboBox's -state=>'disabled' before showing the dialog but that didn't help. Even though the combobox on the first window is disabled, it still pops up the list. Wow, that even confused me a little. Here is a much abbreviated example of the problem:#!c:\perl\bin\perl.exe use strict; use warnings; use Tk; use Tk::JComboBox; use Tk::Dialog; my $form; my %choices = ( 'a'=>1, 'b'=>2, 'c'=>3 ); my $selected = "a"; CreateMainForm(); MainLoop(); exit; sub CreateMainForm { $form = MainWindow->new(); $form->title("Test for JComboBox Problem"); my $testbox1 = $form->JComboBox(-textvariable=>\$selected,-validat +e=>'match',-mode=>'editable',-relief=>'sunken',-highlightthickness=>0 +); for my $x(keys %choices) { $testbox1->addItem("$x"); } $testbox1->pack(-side=>'left'); my $button = $form->Button(-text=>"Dialog",-command=>sub{CallDialo +g($testbox1)})->pack(-side=>'right'); return; } sub CallDialog { my $otherbox = shift; $otherbox->configure(-state=>'disabled'); my $dialog = $form->Dialog(-title=>"Part2 of test",-buttons=>["Sub +mit","Cancel"],-default_button=>"Submit"); my $testbox2 = $dialog->JComboBox(-textvariable=>\$selected,-valid +ate=>'match',-mode=>'editable',-relief=>'sunken',-highlightthickness= +>0); for my $x(keys %choices) { $testbox2->addItem("$x"); } $testbox2->pack(-side=>'left'); my $retval = $dialog->Show(-popover=>$form,-overanchor=>'c',-popan +chor=>'c',-global); if($retval eq "Cancel") { $otherbox->configure(-state=>'normal'); return; } elsif($retval eq "Submit") { $otherbox->configure(-state=>'normal'); #SaveConfig(); return; } else { #should never happen return; } }
Janitored by Arunbear - added readmore tags, as per Monastery guidelines
In reply to Help with JComboBox by ChrisR
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |