Adding buttons on toolbar

On occerance of certain ActionEvent i need to add dynamic JButtons & JLabels on the JToolBar. Initially JToolBar will be empty.
Code below is not working properly...
It is creating buttons dynamiclly but i cant set any property for that one.
class DeviceAction extends AbstractAction
         public DeviceAction()
           // Add this action to the toolbar resulting
           // in a new button getting added to the
           // toolbar
          JButton jbutton = xmlFilesToolBar.add( this);
           xmlFilesToolBar.addSeparator();
           jbutton.setActionCommand( "Dynamic" );
}I will call " new DeviceAction(); " when ever ActionEvent occurs.
I[b] need to have controle over the dynamically added JButtons & JLables, bcoz each JButtons shld do some Actions when it is clicked.
Plz do the needful.
Reg,
Bha.

If I understand you correctly, you need each button that is added to execute a different action when it is selected. And you are not sure how to do that with this class. Is that correct?
If so you would probably need to pass an ActionListener to the constructor, then keep a HashMap of these ActionListeners that is keyed off the action command being set.
Then in the ActionPerformed method of the DeviceAction, call the ActionPerformed of the appropriate ActionListener from the HashMap.

Similar Messages

  • Adding buttons to toolbar not in the customize page

    I'm wanting to add buttons like Undo, Redo, Spellcheck and some others to the tool bar, but when customizing the toolbar, adding those buttons isn't an option. Is this possible?

    You have to tell Apple, not us. We are end-user like you.
    In the Pages Pages menu you can Provide feedback or use this link _http://www.apple.com/feedback/pages.html_

  • Standard buttons not displaying ALV when added button by creating PF status

    Hi  All,
    I have added a button(using SE41) in application toolbar for ALV grid using Factory method.But the problem is I am unable to see the standard tool bar buttons(Layout,Download,Mail etc).
    Even I tried adding buttons(using standard FCODES) to the PFstatus.Now the buttons are visible but the functionality is not working for all buttons.Its working only for Graphic and Change layout buttons.
    Can any one suggest...??
    -Phaniram

    Disregard DKS's response...that's the older stuff and you're using NetWeaver ALV.
    In SALV you can cause those buttons to appear, but you may need to copy the SALV_STANDARD GUI from one of the SALV* named program using SE80...sounds like you have that part, but you may need to turn functions ON...
    Perhaps something like this would help:
    data:  gr_f_list  type ref to cl_salv_functions_list,
             gr_alv     type ref to cl_salv_table,
    SALV toolbar & GUI functions
      gr_f_list = gr_alv->get_functions( ).     "Get Toolbar functions
      gr_f_list->set_all( abap_true ).          "All On
      gr_f_list->set_view_lotus( abap_false ).  "Lotus 123 off
      gr_f_list->set_view_excel( abap_false ).  "Excel in Place Off
      gr_f_list->set_graphics( abap_false ).    "Graph tool off
    For undesired buttons, set each tool OFF after turning all ON.

  • How to make separation between added buttons into a jToolBar?

    Hi friends,
    I have made a jToolBar (using NetBeans IDE 5.5) with several buttons, but i dont know how to make custom separation between those added buttons. I will appreciate it if anyboy give me some tips.
    Thanks in advance,
    Reza_mp

    I don't know about NetBeans but yeah U can add horizontal atruts and verticals struts between two components, i.e.
    1.) add first component
    2.) add horizontal or vertical struts(according to ur toolbar)
    3.) add second component
    4.) add add horizontal or vertical struts(according to ur toolbar)
    this will definitely solve ur problem.
    If it does, don't forget to pay ur points.

  • ALV .  How to remove the sort buttons on toolbar in ALV report?

    Hi,experts
      As you know, in default case , the alv report will display two sort buttons(ascending ,descending) on its toolbar , So How to remove the sort buttons on toolbar in ALV report?
      Thanks for your help .

    Hi guixin,
    1. Before calling REUSE_ALV_LIST_DISPLAY
    2. Write this code :
    data : excl type SLIS_T_EXTAB.
    data : exclwa type SLIS_EXTAB.
    exclwa = '&OUP'.
    append exclwa to excl.
    exclwa = '&ODN'.
    append exclwa to excl.
    3. Then while calling the FM,
       pass this parameter also .
    IT_EXCLUDING     = excl
    It will work fantastic.
    regards,
    amit m.

  • How to find function code for buttons on toolbar in oops alv

    Hi experts,
    I want to remove some buttons from toolbar in oops alv, i know the procedure like get function code and pass the value in a table and pass that table to IT_TOOLBAR_EXCLUDING of
    method set_table_for_first_display but I WANT TO KNOW HOW TO FIND FUNCTION CODE FOR BUTTONS ON TOOLBAR IN OOPS ALV

    Hi Prakash,
    -->First you have to set the pf status in your alv program by,
    {FORM pf_status USING rt_extab TYPE slis_t_extab.
      SET PF-STATUS 'FIRST'.
    ENDFORM.                    "PF_STATUS}
    -->Pass this Subroutine name in the Function module, Reuse_alv_grid_display's parameters i.e,
          i_callback_pf_status_set          = 'PF_STATUS'}
    *-->Then doble click on that pf status,
    From the menu bar, select Extras->Adjust Template->List Viewer,
    This will give you the existing statndard gui status of the program*
    ->Then catch that function codes in the User command Parameter of the Function module Reuse.. i.e,
          i_callback_user_command           = 'COMM'
    And make a subroutine of the name 'COMM'i.e,
    FORM comm USING ucomm LIKE sy-ucomm selfield TYPE slis_selfield.
      DATA: okcode TYPE sy-ucomm.
      okcode = ucomm.
      CASE okcode.
        WHEN 'REF'.
        CALL FUNCTION 'POPUP_TO_INFORM'
          EXPORTING
            titel         = 'MANSI'
            txt1          = 'CREATED BY'
            txt2          = SY-UNAME
          TXT3          = ' '
          TXT4          = ' '
    endcase.
    Hope it helps you
    Regrds
    Mansi

  • Cannot keep print button on toolbar

    Since upgrading firefox I cannot keep the print button the toolbar. I can open customize and pull the print icon button onto the toolbar but it is not there when I open a new session. Ii have to drag it again. How can I keep it in place. This just happens on one desktop. I run another desktop and a laptop without this problem
    Thanks

    Print the report where? On what printer? The server's printer?
    Java code runs on the server. You can't affect the client's computer from JSP.
    You can write javascript code which can call window.print() but that is working through the browser to display the print dialog box (as if the user selected file:print)

  • Button on toolbar after executing the report i.e. after result display

    Hi, after executing the report result is being displayed.Now at this stage I want a button on the application toolbar clicking on which will allow a perform to get triggered.
    I tried in following manner:
    SELECTION-SCREEN: FUNCTION KEY 1.
    *INITIALIZATION.
    TABLES: SSCRFIELDS.
    *MOVE icon_mail TO sscrfields-functxt_01.
    *form SEND_EMAIL .
    IF sy-ucomm = 'FC01'.
         PERFORM SEND_MAIL_ASSET_STATUS.
    ENDIF.
    But it's not ok.The above way is not working.
    Please note: I want button on toolbar only after executing the report i.e. after result display.
    How can I do this?
    Kindly guide.
    Best regards.

    hi
    if you are using alv than just pass 3 values to function call
         I_CALLBACK_PROGRAM                = SY-REPID   " program name
         I_CALLBACK_PF_STATUS_SET          = 'STATUS'  "PF-STATUS
         I_CALLBACK_USER_COMMAND           = 'UCOMMAND'  " subroutine name
    and check the value of UCOMM in subroutine

  • Installed Firefox 4 on Mac OS X 10.6.7. (1) How can I delete icons it added to bookmarks toolbar so they'll all fit again? (2) Where is the Organize Bookmarks tool now?

    Don't know what details you might want.

    I'm not sure about the 'icons' added to bookmarks toolbars, but you can control your bookmarks using "Show All Bookmarks". That replaced 'Organize Bookmarks'. It will open the bookmark library & you should be able to rearrange, add, delete, etc from here.

  • Which trigger fires after pressing 'Save' button on toolbar.

    hi,
    I wanted to know which triggers get fired after pressing 'save' button on toolbar, and in which sequence it get's fired.

    When you press 'save' it tries to do a commit_form.
    Before commiting the form, it checks for any errors which might occur at form level, block level or item level and does the commit only when it doesn't find one.

  • Adding Buttons to a ScrollPane??

    Hello Swing people,
    I have had this problem now for quite some time and still have had no luck in getting it right. I am coding an ordering system and on this form is a Jtable displaying product details. Beside the Jtable are category buttons one after the other in a vertical line and there are 18 of them - meaning they cannot fit on the screen!! Therefore i want these buttons to be in some kind of scollpane or list so they can all be viewed.
    I thought this would be a simple matter of adding buttons to a scrollpane and then to the panel but this has proved not the case! Does anyone know how i could do this as i have been trying this for too long without the help of you geniuses???
    To give u an idea of what i was trying here is a snippet of my code:
    import javax.swing.*;
    public class junk2 extends JFrame{
         junk2()    {
         JPanel panel = new JPanel();
         panel.setLayout(new java.awt.GridLayout(0, 1) );
         JButton []button = new JButton[20];
         for(int i=0; i<button.length; i++) {
              button=new JButton(""+(i+1) );
              panel.add(button[i]);
         JScrollPane scroll = new JScrollPane(panel);
         getContentPane().add(scroll, java.awt.BorderLayout.CENTER);
         setSize(50, 100);
         setDefaultCloseOperation( EXIT_ON_CLOSE );
         public static void main(String []args) {
              new junk2().show();
    This code is fine and puts buttons in a vertical line but the buttons only have numbers on them from 1-20, i want the names of the buttons i have declared to be in here - therefore allowing the action performed on these buttons to be recognised and therefore work too! - anyone know how to get around this??
    Also the scrollpane with these buttons in apears in a whole new frame being that it is a small test program but does anyone know how to ensure the buttons appear in the scrollpane only and not in a new frame??
    all 25 dukes if someone can sort this long problem out!!!

    Hi guys thanks a lot for your replies, i compiled both of them and they are fine! the first reply is more what i am looking for but there is still a problem, i am finding it difficult to incorporate this piece of code into my order form class.
    Im trying to take out the current declarations of my JButtons and replace it with the code i was given (reply 1) and obviously keep my action performed methods there as they will be the same but cant seem to do this!
    If anyone can add in the code from reply 1 into my code below or at least help me i will give u the 25 dukes, taking into consideration i still want the form (panel) to be displayed as well as the panel or scrollpane containing the JButtons???
    Can u help - cheers in advance!!
    Pc
    public class OrderForm extends JFrame implements ActionListener {
         private JPanel panel;
         private JButton saveArchive,unCompleted,submitOrder,checkSheet,clear,exit,bread,fruit,dairy,
    salads,cakes,frozen,meat,cheeses,sauces,dry,drinks,soup,cleaning,boxes,cups,cutlery,lids,misc,stick,soup2;
         private JScrollPane pane;
         private JTextField textorderno,textorderdate,textdelivdate,textemp,textshop,textsupp;
         private JLabel heading1,heading2,orderno,orderdate,delivdate,emp,shop,supplier;
         private String todaysDate, deliveryDate;
         private ResultSet result;
         private ResultSet shops;
         private int column_count;
         private JComboBox combobox;
         ResultSetTableModel model = new ResultSetTableModel();
         Result rs = new Result(); 
         Orders orderSaving = new Orders();
         ProductOrders tableSaving = new ProductOrders();
         private boolean save;
         JTable table;
         public OrderForm()throws SQLException {
              displayForm();
              displayFields();//Have not provided coz it aint needed for this
              displayButtons();//Wont need this anymore i dont think
              getContentPane().add(panel);
              setVisible(true);
         public void displayForm() throws SQLException{
              setTitle("Pret Ordering System");
              setSize(700,600);
              // Center the frame
              Dimension dim = getToolkit().getScreenSize();
              setLocation(dim.width/2-getWidth()/2, dim.height/2-getHeight()/2);
              //Creates the coloured bored around the panel
              panel = new JPanel();
              panel.setLayout( null );
              Border paneltitled = BorderFactory.createLineBorder(Color.red.darker().darker(),10);
              panel.setBorder(paneltitled);
              ResultSet result = rs.setBreadProds();
              model.fillTableModel(result);
              table = new JTable(model);
              for(int i = 0; i < column_count; i++) {          
                   table.getColumnModel().getColumn (i).setPreferredWidth (200);                   
              table.setSelectionForeground( Color.white );
              table.setSelectionBackground( Color.red.darker().darker() );
              pane = new JScrollPane(table);
                  pane.setBounds(190, 230, 440, 200);
                  panel.add(pane);
              combobox = new JComboBox();
              ResultSet shops = rs.getSupplierNames();
              while(shops.next()){  
                   combobox.addItem(shops.getString("supplier_name"));
    //Hope you can help - cheers

  • Share button on Toolbar when clicked takes time to load ? Do you get that ?

    Share button on Toolbar when clicked takes time to load ? Do you get that ?

    After activating your iPad, go to the App Store and search for your free apps:
    1. Pages
    2. Numbers
    3. Keynote
    4. iPhoto
    5. iMovie
    6. GarageBand
    If apps are still showing the price: sign out>reboot>and sign in again
    Settings>iTunes and App Store>Apple ID

  • Captiave 2 - Adding Buttons to Question Slides

    I need to use the Captivate Question Slide "maker" to create
    interactive questions with navigation back to the "Jeopardy-esque"
    main page. When doing so, the question slide maker prevents adding
    buttons/navigation, etc.
    Any work arounds, hints, suggestions?
    Thanks...

    Hi Beta Bob and welcome to our community
    As you have seen, you cannot insert interactive objects
    (Buttons, Click Boxes or Text Entry Boxes) on Question slides.
    The only workaround I can think of is to sort of simulate the
    question slide using these objects on a standard slide.
    Cheers... Rick

  • 4.1EA. Open Body button in toolbar does not work

    Hi, All!
    4.1EA. Open Body button in toolbar does not work. In object tree click on some Package. Next - in toolbar click on OpenBody button. Body is not opened.

    Ow, that's a bad one, good catch.
    As a workaround the 'gutter blue arrow' hyperlinks DO work.
    Once I DO manage to get the body open, the button works for me without fail, even after an application restart. And I'm able to open other package bodies. So I can reproduce this bug once, but only once.
    Do you see the same?

  • Remove "execute" button from toolbar

    Hi, colleagues! Is there any way to remove "execute" button from toolbar on selection screen (in custom report)? I only found how to append custom buttons (using function keys).
    Thanks.

    Use EXCLUDING options of the SET PF-STATUS statement and insert the function code of the execute button into a internal table and pass it with EXCLUDING.
    See F1 help on EXCLUDING.
    Regards
    Karthik D

Maybe you are looking for