Rational Numbers GUI; Problem Displaying Answer

I have to make a GUI that adds, subtracts, divides, and multiplies rational numbers. You input them as fractions. I think most of it is right, it does compile, but I don't know how to get my answer to display. I tried simple stuff like just adding it into the setText part at the end, but is there something that I'm missing like convert it to a string or something, I don't really know, I'm still very new to all this.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class RatDemo extends JFrame implements ActionListener {
           private JTextField jtfR1, jtfR2, jtfResult;
           private JButton jbtAdd, jbtSub, jbtDiv, jbtMul, jbtClr, jbtEx;
           public int numerator, denominator;
     public RatDemo(int numerator, int denominator)
            this.numerator = numerator;
            this.denominator = denominator;
             reduce();
     private void reduce()
             int divisor = gcd((numerator < 0)?-1*numerator:numerator,
                  (denominator < 0)?-1*denominator:denominator);
             if (divisor != 0)
                 numerator /= divisor;
                 denominator /= divisor;
     private int gcd(int a, int b)
           if (b == 0) return a; else return gcd(b,a%b);
     public int getNumerator()
         return numerator;
     public void print1(RatDemo RR)
          System.out.print( RR.numerator + "/" + RR.denominator);
     public int getDenominator()
         return denominator;
     public static RatDemo Add(RatDemo r1, RatDemo r2)
               int newNum = r1.numerator * r2.denominator + r1.denominator * r2.numerator ;
               int newDenom = r1.denominator * r2.denominator;
               return new RatDemo(newNum,newDenom);
     public static RatDemo Subtract(RatDemo r1, RatDemo r2)
          int newNum = r1.numerator*r2.denominator-r1.denominator*r2.numerator;
          int newDenom = r1.denominator*r2.denominator;
            return new RatDemo(newNum, newDenom);
     public static RatDemo Multiply(RatDemo r1, RatDemo r2)
               int newNum = r1.numerator * r2.numerator;
               int newDenom = r1.denominator * r2.denominator;
               return new RatDemo(newNum,newDenom);
     public static RatDemo Divide(RatDemo r1, RatDemo r2)
               int newNum = r1.numerator * r2.denominator;
               int newDenom = r1.denominator * r2.numerator;
               return new RatDemo(newNum,newDenom);
     public static void main(String [] args)
           RatDemo frame = new RatDemo();
           RatDemo r1 = new RatDemo(3, 17);
           RatDemo r2 = new RatDemo(5, 9);;
          RatDemo r3 = new RatDemo();
            frame.setTitle(" Rational Numbers ");
            frame.setSize(500,140);
            frame.setVisible(true);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     public RatDemo()
         JPanel p1 = new JPanel();
         p1.setLayout(new FlowLayout());
         p1.add( new JLabel("Rational 1"));
         p1.add( jtfR1 = new JTextField(6));
         p1.add( new JLabel("Rational 2"));
         p1.add( jtfR2 = new JTextField(6));
         JPanel p2 = new JPanel();
         p2.setLayout( new FlowLayout());
         p2.add ( new JLabel("Results "));
         p2.add( jtfResult = new JTextField(30));
         jtfResult.setEditable(false);
         JPanel p3 = new JPanel();
         p3.setLayout(new FlowLayout());
         p3.add( jbtAdd = new JButton("Add"));
         p3.add( jbtSub = new JButton("Subtract"));
         p3.add( jbtDiv = new JButton("Divide"));
         p3.add( jbtMul = new JButton("Multiply"));
         p3.add( jbtClr = new JButton("Clear"));
         p3.add( jbtEx = new JButton("Exit"));
            getContentPane().setLayout(new BorderLayout());
         getContentPane().add(p1, BorderLayout.NORTH);
         getContentPane().add(p2, BorderLayout.CENTER);
         getContentPane().add(p3, BorderLayout.SOUTH);
             jbtAdd.addActionListener(this);
            jbtSub.addActionListener(this);
            jbtMul.addActionListener(this);
            jbtDiv.addActionListener(this);
            jbtClr.addActionListener(this);
            jbtEx.addActionListener(this);
     public void actionPerformed( ActionEvent e)
             String actionCommand = e.getActionCommand();
             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 ("Clear".equals(actionCommand))
                        jtfR1.setText(" ");
                        jtfR2.setText(" ");
                        jtfResult.setText(" ");
                  else if ("Exit".equals(actionCommand))
                        System.exit(0);
     private void calculate(char operator)
            switch(operator)
                  case '+':
                    jtfResult.setText("The sum of the rational numbers is ");
                    break;
                  case '-':
                    jtfResult.setText("The difference of the rational numbers is ");
                   break;
                  case '*':
                    jtfResult.setText("The product of the rational numbers is ");
                   break;
                  case '/':
                    jtfResult.setText("The quotient of the rational numbers is ");
                   break;
                  default:
                   jtfResult.setText("Invalid Output");
}

