JavaScript is required to use Bungie.net

OffTopic

Surf a Flood of random discussion.
Edited by Grenades hurt: 11/25/2013 5:02:57 AM
1

Anyone know Java? (Graphics Issue.)

I am trying to get a a general path drawn and a couple basic shapes, but I can't seem to get them to work together. Is there a way to write it so that they will work? The part I can't fix is italicized. (Code below) import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.RenderingHints; import java.awt.geom.GeneralPath; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.SwingUtilities; class Surface extends JPanel { private double points[][] = { { 0, 85 }, { 75, 75 }, { 100, 10 }, }; private void doDrawing(Graphics g) { Graphics2D g2d = (Graphics2D)g; g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); g2d.translate(25, 5); GeneralPath star = new GeneralPath(); star.moveTo(points[0][0], points[0][1]); for (int k = 1; k < points.length; k++) star.lineTo(points[k][0], points[k][1]); star.closePath(); g2d.fill(star); [i] Graphics2D f2d = (Graphics2D)g; f2d.setColor(new Color(0, 0, 0)); f2d.fillRect(-10, -10, 900, 1100); }[/i] @Override public void paintComponent(Graphics g) { super.paintComponent(g); doDrawing(g); } } public class Star extends JFrame { public Star() { initUI(); } private void initUI() { setTitle("Lines"); add(new Surface()); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(350, 250); setLocationRelativeTo(null); } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { Star sr = new Star(); sr.setVisible(true); } }); } }

Posting in language:

 

Play nice. Take a minute to review our Code of Conduct before submitting your post. Cancel Edit Create Fireteam Post

View Entire Topic
You are not allowed to view this content.
;
preload icon
preload icon
preload icon