custom-painting

Drawing shapes on a JForm java

不想你离开。 提交于 2019-11-29 16:43:40
I have created this code that is supposed to draw certain things when I selected a radio button on a JForm, I have used NetBeans to create the GUI. When I select a radio button nothing happens. I have been trying to figure out what's wrong for a while but I still cannot find a solution that's why I came here. If anyone could spot a mistake I would be thankful. public class DrawShapesGUI extends javax.swing.JFrame { private int figureID; public DrawShapesGUI() { initComponents(); repaint(); } @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"></editor

drawingPanel color change with displacement

这一生的挚爱 提交于 2019-11-28 14:40:53
I'm using JGrasp, and in drawingPanel , I'm trying to create a ball that changes colors as it moves across the screen. Right now, I've got: for (int i = 10; i<=i; i++) { Color c = new Color(i*i, 0, 0); pen.setColor(c); My full simplified code is: import java.awt.*; import java.util.*; import java.awt.Color; public class BallSample { public static final int SIZE = 30; public static final int HALF = SIZE / 2; public static void main(String[] args) { Scanner console = new Scanner(System.in); DrawingPanel panel = new DrawingPanel(1000, 1000); panel.setBackground(Color.CYAN); Graphics pen = panel

When does a JPanel paint (or repaint) its child components?

被刻印的时光 ゝ 提交于 2019-11-28 13:51:35
I've got a JButton which is painted using a custom UI delegate (CustomButtonUI extends BasicButtonUI). The CustomButtonUI's paint() method draws the button with rounded "antialiased" corners, to make the apperance as "smooth" as possible. Somehow the "antialiased" edges of the button disappears each time i drag the mouse over the button. This makes the button edges look "pixelized". However, once I add a line of code to repaint the parent of the button, the antialiasing kicks in even when i drag the mouse over the button. Now, my question relates to wether this is a good idea? I do after all

How to draw the radius of a circle without it being shorter or larger than the circumference

筅森魡賤 提交于 2019-11-28 10:25:34
问题 I am working on a program in which I want to draw a line from circle's center to its parametric point. But it draws line out of circumference and inside circumference. I want to draw line exactly on circumference according to X and Y angles. Circle center points: x = 200 y = 100 radius= 100 public SecondActivity(String azim,String ele) { initialize(); setTitle("My WIndow");` angle_x = Integer.parseInt(azim); angle_y = Integer.parseInt(ele); x = 200+r*Math.cos(angle_x); y = 100+r*Math.sin

Create the square, rectangle, triangle of java in jframe [closed]

筅森魡賤 提交于 2019-11-27 09:54:36
I have a problem with Java As I understood not come Draw Geometric figures in Java, the code and the Following you can help me? This is the code: public class Gioco { public static void main (String args []) { PaintRect(); } public static void PaintRect() { g.drawRect(100,100,300,300); g.drawLine(100,100,100,100); g.setBackground(Color.BLACK); System.out.println("Trasut"); credits.setText("Kitebbiv"); credits.setBackground(null); credits.setEditable(false); credits.setFocusable(false); credits.setBounds(0,0,100,100); credits.setForeground(Color.BLACK); panel.add(credits); g.getPaint(); } How

How do I draw on a JPanel from multiple outside classes?

纵然是瞬间 提交于 2019-11-27 08:50:00
问题 I am currently making a game with a main menu and a world where you actually play. I have a class called Game , which inherits from JPanel and implements the Runnable , MouseListener , KeyListener and ActionListener interfaces (only important parts included) I also have two classes InWorldHandler and OutWorldHandler for handling the mechanics in the world and outside of it respectively. The Game class: public class Game extends JPanel implements Runnable, KeyListener, MouseListener,

When does a JPanel paint (or repaint) its child components?

删除回忆录丶 提交于 2019-11-27 07:58:06
问题 I've got a JButton which is painted using a custom UI delegate (CustomButtonUI extends BasicButtonUI). The CustomButtonUI's paint() method draws the button with rounded "antialiased" corners, to make the apperance as "smooth" as possible. Somehow the "antialiased" edges of the button disappears each time i drag the mouse over the button. This makes the button edges look "pixelized". However, once I add a line of code to repaint the parent of the button, the antialiasing kicks in even when i

Create the square, rectangle, triangle of java in jframe [closed]

大憨熊 提交于 2019-11-26 14:56:58
问题 I have a problem with Java As I understood not come Draw Geometric figures in Java, the code and the Following you can help me? This is the code: public class Gioco { public static void main (String args []) { PaintRect(); } public static void PaintRect() { g.drawRect(100,100,300,300); g.drawLine(100,100,100,100); g.setBackground(Color.BLACK); System.out.println("Trasut"); credits.setText("Kitebbiv"); credits.setBackground(null); credits.setEditable(false); credits.setFocusable(false);