Tri-state check boxes

I have a requirement to create tri-state check boxes. The check-box is supposed to show an aggregate value from multiple sources, so it may show "entirely on", "entirely off" or "mixed". The appearance for "mixed" (as seen in many word-processors when formatting large section of text, or when installing only some sub-components of a component of Windows,) should be a check on a gray background.
Currently my best effort has been to create a JPanel containing two JCheckBox objects stacked with an OverlayLayout. One has no text and is transparent to the mouse, it is just the check part. The other is partically obscured by the first, but provides the label and response to clicks. The latter updates the former with its state, but the former may be set to "mixed", which is simulated by disabling it.
This is a very ugly way of acheiving what I want. It does give consistently correct results across PLAFs, but it has a tendency to flicker because the functional JCheckBox doesn't like being obscured. It also doesn't show shading in the box while the mouse button is held down over it, because this occurs in the obscured component, not the puppet component shown. Is there an existing component with the functionality I desire? Alternatively is there some way to create a new component without having to extend every PLAF that I want to use with it? Trying to figure out how to add new components in the same look and feel is quite intimidating.
Many thanks,
Andrew Wilson.

The Follwoing code will work out for you i have read in an article
import javax.swing.*;
import javax.swing.event.ChangeListener;
import javax.swing.plaf.ActionMapUIResource;
import java.awt.event.*;
* Maintenance tip - There were some tricks to getting this code
* working:
* 1. You have to overwite addMouseListener() to do nothing
* 2. You have to add a mouse event on mousePressed by calling
* super.addMouseListener()
* 3. You have to replace the UIActionMap for the keyboard event
* "pressed" with your own one.
* 4. You have to remove the UIActionMap for the keyboard event
* "released".
* 5. You have to grab focus when the next state is entered,
* otherwise clicking on the component won't get the focus.
* 6. You have to make a TristateDecorator as a button model that
* wraps the original button model and does state management.
public class TristateCheckBox extends JCheckBox {
/** This is a type-safe enumerated type */
public static class State { private State() { } }
public static final State NOT_SELECTED = new State();
public static final State SELECTED = new State();
public static final State DONT_CARE = new State();
private final TristateDecorator model;
public TristateCheckBox(String text, Icon icon, State initial){
super(text, icon);
// Add a listener for when the mouse is pressed
super.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
grabFocus();
model.nextState();
// Reset the keyboard action map
ActionMap map = new ActionMapUIResource();
map.put("pressed", new AbstractAction() {
public void actionPerformed(ActionEvent e) {
grabFocus();
model.nextState();
map.put("released", null);
SwingUtilities.replaceUIActionMap(this, map);
// set the model to the adapted model
model = new TristateDecorator(getModel());
setModel(model);
setState(initial);
public TristateCheckBox(String text, State initial) {
this(text, null, initial);
public TristateCheckBox(String text) {
this(text, DONT_CARE);
public TristateCheckBox() {
this(null);
/** No one may add mouse listeners, not even Swing! */
public void addMouseListener(MouseListener l) { }
* Set the new state to either SELECTED, NOT_SELECTED or
* DONT_CARE. If state == null, it is treated as DONT_CARE.
public void setState(State state) { model.setState(state); }
/** Return the current state, which is determined by the
* selection status of the model. */
public State getState() { return model.getState(); }
* Exactly which Design Pattern is this? Is it an Adapter,
* a Proxy or a Decorator? In this case, my vote lies with the
* Decorator, because we are extending functionality and
* "decorating" the original model with a more powerful model.
private class TristateDecorator implements ButtonModel {
private final ButtonModel other;
private TristateDecorator(ButtonModel other) {
this.other = other;
private void setState(State state) {
if (state == NOT_SELECTED) {
other.setArmed(false);
setPressed(false);
setSelected(false);
} else if (state == SELECTED) {
other.setArmed(false);
setPressed(false);
setSelected(true);
} else { // either "null" or DONT_CARE
other.setArmed(true);
setPressed(true);
setSelected(true);
* The current state is embedded in the selection / armed
* state of the model.
* We return the SELECTED state when the checkbox is selected
* but not armed, DONT_CARE state when the checkbox is
* selected and armed (grey) and NOT_SELECTED when the
* checkbox is deselected.
private State getState() {
if (isSelected() && !isArmed()) {
// normal black tick
return SELECTED;
} else if (isSelected() && isArmed()) {
// don't care grey tick
return DONT_CARE;
} else {
// normal deselected
return NOT_SELECTED;
/** We rotate between NOT_SELECTED, SELECTED and DONT_CARE.*/
private void nextState() {
State current = getState();
if (current == NOT_SELECTED) {
setState(SELECTED);
} else if (current == SELECTED) {
setState(DONT_CARE);
} else if (current == DONT_CARE) {
setState(NOT_SELECTED);
/** Filter: No one may change the armed status except us. */
public void setArmed(boolean b) {
/** We disable focusing on the component when it is not
* enabled. */
public void setEnabled(boolean b) {
setFocusable(b);
other.setEnabled(b);
/** All these methods simply delegate to the "other" model
* that is being decorated. */
public boolean isArmed() { return other.isArmed(); }
public boolean isSelected() { return other.isSelected(); }
public boolean isEnabled() { return other.isEnabled(); }
public boolean isPressed() { return other.isPressed(); }
public boolean isRollover() { return other.isRollover(); }
public void setSelected(boolean b) { other.setSelected(b); }
public void setPressed(boolean b) { other.setPressed(b); }
public void setRollover(boolean b) { other.setRollover(b); }
public void setMnemonic(int key) { other.setMnemonic(key); }
public int getMnemonic() { return other.getMnemonic(); }
public void setActionCommand(String s) {
other.setActionCommand(s);
public String getActionCommand() {
return other.getActionCommand();
public void setGroup(ButtonGroup group) {
other.setGroup(group);
public void addActionListener(ActionListener l) {
other.addActionListener(l);
public void removeActionListener(ActionListener l) {
other.removeActionListener(l);
public void addItemListener(ItemListener l) {
other.addItemListener(l);
public void removeItemListener(ItemListener l) {
other.removeItemListener(l);
public void addChangeListener(ChangeListener l) {
other.addChangeListener(l);
public void removeChangeListener(ChangeListener l) {
other.removeChangeListener(l);
public Object[] getSelectedObjects() {
return other.getSelectedObjects();
then compile this code
in another class file
import javax.swing.*;
import java.awt.*;
public class TristateCheckBoxTest {
public static void main(String args[]) throws Exception {
JFrame frame = new JFrame("TristateCheckBoxTest");
frame.getContentPane().setLayout(new GridLayout(0, 1, 5, 5));
final TristateCheckBox swingBox = new TristateCheckBox(
"Testing the tristate checkbox");
swingBox.setMnemonic('T');
frame.getContentPane().add(swingBox);
frame.getContentPane().add(new JCheckBox(
"The normal checkbox"));
UIManager.setLookAndFeel(
UIManager.getSystemLookAndFeelClassName());
final TristateCheckBox winBox = new TristateCheckBox(
"Testing the tristate checkbox",
TristateCheckBox.SELECTED);
frame.getContentPane().add(winBox);
final JCheckBox winNormal = new JCheckBox(
"The normal checkbox");
frame.getContentPane().add(winNormal);
// wait for 3 seconds, then enable all check boxes
new Thread() { {start();}
public void run() {
try {
winBox.setEnabled(false);
winNormal.setEnabled(false);
Thread.sleep(3000);
winBox.setEnabled(true);
winNormal.setEnabled(true);
} catch (InterruptedException ex) { }
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.show();
this will give you all the check boxes...
All The Best

Similar Messages

  • Check Boxes in ALV (parent-child relation)

    Hi Friends...
    I am trying to display some data in ALV using the parent child relationship. I require the first field of the parent record to be a check box which is input enabled.
    Whatever i tried the check box is not comming as the first field, instead it comes second after the key field (the link btw the parent and the child).
    If anyone of you knows how to tackle the issue please help..
    Thanks,
    Derek

    Hi Friends...
    I am trying to display some data in ALV using the parent child relationship. I require the first field of the parent record to be a check box which is input enabled.
    Whatever i tried the check box is not comming as the first field, instead it comes second after the key field (the link btw the parent and the child).
    If anyone of you knows how to tackle the issue please help..
    Thanks,
    Derek

  • How to save the session states for a tabular form WITHOUT using check boxs?

    Greeting guys,
    As you know that we can use collections to save the session states of a tabular forms, described in the how-to doc of manual tabular forms. However, what I am trying to do ( or have to do) is to provide a manual tabular form, and save the session states for validation, without using the check boxes. Because a user can put contents into some columns in a row without checking the corresponding checkbox, according to the requirements. So basically what I tried is to loop over all the rows and save Every entry into a collection. However, sometimes I got "no data found" error with unknown reasons.
    My current solution is to use the "dirty" Retry button that gets back the history, which IMO is not a good workabout. So, I'd appreciate if somebody can shed some light on a better solution, especially if it is close to the one in that how-to doc.
    Thanks in advance.
    Luc

    The following is the first collection solutin I've tried:
    htmldb_collection.create_or_truncate_collection('TEMP_TABLE');
    for i in 1..p_row_num loop -- Loop on the whole form rows
    if (htmldb_application.g_f01(i) is not null) or (htmldb_application.g_f05(i) <> 0)
    --If either of them has some input values, the row should be saved into the colleciton.
    then
    htmldb_collection.add_member(
    p_collection_name => 'TEMP_TABLE',
    p_c001 => htmldb_application.g_f01(i),
    p_c002 => htmldb_application.g_f03(i),
    p_c003 => htmldb_application.g_f04(i),
    p_c004 => htmldb_application.g_f05(i),
    p_c005 => htmldb_application.g_f06(i),
    p_c006 => htmldb_application.g_f08(i)
    end if;
    end loop;
    Some of columns have null values, but I don't think that's the reason. Because once I clicked all the check boxes, there would be no error no matter what values were in other columns.
    Another issue would be extract the values FROM the collection, which has been tried because I had problem to store the data into the collection. I used "decode" functions inside the SQL to build the tabular form. I am not sure whether it will be the same as a regular SQL for a tabular form, like the example in the How-to doc.
    Also I didn't use the checksum, for it is not an issue at the current stage. I am not sure whether that's the reason which caused the NO DATA FOUND error.

  • Access 2010 - If Then Else Statement to display text within text box upon Check Box True/False condition

    I have a form called myForm. On this form is a check box called myCheckBox. I also have a text box labeled myTextBox. I have assigned a macro, myMacro, to run upon selection/click of myCheckBox. The macro is an If statement which determines if myCheckBox
    is checked or not checked and spits out a value, "Yes" or "No" for example, into the text box.
    I am not able to get text to display into the text box although I am not receiving any errors when I run the macro. This may be a fault in my logic and would like help resolving where the problem lies. I am fairly new to Access so this could be something
    simple.
    My code is as follows:
    If Forms!myForm =  True Then
      Forms!myForm!myTextBox.Value = "Yes!"
    ElseIf Forms!myForm = False Then
      Forms!myForm!myTextBox.Value = "No!"
    Else
      Forms!myForm!myTextBox.Value = " / ERROR / " 
    End if
    Thanks!

    Hi,
    This is the forum to discuss questions and feedback for Microsoft Office, the issue is more related to coding/programing, you'd better post your question to the MSDN forum for Access
    http://social.msdn.microsoft.com/Forums/en-US/home?forum=accessdev&filter=alltypes&sort=lastpostdesc
    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.
    George Zhao
    TechNet Community Support

  • When trying to check my emails its states it can not connect to the server

    when trying to check my emails its states it can not connect to the server

    Hi Tanya2707,
    If you are having issues checking your email from your iPhone, you may find the troubleshooting steps in the following article helpful:
    iOS: Troubleshooting Mail
    http://support.apple.com/kb/ts3899
    Regards,
    - Brenden

  • Trying to select the Calendar check box in iCloud window and then it asks me If I want to merge I hit ok and the it tries to ad see spinning fan icon and then just quits and is then unchecked.  Does Anyone have a solution to fix this?

    Trying to select the Calendar check box in iCloud window and then it asks me If I want to merge I hit ok and the it tries to ad see spinning fan icon and then just quits and is then unchecked.  Does Anyone have a solution to fix this?  It works just fine on all other 5 Macs I have.  I have tried to sign out and in and even restart the computer.  I am running Yosemite on all 6 of my Macs.

    Search the web or help doco about the Captivate feature called Return to Quiz.  It will do what you are looking for here according to your description.  There's even a Youtube video from a year or two back that shows how it works.

  • Data grid view adding check box not able to check state

     i have make window search a city name result show on data grid view and i have added the check box when i am checking the check box and other search  of keyword that same row i am un checking the chek box when search it remain check how to making
    it check for al type of keyword

     i have make window search a city name result show on data grid view and i have added the check box when i am checking the check box and other search  of keyword that same row i am un checking the chek box when search it remain check how
    to making it check for al type of keyword
    Hello,
    It's not clear what the issue is, you could be more specific by sharing some screenshots and code.
    In addition, it will be more clear if you could separate the description into multiple sentences.
    Which control did you want to get help about? The checkbox or datagridview?
    If it is checkbox, did you want to keep checked or keep it uncheck?
    If it is datagridview, whether you are talking about checkbox column?
    Regards,
    Carl
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How to name the Check Box as "Want Free Gift" using PARAMETERS statements

    Hi all,
    I am new to check boxes. I have a existing report where I have to add a check box to the selection screen.
    So i said
    PARAMETERS: p_cncldc AS CHECKBOX.
    everythibng is fine and I get the check box on the selection screen. when i execute the report i get the name of check box as p_cncldc. but i want the name of the check box as "Want Free Gift".
    How to name the check box as "Want Free Gift".
    if i am saying
    PARAMTERS: Want Free Gift AS CHECKBOX. it says a syntax error saying it canot be more that 8 chars.
    Some one please help. I am new to Check boxes
    Regards,
    Jessica Sam
    Edited by: jessica sam on Mar 31, 2009 10:37 PM

    Text on the Right hand side of check box.
    selection-screen begin of block b1.
    selection-screen begin of line.
    parameters: w_check as checkbox.
    selection-screen: comment  4(30) TEST .
      selection-screen end of line.
    selection-screen end of block b1.
    INITIALIZATION.
    test = 'Want Free Gift AS CHECKBOX'.
    Text on the Left hand side of check box.
    selection-screen begin of block b1.
    selection-screen begin of line.
    selection-screen: comment  2(30) TEST .
    parameters: w_check as checkbox.
      selection-screen end of line.
    selection-screen end of block b1.
    INITIALIZATION.
    test = 'Want Free Gift AS CHECKBOX'.
    OR:
    GOTO(Menubar)>Text Elements>Selection Texts
    Regards,
    Gurpreet

  • Check box in interactive report is literal string not a check box ???

    I'm trying to create a check box in an interactive report using the APEX_ITEM.CHECKBOX function.
    My select statement is :
    select     "CUTOVER_TASKS"."ID" as "ID",
         "CUTOVER_TASKS"."START_DATE" as "START_DATE",
         "CUTOVER_TASKS"."END_DATE" as "END_DATE",
         "CUTOVER_TASKS"."DURATION" as "DURATION",
         "CUTOVER_TASKS"."EFFORT" as "EFFORT",
         APEX_ITEM.CHECKBOX(1,COMPLETED, 1) as "COMPLETED",
         "CUTOVER_TASKS"."ASSIGNED" as "ASSIGNED",
         "CUTOVER_TASKS"."CONSTRAINT_START" as "CONSTRAINT_START",
         "CUTOVER_TASKS"."CONSTRAINT_END" as "CONSTRAINT_END",
         "CUTOVER_TASKS"."DEPENDENCIES" as "DEPENDENCIES",
         "CUTOVER_TASKS"."NOTES" as "NOTES",
         "CUTOVER_TASKS"."PRIORITY" as "PRIORITY",
         "CUTOVER_TASKS"."ORGANIZATION" as "ORGANIZATION",
         "CUTOVER_TASKS"."TASK" as "TASK"
    from     "CUTOVER_TASKS" "CUTOVER_TASKS"
    This produces an interactive report with the COMPLETED column contents "<input type="checkbox" name="f01" value="" 1 />"
    The same sql in a regular report works properly and creates the check box.
    Is there something else required for a check box in an interactive report ?
    Using : Application Express 3.2.0.00.27

    Go to Report Attributes and change the display type to "Standard Report Column" (instead of "Display as Text, escape special characters")
    Go to Column Attributes for that column and change the List Of Values to None and uncheck all the column's interactive features (sort, aggregate, compute, etc)

  • BEX web designer 7.0, update roll time update with check box?

    guys this is what i am trying to do?
    i have few reports on some cubes,
    i have created some queries on the cubes,
    created a web template and in item i have placed each query with data load time, so i get the last time the data was updated.
    now what i want to do is.. if the data was laoaded yesterday, i want the web template to check if it was loaded today or not, if yes then put a check box in the web template that would be clicked? if not then it would be unchcked with the last time loaded.
    in the query designer , i only have the time status of the last query updated, the query is suppose to update everyday? but it can also be updated everyday twice, as once in the morning and once in the evening.
    so how do i go and create , an if statement that if date 1(yesterday) is not equal  to date 2(today), then have the check box in the web template be checked?
    can i create a conditon or exception.. any ideas would be helpful i am stuck...

    i start using visual composer.

  • Row is not deleted when check box is selected urgent please

    my problem is, i am creating number of rows dynamicaly and storing the values in the database. I do have one delete check box. if the user checked that box that row should be deleted. I am using array to return the check box values. It is working fine when there is multiple rows.. suppose if i do have only one row and trying to delete that row i am getting an exception. Please help me to solve this issue, here ismy jsp
    <%@page language="java" import="java.lang.*, java.sql.*, java.io.*,
    java.util.*"%>
    <%@ page import="DatabaseConnection"%>
    <%@ page import="AdjustmentsBean"%>
    <%@ page import="AdjustmentTransactionInfo"%>
    <%@ page import="CustomerLocationInfo"%>
    <%@ page import="EmersonGlobalConstants"%>
    <%@ page import="CallPLSQLFunc"%>
    <%@include file="Security.jsp" %>
    <%
    AdjustmentsBean adjustments = new AdjustmentsBean();
    String userName=(String)session.getAttribute("user_name");
    String divisionCode=(String)session.getAttribute("division_code");
    String divisionName=(String)session.getAttribute("division_code_name");
    if(userName==null){userName="";}
    if(divisionCode==null){divisionCode="";}
    if(divisionName==null){divisionName="";}
    GregorianCalendar calendar = (GregorianCalendar)Calendar.getInstance();
    CallPLSQLFunc callPLSQLFunc = new CallPLSQLFunc();
    Vector months = callPLSQLFunc.getMonths(divisionCode);
    String cMonth = callPLSQLFunc.getCurrentMonth(divisionCode);
    System.out.println("%%%%%%%%%" +months);
    //int mm = calendar.get(Calendar.MONTH) + 1;
    //int yyyy = calendar.get(Calendar.YEAR);
    if(months ==null){
    months=new Vector();
    int mmst=0;
    int yyst=0;
    if(months.size()>=1){
    //mmst=Integer.parseInt(new String(((String)months.get(0)).charAt(0)));
    mmst=Integer.parseInt(String.valueOf(((String)months.get(0)).charAt(0)));
    yyst=Integer.parseInt(((String)months.get(0)).substring(3,6));
    StringTokenizer token1 = new StringTokenizer(cMonth,"-");
    yyst=Integer.parseInt(token1.nextToken());
    mmst=Integer.parseInt(token1.nextToken());
    int ddst = Integer.parseInt(token1.nextToken());
    String currentDate= (mmst<10?"0"+mmst:mmst+"") + "/" + yyst;
    System.out.println("The current date is" + currentDate);
    String slectedMonth = request.getParameter("selectedMonth");
    String selectedDate=currentDate;
    if(slectedMonth != null && slectedMonth.trim().length()>0){
    selectedDate=slectedMonth;
    boolean modifyAllowed=false;
    if(selectedDate.equalsIgnoreCase(currentDate)){
    modifyAllowed=true;
    String admin=(String)session.getAttribute("admin");
    if(admin==null){admin="false";}
    if(admin.equalsIgnoreCase("true") ){
    modifyAllowed=true;
    %>
    <%
    Vector transactions = adjustments.getTransactionsOfMonth(selectedDate,divisionCode);
    Vector customers = adjustments.getAllCustomers();
    System.out.println("customers : "+customers.size());
    %>
    <html>
    <head>
    <script>
    var modifyAllowed;
    if(<%=modifyAllowed%> == true){
    modifyAllowed = '';
    }else{
    modifyAllowed = 'disabled';
    var EAS_Cust_Loc_Num_Key = new Array(<%=customers.size()%>);
    var EAS_Cust_Num_Key = new Array(<%=customers.size()%>);
    var EAS_Cust_Num = new Array(<%=customers.size()%>);
    var EAS_Cust_Name = new Array(<%=customers.size()%>);
    var customerWiseLocationNumKey = new Array(<%=customers.size()%>);
    var customerWiseLocationName = new Array(<%=customers.size()%>);
    <%
    for(int i=0;i<customers.size();i++){
    CustomerLocationInfo cl = (CustomerLocationInfo)customers.get(i);
    %>
    EAS_Cust_Loc_Num_Key[<%=i%>] = "<%=cl.getEAS_Cust_Loc_Num_Key()%>";
    EAS_Cust_Num_Key[<%=i%>] = "<%=cl.getEAS_Cust_Num_Key()%>";
    EAS_Cust_Num[<%=i%>] = "<%=cl.getEAS_Cust_Num()%>";
    EAS_Cust_Name[<%=i%>] = "<%=cl.getEAS_Cust_Name()%>";
    var locationNumKey = new Array(<%=cl.getLocations().size()%>);
    var locationName = new Array(<%=cl.getLocations().size()%>);
    <%
    int j=0;
    Enumeration enum = cl.getLocations().keys();
    while(enum.hasMoreElements()){
    String s = (String)enum.nextElement();
    String name = (String)cl.getLocations().get(s);
    %>
    locationNumKey[<%=j%>]="<%=s%>";
    locationName[<%=j%>]="<%=name%>";
    <%
    j=j+1;
    %>
    customerWiseLocationNumKey[<%=i%>] = locationNumKey;
    customerWiseLocationName[<%=i%>] = locationName;
    <%
    %>
    function changeMonth(){
    window.document.adjustmentForm.action="Adjustments.jsp";
    adjustmentForm.submit();
    function populateLocation(id){
    var table = document.getElementById('myTable');
    var rows = table.rows.length-2;
    var theForm = document.forms[0];
    var wRow = theForm["location"];
    var wCustRow = theForm["customer"];
    var len;
    var locobj ;
    var custobj ;
    if(rows ==1){
    locobj =wRow;
    }else{
    locobj =wRow[id];
    if(rows ==1){
    custobj =wCustRow;
    }else{
    custobj =wCustRow[id];
    len = locobj.options.length;
    locobj.selectedIndex=0;
    for(z=0;z<len;++z){
    locobj.options[z] = null;
    locobj.options.length=0;
    locobj.options[0] = new Option("Select Any Location");
    var cIndex = custobj.selectedIndex;
    if(cIndex !=0){
    for(i=1;i<=customerWiseLocationName[cIndex-1].length;i++){
    locobj.options = new Option(customerWiseLocationName[cIndex-1][i-1],customerWiseLocationNumKey[cIndex-1][i-1]);
    function addRow(id){
    var table = document.getElementById(id);
    var sHTML = new Array() ;
    var cus = "<select name=customer onChange='javascript:populateLocation("+(table.rows.length-2)+")'"+modifyAllowed+"><OPTION VALUE=''>Select Any Customer</OPTION>";
    var options;
    for(i=0;i<EAS_Cust_Num.length;i++){
    options = options+"<OPTION VALUE='" + EAS_Cust_Num +"'>" + EAS_Cust_Name + "</OPTION>";
    cus=cus+options+"</select>";
    sHTML[0] = "<input type=checkbox name=chk "+modifyAllowed+" onClick=changedisable("+(table.rows.length-2)+")><input type=hidden name=adid value='' ><input type=hidden name=isdelete value='false'>";
    sHTML[1] = cus;
    sHTML[2] = "<select name='location'"+modifyAllowed+"><OPTION VALUE=''>Select Any Location</OPTION>";
    sHTML[3] = "<input type=text size=10 maxlength=40 name=sku"+modifyAllowed+"> <input type=button value=Search onClick=window.open('SearchSKU.jsp?cnt="+(table.rows.length-2)+"','SearchSKU','width=350,height=350,top=150,left=150,scrollbars=yes')>";
    sHTML[6] = "<input type=hidden name=shipnotbilled "+modifyAllowed+" onClick=changeisshipnotbilled("+(table.rows.length-2)+")><input type=hidden name=isshipnotbilled value='false'>";
    sHTML[4] = "<input type=text size=10 maxlength=40 name=units "+modifyAllowed+">";
    sHTML[5] = "<input type=text size=10 maxlength=40 name=amount "+modifyAllowed+">";
    var newRow = table.insertRow(-1);
    var sHTMLIndex = sHTML.length ;
    for(i=0;i<sHTMLIndex;i++) {
    var newCellSelect = newRow.insertCell(-1);
    newCellSelect.innerHTML = sHTML;
    function validate(){
    var table = document.getElementById('myTable');
    var theForm = document.forms[0];
    var wRow = theForm["amount"];
    var custRow = theForm["customer"];
    var locRow = theForm["location"];
    var quantityRow = theForm["units"];
    var count = table.rows.length;
    var rows = table.rows.length-2;
    var obj;
    if(rows==1){ //only one row..
    if(wRow.value==""){
    alert("Amount field is mandatory. Please fill in amount");
    return false;
    if(custRow.selectedIndex==0){
    alert("Customer is mandatory. Please select the customer");
    return false;
    if(locRow.selectedIndex==0){
    alert("Location is mandatory. Please select the location");
    return false;
    if(! isAmount(wRow.value) ){
    alert("Amount is numeric. Please enter numeric value for amount");
    return false;
    if(!isQuantity(quantityRow.value)){
    alert("Quantity is numeric. Please enter numeric value for quantity");
    return false;
    }else{ //this means more than one rows..
    for(i=0;i<count-2;i++){
    if(wRow.value==""){
    alert("Amount field is mandatory. Please fill in amount for transaction no "+(i+1));
    return false;
    if(wRow.value== 0){
    alert("Please fill non zero value for Amount "+(i+1));
    return false;
    if(custRow.selectedIndex==0){
    alert("Customer is mandatory. Please select the customer for transaction no "+(i+1));
    return false;
    if(locRow.selectedIndex==0){
    alert("Location is mandatory. Please select the location for transaction no "+(i+1));
    return false;
    if(! isAmount(wRow.value) ){
    alert("Amount is numeric. Please enter numeric value for amount of transaction no "+(i+1));
    return false;
    if(!isQuantity(quantityRow.value)){
    alert("Quantity is numeric. Please enter numeric value for quantity of transaction no "+(i+1));
    return false;
    if(quantityRow.value== 0){
    alert("Please fill non zero value for Units "+(i+1));
    return false;
    return true;
    function isQuantity(value){
    for (k=0;k<value.length;k++){
    if(k==0){
    if(!(value.charAt(k)>=0 && value.charAt(k)<=9) ){
    if(value.charAt(k)!='-'){
    break;
    }else{
    if(!(value.charAt(k)>=0 && value.charAt(k)<=9)){
    break;
    if(k == value.length){
    return true;
    }else{
    return false;
    function isAmount(value){
    for (k=0;k<value.length;k++){
    if(k==0){
    if(!(value.charAt(k)>=0 && value.charAt(k)<=9) ){
    if(value.charAt(k)!='-'){
    break;
    }else{
    if((!(value.charAt(k)>=0 && value.charAt(k)<=9)) ){
    if(value.charAt(k) !='.'){
    break;
    if(k == value.length){
    return true;
    }else{
    return false;
    function changedisable(index){
    if(document.adjustmentForm.chk[index].checked){
    document.adjustmentForm.isdelete[index].value='true';
    }else{
    document.adjustmentForm.isdelete[index].value='false';
    function changeisshipnotbilled(index){
    if(document.adjustmentForm.shipnotbilled[index].checked){
    document.adjustmentForm.isshipnotbilled[index].value='true';
    }else{
    document.adjustmentForm.isshipnotbilled[index].value='false';
    function backtoHome(){
    window.document.adjustmentForm.action="Welcome.jsp";
    adjustmentForm.submit();
    function setData(cnt,num){
    var table = document.getElementById('myTable');
    var rows = table.rows.length-2;
    if(rows==1){
    window.document.adjustmentForm.sku.value=num;
    }else{
    window.document.adjustmentForm.sku[cnt].value=num;
    </script>
    <link rel="stylesheet" type="text/css" href="main.css" />
    <%= EmersonGlobalConstants.TITLE %>
    </head>
    <body class="trAppId1" alink="blue" vlink="blue" link="blue">
    <form name="adjustmentForm" method="get" action="AdjustmentServlet"
    target="display">
    <center>
    <br>
    Manual Sales Application
    <br>User Name: <%=userName%>, Division Code: <%=divisionCode%>,
    Division Name: <%=divisionName%>
    <br>
    <br><br><br>
    <b>Date: </b>
    <Select name="selectedMonth" onChange="javascript:return changeMonth();">
    <%
    for(int i=0;i<months.size();i++){
    String mon = (String)months.get(i);
    System.out.println("mon *********** : "+mon);
    //mmst=Integer.parseInt(new String(((String)months.get(i)).charAt(0)));
    mmst=Integer.parseInt(String.valueOf(((String)months.get(i)).charAt(0)));
    yyst=Integer.parseInt(((String)months.get(i)).substring(3,6));
    out.println("<option value='"+ (mmst<10?"0"+mmst:mmst+"") + "/" + yyst+"' "+(selectedDate.equalsIgnoreCase((mmst<10?"0"+mmst:mmst+"") + "/" + yyst)?"selected":"") +">"+getMonth(mmst) + ", " + yyst+"</option>");
    for(int i=0;i<months.size();i++){
    String mon = (String)months.get(i);
    StringTokenizer token = new StringTokenizer(mon,"/");
    String mmm= token.nextToken();
    String yyy= token.nextToken();
    System.out.println("mon *********** : "+mon);
    mmst=Integer.parseInt(mmm);
    yyst=Integer.parseInt(yyy);
    System.out.println("selectedDate**** "+selectedDate);
    out.println("<option value='"+ (mmst<10?"0"+mmst:mmst+"") + "/" + yyst+"' "+(selectedDate.equalsIgnoreCase((mmst<10?"0"+mmst:mmst+"") + "/" + yyst)?"selected":"") +">"+getMonth(mmst) + ", " + yyst+"</option>");
    %>
    </select>
    <br><br>
    </center>
    <table id="myTable" class="tableForm" border="1" cellpadding="1" cellspacing="1" width="100%" align="center">
    <tr class="trFormHead"><td colspan="7"> Adjustment Transactions</td></tr>
    <tr>
    <td width = 2%><b>Delete</b></td>
    <td width = 25% align=center><b>Customer<font color=red> *</font></td>
    <td width = 25% align=center><b>Location<font color=red> *</font></td>
    <td width = 20% align=center><b>SKU<font color=red> *</font></td>
    <!-- <td width = 5% align=center><b>SNB</td> -->
    <td width = 9% align=center><b>Units<font color=red> *</font></td>
    <td width = 9% align=center><b>Amount<font color=red> *</font></td>
    </tr>
    <%
    int index=0;
    AdjustmentTransactionInfo transacrionInfo;
    for(;index<transactions.size();index++){
    transacrionInfo = (AdjustmentTransactionInfo)transactions.get(index);
    %>
    <input type=hidden name=adid value='<%=transacrionInfo.getAdjustmentId()%>' >
    <TR>
    <td><input type=checkbox name=chk <%=modifyAllowed?"":"disabled"%> onClick=changedisable(<%=index%>) >
    <input type=hidden name=isdelete value='false'></td>
    <td >
    <select name=customer <%=modifyAllowed?"":"disabled"%> onChange='javascript:populateLocation(<%=index%>)' >
    <OPTION VALUE="">Select Any Customer</OPTION>
    <%
    for(int i=0;i<customers.size();i++){
    CustomerLocationInfo cl =(CustomerLocationInfo)customers.get(i);
    //this is done considering that EASCustLocNum of transaction is same as EAS_Cust_Loc_Num_Key of customer table.
    String selected = cl.getLocations().containsKey(transacrionInfo.getEASCustLocNum())?"selected":"";
    out.println ("<OPTION VALUE='" + cl.getEAS_Cust_Num() + "'"+selected+">" + cl.getEAS_Cust_Name() + "</OPTION>");
    %>
    </select>
    </td>
    <td>
    <select name="location" <%=modifyAllowed?"":"disabled"%> >
    <OPTION VALUE="">Select Any Location</OPTION>
    <%
    for(int i=0;i<customers.size();i++){
    CustomerLocationInfo cl = (CustomerLocationInfo)customers.get(i);
    if(cl.getLocations().containsKey(transacrionInfo.getEASCustLocNum())){
    Hashtable locations = cl.getLocations();
    Enumeration enum = locations.keys();
    while(enum.hasMoreElements()){
    String key =(String)enum.nextElement();
    out.println ("<OPTION VALUE='" + key +"'"+(key.equalsIgnoreCase(transacrionInfo.getEASCustLocNum())?"selected":"")+">"+ locations.get(key) + "</OPTION>");
    %>
    </select>
    </td>
    <td>
    <script>
    function openURL(URL,windowName){
    </script>
    <input type=text size=10 maxlength=40 name=sku value="<%=transacrionInfo.getProductionSKUNum()%>"<%=modifyAllowed?"":"disabled"%> >
    <input type=button value="Search"onclick="javascript:window.open('SearchSKU.jsp?cnt=<%=index%>', 'SearchSKU', 'width=350,height=350,top=150,left=150,scrollbars=yes');">
    </td>
    <!--
    <td>
    <input type="checkbox" name="shipnotbilled" <%=transacrionInfo.getShipNotBilled()?"checked":""%><%=modifyAllowed?"":"disabled"%> onClick=changeisshipnotbilled(<%=index%>)><input type=hidden name=isshipnotbilled value='<%=transacrionInfo.getShipNotBilled()?"true":"false"%>'>
    </td>
    -->
    <input type=hidden name="shipnotbilled" <%=transacrionInfo.getShipNotBilled()?"checked":""%> <%=modifyAllowed?"":"disabled"%> onClick=changeisshipnotbilled(<%=index%>) ><input type=hidden name=isshipnotbilled value='<%=transacrionInfo.getShipNotBilled()?"true":"false"%>'>
    <td>
    <input type="text" size="10" name="units" value="<%=transacrionInfo.getAdjustmentQty()%>"<%=modifyAllowed?"":"disabled"%> >
    </td>
    <td>
    <input type="text" size="10" name="amount" value="<%=transacrionInfo.getAdjustmentAmt()%>" <%=modifyAllowed?"":"disabled"%> >
    </td>
    </tr>
    <%
    /*if(transactions== null || transactions.size()==0){
    out.println ("<tr><td></td><td colspan=6 align =
    center><b> Transactions not available</b></td></tr>");
    %>
    </Table>
    <br>
    <br>
    <%
    if(modifyAllowed){
    %>
    <b>AddTransaction</b>
    <br><b>Transactions marked will be deleted on submit</b>
    <br>
    <b>Fields marked with <font color=red>*</font> are mandatory.</b>
    <%
    %>
    <center>
    <br>
    <%
    if(modifyAllowed){
    %>
    <input type=submit value="Submit Form!" onClick='javascript:return validate()'>
    <%
    }else{
    %>
    <input type=button value="Back to Home Page" onClick='javascript:backtoHome()'>
    <%
    %>
    </center>
    </form>
    <br><hr>
    </body>
    </html>
    <%!
    String getMonth(int month){
    switch(month){
    case 1:
    return "JAN";
    case 2:
    return "FEB";
    case 3:
    return "MAR";
    case 4:
    return "APR";
    case 5:
    return "MAY";
    case 6:
    return "JUN";
    case 7:
    return "JUL";
    case 8:
    return "AUG";
    case 9:
    return "SEP";
    case 10:
    return "OCT";
    case 11:
    return "NOV";
    case 12:
    return "DEC";
    return "JAN";
    %>

    I haven't read your code, but can make a guess at what's going wrong. Checkboxes do behave in a weird manner depending upon whether you have selected one or many.
    Assuming this is the statement where you are generating the checkbox :
    <input type="checkbox" name="checkBoxName" value="<%= someValue %>">
    What you could do is read the checked checkBoxes in an array :
    String[] values = request.getParameterValues("checkBoxName");
    int sizeOfValues = values.length;
    Then use the sizeOfValues to perform your delete action :
    if (sizeOfValues==1)
         performDelete();
    else
         for (int i=0; i<sizeOfValues(); i++)
              performDelete();
    Hope this technique works.

  • How tdo you disable a check box

    Hi
    I'm been trying to dynamically disable (grey out) a check box using
    SET_ITEM_PROPERTY('checkbox name', ENABLED, PROPERTY_FALSE);
    This is not working and when I display the value of ENABLED using GET_ITEM_PROPERTY it shows TRUE.
    Can anyone tell me how to dynamically grey out a check box?

    Dear Friend,
    Whatever u have written is perfectly all right. Only thing can be checked is, do you have 2 items with same name if 2 different blocks. if so then provide name of block in Set_item_property statement. This technique works.
    Regards,
    Manish Trivedi
    Software Developer
    India
    [email protected]

  • Check box to copy text from 1 field to another

    I am trying to use a check box to copy the tech from a billing address text box to a shipping address text box only if the check box is checked.
    I am new to using java and building forms in acrobat so please understand.
    I have googled and tried to implement the following script in the shipping address Text field properties under format. but it doesn't work
    if (this.getfield('checkbox').value =='Yes'){SHIP_TO.value = Bill_To.value} else {Ship_To.value =""}
    thank you for any assistance

    Well you cannot use Java within a PDF form. PDF forms use JavaScript which is very different form Java.
    Have you opened the JavaScript console for the form and looked to see if there are any errors?
    You syntax for the "if' statement is wrong.
    The method for obtaining a field object is 'getField" not "getfield".
    Field names should be within quotations marks to indicate the item is a text string and not a variable name.
    Any time one needs to access a property of a field, like "value", one needs to use the field object for the named field and not the name of the field.
    this.getField("Ship_To").value  = ""
    if (this.getField('checkbox').value == 'Yes') {
    this.getField("SHIP_TO").value =  this.getField("Bill_To").value

  • Hide check box in the print preview and print of OO ALV

    Hi Experts,
                      I am working on an OO ALV Report. I am facing an issue as,
    1) I have a check box in the output of the report. If the user clicks on print or print preview the check box should not be printed.
    2) When I am printign top of page in the event PRINT_TOP_OF_PAGE, when I tried to insert new line its not printing a new line.
        please suggest me how to print empty lines in the print top of page event of OO ALV.
    Please help me to complete these issues.
    Thanks in advance.
    Regards.
    Ranganadh.

    hi,
    you can use the write statement in the print_top_of_page event of oo alv.
    regards.

  • Tri - State Checkbox in a pdf form

    Hi all,
    I'm using Adobe Acrobat 9 Standard to create forms. I want to include a tri state checkbox (Checked / Un-Unchecked / Crossed) in my form. There is an option to add checkboxes but they are only bi state ( Checked & Un Checked). Do you have any idea how to solve this?
    Best Regards,
    Sameer

    It doesn't meet your 'design spec' Sameer, but I think many of us would just include two (Y,N) or three (Y,N,N/a) checkboxes against each question and assign them all the same name (eg 'Q1'), but ticks to the Y and N/a, and a cross to the 'N', and different export values so that only one of them can be checked.
    I usually include the boxes in the original file and add a slightly bigger 'no border' checkbox in Acrobat, as I think they look better if the 'tick' is bigger than the box rather than just filling it (much like it would if done in pen and ink), but that's just a personal preference.

Maybe you are looking for

  • How do I save a message in my email acct

    How do i save an email

  • After updating to 10.8.3 my wifi won't power on

    After updating to 10.8.3 my wifi won't power on. When I click the "turn wifi on" button nothing seems to happen.  Anyone else having this issue?  Was working fine before update.

  • Trouble compiling for printed documentation

    hello, i am having trouble compiling a new document layout i have created, i have followed peter grainges instructions on his website but it always fails to generate straight away. Im using Robohelp x5 with word 2000, does anyone have any ideas? than

  • Cannot restore from Time Machine or Reinstall - MacBook Pro Yosemite

    Hi all, I recently started using a new Mac (Macbook Pro 15" with Yosemite) about 2 weeks ago. Upon startup it asked whether I wanted to encrypt and I said yes. It then froze for about 30min with the spinny wheel. After the startup was finally complet

  • Prime Infra 2.1, AP Auto Positioning

    Hi Forum, Ive a situation that our site needs to assign the AP (Access Point) into the existing NMS (Prime Infrastructure 2.1). ive already built the floor as the figure below. so ive many AP on site, how could I make it auto positioning. because, it