Graphics without using paint

Hi!
I want to draw somthing without using paint. Does anyone know how to do that?
f.eks
I want to call a function with some parameters, and then the function draws something for me with these parameters.
Thanks for helping:)
Best regards
Stian

Sure... You could use the function to generate an image file and load that using ImageIcon and pass that to a JLabel.
But that's not going to work nearly as fast as just using paint.

Similar Messages

  • How to initialize Graphics object without using paint method??

    This is a code to make sierpinski triangle using IFS.
    I am using a button called "Iterate" which calls funtion paint() .
    paint1() gets called from paint on pressing the button.
    I want to convert a square into Sierpinski triangle by iterations.
    I want to make a square first .If I put that code in paint() then it gets called everytime.
    so problem lines are: Graphics g;
    g.drawLine(0,0,99,0);
    g.drawLine(0,0,0,99);
    g.drawLine(0,99,99,99);
    g.drawLine(99,0,99,99);
    it gives error as object not initialised.
    rest of the working code is as follows.
    import java.applet.Applet;
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    public class mys31 extends Applet implements ActionListener{
    String msg ="";
    Button iterate;
    int i,j;
    double [][]t;
    double [][]s;
    double []a;
    double []b;
    double []c;
    double []d;
    double []e;
    double []f;
    public void init() {
    t=new double[100][100];
    s=new double[100][100];
    a=new double[]{0.5,0.5,0.5};
    b=new double[]{0.0,0.0,0.0};
    c=new double[]{0.0,0.0,0.0};
    d=new double[]{0.5,0.5,0.5};
    e=new double[]{1.0,1.0,50.0};
    f=new double[]{1.0,50.0,50.0};
    for(i=0;i<100;i++)
    t[0]=1.0;
    t[0][i]=1.0;
    t[99][i]=1.0;
    t[i][99]=1.0;
    for(i=0;i<100;i++)
    for(j=0;j<100;j++)
    s[i][j]=0.0;
    iterate = new Button("Iterate");
    add(iterate);
    iterate.addActionListener(this);
    } // end init
    public void actionPerformed(ActionEvent ae){
    String str = ae.getActionCommand();
    if(str.equals("Iterate"))
    msg=" working";
    repaint();
    } //end of action Performed
    public void paint (Graphics g) {
    g.drawString(msg,200,200);
    paint1(g);
    } // end paint
    public void paint1(Graphics g)
    int j=0,i;
    for(i=0;i<100;i++)
    for(j=0;j<100;j++)
    if(t[i][j]==1)
    s[(int)(a[0]*i b[0]*j e[0])][(int)(c[0]*i + d[0]*j + f [0])]=1;
    s[(int)(a[1]*i b[1]*j e[1])][(int)(c[1]*i + d[1]*j + f [1])]=1;
    s[(int)(a[2]*i b[2]*j e[2])][(int)(c[2]*i + d[2]*j + f [2])]=1;
    g.setColor(Color.red);
    for(i=0;i<100;i++)
    for(j=0;j<100;j++)
    t[i][j]=s[i][j];
    s[i][j]=0.0;
    if(t[i][j]==1.0)
    g.drawLine(i,j,i,j);
    }//end paint1
    } // end class

    I don't see a question here.
    Anyway I would suggest using double buffering - drawing on a BufferedImage and drawing the BufferedImage inside paint.
    You will have to call repaint every iteration.

  • How to fill polygon without using paint component ?

    hello,
    i have a class called "public class Arrow2DRhombus implements Shape" with the following constructor:
    public Arrow2DRhombus(Point2D begin, Point2D end) {
            this.x1 = begin.getX();
            this.y1 = begin.getY();
            this.x2 = end.getX();
            this.y2 = end.getY();
            this.initArrow();the code for .initArrow():
    private void initArrow(){
            int length = (int) Math.sqrt(Math.pow(Math.abs(x1-x2),2) +
                           Math.pow(Math.abs(y1-y2),2));
            length=length-19;
    Polygon poly = new Polygon();
            poly.addPoint((int) x1,(int) y1);
            poly.addPoint((int) x1+ length,(int) y1);
              poly.addPoint((int) x1+ length+10,(int) y1+5);
              poly.addPoint((int) x1+ length+20,(int) y1);
              poly.addPoint((int) x1+ length+10,(int) y1-5);
              poly.addPoint((int) x1+ length,(int) y1);
            double rad = this.calcAngle((float) this.x1,(float) this.y1,(float) this.x2,(float) this.y2);
            AffineTransform tx = AffineTransform.getRotateInstance(rad,x1,y1);
            this.arrow = tx.createTransformedShape((Shape)poly);
        }is there a way i can fill the polygon "poly" with the code above .
    i know that i can fill a polygon using when using paintcomponent(Graphics g)
    but here how can i do it.
    10x

    I don't really understand the question. "Filling" a shape implies (to me) that you have a Graphics Object and are doing custom painting. So you would do this:
    a) in the paintComponent() method of a component
    b) in the paintIcon method of an Icon
    c) by painting onto a BufferedImage
    I'm sure there are other ways, but I don't think you just "fill" a Shape object.

  • Can we create graphic and text in the same window of smartform without using template?

    we create graphic and text in the same window of smartform without using template?

    Hi Kinjal,
    as far as i understand you are talking about a template which you can partitioned and in one part you wants to show your graphics and in other part you wants to print your text, the border of template shall remain invisible.
    If you wants to do it without using a template, you can do it as sujjested by Susmitha, but creating a template will provide you more flexibility that if you wants to change the attributes in future you can do it easily.

  • Displaying X� ,X� and so on  without using graphics

    Hi I want to disply X� X� and so on without using graphics.
    Is it possible if yes how.
    thanks
    dharmendra

    answered in http://forum.java.sun.com/thread.jsp?forum=31&thread=354790

  • Using text in a GUI without using .swing classes

    In a Java application, is there any way to create a text object that can be positioned in a GUI like an ImageIcon (using a class from the standard Java API)? For example, when using ImageIcon, you feed the x and y-coordinates, whereas with .swing, you'd have to create a new panel, position the panel, and re-position the panel using BorderLayout.(direction).
    Ex. (with ImageIcon, you'd place it like so):
    //construct ImageIcon w/ URL
    ImageIcon myImage = new ImageIcon(new URL("http://..."));
    //x and y are pixels to the right and to the bottom from the top left corner
    myImage.paintIcon( (Component), (Graphics), x, y);
    //I'm looking for one that does the same, like this (without using an image, preferrably), TextMessage is what the class might be:
    TextMessage myText = new TextMessage("Here is some string to print out");
    myText.printText( (Component), (Graphics), x, y)

    or you can paint a string, like this
    public void paint(Graphics g) {
         super.paint(g);
         g.drawString("Hello World!", x,y);  // replace x, y with your own coordinates
    }hope that helps

  • Any way to open new browser window without using image maps?

    Is there any way to open new browser window without using image maps? My code works fine in Firefox, but not in IE. There are 2 problems in IE: 1st is that the thumbnail images move up within their own borders & 2nd that when you click on an image it does open up a new browser window, but also redirects to the index page (in this case it's just a placeholder index page - the new one I've called index_new.html for the time being).
    Here is the link:
    http://www.susieharperdesigns.com/gallery_beads.html
    Any help is greatly appreciated.

    Your missing a value on the HREF.  In your code you have this:
    <area shape="rect" coords="-24,-9,106,144" href=" " onclick="MM_openBrWindow('gallery_bead1.html','','width=255,height=360')" />
    </map></div>
    and it should be this:
    <area shape="rect" coords="-24,-9,106,144" href="javascript:void()" onclick="MM_openBrWindow('gallery_bead1.html','','width=255,height=360')" />
    </map></div>
    If you fix the code on all your beads, it should work.
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists
    http://alt-web.com/
    http://twitter.com/altweb
    http://alt-web.blogspot.com

  • ATTN: Question for Graphic designers using new 24" aluminum imac

    I am about ready to replace my 2001 G4 867 Quicksilver. Are you happy with the screen and overall build quality? I mainly use photoshop, indesign and illustrator in that order.
    The Mac pro is now too expensive an option for my budget. I read a lot about screen discolorations but would like some feedback from pro users who have adopted this machine.

    Well I'm a graphic designer and student. Recently purchased a 20" aluminium iMac, fantastic piece of kit, and despite being smaller compared to the 24", the resolution is still really high and there is lots of workspace. Many seem to recommend the 24" though and part of me wishes I had got a larger screen instead, but the 20" size is actually better than fine.
    The only problem is, since release last year, all the latest iMacs are having display issues. I didn't know anything about this before purchasing my iMac and expected a higher quality from Apple. They all seem to have gradient issues where the bottom half of the screen is abnormallly brighter in the 20", the left side is brighter in the 24", and also some reported yellowing in the corners. Apparently, more people have reported problems with the 20" than the 24" though.
    If you look through these forums, you will struggle to find one person who actually has an iMac without this issue.
    Unfortunately, for graphic design use (eg Photoshop, Indesign, etc), the iMac's current state is useless. I am writing this on my current iMac and it is impossible to see a full solid colour across the screen at any angle, no good for design use!
    Not sure what I'm doing with mine yet, refund or get Apple to fix it...

  • Copy/paste without using the clipboard?

    Can this be done without using the clipboard?
    myTable.select()
    app.copy()
    app.select(myCopyFrame.insertionPoints.item(0));
    app.paste();

    Can you please not use that site, or (if you must) at the very least not refer to it in this forum?
    Its entire contents is "stolen" -- the guy who made it advertises himself as "proficient XML and HTML programmer", but rather than proving it by doing something worthwhile himself, he copied the entire contents of the heavily improved HTML version I made from Adobe's own documentation. To add insult to injury he wrapped it up in heavily advertised pages.
    The help text is Adobe's own, but I vastly improved upon it by adding yet even more hyperlinks, categories, and a graphic hierarchical view. An even better version than the one this ****head stole can be downloaded for free (and without any advertisements) from http://www.jongware.com/idjshelp.html. I made it better just to prove I could; so far this stinking thief didn't dare copy the latest version -- yet.

  • Confused about how to use paint()

    Hi, I have been working really hard to try to get the following program to work but I am really confused on how to use paint(). I do not have anyone to ask so I thought this forum could help. Anyways, here is my problem...
    I am trying to recursively figure out the Sierpinski fractal. I cannot figure out if my math works or not because I do not know how to call the paint() recursively to draw my triangles.
    Please have a look at the following code. Thank you!
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    public class DrawTriangle extends Frame {
      Point a = new Point(20,480),
            b = new Point(350,40),
            c = new Point(680,480),
            halfB,
            halfC,
            halfB2,
            halfC2,
            halfC3;
      int width;
      public DrawTriangle() {
        super("Sierpinski Fractal");
        addWindowListener( new WindowAdapter() {
          public void windowClosing( WindowEvent we ) {
            dispose();
            System.exit( 0 );
        setBackground( Color.white );
        setSize(700, 500);
        setVisible(true);
      public void paint(Graphics g, Point a, Point b, Point c) {
        width = c.x - a.x;
        if (width < 6){return;}
        g.setColor( Color.GREEN );
        g.drawPolygon( new int[] { a.x, b.x, c.x }, new int[] { a.y, b.y, c.y }, 3 );
        halfC.x = c.x/2;
        halfC.y = c.y;
        halfB.y = b.y/2;
        halfB.x = b.x;
        halfB2.y = halfB.y + a.y;
        halfB2.x = a.x;
        halfC2.x = halfC.x + a.x;
        halfC2.y = a.y;
        halfC3.x = halfC.x/2 + a.x;
        halfC3.y = halfB2.y;
        paint(g, a, halfC, halfB);
        paint(g, halfC3, halfC, halfB);
        paint(g, halfC2, halfC, halfB);
      public static void main(String[] args) {
         new DrawTriangle();

    thanks jsalonen, your tip let me start working on the math to correct it.
    I have a new problem now. My math is correct but I am having problems with the recursion. I can draw only the top , left , or right triangles. I cannot get them all to work together. See code and comments below.
    Any ideas why I cant call all three of the paint()s toegther and have them work?
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    public class DrawTriangle extends Frame {
      Point a = new Point(20,480),
            b = new Point(350,40),
            c = new Point(680,480),
            halfA,
            halfB,
            halfC;
      int width;
      public DrawTriangle() {
        super("Sierpinski Fractal");
        addWindowListener( new WindowAdapter() {
          public void windowClosing( WindowEvent we ) {
            dispose();
            System.exit( 0 );
        setBackground( Color.white );
        setSize(700, 500);
        setVisible(true);
      public void paint(Graphics g)
      paint(g, a, b, c);
      public void paint(Graphics g, Point a, Point b, Point c) {
        width = c.x - a.x;
        if (width < 6){return;}
        halfA = new Point((a.x+b.x)/2, (a.y+b.y)/2);
        halfB = new Point((a.x+c.x)/2, (a.y+c.y)/2);
        halfC = new Point((b.x+c.x)/2, (b.y+c.y)/2);
        g.setColor( Color.GREEN ); //draw left triangle in green
        g.drawPolygon( new int[] { a.x, halfA.x, halfB.x }, new int[] { a.y, halfA.y, halfB.y }, 3 );
        g.setColor( Color.RED ); //draw top triangle in red
        g.drawPolygon( new int[] { b.x, halfA.x, halfC.x }, new int[] { b.y, halfA.y, halfC.y }, 3 );
        g.setColor( Color.BLUE ); //draw right triangle in blue
        g.drawPolygon( new int[] { c.x, halfB.x, halfC.x }, new int[] { c.y, halfB.y, halfC.y }, 3 );
        /*If you were to comment our two of these paint() calls the one will work correctly alone.
         *But my problem is that they do not work together! */
        //g, left point, top point, right point
        paint(g, halfA, b, halfC); //top triangle
        paint(g, halfC, halfB, c); //right triangle
        paint(g, a, halfA, halfB); //left triangle
      public static void main(String[] args) {
         new DrawTriangle();
    }

  • Two ALV's in single report without Using Containers

    Hi All,
    I have a requirement to show two ALV reports in a single report and the thing is I am not supposed to use Containers(Screen Painter). and OOPS concepts.
    Is there a way we can achieve this?
    Any valuable suggestion is highly appreciated.
    Thanks-

    Hi rahul,
    1. This simple program will give u an idea
    of block alv.
    -> Two or more alvs on same screen, without
       using container or oops.
    2. It will print two alv
    a) itab = table from t001
    b) ptab = table from t000
    3. Just copy paste in new program.
    REPORT zam_temp54 .
    type-pools : slis.
    data : alvfc type slis_t_fieldcat_alv.
    data : alvly type slis_layout_alv.
    data : alvev type slis_t_event .
    DATA : BEGIN OF itab OCCURS 0.
    include structure t001.
    DATA: END OF itab.
    DATA : BEGIN OF ptab OCCURS 0.
    INCLUDE STRUCTURE t000.
    DATA: END OF ptab..
    PARAMETERS : a TYPE c.
    start-of-selection.
    *--------------- SELECT DATA
    SELECT * FROM t001 into table itab.
    select * from t000 into table ptab.
    *--------------- INIT BLOCK ALV
    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
    EXPORTING
    i_callback_program = sy-repid.
    *--------------- ADD INTERNAL TABLE ITAB
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
    I_PROGRAM_NAME = SY-REPID
    I_INTERNAL_TABNAME = 'ITAB'
    I_INCLNAME = SY-REPID
    CHANGING
    CT_FIELDCAT = ALVFC.
    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
    EXPORTING
    is_layout = alvly
    it_fieldcat = alvfc
    i_tabname = 'ITAB'
    it_events = alvev
    TABLES
    t_outtab = ITAB
    EXCEPTIONS
    program_error = 1
    maximum_of_appends_reached = 2
    OTHERS = 3.
    *------------------- ADD INTERNAL TABLE PTAB
    REFRESH ALVFC[].
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
    I_PROGRAM_NAME = SY-REPID
    I_INTERNAL_TABNAME = 'PTAB'
    I_INCLNAME = SY-REPID
    CHANGING
    CT_FIELDCAT = ALVFC.
    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
    EXPORTING
    is_layout = alvly
    it_fieldcat = alvfc
    i_tabname = 'PTAB'
    it_events = alvev
    TABLES
    t_outtab = PTAB
    EXCEPTIONS
    program_error = 1
    maximum_of_appends_reached = 2
    OTHERS = 3.
    *--------------- DISPLAY
    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'
    EXCEPTIONS
    program_error = 1
    OTHERS = 2.
    regards,
    amit m.

  • Is it possible to Manage Sun Fire v60 without using Red Hat?

    I've been trying to enable a console connection via an Avocent dongle connected to the serial port using these directions:
    http://download.oracle.com/docs/cd/E19088-01/v65x.srvr/817-2025-13/chap2.html
    All I've been able to view is the BIOS output, and the grub menu; I am unable to control anything.
    Is it possible to manage a Sun Fire v60x without using a Red Hat server to issue power/status commands?
    Thank you.

    Hi.
    Serial console support only text mode. So can freasing after server change mode to graphics.
    For manage server You can read:
    http://download.oracle.com/docs/cd/E19088-01/v65x.srvr/817-2025-13/chap1.html#pgfId-1014396
    Lights Out Management (LOM)
    The Intel Server Management (ISM) software is a set of applications and agents for monitoring and managing servers. The agents can act as low-level stand-alone pieces, or can be used in conjunction with full-featured integrated management suites.
    Available features include power on, power off and reset. System Event Logs (SELs) and Sensor Data Records (SDRs) can be viewed remotely.
    IMHO: It's very old server and remote control of it not user frendly.
    Regards.

  • Using Paint in JFrame

    I am trying to divide a frame into a number of different rectangles, and for some reason I can't get the paintComponent to work. Help!!

    I was wrong in reply one. The paint method in JFrame shows up in the Container methods section, so JFrame uses paint as a Container.
    import java.awt.*;
    import java.awt.geom.*;
    import javax.swing.*;
    public class PaintingDemo extends JPanel {
      int
        width,
        height;
      int[][] circles = {
        {2,20}, {100,50}, {180,200}, {90,150}
      int[][] squares = {
        {40,90}, {100,200}, {150,300}
      int[][] rectangles = {
        {100,100}, {200,100}, {300,300}
      public PaintingDemo(int width, int height) {
        this.width = width;
        this.height = height;
        setBackground(Color.pink);
        setPreferredSize(new Dimension(width, height));
      public void paintComponent(Graphics g) {
        super.paintComponent(g);
        Graphics2D g2 = (Graphics2D)g;
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                            RenderingHints.VALUE_ANTIALIAS_ON);
        g2.setPaint(Color.blue);
        int x,y;
        for(int i = 0; i < circles.length; i++) {
          x = circles[0];
    y = circles[i][1];
    g2.fill(new Ellipse2D.Double(x, y, 20, 20));
    g2.setPaint(Color.red);
    for(int i = 0; i < squares.length; i++)
    g2.fill(new Rectangle2D.Double(squares[i][0], squares[i][1], 10, 10));
    g2.setPaint(Color.orange);
    for(int i = 0; i < rectangles.length; i++)
    g2.fill(new Rectangle2D.Double(rectangles[i][0], rectangles[i][1], 50, 25));
    public static void main(String[] args) {
    JFrame f = new JFrame();
    f.getContentPane().add(new PaintingDemo(400,400));
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.pack();
    f.setLocationRelativeTo(null);
    f.setVisible(true);

  • How to create "Filter- Render- Clouds" without using the filter....?

    Hi,
    I'm trying to do something and it would take forever to explain. So I'll simplify my question, and I hope you guys know how to do this.
    I want to create the same effects the filter called "Clouds" creates. This filter is found in the "Render" sub-menu under "Filter".
    I've tried creating Noise, and then bluring it. I've tried painting blobs of white on black, blurring it, then using the "Sponge" filter with no luck.
    So, again, a way to create the same effect using any method besides "Clouds" filter... to make it look near or very near to what the "Clouds" filter creates, without using that particular filter. I've spent about 3 hours attempting this with no luck.
    Thanks so much!

    Actually, it is not that hard to create clouds from scratch.  The secret is to look at lots of real clouds to see how they work.   But you can create some pretty good clouds with the render Clouds filter.  Start with a canvas way bigger than your target image, and fill with the Render Clouds filter.  Then use Free Transform to flatten and reshape it.  Also use FT to add LOTS of perspective if you want to get that UltraWide lens look.
    Where Render Clouds and FT falls short is that real clouds are layered, and surprisingly dark on their shadow side.  But it is still doable with Dodge Burn and multiple cloud layers.
    Not quite the sme thing, but I saw a really cool tutorial using clouds on Planet Photoshop a while back. Definitely worth a look at.
    http://www.planetphotoshop.com/creating-exploding-brushes.html

  • How to hide a entire tablecontrol without using subscreen....

    hiiiiiii
    iam using input/out and tablecontrol in screen 100...my input/output field is matnr.. before entering matnr tablecontrol should not visible....i.e i want entire tablecontrol to hide not particular column....n tablecontrol is hide.... when iam entering matnr tablecontrol should visible.....
    how to visible and invisible a tablecontrol without using subscreen.....is tre a way to do it...
    table-invisible = 'x'.
    where table is name of tablecontrol n it hides the tablecontrol... but again after entering matnr how to make tablecontrol visible....
    if any one knows how to do it pls help....
    rewards if any tell correctly.......
    thanks...

    In screen painter, open the table control attributes, enter the some value in group column.
    ex:
    PROCESS BEFORE OUTPUT.
      MODULE SCR_INIT.
    *&      Module  SCR_INIT  OUTPUT
          text
    MODULE SCR_INIT OUTPUT.
      LOOP AT SCREEN.
          if g_auth = 'BM'.
            if screen-group1 = 'GR1'.
              SCREEN-ACTIVE = '0'.
              SCREEN-INPUT = '0'.
            endif.
    modify screen.
       endloop.

Maybe you are looking for

  • Problem with CSS in ADF 11g application

    Hi, I have added a CSS code for my login page(login.html), The issue i am facing is When ever i am opening the page the complete CSS is not coming for each time one CSS component is coming that's means if there are 4 CSS components as shown below i n

  • Communication between two clients

    In Java Networking, communication between server-client or bwtween server-multiple clients is general. But How will be the communication between two cients, means two clients can send & receive messages to & from each other(being guided by server).

  • Iphoto keeps crashing on startup

    Hi, I installed Ilife '09 about a month ago, and since then I've had big problems with IPhoto. It loads fine for a couple of days, and then it stops working, just crashes on startup and gives me an error that it has unexpectedly quit. I tried deletin

  • Report where Purchase Orders have been changed

    Hi, I am looking for a report which shows me all the purchase orders in which the prices have been changed by the supplier. Does a report like this exist? Thanks for your help!

  • Training videos

    Does anyone have the recording repository of training videos similar to the "16Scripting.wmv" given in this link?