How to create button in ABAP

Plz tell me the syntax

Go through this
SELECTION-SCREEN - PUSHBUTTON
Syntax
SELECTION-SCREEN PUSHBUTTON [/][pos](len) button_text
                            USER-COMMAND fcode
                            [VISIBLE LENGTH vlen]
                            [MODIF ID modid]
                            [ldb_additions].
Extras:
1. ... [/][pos](len)
2. ... USER-COMMAND fcode
3. ... VISIBLE LENGTH vlen
4. ... MODIF ID modid
Effect
This statement creates a pushbutton on the current selection screen. The text on the pushbutton is determined by the content of button_text. The rules that apply to text also apply to button_text when creating an output field.
The additions ldb_additions can only be used in the selection include for a logical database.
Notes
You can use the function module ICON_CREATE to assign an icon, a quick info text and a corresponding text to a pushbutton. When you do this, you must specify an adequate length len for the pushbutton so that the icon can be displayed internally and adjust the visible length with VISIBLE LENGTH.
Once the event block in AT SELECTION-SCREEN has been processed, the system usually returns to displaying the selection screen. To exit selection screen processing and continue executing the program, you can only choose Execute or Cancel. This means pushbuttons on selection screens are intended primarily for use for dynamic modifications to the selection screen rather than to control the program.
Addition 1
... [/][pos](len)
Effect
You must specify the position of the output field using [/][pos](len). The syntax and meaning of [/][pos](len) are the same as when creating horizontal lines, although in this case, len defines the length of the pushbutton on the selection screen. If a pushbutton extends beyond position 83 or beyond the edge of a block with a frame, it is cut off at the right hand side.
Addition 2
... USER-COMMAND fcode
Effect
If you specify the USER-COMMAND addition, the pushbutton must be assigned a function code fcode. The function code fcode must be specified directly and can only contain a maximum of 20 characters.
Before you can work with the pushbutton, you must specify a TABLES statement to declare an interface work area for the structure SSCRFIELDS from the ABAP Dictionary.
If the user selects the pushbutton on the selection screen, the runtime environment triggers the event AT SELECTION-SCREEN and the function code fcode is transferred to the ucomm component in the interface work area sscrfields.
Note
If the function code of a pushbutton corresponds to a function code used in the GUI status of the selection screen, the selection screen processing is influenced accordingly.
Addition 3
... VISIBLE LENGTH vlen
Effect
The VISIBLE LENGTH addition defines the visible length vlen of the pushbutton and your text. The syntax and meaning of this addition are the same as when creating output fields, although a pushbutton is never displayed as shorter than the text defined for it.
Addition 4
... MODIF ID modid
Effect
The MODIF ID addition assigns the pushbutton to the modification group modid that is assigned to the column group1 on the system table screen. This means it can be modified using a MODIFY SCREEN statement before the selection screen is displayed.
Example
Define and access a stand-alone selection screen 500 with two pushbuttons in an executable program. An icon and a quick info text are created for the second pushbutton.
TABLES sscrfields.
TYPE-POOLS icon.
SELECTION-SCREEN:
  BEGIN OF SCREEN 500 AS WINDOW TITLE title,
    PUSHBUTTON 2(10)  but1 USER-COMMAND cli1,
    PUSHBUTTON 12(30) but2 USER-COMMAND cli2
                           VISIBLE LENGTH 10,
  END OF SCREEN 500.
AT SELECTION-SCREEN.
  CASE sscrfields.
    WHEN 'CLI1'.
    WHEN 'CLI2'.
  ENDCASE.
START-OF-SELECTION.
  title  = 'Push button'.
  but1 = 'Button 1'.
  CALL FUNCTION 'ICON_CREATE'
    EXPORTING
      name   = icon_information
      text   = 'Button 2'
      info   = 'My Quickinfo'
    IMPORTING
      RESULT = but2
    EXCEPTIONS
      OTHERS = 0.
  CALL SELECTION-SCREEN '0500' STARTING AT 10 10.
THnaks
Ankur Sharma

