replaced spaces with tabs + right default server port
All checks were successful
flavien's git/Projet_JAVA_P2P_STRI2A/pipeline/pr-master This commit looks good

This commit is contained in:
js 2020-04-12 17:54:59 +02:00
parent a646836f97
commit d775ee7cbb
3 changed files with 248 additions and 248 deletions

View File

@ -1,7 +1,7 @@
package gui; package gui;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
/** /**
* @author Louis Royer * @author Louis Royer
@ -12,152 +12,152 @@ package gui;
public class ArgumentsGen extends javax.swing.JPanel { public class ArgumentsGen extends javax.swing.JPanel {
private javax.swing.JButton jButton1; private javax.swing.JButton jButton1;
private javax.swing.JComboBox<String> jComboBox1; private javax.swing.JComboBox<String> jComboBox1;
private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel6;
private javax.swing.JTextField jTextField1; private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2; private javax.swing.JTextField jTextField2;
private javax.swing.JTextField jTextField3; private javax.swing.JTextField jTextField3;
private javax.swing.JTextField jTextField4; private javax.swing.JTextField jTextField4;
private static final long serialVersionUID = 13L; private static final long serialVersionUID = 13L;
/** /**
* Creates new form ArgumentsGen * Creates new form ArgumentsGen
*/ */
public ArgumentsGen() { public ArgumentsGen() {
initComponents(); initComponents();
} }
/** /**
* This method is called from within the constructor to initialize the form. * This method is called from within the constructor to initialize the form.
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code"> // <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() { private void initComponents() {
jLabel1 = new javax.swing.JLabel(); jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel(); jLabel6 = new javax.swing.JLabel();
jComboBox1 = new javax.swing.JComboBox<>(); jComboBox1 = new javax.swing.JComboBox<>();
jTextField1 = new javax.swing.JTextField("7071"); jTextField1 = new javax.swing.JTextField("7070");
jTextField2 = new javax.swing.JTextField("localhost"); jTextField2 = new javax.swing.JTextField("localhost");
jTextField3 = new javax.swing.JTextField("localhost"); jTextField3 = new javax.swing.JTextField("localhost");
jTextField4 = new javax.swing.JTextField("6969"); jTextField4 = new javax.swing.JTextField("6969");
jButton1 = new javax.swing.JButton(); jButton1 = new javax.swing.JButton();
jLabel1.setText("Enter connection informations:"); jLabel1.setText("Enter connection informations:");
jLabel2.setText("Server hostname:"); jLabel2.setText("Server hostname:");
jLabel3.setText("Server port:"); jLabel3.setText("Server port:");
jLabel4.setText("Tracker hostname:"); jLabel4.setText("Tracker hostname:");
jLabel5.setText("Tracker port:"); jLabel5.setText("Tracker port:");
jLabel6.setText("Client's protocol:"); jLabel6.setText("Client's protocol:");
jComboBox1.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "TCP", "UDP" })); jComboBox1.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "TCP", "UDP" }));
jTextField1.addActionListener(new java.awt.event.ActionListener() { jTextField1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField1ActionPerformed(evt); jTextField1ActionPerformed(evt);
} }
}); });
jTextField2.addActionListener(new java.awt.event.ActionListener() { jTextField2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField2ActionPerformed(evt); jTextField2ActionPerformed(evt);
} }
}); });
jButton1.setText("Connect"); jButton1.setText("Connect");
jButton1.addActionListener(new java.awt.event.ActionListener() { jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt); jButton1ActionPerformed(evt);
} }
}); });
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout); this.setLayout(layout);
layout.setHorizontalGroup( layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1) .addComponent(jLabel1)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel2) .addComponent(jLabel2)
.addComponent(jLabel3) .addComponent(jLabel3)
.addComponent(jLabel4) .addComponent(jLabel4)
.addComponent(jLabel5) .addComponent(jLabel5)
.addComponent(jLabel6)) .addComponent(jLabel6))
.addGap(71, 71, 71) .addGap(71, 71, 71)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jTextField1) .addComponent(jTextField1)
.addComponent(jTextField2, javax.swing.GroupLayout.DEFAULT_SIZE, 149, Short.MAX_VALUE) .addComponent(jTextField2, javax.swing.GroupLayout.DEFAULT_SIZE, 149, Short.MAX_VALUE)
.addComponent(jTextField3) .addComponent(jTextField3)
.addComponent(jTextField4))))) .addComponent(jTextField4)))))
.addContainerGap(138, Short.MAX_VALUE)) .addContainerGap(138, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap()) .addContainerGap())
); );
layout.setVerticalGroup( layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addComponent(jLabel1) .addComponent(jLabel1)
.addGap(19, 19, 19) .addGap(19, 19, 19)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2) .addComponent(jLabel2)
.addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(7, 7, 7) .addGap(7, 7, 7)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3) .addComponent(jLabel3)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(6, 6, 6) .addGap(6, 6, 6)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4) .addComponent(jLabel4)
.addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel5)) .addComponent(jLabel5))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 12, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 12, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton1) .addComponent(jButton1)
.addContainerGap(16, Short.MAX_VALUE)) .addContainerGap(16, Short.MAX_VALUE))
); );
}// </editor-fold> }// </editor-fold>
private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) { private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here: // TODO add your handling code here:
} }
private void jTextField2ActionPerformed(java.awt.event.ActionEvent evt) { private void jTextField2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here: // TODO add your handling code here:
} }
/** Actions when click on connect: creat a clientP2Pgui with the infos from textfields*/ /** Actions when click on connect: creat a clientP2Pgui with the infos from textfields*/
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
String hostnameServer = jTextField2.getText(); String hostnameServer = jTextField2.getText();
String portServerStr = jTextField1.getText(); String portServerStr = jTextField1.getText();
String hostnameTracker = jTextField3.getText(); String hostnameTracker = jTextField3.getText();
@ -174,6 +174,6 @@ public class ArgumentsGen extends javax.swing.JPanel {
c.connect(); c.connect();
JFrame topFrame = (JFrame) SwingUtilities.getWindowAncestor(this); JFrame topFrame = (JFrame) SwingUtilities.getWindowAncestor(this);
topFrame.dispose(); topFrame.dispose();
} }
} }

