Checkbox Event

I've created an example of what I'm hoping to do here:
http://whendarknessfalls.org/jt/Test.html
(click Preferences tab)
Basically, when someone clicks on a checkbox, I want to
create a new tab button with a set of textboxes and input boxes
(all of this is done at runtime). I looked at the chapter of
documentation called "Creating Instances at Runtime" but I had
difficulty understanding how to do this with a TabNavigator
component.
Does anyone know how to do this? Just adding a tab to the
menu would be a start, we can talk about getting the content into
it afterwards..
I'm guessing the click event will look something along the
lines of this...
click="myTabNavigator.addchild(button, undefined,
label="Educational info")";
Or I may be completely off.. not sure =)

addChild is the right method, but don't even try to do all
this in the click hanldler declaration. Call a function, do it
there.
Tracy

Similar Messages

  • Checkbox event in REUSE_ALV_GRID_DISPLAY

    Hi,
    I have a report using REUSE_ALV_GRID_DISPLAY that a check box.. In the ALV have two quantity fields that have values not equal. then while user click on the checkbox i need to give message that quantity is not equal.
    I need to give message once user click on the checkbox itself.
    Please don't suggest that while saving the ALV we can give message use PF_STATUS_CALLBACK PROGRAM
    Sa_R

    Hi,
    &ic1 is event code for doubleclick or click when we use hotspot
    We can use it in ALV Program.
    Check the follwing program
    in this i used WHEN '&IC1'.
    REPORT zs5.
    TABLES:t001w, " plants / branches
    mard. " Storage Location data for material
    marc. " plant data for material
    TYPE-POOLS:slis.
    SELECT-OPTIONS:s_werks FOR mard-werks. "plant
    DATA:BEGIN OF it_mard OCCURS 0,
    werks LIKE mard-werks, " plant
    matnr LIKE mard-matnr, " material number
    lgort LIKE mard-lgort, " storage location
    END OF it_mard.
    DATA:BEGIN OF it_t001w OCCURS 0,
    werks LIKE t001w-werks, "plant
    name1 LIKE t001w-name1, "name
    ort01 LIKE t001w-ort01, "city
    END OF it_t001w.
    DATA: temp_werks(4) TYPE c.
    DATA: it_listheader TYPE slis_t_listheader .
    DATA: hline TYPE slis_listheader.
    DATA: it_fieldcat TYPE slis_t_fieldcat_alv,
    wa_fieldcat TYPE slis_fieldcat_alv.
    DATA: it_fieldcat1 TYPE slis_t_fieldcat_alv,
    wa_fieldcat1 TYPE slis_fieldcat_alv.
    DATA: it_events TYPE slis_t_event,
    wa_event TYPE slis_alv_event.
    DATA: wa_layout TYPE slis_layout_alv.
    START-OF-SELECTION.
    PERFORM get_data_from_mard.
    PERFORM populate_alv.
    *& Form get_data_from_mard
    FORM get_data_from_mard .
    SELECT werks
    matnr
    lgort
    FROM mard INTO TABLE it_mard WHERE werks IN s_werks.
    ENDFORM. " get_data_from_mard
    *& Form populate_alv
    FORM populate_alv .
    PERFORM populate_fieldcat.
    PERFORM event_call.
    PERFORM populate_event.
    PERFORM build_listheader USING it_listheader.
    PERFORM call_alv_grid_display.
    ENDFORM. " populate_alv
    *& Form populate_fieldcat
    FORM populate_fieldcat .
    wa_fieldcat-col_pos = 1.
    wa_fieldcat-icon = 'X'.
    wa_fieldcat-fieldname = 'WERKS'.
    wa_fieldcat-seltext_l = 'plant'.
    APPEND wa_fieldcat TO it_fieldcat.
    wa_fieldcat-col_pos = 2.
    wa_fieldcat-fieldname = 'MATNR'.
    wa_fieldcat-seltext_l = 'Material no'.
    APPEND wa_fieldcat TO it_fieldcat.
    wa_fieldcat-col_pos = 3.
    wa_fieldcat-fieldname = 'LGORT'.
    wa_fieldcat-seltext_l = 'Storage location'.
    APPEND wa_fieldcat TO it_fieldcat.
    wa_layout-zebra = 'X'.
    wa_layout-colwidth_optimize = 'X'.
    ENDFORM. " populate_fieldcat
    *& Form event_call
    FORM event_call .
    CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
    EXPORTING
    i_list_type = 0
    IMPORTING
    et_events = it_events
    EXCEPTIONS
    list_type_wrong = 1
    OTHERS = 2.
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    ENDFORM. " event_call
    *& Form populate_event
    FORM populate_event .
    READ TABLE it_events INTO wa_event WITH KEY name = 'TOP_OF_PAGE'.
    IF sy-subrc EQ 0.
    wa_event-form = 'TOP_OF_PAGE'.
    MODIFY it_events FROM wa_event TRANSPORTING form WHERE name =
    wa_event-form.
    ENDIF.
    READ TABLE it_events INTO wa_event WITH KEY name = 'USER_COMMAND'.
    IF sy-subrc EQ 0.
    wa_event-form = 'USER_COMMAND'.
    MODIFY it_events FROM wa_event TRANSPORTING form WHERE name =
    wa_event-name.
    ENDIF.
    ENDFORM. " populate_event
    *& Form build_listheader
    FORM build_listheader USING p_it_listheader.
    hline-info = 'PRIMARY LIST'.
    hline-typ = 'H'.
    APPEND hline TO it_listheader.
    ENDFORM. " build_listheader
    *& Form top-of-page
    FORM top-of-page.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
    it_list_commentary = it_listheader.
    ENDFORM. "top-of-page
    *& Form call_alv_grid_display
    FORM call_alv_grid_display .
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    i_callback_program = sy-repid
    i_callback_user_command = 'USER_COMMAND'
    i_callback_top_of_page = 'TOP-OF_PAGE'
    i_grid_title = 'FIRST LIST'
    is_layout = wa_layout
    it_fieldcat = it_fieldcat
    it_events = it_events
    TABLES
    t_outtab = it_mard
    EXCEPTIONS
    program_error = 1
    OTHERS = 2
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    ENDFORM. " call_alv_grid_display
    *& Form user_command
    FORM user_command USING r_ucomm TYPE sy-ucomm rs_selfield TYPE slis_selfield.
    CASE r_ucomm.
    WHEN '&IC1'.
    IF rs_selfield-fieldname = 'WERKS'.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
    EXPORTING
    input = rs_selfield-value
    IMPORTING
    output = temp_werks.
    temp_werks = rs_selfield-value.
    PERFORM get_data_t001w.
    PERFORM populate_fieldcat_t001w.
    PERFORM event_call_t001w.
    PERFORM populate_event_t001w.
    PERFORM build_listheader_t001w USING it_listheader.
    PERFORM alv_grid_display_t001w.
    ENDIF.
    ENDCASE.
    ENDFORM. " user_command
    *& Form get_data_t001w
    FORM get_data_t001w .
    SELECT werks
    name1
    ort01
    FROM t001w INTO TABLE it_t001w WHERE werks = temp_werks.
    ENDFORM. " get_data_t001w
    *& Form populate_fieldcat_t001w
    FORM populate_fieldcat_t001w .
    wa_fieldcat1-col_pos = 1.
    wa_fieldcat1-icon = 'X'.
    wa_fieldcat1-fieldname = 'WERKS'.
    wa_fieldcat1-seltext_l = 'plant'.
    APPEND wa_fieldcat1 TO it_fieldcat1.
    wa_fieldcat1-col_pos = 2.
    wa_fieldcat1-fieldname = 'NAME1'.
    wa_fieldcat1-seltext_l = 'Name'.
    APPEND wa_fieldcat1 TO it_fieldcat1.
    wa_fieldcat1-col_pos = 3.
    wa_fieldcat1-fieldname = 'ORT01'.
    wa_fieldcat1-seltext_l = 'City'.
    APPEND wa_fieldcat1 TO it_fieldcat1.
    wa_layout-zebra = 'X'.
    wa_layout-colwidth_optimize = 'X'.
    ENDFORM. " populate_fieldcat_t001w
    *& Form event_call_t001w
    text
    --> p1 text
    <-- p2 text
    FORM event_call_t001w .
    CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
    EXPORTING
    i_list_type = 0
    IMPORTING
    et_events = it_events
    EXCEPTIONS
    list_type_wrong = 1
    OTHERS = 2.
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    ENDFORM. " event_call_t001w
    *& Form populate_event_t001w
    FORM populate_event_t001w .
    READ TABLE it_events INTO wa_event WITH KEY name = 'TOP_OF_PAGE'.
    IF sy-subrc EQ 0.
    wa_event-form = 'TOP_OF_PAGE'.
    MODIFY it_events FROM wa_event TRANSPORTING form WHERE name = wa_event-form.
    ENDIF.
    ENDFORM. " populate_event_t001w
    *& Form build_listheader
    FORM build_listheader_t001w USING p_it_listheader.
    hline-info = 'SECONDARY LIST'.
    hline-typ = 'H'.
    APPEND hline TO it_listheader.
    ENDFORM. " build_listheader
    *& Form top-of-page_t001w
    FORM top-of-page_t001w.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
    it_list_commentary = it_listheader.
    ENDFORM. "top-of-page_t001w
    *& Form alv_grid_display_t001w
    FORM alv_grid_display_t001w .
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    i_callback_program = sy-repid
    i_callback_top_of_page = 'TOP_OF_PAGE'
    i_grid_title = 'SECONDARY LIST'
    is_layout = wa_layout
    it_fieldcat = it_fieldcat1
    it_events = it_events
    TABLES
    t_outtab = it_t001w
    EXCEPTIONS
    program_error = 1
    OTHERS = 2
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    ENDFORM. " alv_grid_display_t001w
    <b>Reward if helpful.</b>

  • Checkbox event in one mxml calling function in another mxml

    If you have multiple mxml files to break out the components,
    how can you have an event on the main application (like a checkbox)
    activate a function in the scripting on another?
    thanks

    Set up a listener on the component. See addEventListener() in
    the docs.
    Tracy

  • Checkbox event disables checkboxes

    Hi,
    I am building a Search Component for the KM Using in NW 04 Stack 14.
    In the Search Component I User Checkboxes to search in predefined Taxonomies.
    To make it more easy to our Customers there should be a Checkbox to Search in all of these predefined Taxonomies. This Checkbox is per default enabled.
    When a user select one of the other checkboxes for a single taxonomie search the checkbox should be automatically disabled.
    At the moment I use the code below to create the checkboxes.
    I tried the function setOnClick, but I don’t know the correct syntax to deactivate a checkbox by clicking another one.
    Perhaps someone of you can help me.
    Thanks
    Sascha
    private Component createCheckboxes()
                        Checkbox AGS = new Checkbox(Search_WL.m_buzzwords[1]);
                        AGS.setText(Search_WL.m_buzzwords[1]);
                        AGS.setChecked(false);
                        AGS.setTooltip(Search_WL.IndexTooltip[1]);
                        Checkbox BS = new Checkbox(Search_WL.m_buzzwords[2]);
                        BS.setText(Search_WL.m_buzzwords[2]);
                        BS.setChecked(false);
                        BS.setTooltip(Search_WL.IndexTooltip[2]);
                        Checkbox EDV = new Checkbox(Search_WL.m_buzzwords[3]);
                        EDV.setText(Search_WL.m_buzzwords[3]);
                        EDV.setChecked(false);
                        EDV.setTooltip(Search_WL.IndexTooltip[3]);
                        Checkbox FS = new Checkbox(Search_WL.m_buzzwords[4]);
                        FS.setText(Search_WL.m_buzzwords[4]);
                        FS.setChecked(false);
                        FS.setTooltip(Search_WL.IndexTooltip[4]);
                        Checkbox KHM = new Checkbox(Search_WL.m_buzzwords[5]);
                        KHM.setText(Search_WL.m_buzzwords[5]);
                        KHM.setChecked(false);
                        KHM.setTooltip(Search_WL.IndexTooltip[5]);
                        Checkbox MAKO = new Checkbox(Search_WL.m_buzzwords[6]);
                        MAKO.setText(Search_WL.m_buzzwords[6]);
                        MAKO.setChecked(false);
                        MAKO.setTooltip(Search_WL.IndexTooltip[6]);
                        Checkbox VSS = new Checkbox(Search_WL.m_buzzwords[7]);
                        VSS.setText(Search_WL.m_buzzwords[7]);
                        VSS.setChecked(false);
                        VSS.setTooltip(Search_WL.IndexTooltip[7]);
                        Checkbox VPS = new Checkbox(Search_WL.m_buzzwords[8]);
                        VPS.setText(Search_WL.m_buzzwords[8]);
                        VPS.setChecked(false);
                        VPS.setTooltip(Search_WL.IndexTooltip[8]);
                        Checkbox Vertrieb = new Checkbox(Search_WL.m_buzzwords[9]);
                        Vertrieb.setText(Search_WL.m_buzzwords[9]);
                        Vertrieb.setChecked(false);
                        Vertrieb.setTooltip(Search_WL.IndexTooltip[9]);
                        Checkbox Alle = new Checkbox(Search_WL.m_buzzwords[0]);
                        Alle.setText(Search_WL.m_buzzwords[0]);
                        Alle.setChecked(true);
                        Alle.setTooltip(Search_WL.IndexTooltip[0]);
                        GridLayout grid = new GridLayout();          
                                            grid.setWidth("100%");
                        grid.addComponent(AGS);
                        grid.addComponent(BS);                    
                        grid.addComponent(EDV);
                        grid.addComponent(FS);
                        grid.addComponent(KHM);                    
                        grid.addComponent(MAKO);
                        grid.addComponent(VSS);
                        grid.addComponent(VPS);                    
                        grid.addComponent(Vertrieb);
         grid.addComponent(Alle);
                        return grid;

    Hi Sascha,
    You can implement a javascript function to disable the other chekboxes one you click a particular chekbox. You can call this javascript function on the onClientClick of this checkbox. So when you click this checkbox all the other chekboxes will get disabled.
    in the javascript function you can write something like this..
    document.forms[0].<%= compId %>.enabled = false;
    you can get the dynamic id of the HTMLB component from your java class like this.
    compId = pageContext.getParamIdForComponent(chkBox);
    where pageContext is the IPageContext.
    hope it helps
    cheers
    Kiran

  • CheckBox reader and other bits

    Hi
    I'm a perl srcipter so I get the basics of programming even if I've got the java terminology wrong. I have a table with 4 rows 5 columns, I want to draw each row as a line on a graph and I want to be able to control which row(s) are displayed with checkboxes. The code below compiles as it stands so hopefully you can see what I'm trying to do. I have the following issues which I've been unable to sort and hope someone will point me the right way.
    Reading the checkbox events. My plan was for a boolean array (checkBoxSetting[]) which recorded true/false for each line on the graph then I could print 'if true'. Do I need to somehow call the 'itemStateChanged' method (line 7 from within the arrayExp() method (line 112)? Do I need the block commented out at lines 60-65 and if so what causes the error "addItemListener(java.awt.event.ItemListener) in javax.swing.AbstractButton cannot be applied to (arrayExp)"? Am I any where close to getting this working?
    Other problems...
    Line 124 I changed from grid layout to box layout so I don't think I sould need this line but if I comment it out I get a very small panel with nothing on it. So what should I put insead?
    Line 163 I need to scale the data by dividing the height of the y axis by the highest data value. With the test data that should be 200/400 = 0.5 but whatever I define scale as (double, float, int) I get zero as the result? (thus it's currently over written on line 164)
    I find testing as an application easyer so I plan to convert this to an applet once I've got it working. Is that a bad plan, should I just make it into an applet now the worry about functionality later?
    Any help on the above problems would be appreciated and if you want to advise on other glaring errors in my structure please do. Thanks Annie
      * 1.1 version.
    import java.awt.*;
    import java.awt.event.*;
    import java.lang.Math;
    import java.net.*;
    import java.io.*;
    import java.util.*;
    import javax.swing.*;
    public class arrayExp extends Frame
                            implements ActionListener {
         boolean inAnApplet = true;
         JCheckBox ATButton;
         JCheckBox CdButton;
         JCheckBox CuButton;
         JCheckBox PAHButton;
         boolean[] checkBoxSetting = {true,true,true,true};
         public static void main(String[] args) {
              arrayExp window = new arrayExp();
              window.inAnApplet = false;
              window.setTitle("expressions");
              window.pack();
              window.setVisible(true);
         public void actionPerformed(ActionEvent event) {
              //The only action event we get is when the
              //user requests we bring up a FileDialog.
              FileDialog fd = new FileDialog(this, "FileDialog");
              fd.setVisible(true);
         public JPanel CheckBoxPanel() {
              //Create the check boxes.
              ATButton = new JCheckBox("AT");
              ATButton.setMnemonic(KeyEvent.VK_C);
              ATButton.setSelected(true);
              checkBoxSetting[0]=true;
              CdButton = new JCheckBox("Cd");
              CdButton.setMnemonic(KeyEvent.VK_G);
              CdButton.setSelected(true);
              checkBoxSetting[1]=true;
              CuButton = new JCheckBox("Cu");
              CuButton.setMnemonic(KeyEvent.VK_H);
              CuButton.setSelected(true);
              checkBoxSetting[2]=true;
              PAHButton = new JCheckBox("PAH");
              PAHButton.setMnemonic(KeyEvent.VK_T);
              PAHButton.setSelected(true);
              checkBoxSetting[3]=true;
    /*          //Register a listener for the check boxes.
              ATButton.addItemListener(this);
              CdButton.addItemListener(this);
              CuButton.addItemListener(this);
              PAHButton.addItemListener(this);
              JPanel p = new JPanel();
              p.setLayout(new GridLayout(4,1));
              p.add(ATButton);
              p.add(CdButton);
              p.add(CuButton);
              p.add(PAHButton);
              return (p);
    // add a checkbox listener
         public void itemStateChanged(ItemEvent event) {
              char c = '-';
              Object source = event.getItemSelectable();
              if (source == ATButton) {
                   checkBoxSetting[0] = false;
                   c = 'T';
                   System.out.println("CheckBox "+c);
              else if (source == CdButton) {
                   checkBoxSetting[1] = false;
                   c = 'd';
                   System.out.println("CheckBox "+c);
              else if (source == CuButton) {
                   checkBoxSetting[2] = false;
                   c = 'u';
                   System.out.println("CheckBox "+c);
              else if (source == PAHButton) {
                   checkBoxSetting[3] = false;
                   c = 'H';
                   System.out.println("CheckBox "+c);
              //Now that we know which button was pushed, find out
              //whether it was selected or deselected.
              if (event.getStateChange() == ItemEvent.DESELECTED) {
                   System.out.println("CheckBox "+c);
                   c = '-';
              repaint();
         public arrayExp() {
              Panel canvasPanel = new Panel();
              JPanel cbp = CheckBoxPanel();
              setLayout(new BorderLayout());
              //layout area as boxes left to right
              canvasPanel.setLayout(new BoxLayout(canvasPanel, BoxLayout.LINE_AXIS));
              //Put a graph (MyCanvas) in the first box.
              canvasPanel.add(new MyCanvas());
              //Put checkboxes in the right box.
              canvasPanel.add(cbp);
              add("East", canvasPanel);  //why do I need this when I changed to a box layout?
              addWindowListener(new WindowAdapter() {
                   public void windowClosing(WindowEvent event) {
                        if (inAnApplet) {dispose();}
                        else {System.exit(0);}
    }//----------------end class arrayExp
    //paint the graph on a canvas.
    class MyCanvas extends Canvas {
         public void paint(Graphics g) {
              System.out.println("Paint");
              //tempory array of expression levels for four treatments X 5 exposures
              //to be read from database in future
              int[][] expLevels =      {  {0, 50, 120, 200, 200},
                                                 {20, 200, 100, 300, 200},
                                                 {100, 100, 100, 400, 200},
                                                 {0, 150, 200, 150, 0}  };
              //find max expression to scale y axis
              int max=0;
              for (int i=0; i<4; i++) {
                   for (int j=0; j<5; j++){
                        if (expLevels[i][j]>max) {max=expLevels[i][j];}
              //origin (form top left x right, y down)
    //      int w = getSize().width;
    //      int h = getSize().height;
              int originX=50;
              int step=100;  //distance between exposures on x axis
              int height=200;
              int originY=height+originX;
              double scale=height/max;
              scale=0.5;
              g.drawString("height"+height+"/ max"+max+" = scale"+scale, 0, originY+60);
              //set up an array of 5 colours
              Color[] EColor = new Color[5];
              EColor[0]= new Color(200,0,255); //magenta
              EColor[1]= new Color(0,0,255);      //green
              EColor[2]= new Color(0,255,0);      //blue
              EColor[3]= new Color(230,230,0); //yellow
              //draw axis
              g.setColor(Color.black);
              g.drawLine(originX, originX, originX, originY);
              g.drawLine(originX, originY, originX+(step*4), originY);
              //lable x axis
              g.drawString("LC0", originX, originY+20);
              g.drawString("LC12.5", originX+step, originY+20);
              g.drawString("LC25", originX+(step*2), originY+20);
              g.drawString("LC37.5", originX+(step*3), originY+20);
              g.drawString("LC50", originX+(step*4), originY+20);
              g.drawString("Exposure", originX+(step*2), originY+40);
              //lable y axis
              int xs=originX; int ys=originY; int zs=(int)((max/height)*0.25);
    //          g.drawString("x"+xs+" y"+ys+" zs"+zs+" max"+max+" scale"+scale, 0, originY+60);
              g.drawString("0", originX-15, originY);
              g.drawString(""+(int)(max*scale*0.25), originX-20, originY- (int) (max*scale*0.25));//400*.5=200*.25=50
              g.drawString(""+(int)(max*scale*0.50), originX-20, originY- (int) (max*scale*0.5));
              g.drawString(""+(int)(max*scale*0.75), originX-20, originY- (int) (max*scale*0.75));
              g.drawString(""+max, originX-20, originY- (int) (max*scale));
              g.drawString("Expression", originX-100, originY-(int)(height*0.5));
              int x=originX; int y;
              for (int i=0; i<4; i++) {
    //               if (checkBoxSetting) {
                        g.setColor(EColor[i]);
                        for (int j=0; j<4; j++){
                             y=j+1;
                             g.drawLine(x,originY-(int)(expLevels[i][j]*scale), x+step, originY-(int)(expLevels[i][y]*scale));
                             x=x+step;
                        x=originX;
         //If we don't specify this, the canvas might not show up at all
         //(depending on the layout manager).
         public Dimension getMinimumSize() {return new Dimension(550,300);}
         //If we don't specify this, the canvas might not show up at all
         //(depending on the layout manager).
         public Dimension getPreferredSize() {return getMinimumSize();}
    }//end-------------class MyCanvas

    To address some of your questions:
    Do I need the block commented out at lines 60-65 and if so what causes the error
    "addItemListener(java.awt.event.ItemListener) in javax.swing.AbstractButton cannot be applied
    to (arrayExp)"?Uncommenting that block would seem reasonable. However, you then have to make arrayExp implement ItemListener and provide an itemStateChanged(ItemEvent) method.
    Note that this advice only applies while you're learning. For production-quality code I wouldn't have a component also be a listener, but I'd use an (anonymous, generally) inner class.
    Line 163 I need to scale the data by dividing the height of the y axis by the highest data
    value. With the test data that should be 200/400 = 0.5 but whatever I define scale as (double,
    float, int) I get zero as the result?The problem is on the right hand side of the = sign. You're dividing an int by an int, and that performs integer division. The tidiest way of fixing this is to cast the expression after the / to double:           double scale=height/(double)max;Whenever division produces suspicious zeroes that's something to check.
    if you want to advise on other glaring errors in my structure please do.MyCanvas seems to do an awful lot of work in the paint method. All of the bits which set up data should be pulled out, probably into the constructor. (Some people would disagree with me and have an init() method instead. There are pros and cons).

  • To check the checkbox dynamically used in thmlb tag

    Hi all,
    I am new to crm 2007,
      I have added a thtmlb tab to create a checkbox. I am able to get checkbox event to get value of the check box and process. But when reopen the  view the check box should be checked  dynamically depending on the conditions.
                   how to make a check box checked dynamically.
    Thanks
    Hema

    Hi john,
    I have table control with fore fileds like this..
    'text box'-------'get button'.
    chkbox---item-material---qty
    box1--1abcde--
    10
    box2--2xyhnb--
    20
    Nothing is allow input value except chkbox.
    Values are coming by one text box above this table.
    Text box allow input value..
    if i click box1 ...that row will be selected and it takes to second screen.....
    But this box is not allowing to check...
    kaki
    Message was edited by: Kaki R
    Message was edited by: Kaki R

  • Event handling between JComboBox & JCheckBox

    Hi.
    My problem is that when i click on the JCheckBox object, the code (i have) also executes the condition for JComboBox object. I assume there is a very simple solution, but i have yet to find it.
    This is the code i'm using:
         public void itemStateChanged(ItemEvent e){
              if(qcmCheckBox.isSelected()){
                   System.out.println("checkbox selected");
              if(e.getStateChange() == ItemEvent.SELECTED){
                   System.out.println("combo selected " + comboBoxOptions.getSelectedIndex());
         }My problem is, i think, that the e.getStateChange() is always returning true. I just haven't figured out a way to 'single out' when the JComboBox is selected.

    thanks for the tip, but that didn't exactly work.
    these are my steps:
    select second drop down option (out of 3)
    select checkbox
    deselect checkbox
    old output
    combo selected1
    qcm selected
    combo selected1new output (using instanceof)
    combo selected 1
    combo selected 1
    checkbox selected
    combo selected 1
    combo selected 1here's my code:
    // setting up vars
    private JCheckBox checkBox = new JCheckBox();
    private final String comboNames[] = {"Option 1", "Option 2", "Option 3"};
    private JComboBox comboBoxOptions = new JComboBox(comboNames);
    // combo box
    comboBoxOptions.addItemListener(this);
    // checkbox
    checkBox.addItemListener(this);
    // event handler
    public void itemStateChanged(ItemEvent e){
         if(checkBox.isSelected()){
              System.out.println("checkbox selected");
         //if(comboBoxOptions instanceof JComboBox){ // the suggested alternative
         if(e.getStateChange() == ItemEvent.SELECTED){
              System.out.println("combo selected " + comboBoxOptions.getSelectedIndex());
    }For some reason, the suggested answer gives me duplicate entries for the dropdown and it still gives me duplicate entries when i click on the checkbox.
    Again, what i'm trying to do is just get the checkbox not to execute the 2nd if statement "if(e.getStateChange() == ItemEvent.SELECTED){"
    I think the statement "e.getStateChange()" is returning everything true because its an event happening but i don't know a way to single the checkbox event.
    I would appreciate all the help I can get. Thanks.
    sijis

  • Dynamic Tree menu with checkbox

    Dear Boss
    Now I am in a problem for some task. But I have not ever done these. Please help me if you possible for you. I need a tree menu in java which has the following attributes:
    v This check box will implement on Oracle form
    v Checkbox Event tracking
    v On check event data will save in database
    v On check event text item of form will be re-query
    I am looking for your reply
    Aktar Chowdhury

    Play around with it, it is simpler than you think! Add a spry menu to a page with a css menu on it, see how it is structured, then make the changes to get the results you want. A Spry menu uses a UL/LI structure very similar to that generated by css_menu, you just need to add a class to the LI.
    //CSS Dynamic Menus required file
    require_once('includes/cssmenus2/gwb_Menu2.inc.php');
    //Begin Menu1
      $Menu1 = new MX_Menu2('MenuBar1');
      $Menu1->setQuery($rs_Menu1);
      $Menu1->setPK("MenuID");
      $Menu1->setFK("ParentID");
      $Menu1->setNameField("MenuLabel");
      $Menu1->setTitleField("Tip");
      //URL parameters
      $Menu1->setLinkField("Link");
      $Menu1->setTargetField("");
      // Layout
      $Menu1->setLevel(-1);
      $Menu1->setSkin("MenuBarVertical");  <---------
    //End Menu1
    body
    <?php  // Dynamic CSS Menu 
      echo $Menu1->render();
    ?>
    css_menu2.inc.php
      foreach($this->DBItems[$id] as $key=>$val){
        $li_class = ' class="MenuBarItemSubmenu"';     <-----
        //the efective row

  • How to access TileList checkboxes?

    I have a question that should be relatively easy for you
    veteran Flex developers. I am rendering a series of checkboxes into
    a TileList component via a dataProvider. How can I enumerate all
    checkboxes to determine the checked state of each?
    Here is how I generate my TileList:
    <mx:TileList allowMultipleSelection="true"
    click="handleCheckState(event.target)" id="tlDeptList"
    maxColumns="10" rowHeight="30" columnWidth="70"
    itemRenderer="mx.controls.CheckBox" x="10" y="79" width="478"
    height="229"/>
    I can get the data from the tlDeptList.dataProvider property,
    but I can't seem to locate where the checked (selected) state for
    the rendered checkboxes is located. <shrug>
    Thanks in advance...
    Regards,
    Chris

    This may help.
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="absolute">
    <mx:Script>
    <![CDATA[
    import mx.containers.Box;
    import mx.controls.CheckBox;
    private function handleCheckState(event:Event):void {
    var tempCB:CheckBox = CheckBox(event.target);
    trace(tempCB.selected);
    ]]>
    </mx:Script>
    <mx:TileList allowMultipleSelection="true"
    click="handleCheckState(event)"
    id="tlDeptList" maxColumns="10" rowHeight="30"
    columnWidth="70"
    itemRenderer="mx.controls.CheckBox" x="10" y="79"
    width="478" height="229">
    <mx:dataProvider>
    <mx:String>Item1</mx:String>
    <mx:String>Item2</mx:String>
    <mx:String>Item3</mx:String>
    </mx:dataProvider>
    </mx:TileList>
    </mx:Application>

  • Possible to show/hide sections in a table?

    Hello all,
    First post here. I've only started using LiveCycle Designer a few weeks ago, never knowing that it came with my Acrobat. I've been busy converting forms we use in our business into pdf versions that can be filled, and created some with simple scripting etc.  Anyway my most ambitious effort to date is to create a gross payroll calculator in which I would enter the total hours worked for each employee and the gross payroll is calculated. The calculations I have no issue with.
    I am using a hidden "config" subform (thanks to kingphysh for your easy and simple example!) to store the employee names and payrates and the department they work in.
    My main form, the one on which I am entering total time for each employee, consists of a table with a section for each department. Thus I can put all employees in a department in one section of the table and then easily do subtotals by department etc.
    Table1
    Table1.Section1
          Dept. Name | Emp. Name | Pay Rate | Total Hrs | Gross Pay|  <-- this would be one row in the section     
    Table1.Section2
          Dept. Name | Emp. Name | Pay Rate | Total Hrs | Gross Pay|
    Table1.Section3
          Dept. Name | Emp. Name | Pay Rate | Total Hrs | Gross Pay|
    and so on. Each section also has a footer row for subtotals.
    This form will be used at various physical locations and not every location will have all departments. Thus I want the table to show only those sections for which the corresponding departments exist based on a selection (checkbox) that is on the hidden config page.
    Its not so much the actual scripting thats a problem, but where to put the script. Should I use a Table1 event or the checkbox event? I've tried both but neither works as desired. Or should I use an event for the individual rows in the section itself?
    Any pointers and suggestions will be greatly appreciated!
    Harry.

    Niall,
    Many thanks for all your help. With the examples you provided, I have been able to almost finish the form and learned a little bit along the way too.
    There are a couple of things still vexing me though.
    My form's hierarchy is as follows:
    page1 (flowed)
         - wrapper (flowed)
              - form1  (positioned)  <-- sub-form (form on which data is entered and calculation results are displayed_
                   - table1
                        -HEADER
                        -Section1 - bodyrow
                                       - section1 footer
                        -Section2 - bodyrow
                                        - section2 footer
                        -FOOTER
              - config   (positioned) <--  sub-form (normally hidden "config" form which stores employee data - accessed by password
                   - table1
    The sub-form form1 contains a table with six sections. Each section represents one department and has  body rows and a footer row for subtotals.
    the number of body rows in each section can vary with the number of employees in the department.
    I have two issues remaining with the form and it will be done. Hopefully you will be able to point me in the right direction.
    1. Pagination - in the form, I have set page1 to "flowed". wrapper is also flowed. form1 is positioned.
         I would like to be able to set it so that if any section is going to be split, it would go onto the next page.
         The header should be repeated in each page. Each section footer should be with the section, and the Table footer should be on the last page.
    2. Column Subtotals
         I have set the form to be as general purpose as possible. Thus it can take time totals in either decimal or HH:MM format. I am having trouble adding columns of time totals in HH:MM format.
    For example, given 3 time totals (all are in text fields):
    10:35
    15:59
    03:24
    I would thing the best way to do this is to parse the strings and add the minutes and hrs separately and then depending on the total of the minutes, use the floor and mod functions to get the correct total. I just can't get it to add the columns at all.
    This is the code I am using to add the column:
    if (_FD.count gt 0) then   //make sure at least one body row exists in this section
    for i = 1 upto (_FD.count) do
    mins = Sum(Right (FD[i].fdr_tot[i], 2))        // FD is the row and fdr_tot is the cell in the row which is to be included in the calc.
    hrs = Sum(Left (FD[i].fdr_tot[i], (Len (FD[i].fdr_tot[i]) - 3)))
    endfor
    endif
    I've tried using the code below as well to no avail.
    mins = Sum(Right (FD[*].fdr_tot[*], 2))
    hrs = Sum(Left (FD[*].fdr_tot[*], (Len (FD[*].fdr_tot[*]) - 3)))
    Any suggestions will be greatly appreciated.
    Thanks.

  • Why is this an error???  I don't understand why it is... Help Please

    Hi,
    Ok, I'll preface this by saying there's a lotta code pasted in here but it really quite an easy question, I just need to post all the code so you understand where what came from.
    Now.............the question I'm trying to do is to create an applet that has 2 buttons -- each button when clicked opens an application (one is a simple calculator, the other a Mortgage calculation app). When you click one of the buttons (calc or mortgage), that app opens infront of the 2 button menu so its in "focus". The button on the 2 button menu then switches to a "hide app X" button (ie: "Mortgage", changes to "Hide Mortgage"). Thus if you click the hide button, the app that was opened is hidden, and then that "hide" button switches back to the original "app X" button. Pretty simple.
    Now, I have from my text book an example that does exactly this, with the simple calculator already in it, and with another app (a traffic light thing) where the Mortgage should be in my final product. I also already have the Mortgage applet I need to insert from another book example in place of that Traffic Light portion.
    Now, common sense would dictate that I should be able to just copy my code for the Mortgage applet into the example that has the 2 button menu structure, and overwrite the code I want to get rid of (the traffic light) with the mortgage code & rename the menu buttons. Right?? A simple switch of one thing for another... but therein lies my problem.
    I copied all the Mortgage code in correctly over the traffic lights, switched the button names, tried to compile it but I get one error....
    Exercise12_17.java:52: cannot resolve symbol
    symbol  : method pack ()
    location: class MortgageApplet
            mortgageAppletFrame.pack();I don't understand why..... mortgageAppletFrame.pack(); was a simple rewrite from lightsFrame.pack(); like every other line...... it should work. I've gone over it for 2 days......... Anyone know why it comes up as an error???
    Below, in order going down is (1)my code with the 1 error I can't solve, (2)the original menu example I tried to edit, and (3)the Mortgage app code...........
    Does anyone know what my error is?? Help or a hint would be greatly appreciated........ Thanks.
    My erroring app.......
    // Exercise12_17.java: Create multiple windows
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.border.TitledBorder;
    public class Exercise12_17 extends JFrame implements ActionListener {
      // Declare and create a frame: an instance of MenuDemo
      MenuDemo calcFrame = new MenuDemo();
      // Declare and create a frame: an instance of RadioButtonDemo
      MortgageApplet mortgageAppletFrame = new MortgageApplet();
      // Declare two buttons for displaying frames
      private JButton jbtCalc;
      private JButton jbtMortgage;
      public static void main(String[] args) {
        Exercise12_17 frame = new Exercise12_17();
        frame.setSize( 400, 70 );
        frame.setTitle("Exercise 11.8: Multiple Windows Demo");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);
      public Exercise12_17() {
        // Add buttons to the main frame
        getContentPane().setLayout(new FlowLayout());
        getContentPane().add(jbtCalc = new JButton("Simple Calculator"));
         getContentPane().add(jbtMortgage = new JButton("Mortgage"));
        // Register the main frame as listener for the buttons
        jbtCalc.addActionListener(this);
         jbtMortgage.addActionListener(this);
      public void actionPerformed(ActionEvent e) {
        String arg = e.getActionCommand();
        if (e.getSource() instanceof JButton)
          if ("Simple Calculator".equals(arg)) {
            //show the MenuDemo frame
            jbtCalc.setText("Hide Simple Calculator");
            calcFrame.pack();
            calcFrame.setVisible(true);
          else if ("Hide Simple Calculator".equals(arg)) {
            calcFrame.setVisible(false);
            jbtCalc.setText("Simple Calculator");
          else if ("Mortgage".equals(arg)) {
            //show the CheckboxGroup frame
            mortgageAppletFrame.pack();
            jbtMortgage.setText("Hide Mortgage");
            mortgageAppletFrame.setVisible(true);
          else if ("Hide Mortgage".equals(arg)) {
            mortgageAppletFrame.setVisible(false);
            jbtMortgage.setText("Mortgage");
      class MortgageApplet extends JApplet
      implements ActionListener {
      // Declare and create text fields for interest rate
      // year, loan amount, monthly payment, and total payment
      private JTextField jtfAnnualInterestRate = new JTextField();
      private JTextField jtfNumOfYears = new JTextField();
      private JTextField jtfLoanAmount = new JTextField();
      private JTextField jtfMonthlyPayment = new JTextField();
      private JTextField jtfTotalPayment = new JTextField();
      // Declare and create a Compute Mortgage button
      private JButton jbtComputeMortgage = new JButton("Compute Mortgage");
      /** Initialize user interface */
      public void init() {
        // Set properties on the text fields
        jtfMonthlyPayment.setEditable(false);
        jtfTotalPayment.setEditable(false);
        // Right align text fields
        jtfAnnualInterestRate.setHorizontalAlignment(JTextField.RIGHT);
        jtfNumOfYears.setHorizontalAlignment(JTextField.RIGHT);
        jtfLoanAmount.setHorizontalAlignment(JTextField.RIGHT);
        jtfMonthlyPayment.setHorizontalAlignment(JTextField.RIGHT);
        jtfTotalPayment.setHorizontalAlignment(JTextField.RIGHT);
        // Panel p1 to hold labels and text fields
        JPanel p1 = new JPanel();
        p1.setLayout(new GridLayout(5, 2));
        p1.add(new Label("Annual Interest Rate"));
        p1.add(jtfAnnualInterestRate);
        p1.add(new Label("Number of Years"));
        p1.add(jtfNumOfYears);
        p1.add(new Label("Loan Amount"));
        p1.add(jtfLoanAmount);
        p1.add(new Label("Monthly Payment"));
        p1.add(jtfMonthlyPayment);
        p1.add(new Label("Total Payment"));
        p1.add(jtfTotalPayment);
        p1.setBorder(new
          TitledBorder("Enter interest rate, year and loan amount"));
        // Panel p2 to hold the button
        JPanel p2 = new JPanel();
        p2.setLayout(new FlowLayout(FlowLayout.RIGHT));
        p2.add(jbtComputeMortgage);
        // Add the components to the applet
        getContentPane().add(p1, BorderLayout.CENTER);
        getContentPane().add(p2, BorderLayout.SOUTH);
        // Register listener
        jbtComputeMortgage.addActionListener(this);
      /** Handle the "Compute Mortgage" button */
      public void actionPerformed(ActionEvent e) {
        if (e.getSource() == jbtComputeMortgage) {
          // Get values from text fields
          double interest = (Double.valueOf(
            jtfAnnualInterestRate.getText())).doubleValue();
          int year =
            (Integer.valueOf(jtfNumOfYears.getText())).intValue();
          double loan =
            (Double.valueOf(jtfLoanAmount.getText())).doubleValue();
          // Create a mortgage object
          Mortgage m = new Mortgage(interest, year, loan);
          // Display monthly payment and total payment
          jtfMonthlyPayment.setText(String.valueOf(m.monthlyPayment()));
          jtfTotalPayment.setText(String.valueOf(m.totalPayment()));
    class MenuDemo extends JFrame implements ActionListener {
      // Text fields for Number 1, Number 2, and Result
      private JTextField jtfNum1, jtfNum2, jtfResult;
      // Buttons "Add", "Subtract", "Multiply" and "Divide"
      private JButton jbtAdd, jbtSub, jbtMul, jbtDiv;
      // Menu items "Add", "Subtract", "Multiply","Divide" and "Close"
      private JMenuItem jmiAdd, jmiSub, jmiMul, jmiDiv, jmiClose;
      /** Main method */
      public static void main(String[] args) {
        MenuDemo frame = new MenuDemo();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setVisible(true);
      /** Default constructor */
      public MenuDemo() {
        setTitle("Menu Demo");
        // Create menu bar
        JMenuBar jmb = new JMenuBar();
        // Set menu bar to the frame
        setJMenuBar(jmb);
        // Add menu "Operation" to menu bar
        JMenu operationMenu = new JMenu("Operation");
        operationMenu.setMnemonic('O');
        jmb.add(operationMenu);
        // Add menu "Exit" in menu bar
        JMenu exitMenu = new JMenu("Exit");
        exitMenu.setMnemonic('E');
        jmb.add(exitMenu);
        // Add menu items with mnemonics to menu "Operation"
        operationMenu.add(jmiAdd= new JMenuItem("Add", 'A'));
        operationMenu.add(jmiSub = new JMenuItem("Subtract", 'S'));
        operationMenu.add(jmiMul = new JMenuItem("Multiply", 'M'));
        operationMenu.add(jmiDiv = new JMenuItem("Divide", 'D'));
        exitMenu.add(jmiClose = new JMenuItem("Close", 'C'));
        // Set keyboard accelerators
        jmiAdd.setAccelerator(
          KeyStroke.getKeyStroke(KeyEvent.VK_A, ActionEvent.CTRL_MASK));
        jmiSub.setAccelerator(
          KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK));
        jmiMul.setAccelerator(
          KeyStroke.getKeyStroke(KeyEvent.VK_M, ActionEvent.CTRL_MASK));
        jmiDiv.setAccelerator(
          KeyStroke.getKeyStroke(KeyEvent.VK_D, ActionEvent.CTRL_MASK));
        // Panel p1 to hold text fields and labels
        JPanel p1 = new JPanel();
        p1.setLayout(new FlowLayout());
        p1.add(new JLabel("Number 1"));
        p1.add(jtfNum1 = new JTextField(3));
        p1.add(new JLabel("Number 2"));
        p1.add(jtfNum2 = new JTextField(3));
        p1.add(new JLabel("Result"));
        p1.add(jtfResult = new JTextField(4));
        jtfResult.setEditable(false);
        // Panel p2 to hold buttons
        JPanel p2 = new JPanel();
        p2.setLayout(new FlowLayout());
        p2.add(jbtAdd = new JButton("Add"));
        p2.add(jbtSub = new JButton("Subtract"));
        p2.add(jbtMul = new JButton("Multiply"));
        p2.add(jbtDiv = new JButton("Divide"));
        // Add panels to the frame
        getContentPane().setLayout(new BorderLayout());
        getContentPane().add(p1, BorderLayout.CENTER);
        getContentPane().add(p2, BorderLayout.SOUTH);
        // Register listeners
        jbtAdd.addActionListener(this);
        jbtSub.addActionListener(this);
        jbtMul.addActionListener(this);
        jbtDiv.addActionListener(this);
        jmiAdd.addActionListener(this);
        jmiSub.addActionListener(this);
        jmiMul.addActionListener(this);
        jmiDiv.addActionListener(this);
        jmiClose.addActionListener(this);
      /** Handle ActionEvent from buttons and menu items */
      public void actionPerformed(ActionEvent e) {
        String actionCommand = e.getActionCommand();
        // Handle button events
        if (e.getSource() instanceof JButton) {
          if ("Add".equals(actionCommand))
            calculate('+');
          else if ("Subtract".equals(actionCommand))
            calculate('-');
          else if ("Multiply".equals(actionCommand))
            calculate('*');
          else if ("Divide".equals(actionCommand))
            calculate('/');
        else if (e.getSource() instanceof JMenuItem) {
          // Handle menu item events
          if ("Add".equals(actionCommand))
            calculate('+');
          else if ("Subtract".equals(actionCommand))
            calculate('-');
          else if ("Multiply".equals(actionCommand))
            calculate('*');
          else if ("Divide".equals(actionCommand))
            calculate('/');
          else if ("Close".equals(actionCommand))
            System.exit(0);
      /** Calculate and show the result in jtfResult */
      private void calculate(char operator) {
        // Obtain Number 1 and Number 2
        int num1 = (Integer.parseInt(jtfNum1.getText().trim()));
        int num2 = (Integer.parseInt(jtfNum2.getText().trim()));
        int result = 0;
        // Perform selected operation
        switch (operator) {
          case '+': result = num1 + num2;
                    break;
          case '-': result = num1 - num2;
                    break;
          case '*': result = num1 * num2;
                    break;
          case '/': result = num1 / num2;
        // Set result in jtfResult
        jtfResult.setText(String.valueOf(result));
    Original 2 button menu example....
    // Exercise11_8.java: Create multiple windows
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Exercise11_8 extends JFrame implements ActionListener {
      // Declare and create a frame: an instance of MenuDemo
      MenuDemo calcFrame = new MenuDemo();
      // Declare and create a frame: an instance of RadioButtonDemo
      RadioButtonDemo lightsFrame = new RadioButtonDemo();
      // Declare two buttons for displaying frames
      private JButton jbtCalc;
      private JButton jbtLights;
      public static void main(String[] args) {
        Exercise11_8 frame = new Exercise11_8();
        frame.setSize( 400, 70 );
        frame.setTitle("Exercise 11.8: Multiple Windows Demo");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);
      public Exercise11_8() {
        // Add buttons to the main frame
        getContentPane().setLayout(new FlowLayout());
        getContentPane().add(jbtCalc = new JButton("Simple Calculator"));
        getContentPane().add(jbtLights = new JButton("Traffic Lights"));
        // Register the main frame as listener for the buttons
        jbtCalc.addActionListener(this);
        jbtLights.addActionListener(this);
      public void actionPerformed(ActionEvent e) {
        String arg = e.getActionCommand();
        if (e.getSource() instanceof JButton)
          if ("Simple Calculator".equals(arg)) {
            //show the MenuDemo frame
            jbtCalc.setText("Hide Simple Calculator");
            calcFrame.pack();
            calcFrame.setVisible(true);
          else if ("Hide Simple Calculator".equals(arg)) {
            calcFrame.setVisible(false);
            jbtCalc.setText("Simple Calculator");
          else if ("Traffic Lights".equals(arg)) {
            //show the CheckboxGroup frame
            lightsFrame.pack();
            jbtLights.setText("Hide Traffic Lights");
            lightsFrame.setVisible(true);
          else if ("Hide Traffic Lights".equals(arg)) {
            lightsFrame.setVisible(false);
            jbtLights.setText("Traffic Lights");
         class RadioButtonDemo extends JFrame
      implements ItemListener {
      // Declare radio buttons
      private JRadioButton jrbRed, jrbYellow, jrbGreen;
      // Declare a radio button group
      private ButtonGroup btg = new ButtonGroup();
      // Declare a traffic light display panel
      private Light light;
      /** Main method */
      public static void main(String[] args) {
        RadioButtonDemo frame = new RadioButtonDemo();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(250, 170);
        frame.setVisible(true);
      /** Default constructor */
      public RadioButtonDemo() {
        setTitle("RadioButton Demo");
        // Add traffic light panel to panel p1
        JPanel p1 = new JPanel();
        p1.setSize(200, 200);
        p1.setLayout(new FlowLayout(FlowLayout.CENTER));
        light = new Light();
        light.setSize(40, 90);
        p1.add(light);
        // Put the radio button in Panel p2
        JPanel p2 = new JPanel();
        p2.setLayout(new FlowLayout());
        p2.add(jrbRed = new JRadioButton("Red", true));
        p2.add(jrbYellow = new JRadioButton("Yellow", false));
        p2.add(jrbGreen = new JRadioButton("Green", false));
        // Set keyboard mnemonics
        jrbRed.setMnemonic('R');
        jrbYellow.setMnemonic('Y');
        jrbGreen.setMnemonic('G');
        // Group radio buttons
        btg.add(jrbRed);
        btg.add(jrbYellow);
        btg.add(jrbGreen);
        // Place p1 and p2 in the frame
        getContentPane().setLayout(new BorderLayout());
        getContentPane().add(p1, BorderLayout.CENTER);
        getContentPane().add(p2, BorderLayout.SOUTH);
        // Register listeners for check boxes
        jrbRed.addItemListener(this);
        jrbYellow.addItemListener(this);
        jrbGreen.addItemListener(this);
      /** Handle checkbox events */
      public void itemStateChanged(ItemEvent e) {
        if (jrbRed.isSelected())
          light.turnOnRed(); // Set red light
        if (jrbYellow.isSelected())
          light.turnOnYellow(); // Set yellow light
        if (jrbGreen.isSelected())
          light.turnOnGreen(); // Set green light
    // Three traffic lights shown in a panel
    class Light extends JPanel {
      private boolean red;
      private boolean yellow;
      private boolean green;
      /** Default constructor */
      public Light() {
        turnOnGreen();
      /** Set red light on */
      public void turnOnRed() {
        red = true;
        yellow = false;
        green = false;
        repaint();
      /** Set yellow light on */
      public void turnOnYellow() {
        red = false;
        yellow = true;
        green = false;
        repaint();
      /** Set green light on */
      public void turnOnGreen() {
        red = false;
        yellow = false;
        green = true;
        repaint();
      /** Display lights */
      public void paintComponent(Graphics g) {
        super.paintComponent(g);
        if (red) {
          g.setColor(Color.red);
          g.fillOval(10, 10, 20, 20);
          g.setColor(Color.black);
          g.drawOval(10, 35, 20, 20);
          g.drawOval(10, 60, 20, 20);
          g.drawRect(5, 5, 30, 80);
        else if (yellow) {
          g.setColor(Color.yellow);
          g.fillOval(10, 35, 20, 20);
          g.setColor(Color.black);
          g.drawRect(5, 5, 30, 80);
          g.drawOval(10, 10, 20, 20);
          g.drawOval(10, 60, 20, 20);
        else if (green) {
          g.setColor(Color.green);
          g.fillOval(10, 60, 20, 20);
          g.setColor(Color.black);
          g.drawRect(5, 5, 30, 80);
          g.drawOval(10, 10, 20, 20);
          g.drawOval(10, 35, 20, 20);
        else {
          g.setColor(Color.black);
          g.drawRect(5, 5, 30, 80);
          g.drawOval(10, 10, 20, 20);
          g.drawOval(10, 35, 20, 20);
          g.drawOval(10, 60, 20, 20);
      /** Set preferred size */
      public Dimension getPreferredSize() {
        return new Dimension(40, 90);
    class MenuDemo extends JFrame implements ActionListener {
      // Text fields for Number 1, Number 2, and Result
      private JTextField jtfNum1, jtfNum2, jtfResult;
      // Buttons "Add", "Subtract", "Multiply" and "Divide"
      private JButton jbtAdd, jbtSub, jbtMul, jbtDiv;
      // Menu items "Add", "Subtract", "Multiply","Divide" and "Close"
      private JMenuItem jmiAdd, jmiSub, jmiMul, jmiDiv, jmiClose;
      /** Main method */
      public static void main(String[] args) {
        MenuDemo frame = new MenuDemo();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setVisible(true);
      /** Default constructor */
      public MenuDemo() {
        setTitle("Menu Demo");
        // Create menu bar
        JMenuBar jmb = new JMenuBar();
        // Set menu bar to the frame
        setJMenuBar(jmb);
        // Add menu "Operation" to menu bar
        JMenu operationMenu = new JMenu("Operation");
        operationMenu.setMnemonic('O');
        jmb.add(operationMenu);
        // Add menu "Exit" in menu bar
        JMenu exitMenu = new JMenu("Exit");
        exitMenu.setMnemonic('E');
        jmb.add(exitMenu);
        // Add menu items with mnemonics to menu "Operation"
        operationMenu.add(jmiAdd= new JMenuItem("Add", 'A'));
        operationMenu.add(jmiSub = new JMenuItem("Subtract", 'S'));
        operationMenu.add(jmiMul = new JMenuItem("Multiply", 'M'));
        operationMenu.add(jmiDiv = new JMenuItem("Divide", 'D'));
        exitMenu.add(jmiClose = new JMenuItem("Close", 'C'));
        // Set keyboard accelerators
        jmiAdd.setAccelerator(
          KeyStroke.getKeyStroke(KeyEvent.VK_A, ActionEvent.CTRL_MASK));
        jmiSub.setAccelerator(
          KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK));
        jmiMul.setAccelerator(
          KeyStroke.getKeyStroke(KeyEvent.VK_M, ActionEvent.CTRL_MASK));
        jmiDiv.setAccelerator(
          KeyStroke.getKeyStroke(KeyEvent.VK_D, ActionEvent.CTRL_MASK));
        // Panel p1 to hold text fields and labels
        JPanel p1 = new JPanel();
        p1.setLayout(new FlowLayout());
        p1.add(new JLabel("Number 1"));
        p1.add(jtfNum1 = new JTextField(3));
        p1.add(new JLabel("Number 2"));
        p1.add(jtfNum2 = new JTextField(3));
        p1.add(new JLabel("Result"));
        p1.add(jtfResult = new JTextField(4));
        jtfResult.setEditable(false);
        // Panel p2 to hold buttons
        JPanel p2 = new JPanel();
        p2.setLayout(new FlowLayout());
        p2.add(jbtAdd = new JButton("Add"));
        p2.add(jbtSub = new JButton("Subtract"));
        p2.add(jbtMul = new JButton("Multiply"));
        p2.add(jbtDiv = new JButton("Divide"));
        // Add panels to the frame
        getContentPane().setLayout(new BorderLayout());
        getContentPane().add(p1, BorderLayout.CENTER);
        getContentPane().add(p2, BorderLayout.SOUTH);
        // Register listeners
        jbtAdd.addActionListener(this);
        jbtSub.addActionListener(this);
        jbtMul.addActionListener(this);
        jbtDiv.addActionListener(this);
        jmiAdd.addActionListener(this);
        jmiSub.addActionListener(this);
        jmiMul.addActionListener(this);
        jmiDiv.addActionListener(this);
        jmiClose.addActionListener(this);
      /** Handle ActionEvent from buttons and menu items */
      public void actionPerformed(ActionEvent e) {
        String actionCommand = e.getActionCommand();
        // Handle button events
        if (e.getSource() instanceof JButton) {
          if ("Add".equals(actionCommand))
            calculate('+');
          else if ("Subtract".equals(actionCommand))
            calculate('-');
          else if ("Multiply".equals(actionCommand))
            calculate('*');
          else if ("Divide".equals(actionCommand))
            calculate('/');
        else if (e.getSource() instanceof JMenuItem) {
          // Handle menu item events
          if ("Add".equals(actionCommand))
            calculate('+');
          else if ("Subtract".equals(actionCommand))
            calculate('-');
          else if ("Multiply".equals(actionCommand))
            calculate('*');
          else if ("Divide".equals(actionCommand))
            calculate('/');
          else if ("Close".equals(actionCommand))
            System.exit(0);
      /** Calculate and show the result in jtfResult */
      private void calculate(char operator) {
        // Obtain Number 1 and Number 2
        int num1 = (Integer.parseInt(jtfNum1.getText().trim()));
        int num2 = (Integer.parseInt(jtfNum2.getText().trim()));
        int result = 0;
        // Perform selected operation
        switch (operator) {
          case '+': result = num1 + num2;
                    break;
          case '-': result = num1 - num2;
                    break;
          case '*': result = num1 * num2;
                    break;
          case '/': result = num1 / num2;
        // Set result in jtfResult
        jtfResult.setText(String.valueOf(result));
    Mortgage applet code....
    // MortgageApplet.java: Applet for computing mortgage payments
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.border.TitledBorder;
    public class MortgageApplet extends JApplet
      implements ActionListener {
      // Declare and create text fields for interest rate
      // year, loan amount, monthly payment, and total payment
      private JTextField jtfAnnualInterestRate = new JTextField();
      private JTextField jtfNumOfYears = new JTextField();
      private JTextField jtfLoanAmount = new JTextField();
      private JTextField jtfMonthlyPayment = new JTextField();
      private JTextField jtfTotalPayment = new JTextField();
      // Declare and create a Compute Mortgage button
      private JButton jbtComputeMortgage = new JButton("Compute Mortgage");
      /** Initialize user interface */
      public void init() {
        // Set properties on the text fields
        jtfMonthlyPayment.setEditable(false);
        jtfTotalPayment.setEditable(false);
        // Right align text fields
        jtfAnnualInterestRate.setHorizontalAlignment(JTextField.RIGHT);
        jtfNumOfYears.setHorizontalAlignment(JTextField.RIGHT);
        jtfLoanAmount.setHorizontalAlignment(JTextField.RIGHT);
        jtfMonthlyPayment.setHorizontalAlignment(JTextField.RIGHT);
        jtfTotalPayment.setHorizontalAlignment(JTextField.RIGHT);
        // Panel p1 to hold labels and text fields
        JPanel p1 = new JPanel();
        p1.setLayout(new GridLayout(5, 2));
        p1.add(new Label("Annual Interest Rate"));
        p1.add(jtfAnnualInterestRate);
        p1.add(new Label("Number of Years"));
        p1.add(jtfNumOfYears);
        p1.add(new Label("Loan Amount"));
        p1.add(jtfLoanAmount);
        p1.add(new Label("Monthly Payment"));
        p1.add(jtfMonthlyPayment);
        p1.add(new Label("Total Payment"));
        p1.add(jtfTotalPayment);
        p1.setBorder(new
          TitledBorder("Enter interest rate, year and loan amount"));
        // Panel p2 to hold the button
        JPanel p2 = new JPanel();
        p2.setLayout(new FlowLayout(FlowLayout.RIGHT));
        p2.add(jbtComputeMortgage);
        // Add the components to the applet
        getContentPane().add(p1, BorderLayout.CENTER);
        getContentPane().add(p2, BorderLayout.SOUTH);
        // Register listener
        jbtComputeMortgage.addActionListener(this);
      /** Handle the "Compute Mortgage" button */
      public void actionPerformed(ActionEvent e) {
        if (e.getSource() == jbtComputeMortgage) {
          // Get values from text fields
          double interest = (Double.valueOf(
            jtfAnnualInterestRate.getText())).doubleValue();
          int year =
            (Integer.valueOf(jtfNumOfYears.getText())).intValue();
          double loan =
            (Double.valueOf(jtfLoanAmount.getText())).doubleValue();
          // Create a mortgage object
          Mortgage m = new Mortgage(interest, year, loan);
          // Display monthly payment and total payment
          jtfMonthlyPayment.setText(String.valueOf(m.monthlyPayment()));
          jtfTotalPayment.setText(String.valueOf(m.totalPayment()));
    }

    Does it have to be an applet?
    If you want the same behaviour as in the code with traffic lights, change
    class MortgageApplet extends JApplet implements ActionListener {
    to
    class MortgageApplet extends JFrame implements ActionListener {
    and change
    public void init() {
    to
    public MortgageApplet() {                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • SharePoint Provider Hosted App that can update existing SharePoint Task List

    Note: I am unable to take advantage of the Microsoft.SharePoint library directly. Adding a reference results in a 32bit/64bit library mismatch error.
    I have to find a solution that uses only the Microsoft.SharePoint.Client extension. 
    I am looking for example code where provider-hosted SharePoint App loads a SharePoint Task List View that allows users to interact with the tasks.
    So far I have only been able to programmatically create and then load the SharePoint tasks list, create and populate a DataTable object and set the datasource of a GridView object to that DataTable.
    I am unable to trigger my method linked to my checkbox within the gridview.
    Ideally I would like to just customize a Task View that already has this functionality.
    Here is my default.aspx.cs code-behind file:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Data;
    using SP = Microsoft.SharePoint.Client;
    namespace SPAppBasicWeb
    public partial class Default : System.Web.UI.Page
    protected void Page_PreInit(object sender, EventArgs e)
    Uri redirectUrl;
    switch (SharePointContextProvider.CheckRedirectionStatus(Context, out redirectUrl))
    case RedirectionStatus.Ok:
    return;
    case RedirectionStatus.ShouldRedirect:
    Response.Redirect(redirectUrl.AbsoluteUri, endResponse: true);
    break;
    case RedirectionStatus.CanNotRedirect:
    Response.Write("An error occurred while processing your request.");
    Response.End();
    break;
    protected void Page_Load(object sender, EventArgs e)
    // The following code gets the client context and Title property by using TokenHelper.
    // To access other properties, the app may need to request permissions on the host web.
    var spContext = SharePointContextProvider.Current.GetSharePointContext(Context);
    using (var clientContext = spContext.CreateUserClientContextForSPHost())
    //clientContext.Load(clientContext.Web, web => web.Title);
    //clientContext.ExecuteQuery();
    //Response.Write(clientContext.Web.Title);
    SP.ClientContext cc = new SP.ClientContext("http://server/sites/devapps");
    SP.Web web = cc.Web;
    SP.List list = web.Lists.GetByTitle("General Tasks");
    SP.CamlQuery caml = new SP.CamlQuery();
    Microsoft.SharePoint.Client.ListItemCollection items = list.GetItems(caml);
    cc.Load<Microsoft.SharePoint.Client.List>(list);
    cc.Load<Microsoft.SharePoint.Client.ListItemCollection>(items);
    //try
    //const int ColWidth = 40;
    cc.ExecuteQuery();
    DataTable dt = new DataTable();
    dt.Columns.Add("Task Name", typeof(string));
    dt.Columns.Add("ID", typeof(int));
    foreach (Microsoft.SharePoint.Client.ListItem liTask in items)
    DataRow dr = dt.NewRow();
    dr["Task Name"] = liTask["Title"];
    dr["ID"] = liTask["ID"];
    //dr["chkTask"] = liTask["Checkmark"];
    dt.Rows.Add(dr);
    GridView1.DataSource = dt;
    GridView1.DataBind();
    protected void chkTask_CheckedChanged(object sender, EventArgs e)
    //add code here to update Task Item by ID
    Response.Write("checkbox event triggered");
    Here is my simple default.aspx:
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="SPAppBasicWeb.Default" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    <title></title>
    </head>
    <body>
    <form id="form1" runat="server">
    <div>
    <asp:GridView ID="GridView1" runat="server">
    <Columns>
    <asp:TemplateField>
    <ItemTemplate>
    <asp:CheckBox ID="chkTask" runat="server" OnCheckedChanged="chkTask_CheckedChanged" AutoPostBack="true" />
    </ItemTemplate>
    </asp:TemplateField>
    </Columns>
    </asp:GridView>
    </div>
    </form>
    </body>
    </html>
    http://www.net4geeks.com Who said I was a geek?

    Hi,
    Please try to modify your code as below:
    using (var clientContext = spContext.CreateUserClientContextForSPHost())
    SP.Web web = clientContext.Web;
    SP.List list = web.Lists.GetByTitle("General Tasks");
    SP.CamlQuery caml = new SP.CamlQuery();
    Microsoft.SharePoint.Client.ListItemCollection items = list.GetItems(caml);
    clientContext.Load(items);
    clientContext.ExecuteQuery();
    If the code still not works, I suggest you debug the code or following the blog below to create a Provider-Hosted App for SharePoint and read list items from SharePoint list.
    http://blogs.msdn.com/b/steve_fox/archive/2013/02/22/building-your-first-provider-hosted-app-for-sharepoint-part-2.aspx
    Best Regards
    Dennis Guo
    TechNet Community Support

  • Can't save "Play music during slideshow" setting in iPhoto 6

    Hi,
    I just bought and installed iPhoto 6 today as an upgrade to iPhoto 4. I've discovered that I'm unable to save the "Play music during slideshow" setting in the dialog which appears when I click the "Play" button from the thumbnail screen to play a slideshow. If I uncheck this checkbox and then click on the "Save Settings" button, the next time I play a slideshow, the music starts up again. The most particularly annoying thing about this problem is that I'm trying to create a slideshow that plays no music, and I have to continually uncheck the "Play music during slideshow" checkbox each time I play the slideshow. Has anyone else run into this problem, and is there a solution or workaround for it?
    Thanks,
    Ken

    Hi,
    I think I've figured out what's going on here, but I don't know how to fix it. While I was playing around with the items in the "Play" dialog that appears when you initiate a slideshow, I discovered that if I uncheck the "Play music during slideshow" and then change the selection in the tree of folders underneath the checkbox, that the checkbox becomes selected. This would normally be the considerate thing to do, since if the user were making a selection in that tree, it would be rather "rude" in a software sense to not check the checkbox automatically. Unfortunately, in this case, the logic doesn't seem to be looking at the Preferences flag which (correctly, I think) is remembering that I don't want music to be played. So what I think is happening is when this dialog is first instantiated, the checkbox setting is remembered correctly. However, what happens next is that the saved selection in the folder tree is then restored, which then triggers the "a tree selection was just made, so let's check the checkbox" event. This is why if you've saved the "don't play music" setting, the checkbox is initially cleared, and then when the tree selection is set, the checkbox becomes checked. If I save the settings with the checkbox checked, the checkbox is set from the instant the dialog appears. So assuming that this is what's happening, is it possible to fix this by editing the NIB file using the Developer Tools? Or is this logic embedded in the compiled code?
    Any suggestions would be appreciated.
    Ken

  • Show/Hide a column in a Table region

    I have search page which queries the data and displays the records in a table region. We need to have an option to show or hide a non-database column at the end of the each row in the table. If the checkbox is selected, the last column should appear and if checkbox is deselected it should get disappeared.
    I have used a transient attribute in the VO and using that transient attribute trying to show the text field when the checkbox is selected. For ex, if the search returns 6 rows - if you select the checkbox of the first row , the last column "CTS" gets displayed without any issues but if you select the other rows (without checking the first row), the CTS column is not displayed.
    The column is getting displayed only IF you select the checkbox of the first row and try it other rows. If you try to select the checkbox of other rows without selecting the 1st row, it doesnt show the CTS column.
    AM has the PPR event
    =============
    public void CheckOnClick(String v_chkBox,String SalesContact,Boolean executeQuery)
    System.out.println("Enters Checkbox event()");
    USSContactMainVOImpl pVO= getUSSContactMainVO1();
    Row poRow[]=pVO.getFilteredRows("Chkbox","Y"); // get all the selected rows
    for(int i=0;i<poRow.length;i++ )
    Row rowi=poRow;
    System.out.println("Value:" + rowi.getAttribute("Chkbox") );
    rowi.setAttribute("CTSEngineer_TR",Boolean.TRUE); // transient attr
    //end of CheckOnClick()

    I just referred to the Dev Guide and understand that we can use the identifier of the PPR event source row (Page 262) but still the issue persists.
    String rowReference = pageContext.getParameter(OAWebBeanConstants.EVENT_SOURCE_ROW_REFERENCE);
    I have a rawtext as the first column( its just a dummy column since the PPR event is not getting fired if the checkbox is the 1st control/column) and the 2nd column is the check box which has a PPR event. The PPR event fires whenever the check box is selected or deselected but surprising the text field gets editable only if the 1st row is clicked.
    Changed code is as always - not sure why the table shows/hides the text column only if the 1st column is selected. Will appreciate any help.
    PFR:
    ===
    if ("OnSelect".equals(pageContext.getParameter(OAWebBeanConstants.EVENT_PARAM)))
    OAApplicationModule am = pageContext.getApplicationModule(webBean);
    System.out.println("The AM name is "+am);
    Boolean executeQuery = BooleanUtils.getBoolean(false);
    String str1 = pageContext.getParameter("Check_Box");
    String v_SalesContact = pageContext.getParameter("SalesContact_qry");
    //1401
    String rowReference = pageContext.getParameter(OAWebBeanConstants.EVENT_SOURCE_ROW_REFERENCE);
    Serializable[] parameters = {str1,v_SalesContact,rowReference,executeQuery };//1401
    Class[] paramTypes = { String.class,String.class,String.class,Boolean.class };//1401
    am.invokeMethod("CheckOnClick",parameters,paramTypes);
    AM(PPR Event)
    ==========
    public void CheckOnClick(String v_chkBox,String SalesContact,String rowReference,Boolean executeQuery)
    OARow rowx = (OARow)findRowByRef(rowReference);
    if (rowx !=null){
    System.out.println("row ref");
    System.out.println("reo fref"+ rowx.getAttribute("CTSEngineer_TR") );
    rowx.setAttribute("CTSEngineer_TR",Boolean.TRUE);
    Edited by: MyOAF on Jan 14, 2010 6:25 AM
    Edited by: MyOAF on Jan 14, 2010 6:26 AM

  • Reg. OOPs_____have ur points.

    Hi all,
    In SE24, I m making classes,i took an event there named "myevent". But when i m using it in my method, there it is not visible...system giving me error...that it is not existing...
    Pleas assist me..
    <b>Have ur points.</b>
    Regards,
    pradeep phogat

    Hi Pradeep..
    When you define an Event in a Class , you have to Define the Method to handle the Event.
    So to define the method as Event handler method.
    Put the Cursor on the Method:
    Select the <b>Detail view</b> icon. (Which is next to Exceptions and Code icons on toolbar)
    There you select the Checkbox   "Event Handler for". Enter the Class name and Event Name.
    Then you can make it...
    <b>Reward if Helpful.</b>

Maybe you are looking for

  • PF- Mid month employees

    Hi all, I am facing some issue in the provident fund for the Mid month joined employees. As per the client requirement, SAP is not calculating. I need your help in this. For all the employees we are maintaining the IT 0587 has whichever is less. I go

  • How Much Ram can I put in a MBP C2D 2.4 15" (08) (MB133LL/A)

    Can I put 2x4gb modules? 8gb? Link?

  • Why do lines show up after converting Word doc?

    Acrobat X Pro After converting a regular Word doc, which doesn't 'appear' to contain lines around the paragraghs, contains lines in the PDF. I believe I have chosen the highest quality in the convert settings, and cannot figure out why I'm getting th

  • How to pass bean variable to resourceID for Document Explorer ?

    Hello experts,   I have added  WebCenter document explorer  task flow in my ADF which as  parameter called resourceId.   I want to pass  bean variable to this parameter since  the Content IDs (doc Name or Ids) are  decided dynamically. When I provide

  • ABAP: Can I reproduce this Excel code in ABAP?

    Hi Experts, I've got a process that I want to improve using ABAP code so that I can reduce user interaction. I have a table (SKAS) on the ECC side that contains some data that I need to report on within BI. I am currently exporting this to a flat fil