diff --git a/src/gui/ArgumentsGen.java b/src/gui/ArgumentsGen.java index 7e70511..c7bb5d3 100644 --- a/src/gui/ArgumentsGen.java +++ b/src/gui/ArgumentsGen.java @@ -1,7 +1,7 @@ package gui; - import javax.swing.JFrame; - import javax.swing.SwingUtilities; +import javax.swing.JFrame; +import javax.swing.SwingUtilities; /** * @author Louis Royer @@ -12,152 +12,152 @@ package gui; public class ArgumentsGen extends javax.swing.JPanel { - private javax.swing.JButton jButton1; - private javax.swing.JComboBox jComboBox1; - private javax.swing.JLabel jLabel1; - private javax.swing.JLabel jLabel2; - private javax.swing.JLabel jLabel3; - private javax.swing.JLabel jLabel4; - private javax.swing.JLabel jLabel5; - private javax.swing.JLabel jLabel6; - private javax.swing.JTextField jTextField1; - private javax.swing.JTextField jTextField2; - private javax.swing.JTextField jTextField3; - private javax.swing.JTextField jTextField4; + private javax.swing.JButton jButton1; + private javax.swing.JComboBox jComboBox1; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel5; + private javax.swing.JLabel jLabel6; + private javax.swing.JTextField jTextField1; + private javax.swing.JTextField jTextField2; + private javax.swing.JTextField jTextField3; + private javax.swing.JTextField jTextField4; private static final long serialVersionUID = 13L; - /** - * Creates new form ArgumentsGen - */ - public ArgumentsGen() { - initComponents(); - } - - /** - * This method is called from within the constructor to initialize the form. - */ - - @SuppressWarnings("unchecked") - // - private void initComponents() { - - jLabel1 = new javax.swing.JLabel(); - jLabel2 = new javax.swing.JLabel(); - jLabel3 = new javax.swing.JLabel(); - jLabel4 = new javax.swing.JLabel(); - jLabel5 = new javax.swing.JLabel(); - jLabel6 = new javax.swing.JLabel(); - jComboBox1 = new javax.swing.JComboBox<>(); - jTextField1 = new javax.swing.JTextField("7071"); - jTextField2 = new javax.swing.JTextField("localhost"); - jTextField3 = new javax.swing.JTextField("localhost"); - jTextField4 = new javax.swing.JTextField("6969"); - jButton1 = new javax.swing.JButton(); - - jLabel1.setText("Enter connection informations:"); - - jLabel2.setText("Server hostname:"); - - jLabel3.setText("Server port:"); - - jLabel4.setText("Tracker hostname:"); - - jLabel5.setText("Tracker port:"); - - jLabel6.setText("Client's protocol:"); - - jComboBox1.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "TCP", "UDP" })); - - jTextField1.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jTextField1ActionPerformed(evt); - } - }); - - jTextField2.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jTextField2ActionPerformed(evt); - } - }); - - jButton1.setText("Connect"); - jButton1.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jButton1ActionPerformed(evt); - } - }); - - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); - this.setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jLabel1) - .addGroup(layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jLabel2) - .addComponent(jLabel3) - .addComponent(jLabel4) - .addComponent(jLabel5) - .addComponent(jLabel6)) - .addGap(71, 71, 71) - .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) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addComponent(jTextField1) - .addComponent(jTextField2, javax.swing.GroupLayout.DEFAULT_SIZE, 149, Short.MAX_VALUE) - .addComponent(jTextField3) - .addComponent(jTextField4))))) - .addContainerGap(138, Short.MAX_VALUE)) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE) - .addContainerGap()) - ); - layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addComponent(jLabel1) - .addGap(19, 19, 19) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel2) - .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGap(7, 7, 7) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel3) - .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGap(6, 6, 6) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel4) - .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .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(jLabel5)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .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(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 12, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jButton1) - .addContainerGap(16, Short.MAX_VALUE)) - ); - }// - - private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) { - // TODO add your handling code here: - } - - private void jTextField2ActionPerformed(java.awt.event.ActionEvent evt) { - // TODO add your handling code here: - } + /** + * Creates new form ArgumentsGen + */ + public ArgumentsGen() { + initComponents(); + } + + /** + * This method is called from within the constructor to initialize the form. + */ + + @SuppressWarnings("unchecked") + // + private void initComponents() { + + jLabel1 = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + jLabel3 = new javax.swing.JLabel(); + jLabel4 = new javax.swing.JLabel(); + jLabel5 = new javax.swing.JLabel(); + jLabel6 = new javax.swing.JLabel(); + jComboBox1 = new javax.swing.JComboBox<>(); + jTextField1 = new javax.swing.JTextField("7070"); + jTextField2 = new javax.swing.JTextField("localhost"); + jTextField3 = new javax.swing.JTextField("localhost"); + jTextField4 = new javax.swing.JTextField("6969"); + jButton1 = new javax.swing.JButton(); + + jLabel1.setText("Enter connection informations:"); + + jLabel2.setText("Server hostname:"); + + jLabel3.setText("Server port:"); + + jLabel4.setText("Tracker hostname:"); + + jLabel5.setText("Tracker port:"); + + jLabel6.setText("Client's protocol:"); + + jComboBox1.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "TCP", "UDP" })); + + jTextField1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jTextField1ActionPerformed(evt); + } + }); + + jTextField2.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jTextField2ActionPerformed(evt); + } + }); + + jButton1.setText("Connect"); + jButton1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton1ActionPerformed(evt); + } + }); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel1) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel2) + .addComponent(jLabel3) + .addComponent(jLabel4) + .addComponent(jLabel5) + .addComponent(jLabel6)) + .addGap(71, 71, 71) + .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) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(jTextField1) + .addComponent(jTextField2, javax.swing.GroupLayout.DEFAULT_SIZE, 149, Short.MAX_VALUE) + .addComponent(jTextField3) + .addComponent(jTextField4))))) + .addContainerGap(138, Short.MAX_VALUE)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel1) + .addGap(19, 19, 19) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel2) + .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(7, 7, 7) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel3) + .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(6, 6, 6) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel4) + .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .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(jLabel5)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .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(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 12, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jButton1) + .addContainerGap(16, Short.MAX_VALUE)) + ); + }// + + private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) { + // TODO add your handling code here: + } + + private void jTextField2ActionPerformed(java.awt.event.ActionEvent evt) { + // TODO add your handling code here: + } /** 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 portServerStr = jTextField1.getText(); String hostnameTracker = jTextField3.getText(); @@ -174,6 +174,6 @@ public class ArgumentsGen extends javax.swing.JPanel { c.connect(); JFrame topFrame = (JFrame) SwingUtilities.getWindowAncestor(this); topFrame.dispose(); - } + } } diff --git a/src/gui/DownloadSelectionGen.java b/src/gui/DownloadSelectionGen.java index 4785687..c166447 100644 --- a/src/gui/DownloadSelectionGen.java +++ b/src/gui/DownloadSelectionGen.java @@ -31,106 +31,106 @@ public class DownloadSelectionGen extends javax.swing.JPanel { private ClientManagement clientManagement; private Logger logger; - /** + /** * @param listFilesToDownload list of files to display * @param clientManagement clientManagement * @param logger logger - * Creates new form ArgumentsGen - */ - public DownloadSelectionGen(String[] listFilesToDownload, ClientManagement clientManagement, Logger logger) { + * Creates new form ArgumentsGen + */ + public DownloadSelectionGen(String[] listFilesToDownload, ClientManagement clientManagement, Logger logger) { this.listFilesToDownload = listFilesToDownload; this.clientManagement = clientManagement; this.logger = logger; - initComponents(); - } - - /** - * This method is called from within the constructor to initialize the form. - */ - @SuppressWarnings("unchecked") - // - private void initComponents() { - - jLabel1 = new javax.swing.JLabel(); - jButton1 = new javax.swing.JButton(); - jScrollPane1 = new javax.swing.JScrollPane(); - jList1 = new javax.swing.JList<>(); - jButton2 = new javax.swing.JButton(); - - jLabel1.setText("Select a file to download:"); - - jButton1.setText("Download"); - jButton1.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jButton1ActionPerformed(evt); - } - }); - - jList1.setModel(new javax.swing.AbstractListModel() { - String[] strings = listFilesToDownload; - public int getSize() { return strings.length; } - public String getElementAt(int i) { return strings[i]; } - }); - jScrollPane1.setViewportView(jList1); + initComponents(); + } + + /** + * This method is called from within the constructor to initialize the form. + */ + @SuppressWarnings("unchecked") + // + private void initComponents() { + + jLabel1 = new javax.swing.JLabel(); + jButton1 = new javax.swing.JButton(); + jScrollPane1 = new javax.swing.JScrollPane(); + jList1 = new javax.swing.JList<>(); + jButton2 = new javax.swing.JButton(); + + jLabel1.setText("Select a file to download:"); + + jButton1.setText("Download"); + jButton1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton1ActionPerformed(evt); + } + }); + + jList1.setModel(new javax.swing.AbstractListModel() { + String[] strings = listFilesToDownload; + public int getSize() { return strings.length; } + public String getElementAt(int i) { return strings[i]; } + }); + jScrollPane1.setViewportView(jList1); jList1.setSelectedIndex(0); jButton2.setText("Back"); - jButton2.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jButton2ActionPerformed(evt); - } - }); - - - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); - this.setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addComponent(jLabel1) - .addGap(0, 0, Short.MAX_VALUE)) - .addGroup(layout.createSequentialGroup() - .addGap(97, 97, 97) - .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE) - .addContainerGap(104, Short.MAX_VALUE)) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() - .addGap(25, 25, 25) - .addComponent(jButton2) - .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) - .addGap(23, 23, 23)) - ); - layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addComponent(jLabel1) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 134, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jButton1) - .addComponent(jButton2)) - .addContainerGap(24, Short.MAX_VALUE)) - ); - }// + jButton2.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton2ActionPerformed(evt); + } + }); + + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel1) + .addGap(0, 0, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addGap(97, 97, 97) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(104, Short.MAX_VALUE)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addGap(25, 25, 25) + .addComponent(jButton2) + .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) + .addGap(23, 23, 23)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 134, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jButton1) + .addComponent(jButton2)) + .addContainerGap(24, Short.MAX_VALUE)) + ); + }// /** 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(); System.out.println("File to download: " + fileSelected); DownloadFileGUI dl = new DownloadFileGUI(fileSelected, clientManagement, logger); dl.download(); - } + } /** 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(); JFrame topFrame = (JFrame) SwingUtilities.getWindowAncestor(this); topFrame.add(a); this.setVisible(false); - } + } } diff --git a/src/gui/ErrorFrame.java b/src/gui/ErrorFrame.java index be94d56..2cdb577 100644 --- a/src/gui/ErrorFrame.java +++ b/src/gui/ErrorFrame.java @@ -12,11 +12,11 @@ package gui; * @author Flavien Haas * @author JS Auge * @version 1.0 - */ + */ public class ErrorFrame extends javax.swing.JFrame { - private javax.swing.JLabel jLabel1; - private javax.swing.JToggleButton jToggleButton1; + private javax.swing.JLabel jLabel1; + private javax.swing.JToggleButton jToggleButton1; private String message; 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 */ - public ErrorFrame(String message) { + public ErrorFrame(String message) { this.message = message; - initComponents(); + initComponents(); this.setVisible(true); - } + } - /** - * This method is called from within the constructor to initialize the form. - */ - @SuppressWarnings("unchecked") - // - private void initComponents() { + /** + * This method is called from within the constructor to initialize the form. + */ + @SuppressWarnings("unchecked") + // + private void initComponents() { - jToggleButton1 = new javax.swing.JToggleButton(); - jLabel1 = new javax.swing.JLabel(); + jToggleButton1 = new javax.swing.JToggleButton(); + jLabel1 = new javax.swing.JLabel(); - setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jToggleButton1.setText("Close"); - jToggleButton1.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jToggleButton1ActionPerformed(evt); - } - }); - - jLabel1.setText(message); - - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); - getContentPane().setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addComponent(jLabel1)) - .addGroup(layout.createSequentialGroup() - .addGap(253, 253, 253) - .addComponent(jToggleButton1))) - .addContainerGap(205, Short.MAX_VALUE)) - ); - layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() - .addContainerGap() - .addComponent(jLabel1) - .addGap(30, 30, 30) - .addComponent(jToggleButton1) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - ); + jToggleButton1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jToggleButton1ActionPerformed(evt); + } + }); + + jLabel1.setText(message); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel1)) + .addGroup(layout.createSequentialGroup() + .addGap(253, 253, 253) + .addComponent(jToggleButton1))) + .addContainerGap(205, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel1) + .addGap(30, 30, 30) + .addComponent(jToggleButton1) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); this.setLocationRelativeTo(null); this.setAlwaysOnTop(true); - pack(); - }// + pack(); + }// /**force exit the program when the button "Close" is pressed*/ private void jToggleButton1ActionPerformed(java.awt.event.ActionEvent evt) { - System.exit(1); - } + System.exit(1); + } }