View File

@ -31,106 +31,106 @@ public class DownloadSelectionGen extends javax.swing.JPanel {
private ClientManagement clientManagement; private ClientManagement clientManagement;
private Logger logger; private Logger logger;
/** /**
* @param listFilesToDownload list of files to display * @param listFilesToDownload list of files to display
* @param clientManagement clientManagement * @param clientManagement clientManagement
* @param logger logger * @param logger logger
* Creates new form ArgumentsGen * Creates new form ArgumentsGen
*/ */
public DownloadSelectionGen(String[] listFilesToDownload, ClientManagement clientManagement, Logger logger) { public DownloadSelectionGen(String[] listFilesToDownload, ClientManagement clientManagement, Logger logger) {
this.listFilesToDownload = listFilesToDownload; this.listFilesToDownload = listFilesToDownload;
this.clientManagement = clientManagement; this.clientManagement = clientManagement;
this.logger = logger; this.logger = logger;
initComponents(); initComponents();
} }
/** /**
* This method is called from within the constructor to initialize the form. * This method is called from within the constructor to initialize the form.
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code"> // <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() { private void initComponents() {
jLabel1 = new javax.swing.JLabel(); jLabel1 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton(); jButton1 = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane(); jScrollPane1 = new javax.swing.JScrollPane();
jList1 = new javax.swing.JList<>(); jList1 = new javax.swing.JList<>();
jButton2 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton();
jLabel1.setText("Select a file to download:"); jLabel1.setText("Select a file to download:");
jButton1.setText("Download"); jButton1.setText("Download");
jButton1.addActionListener(new java.awt.event.ActionListener() { jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt); jButton1ActionPerformed(evt);
} }
}); });
jList1.setModel(new javax.swing.AbstractListModel<String>() { jList1.setModel(new javax.swing.AbstractListModel<String>() {
String[] strings = listFilesToDownload; String[] strings = listFilesToDownload;
public int getSize() { return strings.length; } public int getSize() { return strings.length; }
public String getElementAt(int i) { return strings[i]; } public String getElementAt(int i) { return strings[i]; }
}); });
jScrollPane1.setViewportView(jList1); jScrollPane1.setViewportView(jList1);
jList1.setSelectedIndex(0); jList1.setSelectedIndex(0);
jButton2.setText("Back"); jButton2.setText("Back");
jButton2.addActionListener(new java.awt.event.ActionListener() { jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt); jButton2ActionPerformed(evt);
} }
}); });
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout); this.setLayout(layout);
layout.setHorizontalGroup( layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addComponent(jLabel1) .addComponent(jLabel1)
.addGap(0, 0, Short.MAX_VALUE)) .addGap(0, 0, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addGap(97, 97, 97) .addGap(97, 97, 97)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(104, Short.MAX_VALUE)) .addContainerGap(104, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(25, 25, 25) .addGap(25, 25, 25)
.addComponent(jButton2) .addComponent(jButton2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(23, 23, 23)) .addGap(23, 23, 23))
); );
layout.setVerticalGroup( layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addComponent(jLabel1) .addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 134, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 134, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton1) .addComponent(jButton1)
.addComponent(jButton2)) .addComponent(jButton2))
.addContainerGap(24, Short.MAX_VALUE)) .addContainerGap(24, Short.MAX_VALUE))
); );
}// </editor-fold> }// </editor-fold>
/** Actions to initiate when button "Download" is pressed */ /** Actions to initiate when button "Download" is pressed */
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
String fileSelected = jList1.getSelectedValue(); String fileSelected = jList1.getSelectedValue();
System.out.println("File to download: " + fileSelected); System.out.println("File to download: " + fileSelected);
DownloadFileGUI dl = new DownloadFileGUI(fileSelected, clientManagement, logger); DownloadFileGUI dl = new DownloadFileGUI(fileSelected, clientManagement, logger);
dl.download(); dl.download();
} }
/** Actions to initiate when button "Back" is initiate */ /** Actions to initiate when button "Back" is initiate */
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
ArgumentsGen a = new ArgumentsGen(); ArgumentsGen a = new ArgumentsGen();
JFrame topFrame = (JFrame) SwingUtilities.getWindowAncestor(this); JFrame topFrame = (JFrame) SwingUtilities.getWindowAncestor(this);
topFrame.add(a); topFrame.add(a);
this.setVisible(false); this.setVisible(false);
} }
} }

