Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package legyenonismilliomos;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- import java.util.List;
- import java.util.logging.Level;
- import java.util.logging.Logger;
- import javax.swing.JOptionPane;
- import modell.DbModell;
- import modell.Imodel;
- import modell.Kerdes;
- public class KezdoAblak extends javax.swing.JFrame {
- private Imodel model;
- private Kerdes kerdesek;
- Kerdes kerdes;
- int i=1;
- String helyesvalasz="";
- public KezdoAblak() {
- initComponents();
- setLocationRelativeTo(null);
- setTitle("Legyen ön is milliomos 2016");
- String connURL="jdbc:mysql://localhost:3306/java_vizsga";
- String user ="root";
- String pass="1234";
- try {
- Connection conn= DriverManager.getConnection(connURL, user, pass);
- model=new DbModell(conn);
- }catch(SQLException ex) {
- JOptionPane.showMessageDialog(rootPane, ex.getMessage(), "Adatbázis hiba", JOptionPane.ERROR_MESSAGE);
- }
- try {
- kerdesek =model.getKerdes(i);
- } catch (SQLException ex) {
- JOptionPane.showMessageDialog(rootPane, ex.getMessage(), "Adatbázis hiba", JOptionPane.ERROR_MESSAGE);
- }
- jlbKerdesek.setText(kerdesek.getKerdes());
- jButton1.setText(kerdesek.getValasz0());
- jButton2.setText(kerdesek.getValasz1());
- jButton3.setText(kerdesek.getValasz2());
- jButton4.setText(kerdesek.getValasz3());
- helyesvalasz=kerdesek.getValasz3();
- }
- /**
- * 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.
- */
- @SuppressWarnings("unchecked")
- // <editor-fold defaultstate="collapsed" desc="Generated Code">
- private void initComponents() {
- jScrollPane1 = new javax.swing.JScrollPane();
- jlsOsszeg = new javax.swing.JList<>();
- jLabel1 = new javax.swing.JLabel();
- jButton1 = new javax.swing.JButton();
- jButton2 = new javax.swing.JButton();
- jButton3 = new javax.swing.JButton();
- jButton4 = new javax.swing.JButton();
- jlbKerdesek = new javax.swing.JLabel();
- jMenuBar1 = new javax.swing.JMenuBar();
- jMenu1 = new javax.swing.JMenu();
- jMenuItem1 = new javax.swing.JMenuItem();
- jMenu2 = new javax.swing.JMenu();
- jMenuItem2 = new javax.swing.JMenuItem();
- jMenuItem3 = new javax.swing.JMenuItem();
- jMenu3 = new javax.swing.JMenu();
- jMenuItem4 = new javax.swing.JMenuItem();
- setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
- jlsOsszeg.setModel(new javax.swing.AbstractListModel<String>() {
- String[] strings = { "40000000", "20000000", "10000000", "5000000", "2000000", "1000000", "800000", "500000", "300000", "200000", "100000", "50000", "20000", "10000", "5000", " ", " ", " ", " ", " " };
- public int getSize() { return strings.length; }
- public String getElementAt(int i) { return strings[i]; }
- });
- jScrollPane1.setViewportView(jlsOsszeg);
- jButton1.setText("jButton1");
- jButton1.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton1ActionPerformed(evt);
- }
- });
- jButton2.setText("jButton2");
- jButton2.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton2ActionPerformed(evt);
- }
- });
- jButton3.setText("jButton3");
- jButton4.setText("jButton4");
- jMenu1.setText("Fájl");
- jMenuItem1.setText("Kilépés");
- jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jMenuItem1ActionPerformed(evt);
- }
- });
- jMenu1.add(jMenuItem1);
- jMenuBar1.add(jMenu1);
- jMenu2.setText("Jaték");
- jMenuItem2.setText("Új játék");
- jMenu2.add(jMenuItem2);
- jMenuItem3.setText("Kilépés");
- jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jMenuItem3ActionPerformed(evt);
- }
- });
- jMenu2.add(jMenuItem3);
- jMenuBar1.add(jMenu2);
- jMenu3.setText("Kérdések kezelése");
- jMenuItem4.setText("Kérdés szerkesztés");
- jMenu3.add(jMenuItem4);
- jMenuBar1.add(jMenu3);
- setJMenuBar(jMenuBar1);
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(28, 28, 28)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jButton1)
- .addComponent(jButton3))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jButton2)
- .addComponent(jButton4))
- .addGap(16, 16, 16))
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
- .addContainerGap(53, Short.MAX_VALUE)
- .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 251, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(jlbKerdesek, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
- .addGap(18, 18, 18)
- .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(27, 27, 27))
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 288, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
- .addContainerGap(200, Short.MAX_VALUE)
- .addComponent(jlbKerdesek, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(18, 18, 18)
- .addComponent(jLabel1)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jButton1)
- .addComponent(jButton2))
- .addGap(18, 18, 18)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jButton3)
- .addComponent(jButton4))
- .addGap(23, 23, 23))
- );
- pack();
- }// </editor-fold>
- private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {
- if(model!=null){
- try {
- model.close();
- } catch (SQLException ex) {
- JOptionPane.showMessageDialog(rootPane, ex.getMessage(), "Adatbázis hiba", JOptionPane.ERROR_MESSAGE);
- }
- }
- System.exit(0);
- }
- private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {
- System.exit(0);
- }
- private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
- }
- private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
- }
- public static void main(String args[]) {
- /* Set the Nimbus look and feel */
- //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
- /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
- * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
- */
- try {
- for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
- if ("Nimbus".equals(info.getName())) {
- javax.swing.UIManager.setLookAndFeel(info.getClassName());
- break;
- }
- }
- } catch (ClassNotFoundException ex) {
- java.util.logging.Logger.getLogger(KezdoAblak.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (InstantiationException ex) {
- java.util.logging.Logger.getLogger(KezdoAblak.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (IllegalAccessException ex) {
- java.util.logging.Logger.getLogger(KezdoAblak.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (javax.swing.UnsupportedLookAndFeelException ex) {
- java.util.logging.Logger.getLogger(KezdoAblak.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- }
- //</editor-fold>
- /* Create and display the form */
- java.awt.EventQueue.invokeLater(new Runnable() {
- public void run() {
- new KezdoAblak().setVisible(true);
- }
- });
- }
- // Variables declaration - do not modify
- private javax.swing.JButton jButton1;
- private javax.swing.JButton jButton2;
- private javax.swing.JButton jButton3;
- private javax.swing.JButton jButton4;
- private javax.swing.JLabel jLabel1;
- private javax.swing.JMenu jMenu1;
- private javax.swing.JMenu jMenu2;
- private javax.swing.JMenu jMenu3;
- private javax.swing.JMenuBar jMenuBar1;
- private javax.swing.JMenuItem jMenuItem1;
- private javax.swing.JMenuItem jMenuItem2;
- private javax.swing.JMenuItem jMenuItem3;
- private javax.swing.JMenuItem jMenuItem4;
- private javax.swing.JScrollPane jScrollPane1;
- private javax.swing.JLabel jlbKerdesek;
- private javax.swing.JList<String> jlsOsszeg;
- // End of variables declaration
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement