You are not logged in.

Dear visitor, welcome to Jabaco - Community. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

josem

Beginner

  • "josem" started this thread

Posts: 2

Date of registration: Mar 26th 2010

  • Send private message

1

Thursday, August 26th 2010, 9:48pm

UserControl and Graphics2d

How i convert this code to jabaco?, i don´t know how to pass the Graphics2D to a Graphics

this is the code

Source code

1
2
3
4
5
6
7
8
9
10
public void paint(Graphics g) {
     	Graphics2D g2 = (Graphics2D) g; 
     	g2.setStroke(new BasicStroke(2.0f));
     	g2.draw(new Rectangle2D.Double(5, 5, 50, 20));
     	g2.setStroke(new BasicStroke(4.0f));
     	g2.draw(new RoundRectangle2D.Double(5, 30, 50, 20, 5, 5));
     	g2.setStroke(new BasicStroke(2.0f));
     	g2.draw(new Arc2D.Double(5, 55, 50, 20, 90, 135, Arc2D.OPEN));
     	g2.draw(new Ellipse2D.Double(5, 80, 50, 20));
}

I would like to create a usercontrol for a gradient frame.

Thank's

A1880

Intermediate

  • "A1880" is male

Posts: 500

Date of registration: Jan 1st 2009

Location: Hanover, Germany

Occupation: Software Engineer

Hobbies: Hilbert Curves

  • Send private message

2

Thursday, August 26th 2010, 10:30pm

As a startingpoint for your experiments:

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Option Explicit

Import java#awt 
Import java#awt#geom 

Public Sub Command1_Click()
   '  Picture1 is a control of type PictureBox
   myPaint Picture1.Parent.getGraphics() 
End Sub

Public Sub myPaint(g As Graphics) 
     	Dim g2 As Graphics2D = Cast(g, Graphics2D)
      
     	Call g2.setStroke(New BasicStroke(2.0))
        Call g2.draw(New Rectangle2D$Double(5, 5, 50, 20))
     	Call g2.setStroke(New BasicStroke(4.0))
     	Call g2.draw(New RoundRectangle2D$Double(5, 30, 50, 20, 5, 5))

     	Call g2.setStroke(New BasicStroke(2.0))
     	Call g2.draw(New Arc2D$Double(5, 55, 50, 20, 90, 135, Arc2D.OPEN))

     	Call g2.draw(New Ellipse2D$Double(5, 80, 50, 20))
End Sub


Jabaco had problems with nested classes in the beginning.

Look here for how to solve that.
The syntax is java#awt#geom#Rectangle2D$Double . Note the "$" sign as separator for nested classes.

You might want to use the search facility of this forum to find the other Graphics2D and Cast samples.

Happy experimenting!

A1880

This post has been edited 1 times, last edit by "A1880" (Aug 26th 2010, 11:19pm)


josem

Beginner

  • "josem" started this thread

Posts: 2

Date of registration: Mar 26th 2010

  • Send private message

3

Friday, August 27th 2010, 3:26pm

Thank you very much, it´s very useful. :rolleyes:

Rate this thread
WoltLab Burning Board