|
|
Jabaco Source |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
Option Explicit 'override 'SuperClass: javax/swing/JLabel Dim gradientPaint As java#awt#GradientPaint = New GradientPaint(0, 70, color.gray, 0, 0, color.white, False) Public Sub paintComponent(g As Graphics) 'Public Sub paint(g As Graphics) On Error Goto LoadErr Debug.Print Me.getText() Dim g2 As Graphics2D = Cast(g, Graphics2D) g2.setPaint(gradientPaint) g2.fillRect(1, 0, Base.getWidth(), Base.getHeight()) Me.paintComponent(g) ' Me.paint(g) Exit Sub LoadErr: Stop End Sub |
|
|
Jabaco Source |
1 2 3 4 5 6 7 8 9 |
Public Sub Form_Load() Dim Label1 As New GradientLabel With Label1 .setText("Hey there,") .setForeground(color.black) .setBounds(10,25,120,30) End With Me.add Label1 End Sub |
|
|
Jabaco Source |
1 |
Me.paintComponent(arg2)
|
|
|
Jabaco Source |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
Option Explicit 'override 'SuperClass: javax/swing/JLabel Dim gradientPaint As java#awt#GradientPaint = New GradientPaint(0, 70, color.gray, 0, 0, color.white, False) 'Public Sub paintComponent(g As Graphics) Public Sub paint(g As Graphics) On Error Goto LoadErr Debug.Print Me.getText() Dim g2 As Graphics2D = Cast(g, Graphics2D) g2.setPaint(gradientPaint) g2.fillRect(1, 0, Base.getWidth(), Base.getHeight()) Me.paintComponent(g) ' Me.paint(g) Exit Sub LoadErr: ' Stop End Sub |
|
|
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 'override 'SuperClass: javax/swing/JLabel Dim gradientPaint As java#awt#GradientPaint = New GradientPaint(0, 70, color.gray, 0, 0, color.white, False) Public Sub paintComponent(g As Graphics) 'Public Sub paint(g As Graphics) On Error Goto LoadErr ''Debug.Print Me.getText() Dim g2 As Graphics2D = Cast(g, Graphics2D) g2.setPaint(gradientPaint) g2.fillRect(1, 0, Base.getWidth(), Base.getHeight()) g2.setPaint(Color.black) g2.drawString(Me.getText,0,20) Me.paintComponent(g) 'Me.paint(g) Exit Sub LoadErr: ' Stop End Sub |
Quoted
You have to uncomment the line with paint() and comment the line with paintComponent().
Then it works fine.
)
Quoted
'Public Sub paintComponent(g As Graphics)
Public Sub paint(g As Graphics)
...
Me.paintComponent(g)
' Me.paint(g)
|
|
Jabaco Source |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
Option Explicit 'override 'SuperClass: javax/swing/JLabel Dim gradientPaint As java#awt#GradientPaint = New GradientPaint(0, 70, color.gray, 0, 0, color.white, False) Public Sub paintComponent(g As Graphics) ' On Error Goto LoadErr Dim g2 As Graphics2D = Cast(g, Graphics2D) g2.setPaint(gradientPaint) g2.fillRect(1, 0, Base.getWidth(), Base.getHeight()) g2.setPaint(Color.black) g2.drawString(Me.getText,0,20) Me.paintComponent(g) Exit Sub LoadErr: ' Stop End Sub |
Quoted
Exception In thread "AWT-EventQueue-0" java.lang.StackOverflowError
at java.util.HashMap.hash(Unknown Source)
at java.util.HashMap.put(Unknown Source)
at java.awt.RenderingHints.put(Unknown Source)
at sun.java2d.SunGraphics2D.makeHints(Unknown Source)
at sun.java2d.SunGraphics2D.getRenderingHints(Unknown Source)
at sun.java2d.pipe.AlphaPaintPipe.startSequence(Unknown Source)
at sun.java2d.pipe.SpanShapeRenderer$Composite.startSequence(Unknown Source)
at sun.java2d.pipe.SpanShapeRenderer.renderRect(Unknown Source)
at sun.java2d.pipe.SpanShapeRenderer.fill(Unknown Source)
at sun.java2d.pipe.PixelToShapeConverter.fillRect(Unknown Source)
at sun.java2d.SunGraphics2D.fillRect(Unknown Source)
at GradientLabel.paintComponent(GradientLabel.jsrc:64)
at GradientLabel.paintComponent(GradientLabel.jsrc:65)
|
|
Jabaco Source |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
Option Explicit 'override 'SuperClass: javax/swing/JLabel Dim gradientPaint As java#awt#GradientPaint = New GradientPaint(0, 70, color.gray, 0, 0, color.white, False) Public Sub paint(g As Graphics) Me.setOpaque(False) Dim g2 As Graphics2D = Cast(g, Graphics2D) g2.setPaint(gradientPaint) g2.fillRect(1, 0, Base.getWidth(), Base.getHeight()) Me.paintComponent(g) End Sub |
This post has been edited 2 times, last edit by "Dani" (Aug 22nd 2013, 11:22am)