daily pastebin goal
58%
SHARE
TWEET

Untitled

a guest Jul 20th, 2017 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.awt.GridBagConstraints;
  2. import java.awt.GridBagLayout;
  3. import java.awt.event.ActionEvent;
  4. import java.awt.event.ActionListener;
  5. import java.sql.Connection;
  6. import java.sql.DriverManager;
  7. import java.sql.ResultSet;
  8. import java.sql.SQLException;
  9. import javax.swing.JCheckBox;
  10. import javax.swing.JButton;
  11. import javax.swing.JLabel;
  12. import javax.swing.JOptionPane;
  13. import javax.swing.JPanel;
  14.  
  15.  
  16. public class RemoverFed extends JPanel {
  17.    
  18.     int count;
  19.    
  20.     public RemoverFed(){
  21.         try {
  22.             this.setLayout(new GridBagLayout());
  23.             GridBagConstraints c = new GridBagConstraints();
  24.             c.gridx = 0;
  25.             c.gridy = 0;
  26.        
  27.             JButton botao = new JButton();
  28.             JButton voltar = new JButton();
  29.             voltar.setText("Voltar");
  30.             voltar.addActionListener(new ActionListener() {
  31.                 public void actionPerformed(ActionEvent e) {
  32.                     JanelaPrincipal.getInstance().trocaPainel(new JanelaInstrucoes());
  33.                 }
  34.             });
  35.            
  36.             botao.setText("Cadastrar nova federação");
  37.             Class.forName("com.mysql.jdbc.Driver");
  38.             Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/projetoserio?user=root&password=root");
  39.             java.sql.Statement stmt = conn.createStatement();
  40.             ResultSet teste = stmt.executeQuery("Select count(nome) from federacao;");
  41.             while (teste.next()) {
  42.                 count = teste.getInt(1);
  43.             }
  44.             ResultSet federacoes = stmt.executeQuery("Select nome from federacao;");
  45.             JCheckBox feds[] = new JCheckBox[count];
  46.             int i=1;
  47.             while (federacoes.next()){
  48.                 feds[i-1].setText(federacoes.getString(1));
  49.                 c.gridy++;
  50.                 this.add(feds[i-1], c);
  51.                 i++;
  52.                 }
  53.             botao.addActionListener(new ActionListener() {
  54.                 public void actionPerformed(ActionEvent e) {   
  55.                 }
  56.             });
  57.             c.gridwidth = 0;
  58.             c.gridy++;
  59.             this.add(botao, c);
  60.             c.gridy++;
  61.             this.add(voltar, c);
  62.         } catch (ClassNotFoundException e2) {
  63.             e2.printStackTrace();
  64.         } catch (SQLException e2) {
  65.             e2.printStackTrace();
  66.         }
  67. }
  68.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top