stharmon 0 Newbie Poster

It looks like I figured this out myself. To clear the selection on a combobox, use "setSelectedIndex(-1);"


Hey all,

I have a simple one I hope. I have created an editable combobox and wanted to clear what is currently displayed in the box once the user sets focus on it either through "tab" or a "mouse click". For example, the combobox would say "Enter a phone number or select your from a list". When the user puts focus on the combobox I want the above string cleared.

So far I have setup the following event.

private void clearPhoneUponFocus(java.awt.event.FocusEvent evt) {
jComboBox1.setModel();
}

I thought I might have to use the setModel method, but can't seem to figure it out. Am I going down the right path? Does anyone have experience doing this and mind lending a hand?

Thanks!

stharmon 0 Newbie Poster

Hey all,

I have a simple one I hope. I have created an editable combobox and wanted to clear what is currently displayed in the box once the user sets focus on it either through "tab" or a "mouse click". For example, the combobox would say "Enter a phone number or select your from a list". When the user puts focus on the combobox I want the above string cleared.

So far I have setup the following event.

private void clearPhoneUponFocus(java.awt.event.FocusEvent evt) {
jComboBox1.setModel();
}

I thought I might have to use the setModel method, but can't seem to figure it out. Am I going down the right path? Does anyone have experience doing this and mind lending a hand?

Thanks!

stharmon 0 Newbie Poster

Woohoo! That is exactly what I was looking for. Thank you for taking the time to respond, as well as the clear explanation.

stharmon 0 Newbie Poster

Hi All,

I am sed and awk illiterate and needed some assistance. I would like to write a script that will have sed replace all spaces with \space.

For example.

Program Files would be... Program\ Files

I can figure out how to replace the space with a backslash, however, when I add a space in there it complains that it is not terminated. Does anyone out there know how to accomplish this?

Thanks in advance.

stharmon 0 Newbie Poster

I understand what ; does on a command prompt and what not. What I DON'T understand, is how you were able to pass the password to SU with multiple commands (using ; )? So how'd you do it?

I wasn't able to "pass" the password to SU. Instead, I combined the commands into one (using ;). That way the users were only prompted once during the install... If you ever find out how to pass the password to SU, I would like to know as well...

stharmon 0 Newbie Poster

It looks like I was able to use ; to separate the commands and it worked just fine. I had problems using &

Thanks for the help!

stharmon 0 Newbie Poster

I am trying to install 2 rpm files that need root privileges. However, I don't want to prompt the user twice. Currently I am doing the following in my script:

echo "*************************************************************"
echo "In order to install acme package, you need to log in as root"
echo "*************************************************************"
su -c "ACME_QUIET=y rpm -ivh /home/acmeUser/acme_install/components/acme/acme*"
echo "**************************************************************************"
echo "In order to install acmebase package, you need to log in as root."
echo "**************************************************************************"
su -c "rpm -ivh /home/acmeUser/acme_install/components/acme/acmebase*"

The above works just fine. However, they have to login twice.

I would like to do something like this:


echo "*************************************************************"
echo "In order to install acme package, you need to log in as root"
echo "*************************************************************"
read PASSWORD

I would then like to give the $PASSWORD variable to the SU command somehow. I just can't seem to figure it out. Another option would be to use SUDO (so people tell me), but I thought you had to configure it before hand. This is a script that is run on many many machines and I can't configure SUDO for this purpose. Does anyone have an idea on how to get around this?

Thanks!

stharmon 0 Newbie Poster

Hello,

I have written a script to automate a software install. I am running the script as root, but need to su to another user to configure and complile the program properly. Whenever I do the shell script su's to the user properly but the scripts stops executing until I exit out of the new shell that su put me into. The following is an example of my script.

echo -e "\033[1m \n\t Installing courier-imap... \033[0m"
sleep 2
cd /var/src
tar -xjf tar/courier-imap-2.2.2.20040207.tar.bz2
cd courier-imap-2.2.2.20040207

# build as vpopmail
chown -R vpopmail:vchkpw ../courier-imap-2.2.2.20040207
su - vpopmail

./configure --with-redhat

I have also tried using the following to stay in the same shell and preserve the environment:
su - -m -p vpopmail

Does anyone have any thought as to how I can successfully SU and keep the script running?

Thanks,

Stephen