custom-painting

Painting custom background of parent and parent children in C#

↘锁芯ラ 提交于 2019-12-06 00:32:52
I am trying to use this tutorial so that I can have a transparent button. It works fine for the main background, but it doesn't draw over the other children. If I use BringToFront() it then doesn't have the other child's drawing where it should be. I have started to get around it by adding this to the code: foreach (Control child in Parent.Controls) { if(child != this) { InvokePaintBackground(child, pea); InvokePaint(child, pea); } } And although I get some of what I want, it's in the wrong location (on the left instead of in the middle where it shoudl be) and the shapes which are drawn in the

Swing custom painting animation stops after reaching half width of frame

我只是一个虾纸丫 提交于 2019-12-04 05:51:30
问题 I was trying to answer a question related to moving a ball across the screen while changing its color over time, however I came through a weird bug, (most probably in my code) and while asking this question I came to a related question but that question is using a Client-Server architecture while mine is simply a Swing app running itself. What is happening is that when the circle / ball, however you want to name it, reaches the half width of the JPanel or JFrame it becomes invisible or stops.

Java Painting not working

巧了我就是萌 提交于 2019-12-02 21:41:53
问题 So I have this code: package tictactoe; import java.awt.Graphics; import java.awt.Graphics2D; import javax.swing.JFrame; import javax.swing.JPanel; public class TicTacToe extends JFrame { public static void main(String[] args) { JFrame masterFrame = new JFrame("TicTacToe"); JPanel drawingPanel = new JPanel(); GameBoard theGame = new GameBoard(); masterFrame.add(drawingPanel); masterFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); masterFrame.setSize(504, 504); masterFrame.setResizable

Java drawing on JPanel which on a JFrame [closed]

对着背影说爱祢 提交于 2019-12-02 19:59:03
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 6 years ago . Hi I have a JFrame and there are two JPanels on top of it. My intention is to draw on the JPanels. Can anyone please share any Java code? 回答1: All the JComponents ( of which JPanel inherits from ) have a

Java Painting not working

陌路散爱 提交于 2019-12-02 10:24:27
So I have this code: package tictactoe; import java.awt.Graphics; import java.awt.Graphics2D; import javax.swing.JFrame; import javax.swing.JPanel; public class TicTacToe extends JFrame { public static void main(String[] args) { JFrame masterFrame = new JFrame("TicTacToe"); JPanel drawingPanel = new JPanel(); GameBoard theGame = new GameBoard(); masterFrame.add(drawingPanel); masterFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); masterFrame.setSize(504, 504); masterFrame.setResizable(false); masterFrame.setLocationRelativeTo(null); masterFrame.setVisible(true); } //End of Main method

Java drawing on JPanel which on a JFrame [closed]

♀尐吖头ヾ 提交于 2019-12-02 10:01:06
Hi I have a JFrame and there are two JPanels on top of it. My intention is to draw on the JPanels. Can anyone please share any Java code? All the JComponents ( of which JPanel inherits from ) have a paintComponent(Graphics g ) method that you can override. Basically... oh.. well, I think this would be more appropiate: http://java.sun.com/developer/technicalArticles/GUI/java2d/java2dpart1.html Naive sample: Source code: import javax.swing.*; import java.awt.*; import java.awt.geom.*; public class X { public static void main( String [] args ) { JFrame frame = new JFrame(); frame.add( new JPanel(

How to remove “stretch marks” on custom button border?

和自甴很熟 提交于 2019-12-01 08:10:06
When performing some custom painting on a button's Graphics2D object, I get the following results: The leftmost button is untoggled and the other is toggled. As you can see, the toggled button has these white "stretch marks." Why are these there and how do I remove them? And here is the code I use to draw the border: // Draw border of button if(!getModel().isSelected()) { g2.fillRoundRect(2, 2, getWidth() - 5, getHeight() - 5, ARC_WIDTH, ARC_HEIGHT); g2.setColor(Color.BLACK); g2.drawRoundRect(0, 0, getWidth() - 1, getHeight() - 1, ARC_WIDTH, ARC_HEIGHT); g2.setColor(Color.WHITE); g2

How to remove “stretch marks” on custom button border?

非 Y 不嫁゛ 提交于 2019-12-01 06:10:58
问题 When performing some custom painting on a button's Graphics2D object, I get the following results: The leftmost button is untoggled and the other is toggled. As you can see, the toggled button has these white "stretch marks." Why are these there and how do I remove them? And here is the code I use to draw the border: // Draw border of button if(!getModel().isSelected()) { g2.fillRoundRect(2, 2, getWidth() - 5, getHeight() - 5, ARC_WIDTH, ARC_HEIGHT); g2.setColor(Color.BLACK); g2.drawRoundRect

Draw on one side of a JPanel

旧街凉风 提交于 2019-11-30 09:55:25
问题 I want to program an application that lets you draw circles with a mouse click on the left side of a JFrame , and all the points are getting "mirrored" to the right side. The first problem I encountered was that when I try to implement this draw-mechanic in my frame, no circles appear. public class Application{ int x,y; private JPanel container; public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { new Application().gui(); } }); }

Draw on one side of a JPanel

你。 提交于 2019-11-29 18:00:42
I want to program an application that lets you draw circles with a mouse click on the left side of a JFrame , and all the points are getting "mirrored" to the right side. The first problem I encountered was that when I try to implement this draw-mechanic in my frame, no circles appear. public class Application{ int x,y; private JPanel container; public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { new Application().gui(); } }); } public void gui() { int height = 250; int width = 700; JFrame jframe = new JFrame(); container = new