|
| 1 | +/******************************************************************************************* |
| 2 | +* Copyright (C) 2026 PACIFICO PAUL |
| 3 | +* |
| 4 | +* This program is free software; you can redistribute it and/or modify |
| 5 | +* it under the terms of the GNU General Public License as published by |
| 6 | +* the Free Software Foundation; either version 2 of the License, or |
| 7 | +* (at your option) any later version. |
| 8 | +* |
| 9 | +* This program is distributed in the hope that it will be useful, |
| 10 | +* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | +* GNU General Public License for more details. |
| 13 | +* |
| 14 | +* You should have received a copy of the GNU General Public License along |
| 15 | +* with this program; if not, write to the Free Software Foundation, Inc., |
| 16 | +* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 17 | +* |
| 18 | +********************************************************************************************/ |
| 19 | + |
| 20 | +package application; |
| 21 | + |
| 22 | +import java.awt.Color; |
| 23 | +import java.awt.Cursor; |
| 24 | +import java.awt.Desktop; |
| 25 | +import java.awt.Font; |
| 26 | +import java.awt.MouseInfo; |
| 27 | +import java.awt.event.MouseEvent; |
| 28 | +import java.awt.event.MouseListener; |
| 29 | +import java.awt.event.MouseMotionListener; |
| 30 | +import java.awt.geom.Area; |
| 31 | +import java.io.IOException; |
| 32 | +import java.net.URI; |
| 33 | +import java.net.URISyntaxException; |
| 34 | + |
| 35 | +import javax.swing.BorderFactory; |
| 36 | +import javax.swing.ImageIcon; |
| 37 | +import javax.swing.JFrame; |
| 38 | +import javax.swing.JLabel; |
| 39 | +import javax.swing.JPanel; |
| 40 | +import javax.swing.SwingConstants; |
| 41 | +import javax.swing.border.MatteBorder; |
| 42 | + |
| 43 | +import com.formdev.flatlaf.extras.FlatSVGIcon; |
| 44 | + |
| 45 | +public class Donate { |
| 46 | + |
| 47 | + private static int MousePositionX; |
| 48 | + private static int MousePositionY; |
| 49 | + |
| 50 | + public Donate() { |
| 51 | + |
| 52 | + JFrame frame = new JFrame(); |
| 53 | + frame.getContentPane().setBackground(Utils.bg32); |
| 54 | + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
| 55 | + frame.setTitle("Thanks!"); |
| 56 | + frame.setBackground(Utils.bg32); |
| 57 | + frame.setForeground(Color.WHITE); |
| 58 | + frame.getContentPane().setLayout(null); |
| 59 | + frame.setSize(280, 335); |
| 60 | + |
| 61 | + frame.setResizable(false); |
| 62 | + frame.setUndecorated(true); |
| 63 | + frame.getRootPane().setBorder(BorderFactory.createMatteBorder(0, 1, 1, 1, new Color(45,45,45))); |
| 64 | + Area shape1 = new Area(new AntiAliasedRoundRectangle(0, 0, frame.getWidth(), frame.getHeight(), 15, 15)); |
| 65 | + Area shape2 = new Area(new AntiAliasedRoundRectangle(0, frame.getHeight() - 15, frame.getWidth(), 15, 15, 15)); |
| 66 | + shape1.add(shape2); |
| 67 | + frame.setShape(shape1); |
| 68 | + frame.setAlwaysOnTop(true); |
| 69 | + |
| 70 | + if (System.getProperty("os.name").contains("Mac") == false) |
| 71 | + frame.setIconImage(new ImageIcon(getClass().getClassLoader().getResource("contents/icon.png")).getImage()); |
| 72 | + |
| 73 | + frame.setLocation(Shutter.frame.getX() + (Shutter.frame.getWidth() - frame.getWidth()) / 2, Shutter.frame.getY() + (Shutter.frame.getHeight() / 2 - frame.getHeight())); |
| 74 | + |
| 75 | + JPanel topPanel = new JPanel(); |
| 76 | + topPanel.setLayout(null); |
| 77 | + topPanel.setBackground(Utils.bg32); |
| 78 | + topPanel.setBounds(0, 0, frame.getWidth(), 28); |
| 79 | + |
| 80 | + JLabel quit = new JLabel(new FlatSVGIcon("contents/quit.svg", 15, 15)); |
| 81 | + quit.setHorizontalAlignment(SwingConstants.CENTER); |
| 82 | + quit.setBounds(frame.getSize().width - 20, 4, 15, 15); |
| 83 | + topPanel.add(quit); |
| 84 | + |
| 85 | + quit.addMouseListener(new MouseListener() { |
| 86 | + |
| 87 | + private boolean accept = false; |
| 88 | + |
| 89 | + @Override |
| 90 | + public void mouseClicked(MouseEvent e) { |
| 91 | + } |
| 92 | + |
| 93 | + @Override |
| 94 | + public void mousePressed(MouseEvent e) { |
| 95 | + |
| 96 | + quit.setIcon(new FlatSVGIcon("contents/quit_pressed.svg", 15, 15)); |
| 97 | + accept = true; |
| 98 | + } |
| 99 | + |
| 100 | + @Override |
| 101 | + public void mouseReleased(MouseEvent e) { |
| 102 | + |
| 103 | + if (accept) |
| 104 | + { |
| 105 | + System.exit(0); |
| 106 | + } |
| 107 | + } |
| 108 | + |
| 109 | + @Override |
| 110 | + public void mouseEntered(MouseEvent e) { |
| 111 | + quit.setIcon(new FlatSVGIcon("contents/quit_hover.svg", 15, 15)); |
| 112 | + } |
| 113 | + |
| 114 | + @Override |
| 115 | + public void mouseExited(MouseEvent e) { |
| 116 | + quit.setIcon(new FlatSVGIcon("contents/quit.svg", 15, 15)); |
| 117 | + accept = false; |
| 118 | + } |
| 119 | + |
| 120 | + }); |
| 121 | + |
| 122 | + JLabel title = new JLabel(frame.getTitle()); |
| 123 | + title.setHorizontalAlignment(JLabel.CENTER); |
| 124 | + title.setBounds(0, 1, frame.getWidth(), 24); |
| 125 | + title.setFont(new Font(Shutter.mainFont, Font.PLAIN, 17)); |
| 126 | + topPanel.add(title); |
| 127 | + |
| 128 | + JLabel topImage = new JLabel(); |
| 129 | + topImage.setBackground(new Color(35,35,40)); |
| 130 | + topImage.setOpaque(true); |
| 131 | + topImage.setBorder(new MatteBorder(1, 0, 1, 0, new Color(45,45,45))); |
| 132 | + topImage.setBounds(0, 0, topPanel.getWidth(), 24); |
| 133 | + topPanel.add(topImage); |
| 134 | + |
| 135 | + topImage.addMouseListener(new MouseListener() { |
| 136 | + |
| 137 | + @Override |
| 138 | + public void mouseClicked(MouseEvent down) { |
| 139 | + } |
| 140 | + |
| 141 | + @Override |
| 142 | + public void mousePressed(MouseEvent down) { |
| 143 | + MousePositionX = down.getPoint().x; |
| 144 | + MousePositionY = down.getPoint().y; |
| 145 | + } |
| 146 | + |
| 147 | + @Override |
| 148 | + public void mouseReleased(MouseEvent e) { |
| 149 | + } |
| 150 | + |
| 151 | + @Override |
| 152 | + public void mouseEntered(MouseEvent e) { |
| 153 | + } |
| 154 | + |
| 155 | + @Override |
| 156 | + public void mouseExited(MouseEvent e) { |
| 157 | + } |
| 158 | + |
| 159 | + }); |
| 160 | + |
| 161 | + topImage.addMouseMotionListener(new MouseMotionListener(){ |
| 162 | + |
| 163 | + @Override |
| 164 | + public void mouseDragged(MouseEvent e) { |
| 165 | + frame.setLocation(MouseInfo.getPointerInfo().getLocation().x - MousePositionX, MouseInfo.getPointerInfo().getLocation().y - MousePositionY); |
| 166 | + } |
| 167 | + |
| 168 | + @Override |
| 169 | + public void mouseMoved(MouseEvent e) { |
| 170 | + } |
| 171 | + |
| 172 | + }); |
| 173 | + |
| 174 | + frame.getContentPane().add(topPanel); |
| 175 | + |
| 176 | + JLabel qrcode = new JLabel(); |
| 177 | + qrcode.setIcon(new ImageIcon(getClass().getClassLoader().getResource("contents/qrcode.png"))); |
| 178 | + qrcode.setHorizontalAlignment(SwingConstants.CENTER); |
| 179 | + qrcode.setBounds((frame.getWidth() - 250) / 2, topPanel.getHeight() + 10, 250, 250); |
| 180 | + frame.getContentPane().add(qrcode); |
| 181 | + |
| 182 | + qrcode.addMouseListener(new MouseListener() { |
| 183 | + |
| 184 | + @Override |
| 185 | + public void mouseClicked(MouseEvent arg0) { |
| 186 | + try { |
| 187 | + Desktop.getDesktop().browse(new URI("https://donate.stripe.com/28o29m0QwfRZ4U0cMM")); |
| 188 | + } catch (IOException | URISyntaxException e) {} |
| 189 | + |
| 190 | + System.exit(0); |
| 191 | + } |
| 192 | + |
| 193 | + @Override |
| 194 | + public void mouseEntered(MouseEvent arg0) { |
| 195 | + frame.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
| 196 | + } |
| 197 | + |
| 198 | + @Override |
| 199 | + public void mouseExited(MouseEvent arg0) { |
| 200 | + frame.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); |
| 201 | + } |
| 202 | + |
| 203 | + @Override |
| 204 | + public void mousePressed(MouseEvent arg0) { |
| 205 | + } |
| 206 | + |
| 207 | + @Override |
| 208 | + public void mouseReleased(MouseEvent arg0) { |
| 209 | + } |
| 210 | + |
| 211 | + }); |
| 212 | + |
| 213 | + JLabel line1 = new JLabel("Hope you enjoyed the software!"); |
| 214 | + line1.setHorizontalAlignment(SwingConstants.CENTER); |
| 215 | + line1.setSize(frame.getWidth(), 16); |
| 216 | + line1.setFont(new Font(Shutter.mainFont, Font.PLAIN, 12)); |
| 217 | + line1.setLocation((frame.getWidth() - line1.getWidth()) / 2, qrcode.getY() + qrcode.getHeight() + 7); |
| 218 | + frame.getContentPane().add(line1); |
| 219 | + |
| 220 | + JLabel line2 = new JLabel("Support me to make it even better!"); |
| 221 | + line2.setHorizontalAlignment(SwingConstants.CENTER); |
| 222 | + line2.setSize(frame.getWidth(), 16); |
| 223 | + line2.setFont(new Font(Shutter.mainFont, Font.PLAIN, 12)); |
| 224 | + line2.setLocation((frame.getWidth() - line2.getWidth()) / 2, line1.getY() + line1.getHeight()); |
| 225 | + frame.getContentPane().add(line2); |
| 226 | + |
| 227 | + frame.setVisible(true); |
| 228 | + } |
| 229 | +} |
0 commit comments