cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
alon2580
Level 5

get user input gray textbox

Hi,
In the advanced get user input, I want to add a check box and a text field, and I want the text filed to be available only if the text box has been checked, otherwise I want it to be grayed out.
any one knows on a good way to do it?

I'm using Installanywhere 2008 VP1

thanks
Alon
Labels (1)
0 Kudos
10 Replies
prabubiginstall
Level 5

i would recommend you to go for custom code panels..
0 Kudos
alon2580
Level 5

but I guess there is no other way...
any clue on how to do it?
0 Kudos
Juhana
Level 3

Hi
The most obious way to do this is to add ItemListener to JCheckBox. Unfortunately I do not know how these Listeners work in InstallAnywhere (See the other thread).
0 Kudos
alon2580
Level 5

hi thanks for the help
what other thread did you mean?about listeners?
0 Kudos
Juhana
Level 3

I started another thread but It has not appeared yet. I guess a moderator needs to approve it first.
0 Kudos
alon2580
Level 5

oh o.k I'll wait.
does a listener can make a text filed to appear gray if not wanted?
0 Kudos
Juhana
Level 3

There are two issues here.

1. Detect a change in checkbox values.

2. Turn textfield to grey

Listener would just detect that someone has changed the checkbox value. Then you could write the code that turns the textfield to grey. e.g
MyText.setEditable(false);

Perhaps there is an easier way. I am new to InstallAnywhere.
0 Kudos
pv7721
Level 20

Juhana wrote:
I started another thread but It has not appeared yet. I guess a moderator needs to approve it first.


Offtopic:

FYI AFAIK normally there is no moderation here in the sense of a message needing approval (i.e. there is no action BEFORE posting, most of the time it's action AFTER posting, if for instance a post has been tagged as spam or for instance if your post has been duplicated).
0 Kudos
Juhana
Level 3

The following code should do it. There is a small issue with back button but I do not know how to fix it yet.

You just need to unzip IAClasses.zip to somewhere and put this into a classpath (e.g. C:\Java).


then just type
javac -classpath C:\Java CustomCodePanelTemplate.java
jar -cvfM CustomCodePanelTemplate.jar CustomCodePanelTemplate.class

Then you should haveCustomCodePanelTemplate.jar -file. Add this jar file to
Custom code panel and type in the class CustomCodePanelTemplate.

It should work. See the back button functionality and see if it is ok (there might be some confusion). If you can fix it then please tell me.


//package com.acme; // you should change this to your own package location
import java.awt.*;
import com.zerog.ia.api.pub.*;
import java.io.*;
import javax.swing.*;
import java.awt.event.*;

public class CustomCodePanelTemplate extends CustomCodePanel implements ItemListener
{
//Constructor
public CustomCodePanelTemplate (){
selected=false;
}


public boolean setupUI(CustomCodePanelProxy customCodePanelProxy)
{
//Get the frame (window that displays all stuff)
ccpp = customCodePanelProxy;
gui = (GUIAccess)customCodePanelProxy.getService(com.zerog.ia.api.pub.GUIAccess.class);
frame = gui.getFrame();

//put components
label1 = new JLabel("Here is some instruction text....");
label1.setFont((label1.getFont()).deriveFont(14));
panel=new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
panel.setBackground(new Color(255,255,255));
panel.add(label1);
check = new JCheckBox ("Click here to activate the text field",selected);
check.setBackground(new Color(255,255,255));
panel.add(check);
field =new JTextField(20);
field.setEditable(selected);
field.setBorder(BorderFactory.createLineBorder(new Color(0,0,0)));
panel.add(field);
label2 = new JLabel("Here is some instruction text again....");
label2.setFont((label1.getFont()).deriveFont(14));
panel.add(label2);
add(BorderLayout.NORTH,panel);

//Add the listener
check.addItemListener(this);

//This might be useless
if (selected==true)
field.setEditable(true);
else
field.setEditable(false);

return true; // true if you want your panel displayed or false if not
}

public void panelIsDisplayed()
{
}

public boolean okToContinue()
{
return true; // or false
}

public String getTitle()
{
return "Some Title";
}

//Listener code is here
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange()==1) {
field.setEditable(true);
selected=true;
}
else{
field.setEditable(false);
selected=false;
}
}

//Components
private boolean selected;
private JLabel label1,label2;
private Frame frame;
private JPanel panel;
private JTextField field;
private JCheckBox check;
GUIAccess gui;
CustomCodePanelProxy ccpp;
}
0 Kudos
alon2580
Level 5

Thank you very much it seems to work fine.(didn't test the back button though)
Any idea on how to change the design to match the default installanywhere panels(e.g textfield doesn't look the same)

Thanks again
0 Kudos