View File

@ -12,11 +12,11 @@ package gui;
* @author Flavien Haas * @author Flavien Haas
* @author JS Auge * @author JS Auge
* @version 1.0 * @version 1.0
*/ */
public class ErrorFrame extends javax.swing.JFrame { public class ErrorFrame extends javax.swing.JFrame {
private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel1;
private javax.swing.JToggleButton jToggleButton1; private javax.swing.JToggleButton jToggleButton1;
private String message; private String message;
private static final long serialVersionUID = 13L; private static final long serialVersionUID = 13L;
@ -26,67 +26,67 @@ public class ErrorFrame extends javax.swing.JFrame {
* Create new Errorframe, used to display an error and stop the program when needed * Create new Errorframe, used to display an error and stop the program when needed
*/ */
public ErrorFrame(String message) { public ErrorFrame(String message) {
this.message = message; this.message = message;
initComponents(); initComponents();
this.setVisible(true); this.setVisible(true);
} }
/** /**
* This method is called from within the constructor to initialize the form. * This method is called from within the constructor to initialize the form.
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code"> // <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() { private void initComponents() {
jToggleButton1 = new javax.swing.JToggleButton(); jToggleButton1 = new javax.swing.JToggleButton();
jLabel1 = new javax.swing.JLabel(); jLabel1 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jToggleButton1.setText("Close"); jToggleButton1.setText("Close");
jToggleButton1.addActionListener(new java.awt.event.ActionListener() { jToggleButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { public void actionPerformed(java.awt.event.ActionEvent evt) {
jToggleButton1ActionPerformed(evt); jToggleButton1ActionPerformed(evt);
} }
}); });
jLabel1.setText(message); jLabel1.setText(message);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout); getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addComponent(jLabel1)) .addComponent(jLabel1))
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addGap(253, 253, 253) .addGap(253, 253, 253)
.addComponent(jToggleButton1))) .addComponent(jToggleButton1)))
.addContainerGap(205, Short.MAX_VALUE)) .addContainerGap(205, Short.MAX_VALUE))
); );
layout.setVerticalGroup( layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addComponent(jLabel1) .addComponent(jLabel1)
.addGap(30, 30, 30) .addGap(30, 30, 30)
.addComponent(jToggleButton1) .addComponent(jToggleButton1)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
); );
this.setLocationRelativeTo(null); this.setLocationRelativeTo(null);
this.setAlwaysOnTop(true); this.setAlwaysOnTop(true);
pack(); pack();
}// </editor-fold> }// </editor-fold>
/**force exit the program when the button "Close" is pressed*/ /**force exit the program when the button "Close" is pressed*/
private void jToggleButton1ActionPerformed(java.awt.event.ActionEvent evt) { private void jToggleButton1ActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(1); System.exit(1);
} }
} }