1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
package com.rafa_99.pkrandom.newgui;
/*----------------------------------------------------------------------------*/
/*-- OperationDialog.java - a dialog that displays the loading spinner --*/
/*-- --*/
/*-- Part of "Universal Pokemon Randomizer ZX" by the UPR-ZX team --*/
/*-- Originally part of "Universal Pokemon Randomizer" by rafa_99 --*/
/*-- 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.rafa_99.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/rafa_99/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 */
}
|