If I understand correctly, in your calculate method you just concatenate the result onto the end of the string.
System.out.println("Hello " + 3);  // Hello 3
System.out.println("Hello " + 4 + 2);  // Hello 42
System.out.println("Hello " + ( 2 + 3)); // Hello 5

Similar Messages

  • Problem displaying the value zero in dashboard

    Hello,
    I have a problem displaying the value zero.
    When I am Treat Numbers As number, the value that appears
    When Treat Numbers As Percentage box is empty.
    Can you tell me how to display this value when the criterion
    is in percentage format.
    thanks for answers
    Best regards

    cast the number as float or multiply by 1.00 e.g. 1.00 * table.column

  • Server Admin GUI not displaying complete information

    Recently, the Server Admin GUI stopped displaying complete information for one of our servers. It works fine for the other.
    All servers are set up very much the same, other than one is an Xserve and one is a G5 tower. The one giving the grief is the G5 tower.
    Server Admin is version 10.4.7 and was working fine until a few days ago.
    When I click on the computer name (or IP) in the "Computers and Services" list, then look at any of the tabs > "Overview" "Logs" "System" "Graphs" or "Update" no information is retrieved. With the exception of Hard Drive capacity.
    All other services (Web, VPN, Mail) report all info without problems.
    Weird, hey? Any thoughts appreciated.
    Message was edited by: mebs2

    Well it pretty easy. I've taken out the code that is unused so you can see what is going on.
    import javax.swing.* ;
    public class Shareddilog extends JDialog
    public static void main(String[] args)
    Shareddilog s=new Shareddilog();
    s.show();
    }This is the only code that is executed in your program. It created a JDialog and then shows it. What you want to do, I imagine, is to put all the GUI stuff in your constructor and make sure you call pack() on it before you are done.

  • Problem displaying CLOB in text file

    Hello All,
    I have a problem displaying the content from the database in notepad. When I click on a link on my jsf screen, I retrieve the data and display it in notepad.
    I have my text content stored in the database with CLOB datatype. When I look in the database the data looks in the following format:
    ---------STARTS FROM NEXT LINE-------------
    The firm, known for its keen oversight of products, has been the subject of complaints from firms who have had apps blocked from the store. Some developers have complained that the company's rules seem inconsistent.
    Some have found apps blocked after seemingly minor updates, or for having content deemed inappropriate by them. In light of this, and after careful consideration, I believe it is unnecessary to sign this measure at this time.
    Sincerely,
    ABC
    ----------ENDS IN THE PREVIOUS LINE------------
    Now when I display this content onto the notepad, all the spaces and new line characters are lost, and the entire display looks awkward. This is how it looks:
    The firm, known for its keen oversight of products, has been the subject of complaints from firms who have had apps blocked from the store. Some developers have complained that the company's rules seem inconsistent.[]Some have found apps blocked after seemingly minor updates, or for having content deemed inappropriate by them. In light of this, and after careful consideration, I believe it is unnecessary to sign this measure at this time.[]Sincerely,[]ABC
    All the new line characters are lost and it just puts some junk character in place of a new line.
    When I copy the same text onto textpad, everything is alright and it displays exactly the way it is present in the database. I am also open to display the content in html, but in HTML it doesn't even display me the junk character in place of new line. It is just one single string without any line separators.
    I am using the following code to put the content into the text.
    public String writeMessage(){
       OutputStream outStream = null;
       HttpServletResponse response = getServletResponseFromFacesContext();
       Reader data = null;
       Writer writer = null;
       try{
          response.reset();
          response.setContentType("text/plain; charset=UTF-8");
          response.setHeader("Content-Disposition","attachment; filename="+id+"_Message.txt");
          outStream = response.getOutputStream();
          QueryRemote remote = serviceLocator.getQueriessEJB();
          data = remote.retrieveGovernorsVetoMessage(billId);
          writer = new BufferedWriter(new OutputStreamWriter( outStream, "UTF-8" ) );
          int charsRead;
          char[] cbuf = new char[1024];
          while ((charsRead = data.read(cbuf)) != -1) {
             System.out.println(charsRead);
          writer.write(cbuf, 0, charsRead);
          writer.flush();
       }catch(Exception ex){
          ex.printStackTrace();
       }finally{
          //Close outStream, data, writer
          facesContext.responseComplete();
       return null;
    }Any help or hints on resolving this issue would be highly appreciated.
    Thanks.

    The data is imported from a third party application to my database. It doesn't display any newline characters when I view the data.
    But when I do a regular expression search on text pad, I could see that my clob contains \n as the new line character. Is there a way to replace \n with \n\r while writing the data.
    Thanks.

  • Numbers search problem

    I have Numbers 08, OX, the search works some of the time but will suddenly quit. The other day I was searching books by a certain author, to compare to a list of her books, trying to figure out which ones I had not read. (yes, I keep a log of the books I have read). For instance, I had searched & found a book, then searched for another, no find. Yet, when I looked at the one before, I see the one I searched for a few lines below. I tried other searches that should have landed on books but nothing happened. I quit Numbers & then checked it again, nada. It is working today...did it just need a reboot of Mac? I really can't imagine software that requires that. Oh yes, there were about 30 books that I searched.
    Thanks for your help in solving my problem in Numbers.

    I have Numbers 08, OX, the search works some of the time but will suddenly quit. The other day I was searching books by a certain author, to compare to a list of her books, trying to figure out which ones I had not read. (yes, I keep a log of the books I have read). For instance, I had searched & found a book, then searched for another, no find. Yet, when I looked at the one before, I see the one I searched for a few lines below. I tried other searches that should have landed on books but nothing happened. I quit Numbers & then checked it again, nada. It is working today...did it just need a reboot of Mac? I really can't imagine software that requires that. Oh yes, there were about 30 books that I searched.
    Thanks for your help in solving my problem in Numbers.

  • Numbers will not display 3D charts on my new computer. I am running system 10.6.8. A 2D chart turns into a selected empty rectangle when I change it to a 3D chart. What do I do?

    Numbers will not display 3D charts on my new computer. I am running system 10.6.8. A 2D chart turns into a selected empty rectangle when I change it to a 3D chart. What do I do? I am running iWork 9.1.

    Hello
    Numbers 2.1 under 10.7.2 on my iMac described below.
    There is at least a thread describing what you get:
    https://discussions.apple.com/message/15526080
    It claims that it strike when the app is using the NVIDIA video card available in some macBook pro.
    Yvan KOENIG (VALLAURIS, France) samedi 7 janvier 2012
    iMac 21”5, i7, 2.8 GHz, 12 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.2

  • Problem displaying picture stored in mySQL

    Hi, i just have got problem displaying picture stored in database as BLOB and presented on JSP over servlet. Below is my code i am using to upload file into database, than download it and display again. The result is the picture can not draw inself and there is always only empty picture space on the web page i am displaying. Please help me to find why it is not working, thanx.
    servlet uploading picture to database
                   boolean isMultipart = FileUpload.isMultipartContent(req);
                   DiskFileUpload upload = new DiskFileUpload();
                   List items = upload.parseRequest(req);
                   Hashtable textFields = new Hashtable();
                   byte[] data = new byte[4096];
                   if(isMultipart)
                        Iterator iter = items.iterator();
                        while(iter.hasNext())
                             FileItem item = (FileItem)iter.next();
                             if(item.isFormField())
                                  textFields.put(item.getFieldName(), item.getString());
                             }else{
                                  data = item.get();
                   String sqlStatement = "INSERT INTO cds VALUES('" textFields.get("id")"'," +
                                            "'" textFields.get("album") "','" textFields.get("interpreter") "'," +
                                                      "'" textFields.get("gr1") "','" textFields.get("gr2") "','" textFields.get("price") "')";
                   String sqlStatement2 = "INSERT INTO pics VALUES('" textFields.get("id") "','" data "')";
    servlet to download picture
    String SQL =
         "SELECT Picture " +
         "FROM pics " +
         "WHERE id = '" + request.getParameter("id") + "'";
         ResultSet rs = stmt.executeQuery(SQL);
         rs.next();
         Blob blob = null;
         blob = rs.getBlob(1);
         response.setContentType("image/jpg");
         request.setAttribute("blob", blob);
         System.out.println("just above OutputStream");
         InputStream in = blob.getBinaryStream();
         ServletOutputStream sout = response.getOutputStream();
         int b;
         while ((b = in.read()) != -1) {
         sout.write(b);
         in.close();
         sout.flush();
         sout.close();
    img tag in JSP
    <img src="LoadImageServlet?id=some id>
    plus i am using
    Tomcat 5.0
    mySQL 4.0
    debuging in eclipse
    thanx for help once more, Libor.

    1:
    are there any exceptions throws by the jdbc code
    2:
    is the code in a doGet
    3:
    you should do a if(result.next())
    4:
    Is your mapping code working

  • Problems displaying in IE

    While I love iWeb's ease of use, it seems to have serious problems displaying on IE. There is really no point blaming IE, since it is the dominant browser and most people who will see our sites will use it. The point of iWeb should be to allow people to communicate broadly and effectively, not just to Mac & Safari users.
    Lists do not work well. The indents do not display properly. Text in boxes shift alignment and location. Bullets show up with different sizes. I have had to hand indent and line space all the lists in the sites I make, which is a mess and not scaleable.
    See fieldsforkidsmamk.org.
    Are there any workarounds or fixes?
    The other obvious issues with iWeb are worth noting:
    * inconsistent display in browsers -- pages look different in Safari and Firefox, even on the Mac (let alone IE)
    * difficulty adding html code
    * page names must be identical to nav names, so pages with multiple words (Get Involved) display urls as /Get%20Involved (can't be corrected unless you have Get_Involved as a header.)
    * need to publish whole site for any change
    * need to publish all sites for each change to any site
    * can't change color, display, location, function etc for Nav
    I assume everyone is aware of these problems. The question is, what to do? Grin and bear it? Any help, tips or ideas would be appreciated.
    Thanks!
    MacBook Mac OS X (10.4.8)
    MacBook Mac OS X (10.4.8)
    MacBook Mac OS X (10.4.8)
    MacBook   Mac OS X (10.4.8)  

    * page names must be identical to nav names, so pages
    with multiple words (Get Involved) display urls as
    /Get%20Involved (can't be corrected unless you have
    Get_Involved as a header.)
    You can fix this the same way you add html code, by post processing.
    * need to publish all sites for each change to any
    site
    You can fix this by separating your sites into different Domain files so you only publish one at a time.
    Contrary to the other response, "encoding" is not connected to the points you made. There is never any need to add a UTF-8 "tag" to an iWeb page. If you see question marks or Â's when your page is displayed on any browser, Mac or PC, then you may need to fix your ftp or server settings.

  • Problems displaying rtf memo fields

    Post Author: Davidm
    CA Forum: General
    We use Crystal Reports X to run reports on an Access database with a significant number of rtf memo fields. We use Total Access Memo to allow extended use of rtf within Access as our users require the additional formatting capabilities that this offers.
    However, there are considerable problems displaying items like bullet points, tables and hyperlinks in the Crystal Viewer with tables in particular coming out in a real mess with all entries in the table being displayed in a list with a small square marking each cell at the end of each line.
    Curiously, if you preview the report in the full version of Crystal X, it appears a bit better with the hyperlinks still underlined (bullet points still vanish) and rows in rtf tables are at least presented as a row even if the columns are not ordered and mixed (with no bounding cells visible).
    Firstly, is this disparity of end result between full Crystal X Print Preview and the Crystal X Viewer fixable?
    Secondly, is the limited handling of rtf tags likely to be solved in the next release of Crystal?

    Hi Mathias,
    If I caught you correctly, you want to display data in Adobe forms in form of tabel, right?
    So, follow the steps:
    1. Insert one sub form on your adobe form.
    2. Set its type as "flow content" in object->subform property.
    3. Set flow direction as "Table".
    4. Insert another subform inside this subform.
    5. set its type as "flow content" and flow direction as "Table row".
    6. Now, choose binding tab, and there check "repeat subform for each Data item check box" and specify min. count for your rows.
    7. Now, insert your column fields inside this sub form once.
    8. Format its look and feel as you want.
    When you run this application, it will show you multiple data as table on Adobe form.
    Regards,
    Bhavik

  • N73 displays answer phone icon even though i have ...

    N73 displays answer phone icon even though i have no message. Any ideas?
    Its not who i am underneath. But what i do that defines me.
    You are here for a reason Superman.
    "Come to me son of Jor-EL. KNEEL BEFORE ZOD"

    Thanks alot mate. Sorted the problem.
    Cheers
    Its not who i am underneath. But what i do that defines me.
    You are here for a reason Superman.
    "Come to me son of Jor-EL. KNEEL BEFORE ZOD"

  • Problem displaying php page in dreamweaver

    I am having problems displaying php scripting on dreamweaver.
    Need your advice.
    Installed dreamweaver 8, Coldfusion 7, mysql, php5.2 (using
    windows installer).
    Created file test.php ror testing containing
    <!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>
    <meta http-equiv="Content-Type" content="text/html;
    charset=iso-8859-1" />
    <title>Untitled Document</title>
    </head>
    <body>
    date is:<b><?php echo Hello ?></b>
    </body>
    </html>

    ulises_arsi wrote:
    > I am having problems displaying php scripting on
    dreamweaver.
    Tell us what the problems are.
    > Installed dreamweaver 8, Coldfusion 7, mysql, php5.2
    (using windows installer).
    PHP needs to be configured with a web server, such as Apache
    or IIS.
    ColdFusion is also a webserver, but as far as I know, it
    cannot be
    configured to serve PHP pages.
    > date is:
    <?php echo Hello ?>
    The only thing that would display is an error message. Hello
    needs to be
    enclosed in quotes:
    <?php echo 'Hello'; ?>
    David Powers
    Adobe Community Expert
    Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
    http://foundationphp.com/

  • 've recently upgraded to FireFox v22.0. Originally, a legacy XBAP I use always opened correctly in FireFox and had no problems displaying or running. As of v22.

    I've recently upgraded to FireFox 22. Originally, a legacy XBAP I use always opened correctly in FireFox and had no problems displaying or running. As of 22, it won't even attempt to download the application, let alone try and display it.
    I have the windows Presentation Foundation 3.5.30729.1 installed, which is the same version I have been using in older versions.
    Can anyone shed some light on any changes that would have effected this?

    Hi, I have a similar problem. I did attempt the *.rdf fix on a test system, but it didn't work (em:maxVersion was already 22).
    We got about inflow of phone calls from our clients experiencing the problem mentioned above from the 2nd of July onwards... and more are phoning in.
    All the complaints come from clients (+- 10 so far and rising in number) using Firefox v22 (we have checked), and all of them have said that it was working previously.
    We downgraded one of the clients to an older version of Firefox, and it worked again. So far we are telling our clients to downgrade until a fix comes out, or use Internet Explorer (*blush*)

  • Problem Displaying data from oracle in JTable

    Please can any one help me? I have a problem displaying the data fetched from oracle database(ResultSet) in JTables. Can any one provide me with any possible way out(and any alternative).

    User,
    As suggested in the other post - Google/Books/find a mentor is the best option.

  • Problems displaying itab with 'REUSE_ALV_GRID_DISPLAY'

    Hi experts!
    I have a problem displaying the internal table itab_test. Itab_uload is a TYPE TABLE of a complex and nested structure I defined in the DDIC. I am able to pass the entries, which are not conform with the specifications, to itab_test, but when I execute the program I get a short dump.
    Error message is:" It was tried to pass the internal table IT_FIELDCAT to the formal parameter IT_FIELDCAT. In doing so, a ^type conflict occured between the formal and the actual parameter."
    Can anybody please advise on the code-sample below. What did I wrong and what can I do to correct it?
    Thanks a lot for your help!
    Johann
    P.S.:Points will be rewarded for helpful answers!
    *&          DECLARATIONS
    TYPES: BEGIN OF error_test,
           oz TYPE c,
           bez TYPE c,
           END OF error_test.
    DATA: itab_test TYPE TABLE OF error_test WITH HEADER LINE,
          itab_upload TYPE TABLE OF zstr_gaeb WITH HEADER LINE.
    DATA: wa_upload TYPE zstr_gaeb,
          wa_lvbereich TYPE zstr_lvbereich,
          wa_bereichdeslv TYPE zstr_bereichdeslv,
          wa_beschreibung TYPE zstr_lvbeschreibung,
          wa_position TYPE zstr_position.
    DATA :      it_fieldcat TYPE lvc_t_fcat,
              wa_fieldcat LIKE LINE OF it_fieldcat,
              wrk_pos TYPE i.      
    *&           START OF SELECTION
    START-OF-SELECTION.
    LOOP AT itab_upload INTO wa_upload.
        LOOP AT wa_upload-vergabe-lv-lvbereich INTO wa_lvbereich.
          oz_len = STRLEN( wa_lvbereich-oz ).
          IF oz_len <> 3.
            MOVE wa_lvbereich-oz TO itab_test-oz.
            MOVE wa_lvbereich-bez TO itab_test-bez.
          ENDIF.
        ENDLOOP.
      ENDLOOP.
      CLEAR wa_fieldcat.
      wrk_pos = wrk_pos + 1.
      wa_fieldcat-col_pos = wrk_pos.
      wa_fieldcat-tabname = 'ITAB_TEST'.
      wa_fieldcat-fieldname = 'oz'.
      wa_fieldcat-seltext = 'Ordnungszahl'.
      wa_fieldcat-emphasize = ''.
      wa_fieldcat-hotspot = 'X'.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR wa_fieldcat.
      wrk_pos = wrk_pos + 1.
      wa_fieldcat-col_pos = wrk_pos.
      wa_fieldcat-tabname = 'ITAB_TEST'.
      wa_fieldcat-fieldname = 'bez'.
      wa_fieldcat-seltext = 'Bezeichnung'.
      wa_fieldcat-emphasize = ''.
      wa_fieldcat-hotspot = ''.
      APPEND wa_fieldcat TO it_fieldcat.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                = ' '
      I_BUFFER_ACTIVE                   = ' '
      I_CALLBACK_PROGRAM                = ' '
      I_CALLBACK_PF_STATUS_SET          = ' '
      I_CALLBACK_USER_COMMAND           = ' '
      I_CALLBACK_TOP_OF_PAGE            = ' '
      I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
      I_CALLBACK_HTML_END_OF_LIST       = ' '
      I_STRUCTURE_NAME                  =
      I_BACKGROUND_ID                   = ' '
      I_GRID_TITLE                      =
      I_GRID_SETTINGS                   =
      IS_LAYOUT                         =
         it_fieldcat                       = it_fieldcat
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
      IT_SORT                           =
      IT_FILTER                         =
      IS_SEL_HIDE                       =
      I_DEFAULT                         = 'X'
      I_SAVE                            = ' '
      IS_VARIANT                        =
      IT_EVENTS                         =
      IT_EVENT_EXIT                     =
      IS_PRINT                          =
      IS_REPREP_ID                      =
      I_SCREEN_START_COLUMN             = 0
      I_SCREEN_START_LINE               = 0
      I_SCREEN_END_COLUMN               = 0
      I_SCREEN_END_LINE                 = 0
      I_HTML_HEIGHT_TOP                 = 0
      I_HTML_HEIGHT_END                 = 0
      IT_ALV_GRAPHICS                   =
      IT_HYPERLINK                      =
      IT_ADD_FIELDCAT                   =
      IT_EXCEPT_QINFO                   =
      IR_SALV_FULLSCREEN_ADAPTER        =
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER           =
      ES_EXIT_CAUSED_BY_USER            =
        TABLES
          t_outtab                          = itab_test
    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.

    Hello,
    Make the change like this
      DATA: L_R_REPID LIKE SY-REPID.
      L_R_REPID = SY-REPID.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    I_CALLBACK_PROGRAM = L_R_REPID " CHeck here
    * I_INTERFACE_CHECK = ' '
    * I_BYPASSING_BUFFER = ' '
    * I_BUFFER_ACTIVE = ' '
    * I_CALLBACK_PROGRAM = ' '
    * I_CALLBACK_PF_STATUS_SET = ' '
    * I_CALLBACK_USER_COMMAND = ' '
    * I_CALLBACK_TOP_OF_PAGE = ' '
    * I_CALLBACK_HTML_TOP_OF_PAGE = ' '
    * I_CALLBACK_HTML_END_OF_LIST = ' '
    * I_STRUCTURE_NAME =
    * I_BACKGROUND_ID = ' '
    * I_GRID_TITLE =
    * I_GRID_SETTINGS =
    * IS_LAYOUT =
    it_fieldcat = it_fieldcat
    * IT_EXCLUDING =
    * IT_SPECIAL_GROUPS =
    * IT_SORT =
    * IT_FILTER =
    * IS_SEL_HIDE =
    * I_DEFAULT = 'X'
    * I_SAVE = ' '
    * IS_VARIANT =
    * IT_EVENTS =
    * IT_EVENT_EXIT =
    * IS_PRINT =
    * IS_REPREP_ID =
    * I_SCREEN_START_COLUMN = 0
    * I_SCREEN_START_LINE = 0
    * I_SCREEN_END_COLUMN = 0
    * I_SCREEN_END_LINE = 0
    * I_HTML_HEIGHT_TOP = 0
    * I_HTML_HEIGHT_END = 0
    * IT_ALV_GRAPHICS =
    * IT_HYPERLINK =
    * IT_ADD_FIELDCAT =
    * IT_EXCEPT_QINFO =
    * IR_SALV_FULLSCREEN_ADAPTER =
    * IMPORTING
    * E_EXIT_CAUSED_BY_CALLER =
    * ES_EXIT_CAUSED_BY_USER =
    TABLES
    t_outtab = itab_test
    * 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.
    VAsanth

  • JLabel + GUI problem

    Hello
    I have a JLabel2 which shows the spanish map. The thing is I do wanna draw lines on my spanish map and save it to as an image file in my desktop . I'm able to draw lines and save my JLabel2(spanish map) as an image in my Desktop. The problem is I'm not able to see any lines that I draw before in my image file. I can see those lines when I do click draw button but I can not see them when I save my file as an image to my desktop.Please help me.This problem killed me for two days..you can see how i converted to icon and how i save it as an image file below.Thank you for your helps from now.
    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
    File file3;
    int returnVal = fc.showSaveDialog(routemap.this);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
    try {
    File f3 = fc.getSelectedFile();
    ImageIcon icon = (ImageIcon) jLabel2.getIcon();
    System.out.println(icon.getIconHeight());
    BufferedImage buf = new BufferedImage(icon.getImage().getWidth(
    null), icon.getImage().getHeight(null),
    BufferedImage.TYPE_INT_RGB);
    buf.getGraphics().drawImage(icon.getImage(), 0, 0,
    icon.getIconWidth(), icon.getIconHeight(), null);
    ImageIO.write(buf, "jpg", new File(f3.getAbsolutePath()
    + ".jpg"));
    System.out.println(f3.getAbsolutePath());
    } catch (IOException e) {
    I have drawn lines by using draw function as you see below and I can not see those lines without any problem..Lines disapper in the image file when I do save it..Here is the draw button..
    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
    boolean go = true;
    if (OneClicked == false && go == true) {
    jLabel3.setText(jComboBox1.getSelectedItem() + " to ");
    view = jComboBox1.getSelectedItem().toString() + " to ";
    String m = jComboBox1.getSelectedItem().toString();
    int size1 = City.size();
    for (int i = 0; i < size1; i++) {
    if (City.get(i).equals(m)) {
    Index.add(i);
    OneClicked = true;
    go = false;
    if (OneClicked == true && go == true) {
    jLabel3.setText(view + jComboBox1.getSelectedItem());
    view = "";
    String m = jComboBox1.getSelectedItem().toString();
    int size1 = City.size();
    for (int i = 0; i < size1; i++) {
    if (City.get(i).equals(m)) {
    Index.add(i);
    Graphics g = jLabel2.getGraphics();
    g.setColor(Color.BLUE.darker());
    Graphics2D g2 = (Graphics2D) g;
    g2.setStroke(new BasicStroke(3));
    System.out.println(Index.size());
    System.out.println(Index.size() - 2);
    int m1 = Integer.parseInt(XCoordinate.get(Index
    .get(Index.size() - 2)));
    int n1 = Integer.parseInt(YCoordinate.get(Index
    .get(Index.size() - 2)));
    int m2 = Integer.parseInt(XCoordinate.get(Index
    .get(Index.size() - 1)));
    int n2 = Integer.parseInt(YCoordinate.get(Index
    .get(Index.size() - 1)));
    System.out.println(m1 + " " + n1 + " " + m2 + " " + n2);
    g2.drawLine(m1, n1, m2, n2);
    OneClicked = false;
    System.out.println("index im" + Index);
    }

    Cross-post: [java-forums: jlabel-gui-problem|http://www.java-forums.org/java-applets/15472-jlabel-gui-problem.html]
    To the original poster, cross-posting can frustrate anyone who tries to help you only to find out later that the same answer was given hours ago in a cross-posted thread. No one likes wasting their time, especially a volunteer. The polite thing to do would be to not do this, but if you feel that you absolutely must, to at least provide links in both cross-posts to each other.
    edit: all over the dang place: [javaranch: JLabel-GUI|http://www.coderanch.com/t/428887/Swing-AWT-SWT-JFace/java/JLabel-GUI]
    Now this could get folks wanting to not help you ever. Please take care here.
    Edited by: Encephalopathic on Jan 31, 2009 6:34 AM

Maybe you are looking for

  • Creation of PO only for one particular storage location

    Hi Friends One of my material is extended to four storage location within a plant say S001 S002 S003 and S004 but here requirment is at the time of raising PO for this material,system should always propose only one particular storage location say S00

  • Pivot the table

    Hi, Need help in pivot the table. Table data NAME LINE_TYPE_REF_ID Class CreateShipmentServiceAdapterImpl Method getContactsAndSitesForAccount User skkond Node Name PB15CKY Num Contacts 3 Class CreateShipmentServiceAdapterImpl Method getContactsAndSi

  • Query Out Put

    Hi All,   I generated query the out put of query is as shown below. ma01        10kg   dc01 ma02        20kg   dc02 I dont want kg in the second column but I want only numbers like 10,20...   Thanx in advance.

  • Keyframing Pan/Zoom - How To Simplify?

    I want to do a simple effect where I start the clip centered at 100% and zoom to off-center at 120%. So basically, keyframing size and position over the clip's length. In order to do that, I do the following steps: 1. Select the clip in the timeline

  • How do i colour fill the spaces between my line work

    I have drawn an image using various shapes and lines how do i fill the space in between sections with colour without it just filling the rectangle shape? Ive drawn this dragon and need colour it in what is the easiest way to do it as they are all ind