Similar Messages

  • How to create popup in ABAP webdynpro.

    Hi,
    I found lot of examples to create a popup/ model window for java webdynpro.
    Could anyone give a pointer to an example which explains how to create popup in ABAP webdynpro??
    Kind Regards
    Shahul

    Hi Thomas:
    It worked fine the 1st time. Second time when the user clicks on the button to open up the popup it dumps.
    Here is the code in the action for popup:
    data: l_cmp_api type ref to if_wd_Component,
            l_window_manager type ref to if_wd_window_manager,
            l_api type ref to if_wd_View_controller,
            l_text type string_table.
      l_cmp_api = wd_comp_controller->wd_get_api( ).
      l_window_manager = l_cmp_api->get_window_manager( ).
      if wd_this->m_popup is initial.
        wd_this->m_popup = l_window_manager->create_window(
                 window_name = 'DOCQSOW'
                 button_kind = if_wd_window=>co_buttons_ok
                 message_type = if_wd_window=>co_msg_type_none ).
               component_usage_name = 'DOCQUERY_USAGE_1'
        l_api = wd_this->wd_get_api( ).
        wd_this->m_popup->subscribe_to_button_event(
              button = if_wd_window=>co_button_ok
              button_text = 'Transfer'
              action_name = 'POPUP_CLOSED'
              action_view = l_api  ) .
        wd_this->m_popup->SET_REMOVE_ON_CLOSE( abap_true ).
       endif.
      wd_this->m_popup->open( ).
    Second time when the popup tries to open, I get the following error:
    Method: RENDER_WINDOW of program CL_WDR_WINDOW_RENDERER========CP
    Method: RENDER_WINDOW of program CL_WDR_CLIENT_SSR=============CP
    Method: RENDER_POPUP_WINDOWS of program CL_WDR_CLIENT_SSR=============CP
    Method: RENDER_WINDOWS of program CL_WDR_CLIENT_SSR=============CP
    Method: IF_WDR_RESPONSE_RENDERER~RENDER_VIEWS of program CL_WDR_CLIENT_SSR=============CP
    Method: IF_WDR_RESPONSE_RENDERER~RENDER_USER_INTERFACE_UPDATES of program CL_WDR_CLIENT_SSR=============CP
    Method: IF_WDR_CLIENT~SEND_RESPONSE of program CL_WDR_CLIENT_ABSTRACT_HTTP===CP
    Method: IF_WDR_CLIENT~SEND_RESPONSE of program CL_WDR_CLIENT_SSR=============CP
    Method: EXECUTE of program CL_WDR_MAIN_TASK==============CP
    Method: IF_HTTP_EXTENSION~HANDLE_REQUEST of program CL_WDR_MAIN_TASK==============CP
    Is there a way to destroy the instance of the m_popup?
    Any help is appreciated!
    Thanks

  • How to Create Buttons With some operation

    Hello friends How can create button so that when i click that button it should open another new window so that i can select some options in that new window and do some calculations.
    Kindly help me .
    byee

    Hi JN,
    I have created a Frame which has some checkboxes , a button and text field. when i check some checkboxes and press the Button (ie in my program Metrics level Button ) it should display the result as number of checkboxes that are checked divided by total number of chechboxes. ie if i check some 6 check boxes and press the Metrics level button it should display 6 divided by 12 ie 0.5 in the Result Textfield.
    I am sending the code i have written.
    Thanks in advance.
    public class Frame extends java.awt.Frame {
    /** Creates new form Frame */
    public Frame() {
    initComponents();
    setSize(800, 800);
    private void initComponents() {
    label1 = new java.awt.Label();
    checkbox1 = new java.awt.Checkbox();
    checkbox2 = new java.awt.Checkbox();
    checkbox3 = new java.awt.Checkbox();
    checkbox4 = new java.awt.Checkbox();
    checkbox5 = new java.awt.Checkbox();
    checkbox6 = new java.awt.Checkbox();
    checkbox7 = new java.awt.Checkbox();
    checkbox8 = new java.awt.Checkbox();
    checkbox9 = new java.awt.Checkbox();
    checkbox10 = new java.awt.Checkbox();
    checkbox11 = new java.awt.Checkbox();
    checkbox12 = new java.awt.Checkbox();
    button1 = new java.awt.Button();
    textField1 = new java.awt.TextField();
    setLayout(null);
    addWindowListener(new java.awt.event.WindowAdapter() {
    public void windowClosing(java.awt.event.WindowEvent evt) {
    exitForm(evt);
    label1.setText("Select the Metrics below");
    add(label1);
    label1.setBounds(320, 20, 136, 20);
    checkbox1.setLabel("Architecture Metrics");
    add(checkbox1);
    checkbox1.setBounds(240, 80, 84, 20);
    checkbox2.setLabel("Runtime Metrics");
    add(checkbox2);
    checkbox2.setBounds(240, 200, 115, 20);
    checkbox3.setLabel("Documentation Metrics");
    add(checkbox3);
    checkbox3.setBounds(240, 320, 152, 20);
    checkbox4.setLabel("Size");
    add(checkbox4);
    checkbox4.setBounds(280, 110, 49, 20);
    checkbox5.setLabel("Structure");
    add(checkbox5);
    checkbox5.setBounds(280, 130, 75, 20);
    checkbox6.setLabel("Complexity");
    add(checkbox6);
    checkbox6.setBounds(280, 150, 86, 20);
    checkbox7.setLabel("Size");
    add(checkbox7);
    checkbox7.setBounds(290, 230, 49, 20);
    checkbox8.setLabel("Structure");
    add(checkbox8);
    checkbox8.setBounds(290, 250, 75, 20);
    checkbox9.setLabel("Complexity");
    add(checkbox9);
    checkbox9.setBounds(290, 270, 86, 20);
    checkbox10.setLabel("Size");
    add(checkbox10);
    checkbox10.setBounds(300, 350, 49, 20);
    checkbox11.setLabel("Structure");
    add(checkbox11);
    checkbox11.setBounds(300, 370, 75, 20);
    checkbox12.setLabel("Complexity");
    add(checkbox12);
    checkbox12.setBounds(300, 390, 86, 20);
    button1.setLabel("Metrics level");
    add(button1);
    button1.setBounds(290, 470, 83, 24);
    textField1.setText("Result");
    textField1.setName("Result");
    add(textField1);
    textField1.setBounds(400, 470, 60, 20);
    pack();
    public void actionPerformed(ActionEvent e) {
    ****** I think code should be added here for the button pressed event*******
    /** Exit the Application */
    private void exitForm(java.awt.event.WindowEvent evt) {
    System.exit(0);
    * @param args the command line arguments
    public static void main(String args[]) {
    new Frame().show();
    // Variables declaration - do not modify
    private java.awt.Button button1;
    private java.awt.Checkbox checkbox1;
    private java.awt.Checkbox checkbox10;
    private java.awt.Checkbox checkbox11;
    private java.awt.Checkbox checkbox12;
    private java.awt.Checkbox checkbox2;
    private java.awt.Checkbox checkbox3;
    private java.awt.Checkbox checkbox4;
    private java.awt.Checkbox checkbox5;
    private java.awt.Checkbox checkbox6;
    private java.awt.Checkbox checkbox7;
    private java.awt.Checkbox checkbox8;
    private java.awt.Checkbox checkbox9;
    private java.awt.Label label1;
    private java.awt.TextField textField1;
    // End of variables declaration
    this is the output when i execute the program

  • How to create  webservice  for  abap  RFC

    how to create  webservice  for  abap  RFC.......................
    plz any could tel me

    I'll answer my own question...
    In SE80 you create the Function Group and something called a Virtual End Point.  These are the only items that transport forward to you QA and eventually your production system.  Everything else has to be created in SOAMANAGER on the target systems. 
    In Development in SE80, when you create the Virtual End Point, this creates a corresponding entry visible in transaction SICF.  When you are done in SOAMANAGER, it creates three more entries in SICF.  The process of transporting the Virtual End Point does NOT create any entries in SICF in QA.  Don't let this be confusing.  In QA, SOAMANAGER will create all four SICF entries.
    Also, if you try to secure the web services using the S_SERVICE object, you must actually test the web service before you can add it to any roles.  This is because the USOBHASH table is not populated for the web service until you actually run the web service for the first time.

  • How to create pakage in abap.

    1) How to create  the pakage in abap.
    Edited by: Matt on Mar 10, 2009 3:10 PM - modified subject

    Hi Ganga,
    Follow these steps :
    1. Run the SE80 T-code in the R/3 system.
    2. Click on Edit Objects option on the top of the window.
    3. Select "Development Coordination" in the Object selection window.
    4. Select "Package" radio button and provide the package name(like any name: "BIDEV").
    5. Click on "Create" icon.
    6. Fill the required details ( Short description, Appli.Component, Software Component)
    7. Select "SAVE" Icon.
    Go through the link below for fruther help :
    http://www.sap-img.com/basis/steps-for-creating-package.htm
    Hope the information is very helpful!
    Regards,
    Kittu

  • Create Button  in Abap Program

    Hi anybody,
      I want to use click event button inside abap programe.
    how to use click events of button.
    anybody tell me.
    thanks
    s.muthu

    hiii
    use following code.it will create button
    START-OF-SELECTION.
      SET PF-STATUS 'STATUS'.
      PERFORM get_data_kna1.
    END-OF-SELECTION.
    Now write following code for performing task on clicking that button.
    CASE sy-ucomm.
      WHEN 'CUSTOMER'.
       SELECT SINGLE kunnr
          FROM kna1
          INTO w_kna1
          WHERE kunnr = w_kunnr.
          IF sy-subrc <> 0.
             MESSAGE e015(zmsg9).
           ENDIF.
    WHEN 'ORDER'.
               SELECT SINGLE vbeln
          FROM vbak
          INTO w_vbak
          WHERE vbeln = w_vbeln.
          IF sy-subrc <> 0.
           MESSAGE e015(zmsg9).
          ENDIF.
      ENDCASE.
    reward if useful
    thx
    twinkal

  • How to crete Button through ABAP programming

    Hello Friends,
    I am creating 2 selection screens through ABAP code and using them in my Tabstrip control also created through ABAP programming.
    Can I also create button on the selection screen through abap programming. If yes then how, and how to assign funtion code and capture the Function Code???
    Moderator Message: Read the below advice.
    Edited by: kishan P on Dec 30, 2010 7:44 PM

    Have a look at F1 help on SELECTION-SCREEN. There should be an example as well.

  • How to create metheds in abap

    Hi All,
    Can anybody help me to know how create methods in abap and whats is the perpose of these methods. Any documentation is helpful. Thanks..
    Regards,
    Kalpana

    Hi,
      Check the program demo_abap_objects_methods for methods..
    CLASS MY_CLASS DEFINITION.
    PUBLIC SECTION.
      METHODS: ADDITION IMPORTING IP_1 TYPE INT4
                                  IP_2 TYPE INT4
                        EXPORTING OP_1 TYPE INT4,
               SUBTRACTION IMPORTING IP_1 TYPE INT4
                                     IP_2 TYPE INT4
                           EXPORTING OP_1 TYPE INT4.
    ENDCLASS.
    CLASS MY_CLASS IMPLEMENTATION.
      METHOD ADDITION.
        OP_1 = IP_1 + IP_2.
      ENDMETHOD.
      METHOD SUBTRACTION.
        OP_1 = IP_1 - IP_2.
      ENDMETHOD.
    ENDCLASS.
    START-OF-SELECTION.
    DATA: OBJ TYPE REF TO MY_CLASS.
    CREATE OBJECT OBJ.
    DATA: V_OUTPUT TYPE INT4.
    CALL METHOD OBJ->ADDITION EXPORTING IP_1 = 1
                                        IP_2 = 3
                              IMPORTING OP_1 = V_OUTPUT.
    WRITE: / V_OUTPUT.
    Thanks,
    Naren

  • ABAP Queary Or SAP Queary Doc/ How to Create Tcode for ABAP queary report

    Hi All,
         Please send the documentation on ABAP Queary.
        How to create transaction code Report developed using ABAP Queary.
    Regards
    sudheer

    Hi,
    Check out these links.
    http://help.sap.com/saphelp_46c/helpdata/en/35/26b413afab52b9e10000009b38f974/content.htm
    http://www.thespot4sap.com/Articles/SAP_ABAP_Queries_Introduction.asp
    Step-by-step guide for creating ABAP query
    http://www.sappoint.com/abap/ab4query.pdf
    ABAP query is mostly used by functional consultants.
    SAP Query
    Purpose
    The SAP Query application is used to create lists not already contained in the SAP standard system. It has been designed for users with little or no knowledge of the SAP programming language ABAP. SAP Query offers users a broad range of ways to define reporting programs and create different types of reports such as basic lists, statistics, and ranked lists.
    Features
    SAP Query's range of functions corresponds to the classical reporting functions available in the system. Requirements in this area such as list, statistic, or ranked list creation can be met using queries.
    All the data required by users for their lists can be selected from any SAP table created by the customer.
    To define a report, you first have to enter individual texts, such as titles, and select the fields and options which determine the report layout. Then you can edit list display in WYSIWYG mode whenever you want using drag and drop and the other toolbox functions available.
    ABAP Query, as far as I Believe, is the use of select statements in the ABAP Programming. This needs a knowledge of Open SQL commands like Select,UPdtae, Modify etc. This has to be done only by someone who has a little bit of ABAP experience.
    To sum up, SAP queries are readymade programs given by SAP, which the user can use making slight modification like the slection texts, the tables from which the data is to be retrieved and the format in which the data is to be displayed.ABAP queries become imperative when there is no such SAP query existing and also when there is a lot of customizing involved to use a SAP Query directly

  • How to create button programmatically and assign trigger for it and add code

    is that possible ?
    How can I create item a button for example programmatically (at run time)
    and create trigger (when-button-pressed) programmatically and write a code
    in the trigger body as well programmatically.
    thankx

    Hello David
    I used the way list and go button which is more safer than creating buttons because
    you can populate the list on fly.
         | dropdown list     \/
              | go button |
    PROCEDURE populate_user_function_list IS
         rg_list_id RECORDGROUP;
         ret_code     NUMBER;
    BEGIN
         rg_list_id := FIND_GROUP('RG_LIST');
         IF NOT ID_NULL(rg_list_id) THEN
              DELETE_GROUP(rg_list_id);
         END IF;
         rg_list_id := CREATE_GROUP_FROM_QUERY('RG_LIST','SELECT FUNCTION_ID, FUNCTION_ID FROM SMS_ROLE_FUNCTION WHERE SMS_ROLE_FUNCTION.DB_ROLE ='||''''||:GLOBAL.USER_ROLE||''''||' ORDER BY SEQUENCE_NO');
         ret_code := POPULATE_GROUP(rg_list_id);
         --Populate record group.
              IF ret_code <> 0 THEN
              bell;
              MESSAGE('Record Group could not be populated');
              RAISE FORM_TRIGGER_FAILURE;
              END IF;
         POPULATE_LIST('DYNAMIC_BLK.USER_FUNCTION','RG_LIST');
         DELETE_GROUP(rg_list_id);
    END;
    --this is the button to go the user selection
    begin
         if :DYNAMIC_BLK.USER_FUNCTION is not null then
              --go to selected form
              call_form(:DYNAMIC_BLK.USER_FUNCTION,NO_HIDE,DO_REPLACE,NO_QUERY_ONLY,NO_SHARE_LIBRARY_DATA);     
         else
              bell;
              message('Please select a function');
         end if;
    end;

  • How to create buttons

    Hello,
    I am trying to create a simple flash piece but no luck so
    far.
    I'd like to create 4 text buttons. When each button clicked,
    an image will slide into the scene...That's it. WHen the second
    button is clicked, a new image will slide in. I dont care much
    about sliding out the other one -- although it'd be nice...
    I cant even find a tutorial that explains how to assign
    actions to buttons. I know how to create the buttons and tweening.
    BUt i cant put everything together to work. Can anyone help?
    Thankx in adavnce and happy new year!

    yes, this is great. i see it's the exact effect i am looking
    fir but this is way too complex for me. I am just trying to create
    a button... and when clicked, an image will open. is there an
    easier way to do this? thanks again advance for any help.

  • How to create objects in ABAP Webdynpro?

    Hi,
    I want to create the object for the class: <b>CL_GUI_FRONTEND_SERVICES.</b>
    then i want to call file_save_dialog method.
    how shoud i write the code, plz?

    I have written this code:
    v_guiobj TYPE REF TO cl_gui_frontend_services.
    <u> ?????????????</u>
    v_guiobj->file_save_dialog( ...).
    How to create object in the place of ?????????????.
    Bcoz, when i run this i am getting:
    <b>Access via Null object reference not possible.</b>

  • How to create Spool through ABAP program

    How to create spool request for Smartforms through program. So I can go in TCODE SP01 and see the output of my smartforms.

    Include the below code in ur program .......
      DATA: PRINT_PARAMETERS TYPE PRI_PARAMS,
            VALID_FLAG       TYPE C LENGTH 1.
      CALL FUNCTION 'GET_PRINT_PARAMETERS'
      EXPORTING
      IMMEDIATELY = 'X' "C_IMMEDIATELY
    *LAYOUT = 'Z_48_144'
    *LINE_COUNT = '48'
      LINE_SIZE = '255'
    *NEW_LIST_ID = C_NEW_LIST_ID
      NO_DIALOG = 'X'
      RELEASE = 'X'
      IMPORTING
      OUT_PARAMETERS = PRINT_PARAMETERS
      VALID = VALID_FLAG
      EXCEPTIONS
      ARCHIVE_INFO_NOT_FOUND = 1
      INVALID_PRINT_PARAMS = 2
      INVALID_ARCHIVE_PARAMS = 3
      OTHERS = 4 .
      G_PDEST = PRINT_PARAMETERS-PDEST.
      NEW-PAGE PRINT ON PARAMETERS PRINT_PARAMETERS
                        NO DIALOG.
    List of write statements to be output.......
    NEW-PAGE PRINT OFF.
    Reward if useful..............

  • How to create Button which size is calculated from its text ?

    I think JButton works like this: either in constructor or by setText() method the text is set and according the lenght, font and fontRendererContext preffered size is calculated before the layout manager ask for the prefferedSize for first time.
    I want to override paint() method because i want to draw my own text(and the only way i discovered how to force button not to paint text is to set text to
    null or empty String). I want the button to be as long as length of text plus insets.
    But layout manager ask for preffered size before paint method is invoked but i find out what size should be in paint method because i need graphics
    parameter to get FontRendererContext from it. So layout manager shrink button to minimum because first time the preffered size calculated from null or
    empty String is returned.
    public class MyButton extends JButton {
            public MyButton() {
                this.setText(null);  //or setText("");
                this.setContentAreaFilled(false);
                this.setFocusPainted(false);
                this.setBorderPainted(false);
                                                          ////already here i need to know what the size should be
            @Override
            public void paint(Graphics g) {
                Graphics2D g2 = (Graphics2D) g;
                TextLayout textLayout = new TextLayout("MyButton", this.getFont(), g2.getFontRenderContext());
                Rectangle2D boundsOfText = textLayout.getBounds();                                                                    /////////here i find out what size should be
                this.prefferedSize = new Dimension((int)boundsOfText.getWidth()+10,(int) boundsOfText.getHeight()+10);
                g2.setColor(Color.WHITE);
                g2.fillRoundRect(1, 1,(int)getPreferredSize().getWidth(),(int) getPreferredSize().getHeight(), 10, 10);
                g2.setColor(Color.BLACK);
                g2.drawRoundRect(1, 1,(int)getPreferredSize().getWidth(),(int)getPreferredSize().getHeight(), 10, 10);
                g2.drawString("MyButton", 7, (int)boundsOfText.getHeight() + 6);
                g2.dispose();
        }So how can i do that? How can JButton know prefferedSize before its paint method is invoked?

    The previous example was simplified.
    public class MyButton0 extends JButton {
        private String myText;
        public MyButton0(String text) {
            this.myText = "Button";
            //this.myText = text.toUpperCase();
            this.setFont(new Font("SansSerif", Font.PLAIN, 13));
            setContentAreaFilled(false);
            setBorderPainted(false);
            setFocusPainted(false);
        @Override
        public void paint(Graphics g) {
            Graphics2D g2 = (Graphics2D) g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
            //backround painting
            GradientPaint background = new GradientPaint(0, 0, new Color(255, 255, 255), 0, getPreferredSize().height / 2, new Color(0, 0, 0), true);
            if(getModel().isRollover()){
                background = new GradientPaint(0, 0, new Color(255, 255, 255), getPreferredSize().width , getPreferredSize().height , new Color(0, 0, 0), true);
            if(getModel().isPressed()){
                background = new GradientPaint(0, 0, new Color(255, 255, 255), 0, getPreferredSize().height / 2, new Color(210, 210, 210), true);
            g2.setPaint(background);
            g2.fillRoundRect(1, 1, getPreferredSize().width - 3 , getPreferredSize().height - 3, 10, 10);
            //Border painting
            g2.setColor(new Color(255, 255, 255));
            g2.setStroke(new BasicStroke(2.0f, BasicStroke.CAP_BUTT, BasicStroke.CAP_BUTT, 10.0f));
            g2.draw(new RoundRectangle2D.Double(1, 1, getPreferredSize().width - 3, getPreferredSize().height - 3, 10, 10));
            //text paiting
            g2.setFont(getFont());
            TextLayout tl = new TextLayout(this.myText, getFont(), g2.getFontRenderContext());
            int startPositionOfText = getPreferredSize().width - (int) tl.getBounds().getWidth();
            startPositionOfText = startPositionOfText / 2;
            g2.setColor(new Color(255, 255, 255));
            g2.drawString(this.myText, startPositionOfText -2, getHeight() / 2 + 5);
            g2.dispose();
        @Override
        public Dimension getPreferredSize() {
            return new Dimension(133, 31);
    }Assume text is so long as doesn't fit inside button. I have hard-set preffered size but i would like to calculate preffered size from text lenght.
    Or i need calculate startPosition of text to center it. But i don't want have preffered size hard-set.

  • How to create Buttons for Excel,Print & help!

    Hi Experts
      Anyone has an experience how to create a Buttopn Group for the following options.
    1.Excel
    2.Printchart
    3.Printtable
    4.Printreport
    5.Help
    Pls revert to me <removed by moderator>.
    Thanks
    BI Learner
    Edited by: Siegfried Szameitat on Dec 1, 2008 10:46 AM

    Hi,
    Your PDF output and the output of the Template on Web should be similar, ideally. But, if the width of the 2 reports are bigger and that cannot fix in one page, then the PDF output will not be as you require it to be.
    You have to decrease the dimensions of the Analysis item in the Template and see how the output size varies in the Web.
    Also, when you have defined the command for converting to PDF, select the checkbox which allows you to see the "Page Setup" while you are converting it to PDF in the Web, ie in the output of the template. Here, set the margins to the minimum (Left, right, top and bottom). This also ensures that the Analysis item gets the maximum area in the output.
    Just try this piece of code too,
    <bi:CAPTION value="Print PDF" />
    <bi:TOOLTIP value="Print to PDF Document" />
    <bi:ACTION type="CHOICE" value="INSTRUCTION" >
    <bi:INSTRUCTION >
    <bi:EXPORT >
    <bi:REPEAT_KEYCOL value="" />
    <bi:PAPER_ORIENTATION value="LANDSCAPE" />
    <bi:MARGIN_RIGHT value="10" />
    <bi:MARGIN_LEFT value="10" />
    <bi:MARGIN_TOP value="10" />
    <bi:MARGIN_BOTTOM value="10" />
    Here the margins are set to 10. You can even try decreasing this depending on your requirement.

Maybe you are looking for

  • How to print page numbers on a PDF

    I have a large PDF (50+ pages) that I need to print out. The PDF does not have page numbers on it, so I am wanting to know if there is a way to have Preview or Acrobat add page numbers to each page for printing?

  • How to set the database in NOARCHIVELOG mode

    hellow world, I knewly joined this organization. Our database is very small < 4GB data. Database is running in ARCHIVELOG MODE. since we are not keeping any physical backup, so I opted to run the datbase in NOARCHIVELOG mode. For bringing the databas

  • Is it possible to use a variable after

    ...after popup message. Like the following example. I want to inform the user about the next number he can enter into a database.. MESSAGE 'Please enter another value. The value may be  '  +  VARIABLENAME TYPE 'I'. How can I achieve using a variable

  • Essbase add-in - Formula Preservation

    Hi, I have one question regarding formula preservation in essbase addin. I want to calculate price value from volume and sales as given in the below example.The price is not a member of the cube. But i want to keep the price header during the essbase

  • I can't open adobe illustrator CS6 -Java  issues, can anyone help please

    I can't open adobe illustrator CS6 - I downloaded latest java for OSx, and it still directs me to download Java 6.  Can anyone help please, thanks