Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.*;
- import java.awt.*;
- import java.awt.event.*;
- import java.sql.*;
- import java.util.*;
- public class Main extends JFrame{
- public class SQL{
- private Connection Conn = null;
- public boolean SetUp(){
- try {
- Conn = DriverManager.getConnection("jdbc:mysql://localhost/test?user=root&password=toor");
- return true;
- } catch (SQLException e) {
- System.out.println( e.getMessage() );
- return false;
- }
- }
- public void Query(){
- Statement stmt = null;
- ResultSet rs = null;
- try {
- stmt = Conn.createStatement();
- rs = stmt.executeQuery("SELECT DisplayID FROM Whereever GROUP BY DisplayID");
- }catch(SQLException ex){
- System.out.println("SQLException: " + ex.getMessage());
- System.out.println("SQLState: " + ex.getSQLState());
- System.out.println("VendorError: " + ex.getErrorCode());
- // You see, I dont know the colum names at all, and i dont need to.
- // I love to dig in assembler, not databses, this is just an example,
- }
- // now add the result as a list to design id and you got it.
- }
- }
- public class MainPan extends JPanel implements ActionListener{
- private String Choose[] = { "Yes", "No" };
- private JTextField Name = new JTextField("Enter a NPC Name here");
- private JTextField SubName = new JTextField("Enter a NPC SubName here");
- private JTextField Entry = new JTextField("Enter an Entry discriptor here");
- private JComboBox DisplayID_1;
- private JComboBox DisplayID_2;
- private JComboBox DisplayID_3;
- private JComboBox DisplayID_4;
- private JComboBox ModelSize;
- private JComboBox NPCLevel;
- private JComboBox Vendor_Q = new JComboBox(Choose);
- private JComboBox QGiver_Q = new JComboBox(Choose);
- private JButton Print = new JButton("Print");
- public MainPan (){
- Vector < Integer > IVec = new Vector < Integer > ();
- for ( int i = 1; i <= 10; i++ )
- IVec.add(i);
- setLayout( new GridLayout( 0, 1 ));
- ModelSize = new JComboBox(IVec.toArray());// Without to Array you'll get the number from 1 to 80 in model, guess why ? ;D
- IVec.clear();
- for ( int i = 0; i <= 80; i+=10 )
- IVec.add(i);
- NPCLevel = new JComboBox(IVec.toArray());
- add( Name );
- add( SubName );
- add( Entry );
- //add( DisplayID_1 ); Retrieve from sql
- //add( DisplayID_2 );
- //add( DisplayID_3 );
- //add( DisplayID_4 );
- add( ModelSize );
- add( NPCLevel );
- add( Vendor_Q );
- add( QGiver_Q );
- add( Print );
- Print.addActionListener( this );
- }
- @Override
- public void actionPerformed(ActionEvent arg0) {
- if ( arg0.getSource() == Print )
- System.out.println("Click!");
- }
- }
- public Main(){
- add( new MainPan() );
- pack();
- setDefaultCloseOperation(EXIT_ON_CLOSE);
- setVisible(true);
- }
- public static void main(String[] args) {
- new Main();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement