Advertisement
Guest User

Untitled

a guest
May 6th, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.87 KB | None | 0 0
  1. import javax.swing.*;
  2. import java.awt.*;
  3. import java.awt.event.*;
  4. import java.sql.*;
  5. import java.util.*;
  6.  
  7.  
  8. public class Main extends JFrame{
  9.     public class SQL{
  10.         private Connection Conn = null;
  11.        
  12.         public boolean SetUp(){
  13.             try {
  14.                 Conn = DriverManager.getConnection("jdbc:mysql://localhost/test?user=root&password=toor");         
  15.                 return true;
  16.             } catch (SQLException e) {
  17.                 System.out.println( e.getMessage() );
  18.                 return false;
  19.             }
  20.         }
  21.        
  22.         public void Query(){
  23.             Statement stmt = null;
  24.             ResultSet rs = null;
  25.  
  26.             try {
  27.                 stmt = Conn.createStatement();
  28.                 rs = stmt.executeQuery("SELECT DisplayID FROM Whereever GROUP BY DisplayID");
  29.             }catch(SQLException ex){
  30.                 System.out.println("SQLException: " + ex.getMessage());
  31.                 System.out.println("SQLState: " + ex.getSQLState());
  32.                 System.out.println("VendorError: " + ex.getErrorCode());
  33.                 // You see, I dont know the colum names at all, and i dont need to.
  34.                 // I love to dig in assembler, not databses, this is just an example,
  35.             }
  36.  
  37.             // now add the result as a list to design id and you got it.
  38.         }
  39.  
  40.  
  41.     }
  42.    
  43.    
  44.     public class MainPan extends JPanel implements ActionListener{
  45.         private String Choose[] = { "Yes", "No" };
  46.         private JTextField Name = new JTextField("Enter a NPC Name here");
  47.         private JTextField SubName = new JTextField("Enter a NPC SubName here");
  48.         private JTextField Entry = new JTextField("Enter an Entry discriptor here");
  49.         private JComboBox DisplayID_1;
  50.         private JComboBox DisplayID_2;
  51.         private JComboBox DisplayID_3;
  52.         private JComboBox DisplayID_4;
  53.         private JComboBox ModelSize;
  54.         private JComboBox NPCLevel;
  55.         private JComboBox Vendor_Q = new JComboBox(Choose);
  56.         private JComboBox QGiver_Q = new JComboBox(Choose);
  57.         private JButton Print = new JButton("Print");
  58.        
  59.         public MainPan (){
  60.             Vector < Integer > IVec = new Vector < Integer > ();
  61.             for ( int i = 1; i <= 10; i++ )
  62.                 IVec.add(i);
  63.             setLayout( new GridLayout( 0, 1 ));
  64.             ModelSize = new JComboBox(IVec.toArray());// Without to Array you'll get the number from 1 to 80 in model, guess why ? ;D
  65.             IVec.clear();
  66.             for ( int i = 0; i <= 80; i+=10 )
  67.                 IVec.add(i);
  68.             NPCLevel = new JComboBox(IVec.toArray());
  69.            
  70.             add( Name );
  71.             add( SubName );
  72.             add( Entry );
  73.             //add( DisplayID_1 ); Retrieve from sql
  74.             //add( DisplayID_2 );
  75.             //add( DisplayID_3 );
  76.             //add( DisplayID_4 );
  77.             add( ModelSize );
  78.             add( NPCLevel );
  79.             add( Vendor_Q );
  80.             add( QGiver_Q );
  81.             add( Print );
  82.             Print.addActionListener( this );
  83.         }
  84.  
  85.         @Override
  86.         public void actionPerformed(ActionEvent arg0) {
  87.             if ( arg0.getSource() == Print )
  88.                 System.out.println("Click!");
  89.         }
  90.     }
  91.    
  92.     public Main(){
  93.         add( new MainPan() );
  94.         pack();
  95.         setDefaultCloseOperation(EXIT_ON_CLOSE);
  96.         setVisible(true);
  97.     }
  98.    
  99.     public static void main(String[] args) {
  100.         new Main();
  101.  
  102.     }
  103.  
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement