summaryrefslogtreecommitdiff
path: root/src/com/pkrandom/newgui/OperationDialog.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/pkrandom/newgui/OperationDialog.java')
-rw-r--r--src/com/pkrandom/newgui/OperationDialog.java137
1 files changed, 137 insertions, 0 deletions
diff --git a/src/com/pkrandom/newgui/OperationDialog.java b/src/com/pkrandom/newgui/OperationDialog.java
new file mode 100644
index 0000000..0028582
--- /dev/null
+++ b/src/com/pkrandom/newgui/OperationDialog.java
@@ -0,0 +1,137 @@
+package com.pkrandom.newgui;
+
+/*----------------------------------------------------------------------------*/
+/*-- OperationDialog.java - a dialog that displays the loading spinner --*/
+/*-- --*/
+/*-- Part of "Universal Pokemon Randomizer ZX" by the UPR-ZX team --*/
+/*-- Pokemon and any associated names and the like are --*/
+/*-- trademark and (C) Nintendo 1996-2020. --*/
+/*-- --*/
+/*-- The custom code written here is licensed under the terms of the GPL: --*/
+/*-- --*/
+/*-- This program is free software: you can redistribute it and/or modify --*/
+/*-- it under the terms of the GNU General Public License as published by --*/
+/*-- the Free Software Foundation, either version 3 of the License, or --*/
+/*-- (at your option) any later version. --*/
+/*-- --*/
+/*-- This program is distributed in the hope that it will be useful, --*/
+/*-- but WITHOUT ANY WARRANTY; without even the implied warranty of --*/
+/*-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --*/
+/*-- GNU General Public License for more details. --*/
+/*-- --*/
+/*-- You should have received a copy of the GNU General Public License --*/
+/*-- along with this program. If not, see <http://www.gnu.org/licenses/>. --*/
+/*----------------------------------------------------------------------------*/
+
+import com.pkrandom.FileFunctions;
+
+import javax.swing.*;
+import java.awt.*;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ *
+ * @author Stewart
+ */
+public class OperationDialog extends javax.swing.JDialog {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 5965463550336235236L;
+
+ /**
+ * Creates new form OperationDialog
+ */
+ public OperationDialog(String text, Frame parent, boolean modal) {
+ super(parent, modal);
+ initComponents();
+ this.loadingLabel.setText(text);
+ setLocationRelativeTo(parent);
+ }
+
+ public OperationDialog(String text, Dialog parent, boolean modal) {
+ super(parent, modal);
+ initComponents();
+ this.loadingLabel.setText(text);
+ setLocationRelativeTo(parent);
+ }
+
+ /* @formatter:off */
+ /**
+ * This method is called from within the constructor to initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is always
+ * regenerated by the Form Editor.
+ */
+ // <editor-fold defaultstate="collapsed"
+ // desc="Generated Code">//GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ jPanel1 = new javax.swing.JPanel();
+ loadingLabel = new javax.swing.JLabel();
+
+ setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
+ setResizable(false);
+ setUndecorated(true);
+
+ jPanel1.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(
+ 0, 0, 0), 2, true));
+
+ loadingLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
+ loadingLabel.setIcon(getLoadingIcon());
+ loadingLabel.setText("Loading...");
+
+ javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(
+ jPanel1);
+ jPanel1.setLayout(jPanel1Layout);
+ jPanel1Layout.setHorizontalGroup(jPanel1Layout.createParallelGroup(
+ javax.swing.GroupLayout.Alignment.LEADING).addGroup(
+ jPanel1Layout.createSequentialGroup().addContainerGap()
+ .addComponent(loadingLabel)
+ .addContainerGap(53, Short.MAX_VALUE)));
+ jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(
+ javax.swing.GroupLayout.Alignment.LEADING).addGroup(
+ jPanel1Layout
+ .createSequentialGroup()
+ .addContainerGap()
+ .addComponent(loadingLabel)
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
+ Short.MAX_VALUE)));
+
+ javax.swing.GroupLayout layout = new javax.swing.GroupLayout(
+ getContentPane());
+ getContentPane().setLayout(layout);
+ layout.setHorizontalGroup(layout.createParallelGroup(
+ javax.swing.GroupLayout.Alignment.LEADING).addComponent(
+ jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,
+ javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE));
+ layout.setVerticalGroup(layout.createParallelGroup(
+ javax.swing.GroupLayout.Alignment.LEADING).addComponent(
+ jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
+ javax.swing.GroupLayout.DEFAULT_SIZE,
+ javax.swing.GroupLayout.PREFERRED_SIZE));
+
+ pack();
+ }// </editor-fold>//GEN-END:initComponents
+
+ private ImageIcon getLoadingIcon() {
+ try {
+ InputStream in = OperationDialog.class
+ .getResourceAsStream("/com/pkrandom/newgui/loading.gif");
+ byte[] buf = FileFunctions.readFullyIntoBuffer(in, in.available());
+ in.close();
+ Image image = Toolkit.getDefaultToolkit().createImage(buf);
+ return new ImageIcon(image);
+ } catch (IOException ex) {
+ return null;
+ }
+ }
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JPanel jPanel1;
+ private javax.swing.JLabel loadingLabel;
+
+ // End of variables declaration//GEN-END:variables
+ /* @formatter:on */
+}