Draw graphics in ABAP

Hi,
i'm looking for a way to draw graphics in my SAP-GUI. I need really drawing, not only charts.
I searched the forum for this topic, and found the solution via a HTML-Control with SVG.
Basicly this is exactly what im looking for, but isn't there any other way?? In best case a solution, that don't need a plug-in..

Hi Bernd
For pictures you can use the class "cl_gui_picture". You can find more in the demo program Nablan mentioned.
It may also be OK to use an HTML viewer if possible. It can be instantiated from the class "cl_gui_html_viewer"
To store your picture files you can use the Web Repository.
To draw graphics, you can use "GRAPH_MATRIX_*" function modules. You can inspect those.
A better way that I would prefer to draw graphics, is using GFW (Graphical FrameWork). Inspect demo programs "GFW_DEMO_*" for those.
Hope this clue helps...
*--Serdar

Similar Messages

  • How to Generate and Display SVG Graphics in ABAP

    Hi everybody,
    I tried to complete the Tutorial "How to Generate and Display SVG Graphics in ABAP, Part 1" by Siarhei Ulasenka (https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/ad83a990-0201-0010-d680-a189f8bc20fa).
    Unfortunately when I tried the example to display an SVG Drawing in an ABAP Report I get the error message "Es ist ein Laufzeitfehler aufgetreten, ungültiges Zeichen" (english should be something like "Runtime Error, unkown character"). But it works when I open the svgfile in a new IE Window (parameter in_place from cl_gui_html_viewer->show_url). Also when I open a svg file from the local disc it works fine.
    The code:
        CALL METHOD html_control->load_data
          EXPORTING
            url            = 'chart.svg'
            type         = 'image'
            subtype    = 'svg+xml'
          CHANGING
            data_table = lt_svg
          EXCEPTIONS
            OTHERS     = 1.
        CALL METHOD html_control->show_url
          EXPORTING
            url        = 'chart.svg'
            in_place   = 'X'
          EXCEPTIONS
            cntl_error = 1.
    Has anyone a solution? Thanks in advance for your help!
    Regards
    Kathrin

    Hello Alex,
    The Corel SVG viewer has problems loading and displaying the examples (see the list of limitations at their site). Try to use the Adobe viewer instead.
    Regards,
    Sergei Ulasenka

  • Drawing graphics in RT

    Ok, gonna try to explain my problem:
    I'm into a program who draws graphics using points as they come in.
    By now I repaint() every second the graphs every second but my paint() method redraws all the points received instead of just adding the last one received.
    Any help for getting my already received points in the graph and just add the last one? ( I wanna repaint only if my scale changes )

    I suppose you have a datastructure (like an array or ArrayList) for storing the points, and in the paint method you are redrawing them all.
    So you have to change your strategy. Instead of keeping your points in an array, just draw them in a BufferedImage, and in the paint draw the BufferedImage on the Panel. The code inside paint(Graphics g) will look something like : g.drawImage(bufferedImage, 0, 0, this);
    That way you have a fast and flicker free repaint method.
    Notice that this method will loose all information about point coordinates because it will simply draw them on the BufferedImage. So if you want to be storing the point coordinates for further use (maybe the ability to edit or delete them) you'll have to keep them in a separate datastructure also.
    Hope this helps,
    Ioannis

  • Help in drawing graphics.

    Hi friends,
    I'm newbie in drawing graphics with Java, and I need some help in a specific part of my program.
    What I want to do is to draw a waveform of a sound file. That waveform is built based on the amplitude of each sound sample. So I have a big vector full of those amplitudes. Now what I need to do is plot each point on the screen. The x coordinate of the point will be its time position in the time axis. The y coordinate of the point will be the amplitude value. Ok... Now I have a lot of doubts...
    1 - can someone give me a simple example on how to plot points in a java app? I know I have to extend a JPainel class, but I don't know much about those paint, and repaint methods. It's all weird to me. I already searched through the tutorial and the web, but I couldn't see a simple, good example. Can someone hand me this?
    2 - Once I know how to draw those graphics, I need to find a way to put a button, or anything like that, in my app, so the user can press that button to see to next part of the waveform, since the wave is BIG, and doesn't fit entirely on the screen. Is this button idea ok? Can I use some sort of SCROLL on it, would it be better?
    Well... I'm trying to learn it all. ANY help will be appreciated, ANY good link, little hint, first step, anything.
    Thanks for all, in advance.
    Leonardo
    (Brazil)

    This will lead you, in this sample you have a panel and a button,
    every click will fill a vector with random 700 points and draw them on the panel,
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    public class Wave extends Frame implements ActionListener
         WPanel   pan    = new WPanel();
         Vector   points = new Vector();
         Button   go     = new Button("Go");
         Panel    cont   = new Panel();
    public Wave()
         super();
         setBounds(6,6,700,400);     
         addWindowListener(new WindowAdapter()
        {     public void windowClosing(WindowEvent ev)
                   dispose();     
                   System.exit(0);
         add("Center",pan);
         go.addActionListener(this);
         cont.add(go);
         add("South",cont);
         setVisible(true);
    public void actionPerformed(ActionEvent a)
         points.removeAllElements();
         for (int j=0; j < 700; j++)
              int y = (int)(Math.random()*350);
              points.add(new Point(j,y+1));
         pan.draw(points);
    public class WPanel extends Panel
         Vector   points;
    public WPanel()
         setBackground(Color.pink);
    public void draw(Vector points)
         this.points = points;
         repaint();
    public void paint(Graphics g)
         super.paint(g);
         if (points == null) return;
         for (int j=1; j < points.size(); j++)
              Point p1 = (Point)points.get(j-1);
              Point p2 = (Point)points.get(j);
              g.drawLine(p1.x,p1.y,p2.x,p2.y);
    public static void main (String[] args)
         new Wave();  
    Noah

  • Draw graphics on Image and Save it

    hi!,
    Can anyone help me how to draw graphics(Line, rectangle.ect) on an Image and save it. I need to do the following steps.
    1. Get the Image from the local file system
    2. Based on the parameters i receive for graphics(Ex: rectangle).
    -I have to draw a rectangle on the Image.
    3. Save the Image again to the file system
    I would appreciate if any one has any ideas or sample code I can start with.
    Thanks!!!

    Here's an example using the javax.imageio package.
    import java.awt.Color;
    import java.awt.Graphics2D;
    import java.awt.Rectangle;
    import java.awt.image.BufferedImage;
    import java.io.File;
    import java.io.IOException;
    import javax.imageio.ImageIO;
    public class DrawOnImage {
        public static void main(String[] args) {
            try {
                BufferedImage buffer = ImageIO.read(new File(args[0]));
                Graphics2D g2d = buffer.createGraphics();
                Rectangle rect = new Rectangle(10, 10, 100, 100);
                g2d.setPaint(Color.RED);
                g2d.draw(rect);
                ImageIO.write(buffer, "JPG", new File(args[1]));
            } catch (IOException e) {
                e.printStackTrace();
    }

  • How to call - draw(Graphics g)

    This is a little method in my Applet:
    public void draw(Graphics g)
    g.drawImage(image, 0, 0, this);
    What I want is to call this method when I need it, not automatically like paint(Graphics g), but I couldn't figure out how to call, because Graphics is abstract class, can not be instantiated .
    Pleeeeeeeeeeeeease help me out , many thanks !!!

    This is a little method in my Applet:
    public void draw(Graphics g)
    g.drawImage(image, 0, 0, this);
    What I want is to call this method when I need it,Why?
    not automatically like paint(Graphics g), but I
    couldn't figure out how to call, because Graphics is
    abstract class, can not be instantiated .Right. You can't, nor should you ever need to do what you want to do. The Graphics object is passed to you in the paint() method.
    See:
    http://java.sun.com/products/jfc/tsc/articles/painting/index.html

  • Draw graphics, circles

    Hi Guys,
    I ahve a question in ABAP using graphics.
    can we draw a circle, rectangle(a box) , arrows in ABAP.
    My requierment is, we have certain products which we need to link with arrows and there are group of products which I need to put into circle or rectangle.
    plz suggest..
    regards,
    Nazeer

    Hi Nazeer,
    use given below code & try to understand. Test run on your server.
    DATA: BEGIN OF TAB OCCURS 5,
          CLASS(10) TYPE C,
          VAL1(2) TYPE I,
          VAL2(2) TYPE I,
          VAL3(2) TYPE I,
          VAL4(2) TYPE I,
          VAL5(2) TYPE I,
          VAL6(2) TYPE I,
          END OF TAB.
    DATA: BEGIN OF OPTTAB OCCURS 1,
            C(20),
          END OF OPTTAB.
    MOVE: 'anik' TO TAB-CLASS,
          6 TO TAB-VAL1, 7 TO TAB-VAL2, 8 TO TAB-VAL3, 3 TO TAB-VAL4,  5 TO TAB-VAL5, 6 TO TAB-VAL6.
    APPEND TAB.
    CLEAR TAB.
    MOVE: 'narendra' TO TAB-CLASS,
          15 TO TAB-VAL1, 10 TO TAB-VAL2, 18 TO TAB-VAL3, 3 TO TAB-VAL4,  5 TO TAB-VAL5, 6 TO TAB-VAL6 .
    APPEND TAB.
    CLEAR TAB.
    MOVE: 'gaurav' TO TAB-CLASS,
          17 TO TAB-VAL1, 11 TO TAB-VAL2, 20 TO TAB-VAL3, 3 TO TAB-VAL4,  5 TO TAB-VAL5, 6 TO TAB-VAL6.
    APPEND TAB.
    CLEAR TAB.
    MOVE: 'Kushagra' TO TAB-CLASS,
          10 TO TAB-VAL1, 12 TO TAB-VAL2, 15 TO TAB-VAL3, 3 TO TAB-VAL4,  5 TO TAB-VAL5, 6 TO TAB-VAL6.
    APPEND TAB.
    OPTTAB = 'FIFRST = 3D'.     APPEND OPTTAB.
    OPTTAB = 'P2TYPE = TO'.     APPEND OPTTAB.
    OPTTAB = 'P3TYPE = PY'.     APPEND OPTTAB.
    OPTTAB = 'P3CTYP = RO'.     APPEND OPTTAB.
    OPTTAB = 'TISIZE = 5'.      APPEND OPTTAB.
    OPTTAB = 'CLBACK = X'.      APPEND OPTTAB.
    *CALL FUNCTION 'GRAPH_MATRIX_3D'
        EXPORTING*
             COL1        = 'monday'*
             COL2        = 'tuesday'*
             COL3        = 'wednesday'*
             DIM2        = 'employees'*
             DIM1        = 'months'*
             TITL        = 'Comparison of Employee attendace in different months.'*
        TABLES*
             DATA        = TAB*
             OPTS        = OPTTAB*
        EXCEPTIONS*
             OTHERS      = 1.*
    CALL FUNCTION 'GRAPH_MATRIX_3D'
      EXPORTING
        COL1 = 'monday'
        COL2 = 'tuesday'
        COL3 = 'wednesday'
        COL4 = 'thursday'
        COL5 = 'friday'
        COL6 = 'saturday'
        DIM1 = 'week days'
        DIM2 = 'employees'
      TABLES
        DATA = TAB
        OPTS = OPTTAB.
    LEAVE PROGRAM.
    I hope it will help u a lot.
    Regards,
    Narendra

  • Graphics in ABAP OO

    Hi,
         I have to do an application and I have doubt about using ABAP OO or JAVA: it is necessary using a gantt graphic, but the user can move the bars! I know that is possible in Java, using an applet, but would be better using ABAP OO. It's is possible?
    Tks,
    Regards,
    Rafael Soares

    Rafael,
       Take a look at the following Classes that deals with the Graphics:
        1. CL_ALV_GRAPHICS
        2. CLG_GRAPHICS_CHART
        3. CL_DC_GRAPH_RFW
        4. CL_GRAPH_TUT_CHART_MODEL
    It would help you.
    Thanks
    Kam

  • JAVA Drawing Graphics Save as JPEG?

    My problem is this, I am trying to save my g2 graphic image to a jpg. This is how I have things setup, I will show code and my thoughts. What I need is help to figure out how I could save seperate .java files graphics g to the jpg format from a JFileChooser in a different .java file.
    HERE IS THE CODE FOR HOW GRAPH IS CREATED. graph.java
    I have a graph I am drawing in a seperate .java file and it is created like this:
    public class graph extends JPanel {
        public static Graphics2D g2;
        final int HPAD = 60, VPAD = 40;
        int[] data;
        Font font;
        public test() {
            data = new int[] {120, 190, 211, 75, 30, 290, 182, 65, 85, 120, 100, 101};
            font = new Font("lucida sans regular", Font.PLAIN, 8);       
            setBackground(Color.white);
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            g2.setFont(font);
            FontRenderContext frc = g2.getFontRenderContext();
            int w = getWidth();
            int h = getHeight();
            // scales
            float xInc = (w - HPAD - HPAD) / 10f;
            float yInc = (h - 2*VPAD) / 10f;
            int[] dataVals = getDataVals();
            float yScale = dataVals[2] / 10f;
    //        etc... (the rest is just drawing...blah...blah)
    }HERE IS THE CODE FOR HOW MY GRAPH IS DISPLAYED AND TRYING TO BE SAVED. results.java
    The graph I created is then displayed in a JPanel and there is a button in the results window to save the graph results. This is where I am having difficulty as I am trying to save the g2 from graph.java (declared public static...not sure if this a good idea) but anyway I want to save this as a jpg heres the code:
            resultPanel = new JPanel(new PercentLayout());
            graph drawing = new graph();
            resultPanel.add (
                drawing,
                new PercentLayout.Constraint(1,41,49,50));
            resultPanel.add (
                saveButton1,
                new PercentLayout.Constraint(1,94,25,5));
        public void actionPerformed(ActionEvent e) {
            if(e.getSource() == saveButton1) {
                doSaveGraph();
        public void doSaveGraph() {
            JFileChooser fileSaver;
            fileSaver = new JFileChooser(); // The file-opening dialog
            ExampleFileFilter filter = new ExampleFileFilter("jpg");
            filter.setDescription("JPEG Picture File");
            fileSaver.addChoosableFileFilter(filter);
            try {
                if(fileSaver.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
                    File f = fileSaver.getSelectedFile();
                    BufferedImage img = new BufferedImage(672,600, BufferedImage.TYPE_INT_RGB);
          // SOMEWHERE IN HERE IS WHERE I NEED TO GRAB G2?  I AM NOT SURE WHAT TO DO HERE
                    //Graphics g = img.getGraphics();
                    //panel.paint(g);
                    BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(f));
                    JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
                    JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(img);
                    param.setQuality(1f, true);
                    encoder.setJPEGEncodeParam(param);
                    encoder.encode(img);
                    System.out.println("It worked");
                else{}
            catch (Exception e) {
                e.printStackTrace();
    ...If you can help me I will be very happy, and give you 10 dukes! LOL and I appreciate the help!

    import java.awt.*;
    import java.awt.event.*;
    import java.awt.font.*;
    import java.awt.geom.*;
    import java.awt.image.BufferedImage;
    import java.io.*;
    import javax.imageio.ImageIO;
    import javax.swing.*;
    public class SavingGraphics
        public static void main(String[] args)
            GraphicsCreationPanel graphicsPanel = new GraphicsCreationPanel();
            GraphicsSaver saver = new GraphicsSaver(graphicsPanel);
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(saver.getUIPanel(), "North");
            f.getContentPane().add(graphicsPanel);
            f.setSize(400,400);
            f.setLocation(200,200);
            f.setVisible(true);
    class GraphicsCreationPanel extends JPanel
        String text;
        Font font;
        public GraphicsCreationPanel()
            text = "hello world";
            font = new Font("lucida bright regular", Font.PLAIN, 36);
            setBackground(Color.white);
        protected void paintComponent(Graphics g)
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            int w = getWidth();
            int h = getHeight();
            g2.setPaint(Color.blue);
            g2.draw(new Rectangle2D.Double(w/16, h/16, w*7/8, h*7/8));
            g2.setPaint(Color.orange);
            g2.fill(new Ellipse2D.Double(w/12, h/12, w*5/6, h*5/6));
            g2.setPaint(Color.red);
            g2.fill(new Ellipse2D.Double(w/6, h/6, w*2/3, h*2/3));
            g2.setPaint(Color.black);
            g2.setFont(font);
            FontRenderContext frc = g2.getFontRenderContext();
            LineMetrics lm = font.getLineMetrics(text, frc);
            float textWidth = (float)font.getStringBounds(text, frc).getWidth();
            float x = (w - textWidth)/2;
            float y = (h + lm.getHeight())/2 - lm.getDescent();
            g2.drawString(text, x, y);
    class GraphicsSaver
        GraphicsCreationPanel graphicsPanel;
        JFileChooser fileChooser;
        public GraphicsSaver(GraphicsCreationPanel gcp)
            graphicsPanel = gcp;
            fileChooser = new JFileChooser(".");
        private void save()
            if(fileChooser.showSaveDialog(null) == JFileChooser.APPROVE_OPTION)
                File file = fileChooser.getSelectedFile();
                String ext = file.getPath().substring(file.getPath().indexOf(".") + 1);
                BufferedImage image = getImage();
                try
                    ImageIO.write(image, ext, file);
                catch(IOException ioe)
                    System.out.println("write: " + ioe.getMessage());
        private BufferedImage getImage()
            int w = graphicsPanel.getWidth();
            int h = graphicsPanel.getHeight();
            BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
            Graphics2D g2 = bi.createGraphics();
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            graphicsPanel.paint(g2);
            g2.dispose();
            return bi;
        public JPanel getUIPanel()
            JButton save = new JButton("save");
            save.addActionListener(new ActionListener()
                public void actionPerformed(ActionEvent e)
                    save();
            JPanel panel = new JPanel();
            panel.add(save);
            return panel;
    }

  • How to mail chart/graphics in abap

    Hi there,
    I have some abap that creates great charts using GRAPH_MATRIX.
    I have also abaps that send emails with attachments.
    Now I want to email a chart, but I don't know what to specify inn the SO_CONTENT.
    Has anyone experince with this please?
    I did found the following:
    "If the field SO_SEND is set to a value other than SPACE, then the graphic is NOT output on the screen. Instead, a SAPoffice document is generated which is described by the parameters SO_RECEIVER, SO_TITLE and SO_CONTENTS."
    any help appreciated!!
    danny

    Hi,
    You can see a PERFORM GR_SEND called in this function
    Which in turn calls functions SO_OBJECT_INSERT & SO_DYNP_OBJECT_SEND & SO_OBJECT_SEND
    in the include LGRAPFGL  to send the email.
    May be you can debug and check what is happening and you can include the same logic in your program.

  • Possible to view graphics in ABAP documentation without printing?

    I have uploaded a bitmap to the document server and included it in the documentation of my component (an interface, in this case), for which the ABAP workbench generates the statement
    BITMAP 'BO_VSAB' OBJECT GRAPHICS ID BMAP TYPE BCOL DPI 300
    The picture is displayed in the print preview, and also prints alright.  I'd prefer to see it without printing, though, while simply viewing the documentation online. Is there a trick to achieve that, for example by using a different form than the standard S_DOCU_SHOW, or whatever?
    -- Sebastian

    Quite honestly, so far I've never seen any ABAP documentation with images. I kind of doubt it is feasible because the thingy that displays documentation most likely doesn't have any capability of displaying graphics. I'm guessing there is simply no container or screen element for that.
    I'm affraid you'll have to create your own screen to achieve this.

  • Drawing Graphics in AWT panel

    I was wondering if anybody knows how I would go about drawing onto a Panel as a result of an actionPerformed() call. I got the original code for displaying an image onto the Panel from aresICO on this forum and now I need to be able to click a button on the GUI and have something drawn onto that Panel.
    import java.applet.*;
    import java.awt.*;
    import java.awt.image.ImageObserver;
    public class iPane extends Panel {
         Image im;
         boolean loaded = false;
         public iPane () {
              Toolkit tk = Toolkit.getDefaultToolkit ();
              im = tk.getImage ("Map of Dublin.jpg");
              prepareImage (im, -1, -1, this);
         public void paint (Graphics g) {
              if (loaded)
              g.drawImage (im, 20, 20, this);
         public void update (Graphics g) {
              paint (g);
              // if proper values loaded then:
              //drawRoute (g);
         public void drawRoute (Graphics g) {
              g.setColor(Color.red);
              g.drawLine(273,51,334,61);
              // method takes in values from a file etc.
         public synchronized boolean imageUpdate (Image image, int infoFlags,int x, int y, int width, int height) {
              if ((infoFlags & ImageObserver.ALLBITS) != 0) {
                   loaded = true;
                   repaint();
                   return false;
              else {
                   return true;
         public Dimension getPreferredSize() {
              return new Dimension(im.getWidth(this),im.getHeight(this));
         public Dimension getMinimumSize() {
              return getPreferredSize();
    }; // end iPane class
    This is a the relevant part of the class which uses an iPane object:
    iPane mapPanel;
    public void actionPerformed(ActionEvent e)
         String buttonLabel = e.getActionCommand();
         if (e.getSource() instanceof Button)
              if (buttonLabel.equals("Get Directions"))     
    // What goes in here to draw a line for example?
    // How do I call a method from iPane to draw something?
    Thanks.

    Davey,
    I don't think your approach is correct. The golden rule of Java graphics is that ALL of painting on a component should be done within the componen'ts paint method(). If you write to iPane from outside the class, then if your iPanel needs to be repainted (because, for example, it got obscured by another window and then unobscured) then the route would not be shown.
    You have to think OOD on this.
    The route and the image are properties of the of iPanel. The button push requests a change of those properties and display of the results on the screen.
    This is what I would do:
    1. Create member variables in the class iPanel that define the route.
    2. Have a method which sets those variables. This method should call repaint after setting the variables.
    2. Maybe have another boolean which says whether the routine is to be displayed or not. This method should call repaint after setting the boolean.
    3. Change the paint method to draw the route, if required.
    4. In the class that uses iPanel, simply call the methods in iPanel that set the route properties.
    5. Change your class name to IPanel. All class names should start with an upper case letter.
    e.g.,
    private Point start;
    private Point end;
    private boolean displayRoute
    public setRoute(Point newStart, Point newEnd) {
    start = newStart;
    end = newEnd;
    repaint(); // maybe only call if new value is different
    public void setDisplayRoute(boolean value) {
    displayRoute = value;
    repaint(); // maybe only call if new value is different
    public void paint(Graphics g) {
    g.drawImage( ..... blah
    if (displayRoute) {
    g.drawline ( .... blah
    // Then
    onActionPerformed
    iPanel.setRoute(new Point(1,2), new Point(3,4));

  • Drawing graphics in an Applet in layers??

    Hello,
    I have a tricky question, where I am not sure if java would supprot what I need.
    I am drawing grahps using Graphics in a class that exdends Applet.
    I would like to be able to draw two different things on the same 'canvas' without overwriting one another. Something that comes to mind as analogy is Layers but I couldn't find if Graphics has this or similar feature.
    Basically, right now, if I want to draw something new on the canvas, I have to erase (owervrite) what was there before but I don't want to do that. I want to be able to add something on top of the old graphic and then later remove what I had drawn on top and still have the old graphic be there intact.
    Any suggestions if this is possible and if yes, how I can do that?
    (I am using Graphics methods such as: g.drawString, g.drawLine, g.drawLine etc.)
    Helo appreciated,
    Ivan

    Keep a java.util.List of things you want to draw. Each item in the list is like a layer. Draw the items in order in your paint method.
    If you choose that you want to remove the top item, then remove the last item from the list, and redraw.

  • Compile error in paint() method while trying to draw graphics

    Hi ,
    I am trying to draw two lines given the sceen coordinated through a mouse click. I am getting the following error
    Pos.java:90: illegal start of expression
    public void paint(Graphics g)
    ^
    Pos.java:102: ';' expected
    ^
    2 errors
    My code is as follows:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.awt.geom.*;
    public class Pos extends Container {
    //public void paint(Graphics);
    public static void main(String args[]) {
    Pos p = new Pos();
         p.getPosition();
    JButton bn = new JButton("Draw Line");
    int posx=0;
    int posy=0;
    int i=0;
    int x[] = new int[4];
    int y[] = new int[4];
    public void getPosition() {
    JFrame frame = new JFrame("Mouse Position");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JLabel label = new JLabel();
    label.setHorizontalAlignment(JLabel.CENTER);
    /*MouseMotionListener mouseMotionListener = new MouseMotionListener() {
    public void mouseDragged(MouseEvent e) {
    public void mouseMoved(MouseEvent e) {
              MouseListener mouseListener = new MouseListener(){
                   public void mouseEntered(MouseEvent evnt){
                   public void mouseExited(MouseEvent evnt){
                   public void mousePressed(MouseEvent evnt){
                   public void mouseReleased(MouseEvent evnt){
                   public void mouseClicked(MouseEvent evnt) {
                        showMousePos(evnt);
                        //mon.setText("("+MouseInfo.getPointerInfo().getLocation().x+","+
                                            //MouseInfo.getPointerInfo().getLocation().y+")");
                   private void showMousePos(MouseEvent evnt) {
    JLabel src = (JLabel)evnt.getComponent();
                   posx = MouseInfo.getPointerInfo().getLocation().x;
                   posy = MouseInfo.getPointerInfo().getLocation().y;
    System.out.println("x-coordinate="+posx);
                   System.out.println("y-coordinate="+posy);
                   x=posx;
                   y[i]=posy;
                   i=i+1;
              label.addMouseMotionListener(mouseMotionListener);
              label.addMouseListener(mouseListener);
              label.addActionListener(actionListener);
    frame.add(label, BorderLayout.CENTER);
              bn.setSize(10,10);
              frame.add(bn, BorderLayout.NORTH);
    frame.setSize(300, 300);
    frame.setVisible(true);
         ActionListener actionListener = new ActionListener(){
                   public void actionPerformed(ActionEvent ae)
                        Object o = ae.getSource();
                        if (o==button)
                             public void paint(Graphics g)
                                  Graphics2D g2D = (Graphics2D)g;
                                  //int p[]=new int[4];
                                  g2D.setColor(Color.red);
                                  //for (int j=0;j<2;j++)
                                       //Point2D.Int p[j]= new Point2D.Int(x[j],y[j]);                              
                                  //Line2D line = new Line2D.Int(p[0],p[1]);
                                  g2D.drawline(x[0],y[0],x[1],y[1]);
                                  i=0;
    Please tell me what the mistake is.
    lakki

    Thank you all for the sggestions. The error was exactly due to what you mentioned above. I fixed that by drawing the lines on another JPanel and it is working now.
    But I have a bigger problem. How to make a JPanel transparent. I have to draw lines on a video. The panel for drawing lines is opaque and so I can draw lines only if I am able to see the video. setOpaque(false) does not seem to work. I am posting my code below. Please see if you can help me out.
    import javax.media.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.util.*;
    import java.lang.Math;
    import javax.media.control.FramePositioningControl;
    import javax.media.protocol.*;
    import javax.swing.*;
    class MPEGPlayer2 extends JFrame implements ActionListener,ControllerListener,ItemListener
         Player player;
         Component vc, cc;
         boolean first = true, loop = false;
         String currentDirectory;
         int mediatime;
         BufferedWriter out;
         FileWriter fos;
         String filename = "";
         Object waitSync = new Object();
         boolean stateTransitionOK = true;
         JButton bn = new JButton("DrawLine");
         MPEGPlayer2 (String title)
              super (title);
              addWindowListener(new WindowAdapter ()
                   public void windowClosing (WindowEvent e)
                        dispose ();
                public void windowClosed (WindowEvent e)
                        if (player != null)
                        player.close ();
                        System.exit (0);
              Menu m = new Menu ("File");
              MenuItem mi = new MenuItem ("Open...");
              mi.addActionListener (this);
              m.add (mi);
              m.addSeparator ();
              CheckboxMenuItem cbmi = new CheckboxMenuItem ("Loop", false);
              cbmi.addItemListener (this);
              m.add (cbmi);
              m.addSeparator ();
              mi = new MenuItem ("Exit");
              mi.addActionListener (this);
              m.add (mi);
              MenuBar mb = new MenuBar ();
              mb.add (m);
              setMenuBar (mb);
              setSize (500, 500);
              setVisible (true);
         public void actionPerformed (ActionEvent ae)
                        FileDialog fd = new FileDialog (this, "Open File",FileDialog.LOAD);
                        fd.setDirectory (currentDirectory);
                        fd.show ();
                        if (fd.getFile () == null)
                        return;
                        currentDirectory = fd.getDirectory ();
                        try
                             player = Manager.createPlayer (new MediaLocator("file:" +fd.getDirectory () +fd.getFile ()));
                             filename = fd.getFile();
                        catch (Exception exe)
                             System.out.println(exe);
                        if (player == null)
                             System.out.println ("Trouble creating a player.");
                             return;
                        setTitle (fd.getFile ());
                        player.addControllerListener (this);
                        player.prefetch ();
         }// end of action performed
         public void controllerUpdate (ControllerEvent e)
              if (e instanceof EndOfMediaEvent)
                   if (loop)
                        player.setMediaTime (new Time (0));
                        player.start ();
                   return;
              if (e instanceof PrefetchCompleteEvent)
                   player.start ();
                   return;
              if (e instanceof RealizeCompleteEvent)
                   vc = player.getVisualComponent ();
                   if (vc != null)
                        add (vc);
                   cc = player.getControlPanelComponent ();
                   if (cc != null)
                        add (cc, BorderLayout.SOUTH);
                   add(new MyPanel());
                   pack ();
         public void itemStateChanged(ItemEvent ee)
         public static void main (String [] args)
              MPEGPlayer2 mp = new MPEGPlayer2 ("Media Player 2.0");
              System.out.println("111111");
    class MyPanel extends JPanel
         int i=0,j;
         public int xc[]= new int[100];
         public int yc[]= new int[100];
         int a,b,c,d;
         public MyPanel()
              setOpaque(false);
              setBorder(BorderFactory.createLineBorder(Color.black));
              JButton bn = new JButton("DrawLine");
              this.add(bn);
              bn.addActionListener(actionListener);
              setBackground(Color.CYAN);
              addMouseListener(new MouseAdapter()
                            public void mouseClicked(MouseEvent e)
                        saveCoordinates(e.getX(),e.getY());
         ActionListener actionListener = new ActionListener()
              public void actionPerformed(ActionEvent aae)
                        repaint();
         public void saveCoordinates(int x, int y)
              System.out.println("x-coordinate="+x);
                   System.out.println("y-coordinate="+y);
                   xc=x;
              yc[i]=y;
              System.out.println("i="+i);
              i=i+1;
         public Dimension getPreferredSize()
    return new Dimension(500,500);
         public void paintComponent(Graphics g)
    super.paintComponent(g);
              Graphics2D g2D = (Graphics2D)g;
              //g2D.setComposite(AlphaComposite.getInstance(AlphaComposite.CLEAR, 0.0f));
              g2D.setColor(Color.GREEN);
              for (j=0;j<i;j=j+2)
                   g2D.drawLine(xc[j],yc[j],xc[j+1],yc[j+1]);

  • Graphic in ABAP Adobe form from SE78

    Hi All,
    I am trying to display image(SE78) in ABAP Adobe interactive form.
    But it is not displaying  any image in run time.
    I use following code. Can any one guide what could be the problem
    method WDDOINIT .
      DATA lo_nd_adobe TYPE REF TO if_wd_context_node.
      DATA lo_el_adobe TYPE REF TO if_wd_context_element.
      DATA ls_adobe TYPE wd_this->element_adobe.
    * navigate from <CONTEXT> to <ADOBE> via lead selection
      lo_nd_adobe = wd_context->get_child_node( name = wd_this->wdctx_adobe ).
    * get element via lead selection
      lo_el_adobe = lo_nd_adobe->get_element(  ).
    * get all declared attributes
      lo_el_adobe->get_static_attributes(
        IMPORTING
          static_attributes = ls_adobe ).
    *---------Code To select LOGO & PERNR
    CONSTANTS:    c_graphics    TYPE   tdobjectgr  VALUE 'GRAPHICS',
                  c_bmap        TYPE   tdidgr      VALUE 'BMAP' ,
                  c_bcol        TYPE   tdbtype     VALUE 'BCOL'.
      DATA:       lv_logo       TYPE   tdobname.
    *--pernr
      ls_adobe-pernr = '80000086'.
    *--Get the Logo
      lv_logo = 'OURSOURCE_LOGO'.
      CALL METHOD cl_ssf_xsf_utilities=>get_bds_graphic_as_bmp
        EXPORTING
          p_object       = c_graphics
          p_name         = lv_logo
          p_id           = c_bmap
          p_btype        = c_bcol
        RECEIVING
          p_bmp          = ls_adobe-logo
        EXCEPTIONS
          not_found      = 1
          internal_error = 2
          OTHERS         = 3.
    *--Send the values back to the node
      lo_el_adobe->set_static_attributes(
        EXPORTING
          static_attributes = ls_adobe ).
    endmethod.

    I'm assuming you want a different logo per document? Otherwise, you could just use an image object in Adobe for your logo.
    does the code return the appropriate subrc when you grab your logo? Do you have your context bound to an image object in Adobe?
    EDIT: also, what does your Context look like?
    Edited by: robert phelan on Feb 19, 2009 10:01 PM

Maybe you are looking for

  • There was an error opening this document.  The file is damaged and could not be repaired.

    Good Day all When busy doing internet banking on www.absa.co.za and I try to print a confirmation, I get the following error message: "C:\Documents and Settings\%user profile%\Local Settings\Temporary Internet Files\Content.IE5\%folder name%\%file na

  • Digital copy codes not working

    Hi, I'm from the uk and I've got quite a few bluray DVDs with digital copies with them, they have codes but I don't have a computer to put the disks in to then move them to the iTunes is there any way I can just put the films straight to iTunes with

  • I cant load some web pages from safari?

    My Mac has over the last 24 hrs become very slow!  It will load some pages but not others.  I can access my email on Hotmail but not google or apple etc?  When I click on safari the apple address comes up but the page doesn't load the blue bar is hal

  • Incorrect results in query

    Hi All, I've created a calculatedKF named 'Asset Cost' which is a sum of 6 KFs. I am using the same in my query as a 'New selection' with restriction based on a varaible on 'posting period'. Means if i give the posting period value as '8', i'll get t

  • Group by week

    Hi, I need to build a SQL Query that group data by week. for example : table looks like this the_date the_qty 6/5/2002 1 6/10/2002 4 6/14/2002 5 6/15/2002 36 6/19/2002 76 6/20/2002 88 6/21/2002 88 6/22/2002 24 6/24/2002 53 6/25/2002 281 6/28/2002 2 6