aboutsummaryrefslogtreecommitdiff
path: root/src/main/block.java
diff options
context:
space:
mode:
authorsowgro <tpoke.ferrari@gmail.com>2023-05-06 14:56:46 -0400
committersowgro <tpoke.ferrari@gmail.com>2023-05-06 14:56:46 -0400
commit372d97fee538f86c8333fbbde43cf51484b8ac67 (patch)
tree055f5560e58d4a83a90a3e1c46ec8d998e12a96f /src/main/block.java
parentcee3ca3fec021c0ddf8f3ee66940bb1cdfba4262 (diff)
downloadNPEhero-372d97fee538f86c8333fbbde43cf51484b8ac67.tar.gz
NPEhero-372d97fee538f86c8333fbbde43cf51484b8ac67.tar.bz2
NPEhero-372d97fee538f86c8333fbbde43cf51484b8ac67.zip
Add JavaFX and seperate source and class files
Diffstat (limited to 'src/main/block.java')
-rw-r--r--src/main/block.java85
1 files changed, 85 insertions, 0 deletions
diff --git a/src/main/block.java b/src/main/block.java
new file mode 100644
index 0000000..cb04132
--- /dev/null
+++ b/src/main/block.java
@@ -0,0 +1,85 @@
+package main;
+
+import java.awt.Dimension;
+import java.awt.EventQueue;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.geom.Path2D;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.UIManager;
+import javax.swing.UnsupportedLookAndFeelException;
+
+//
+
+public class block {
+
+ public static void main(String[] args) {
+ new block();
+ }
+
+ public block() {
+ EventQueue.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ /*try {
+ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+ } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
+ ex.printStackTrace();
+ }
+ */
+
+ JFrame frame = new JFrame("Testing");
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ frame.add(new TestPane());
+ frame.pack();
+ frame.setLocationRelativeTo(null);
+ frame.setVisible(true);
+
+ }
+ });
+ }
+
+ public class TestPane extends JPanel {
+
+ private RightEnd rightEnd;
+
+ public TestPane() {
+ rightEnd = new RightEnd(100, 100, 40);
+ }
+
+ @Override
+ public Dimension getPreferredSize() {
+ return new Dimension(100, 100);
+ }
+
+
+ @Override
+ protected void paintComponent(Graphics g) {
+ super.paintComponent(g);
+ int x = (getWidth() - 100) / 2;
+ int y = (getHeight()- 100) / 2;
+ Graphics2D g2d = (Graphics2D) g.create();
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ g2d.translate(x, y);
+ g2d.fill(rightEnd);
+ g2d.dispose();
+ }
+
+
+ }
+
+ public class RightEnd extends Path2D.Float {
+
+ public RightEnd(float width, float height, float radius) {
+ moveTo(0, 0);
+ lineTo(width - radius, 0);
+ curveTo(width, 0, width, 0, width, radius);
+ lineTo(width, height - radius);
+ curveTo(width, height, width, height, width - radius, height);
+ lineTo(0, height);
+ closePath();
+ }
+ }
+}