How to relate to other objects...

Hello there,
I'm making a Snakes and Ladders game, i'm experienced in programming but not object-orientated programming!
The class diagram is here:
http://tinypic.com/view.php?pic=513l8x&s=3
And the interface so far looks like this:
http://tinypic.com/view.php?pic=syuzcj&s=3
So far the interface consists of two instances, gameBoardSession (which is the board itself) and gameControlsSession, the buttons at the bottom that control each turn of play.
At the moment I have actionListeners on the buttons at the bottom. I've gotten to the stage I want to draw counters on the game board, and create a player object.
My question is, how do I write the code in the actionListener code to reference the instance gameBoardSession? If I do reference it in the code, obviously it hasn't been declared so it doesn't understand it? So for example, on the "Roll" button I want something like gameBoardSession.setPlayerOnePosition(10), which would obviously set player one to position 10, but it won't know what "gameBoardSession" is in the first place since I haven't declared it?
Hope i've explained this well, i'm still new to OO programming so I might have got this completely wrong anyway!
Kind regards,
Colin

To get better help sooner, post a SSCCE that clearly demonstrates your problem.
To post code, use the code tags -- [code]Your Code[/code]will display asYour CodeOr use the code button above the editing area and paste your code between the {code}{code} tags it generates.
luck, db

Similar Messages

  • How to refer to other objects?

    Greetings,
    I'm not sure how objects should refer to other objects.
    Example:
    Class Automobile needs to refer to objects from other classes, namely to tires, color, motor and company.
    So, the way I would do this in C++ or VB is to store all tire, color, motor and company objects into arrays and then store Integer ids in class automobile refering to the index. Like
    tiresId
    colorId
    motorId
    companyId
    So if I would like to know the name of the company of this automobile, I would have to do the following:
    company(automobile.getCompanyId).name
    I'm not sure however if this is the right OOP-Way of doing it. Should I rather put object references into class automobile instead so that I would only have to
    automobile.getCompany ?
    The problem I have with this solution is that I have to read and store the automobile data into files and while it's pretty easy to store an integer-id I'm not sure on how to store object references. They are a little "obscure" to me on this point.
    Thanks in advance for any advice.

    if you just want to save the type of company, color and so on for every automobile, i think integer ID is a good way,
    similar to the existing Color-class with constants:
    Color.BLACK, Color.RED, ..
    the way with references would also work, then all referenced objects will be saved too,

  • How to analyse impact to other objects?

    Hi Friends,
    Suppose i will change any object sometimes definitely that changes impact on other relating objects. Am i right? then my requirement is i have changed one object,now first of all how to find relating objects and then how to analyse impact of those changes.
    Ex: Changes in infoobject that impact on other objects are Cubes, ODS, reports and rules etc.
    Please guide me in this regard <removed by moderator>.
    Thanks,
    Ramki
    Edited by: Siegfried Szameitat on Dec 1, 2008 12:31 PM

    If your upcoming changes will affect any of the compounded objects then rest assured that the concerned InfoObjects shouldn't contain any data otherwise your infoobjects will be unstable and would be throwing error after activation...
    as far as the related objects are concerned then just remember the thumb rule(extended star schema):
    All the objects in BW are related to each other by a key: Fact table is linked to Dim tab by Dim ID,,Dim Tables linked to SID tables by Surrogate ID(SID) and this SID points to Master data tables(Text, attr and Hier)
    So going from Fact table to Master data table, if you make any changes in fact table (including or excluding Key figures) or in Dim table (including/excuding Characteristics) then you have to activate your master data so  that SIDs will be generated and vice-versa
    Edited by: Alok Kashyap on Dec 1, 2008 12:46 PM

  • How do you search through configured Alternate Extensions to correct error message : The phone number or extension has already been assigned to some other object.

    When configuring a new Unity Voicemail Account I receive this message : The phone number or extension has already been assigned to some other object. I understand that this means that the 10 digit number I am trying to configure as the alternate extension for this user is already configured for another object with Unity.
    I need to search by the 10 digit number and determine where it is configured so I can change it and map to the correct end user.
    I have attempted to to search Users via DTMF Access ID using the 10 digit number with nothing being returned via that search.
    How do I Search all of the copnfigured Alternate Extensions within our Unity Server?

    A subscriber info dump is likely the fastest way.  If you're curious regarding other methods, you can also use the Data Link Explorer (CUDLE) tool which is in the Cisco Unity Tools Depot.  All extensions for all objects are referenced in the "DTMFAccessId" table.  The View menu has a Query Builder which you can use to compile a SQL query that searches for a digit string.  It's best to search for both the 10 digit string as well as an abbreviated string as Unity sees them essentially the same and they are usually should be associated with a single subscriber.  Once you find a match, you can use the "ParentObjectId" value associated with the DTMF access ID to look for a matching owner in the "GlobalSubscriber" table.  The ParentObjectId should match the SubscriberObjectId for a subscriber (assuming the DTMF access ID is assigned to a subscriber).  This is the same thing as looking at SQL; however, you are not directly accessing the DB so this is generally considered the safest way to browse and get a feel for where things are.
    Hailey

  • How to Track the table using Trigger or any other Object

    Hi Folks
    I need to audit Inserts, deletions, updates  to inserted into other tracking table. I was planning on using a trigger to do this,
    Can you please help me how can I wright code for trigger for this. or else using any other object we can do this operation.
    can you please help me thanks in advance.
    Thank in advance.

    Also you can use an OUTPUT clause ( need to modify your DML operations)
    create table itest ( i int identity not null primary key, j int not null unique )
    create table #new ( i int not null, j int not null)
    insert into itest (j)
    output inserted.i, inserted.j into #new
    select o.object_id from sys.objects as o
    select * from #new
    drop table #new, itest;
    go
    The example below shows code that uses OUTPUT clause in UPDATE and DELETE statements to insert rows into an audit table.
    create table t ( i int not null );
    create table t_audit ( old_i int not null, new_i int null );
    insert into t (i) values( 1 );
    insert into t (i) values( 2 );
    update t
       set i  = i + 1
    output deleted.i, inserted.i into t_audit
     where i = 1;
    delete from t
    output deleted.i, NULL into t_audit
     where i = 2;
    select * from t;
    select * from t_audit;
    drop table t, t_audit;
    go
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • How to organize Data Objects and other Objects in SWCV

    Hi,
    I am looking for Best Practices on how to organize data objects in SWCV as well as other objects such as a Distribution Rules.
    We are planning to develop three occasionally connected applications with NW Mobile 7.1 this year and maybe additional one the following year. We will create multiple Standard Data Objects (e.g. Plant, Company Code, Reservations, ...) which are shared in the first set of transactions and in the future transactions.
    I have heard before to separate out Standard Data Objects from Distribution Models and have two different SWCV.
    Should I have a) one SWCV for all current and future Standard Data Objects and one for the distribution rtules or b) should I separate out common data objects into one SWCV, and all transaction-specific data object each into separate SWCV?
    Just wondering if there are any best practices available for this so that I won't run into problems in the future when we want to add more transactions/data objects?
    Any advise is appreciated.
    Thanks,
    W. Berger

    Hi Siva,
    Thanks for quick reply!!
    I have created say SWCV1 for Dataobjects.
    Now i want to create seperate SWCV2 for defining distribution model.
    How i should proceed..I cannot see the uses option while creating new SWCV2  ( Only option i see is  'backward compatibility checkbox : uses NW04/NW04s MI Application')
    where to check the following which you have mentioned?
    SWCV2 was created and inherited SWCV1 in uses tab of SWCV2.
    Thanks in advance!!
    Regards
    Devendra

  • How to recover a state of  one objects threads by other object

    hi everyone
    how to recover a state of one object's threads by other object..
    i am creating a object in that i have 10 thread..... i have started it then i have closed that object ...then i am creating a new object for the same class ...i need to stop those thread which i have started earlier

    saiyath_babuhussain wrote:
    hi everyone
    how to recover a state of one object's threads by other object..Objects don't own threads so that's hard to understand
    >
    i am creating a object in that i have 10 thread..... i have started it then i have closed that object ...then i am creating a new object for the same class ...i need to stop those thread which i have started earlierWe don't so much stop threads as inform them politely that their services are no longer required. When you have a long running thread it's almost always a loop, often with a wait or sleep which causes it to wait until it's activitty is needed.
    So if you want to be able to wind up a thread from another thread then you put a boolean flag in which can break the loop. The other thread then changes that flag and calls interupt() on the thread it's trying to stop. Interupt will kick the thread out of wait or sleep if that's where it is, causing an InterruptedException. On discovering that the flag indicates it should stop, or on catching an InterruptedException the thread should then clean up and finish.
    The master thread can call join on the thread it's stopping if it needs to wait for it to terminate.

  • How to make references to other objects

    Hello, I have a project that I need to do and I am not sure how to start it. I need to have a class that has references to four other objects. I have the class, but am unsure how to do the references. would i use extends? like the class name extends the object name? thanks in advance.

    jn3al wrote:
    i marked it as correct because i thought it was funny that he said that. And to the person talking about driving and other stuff i am not like that when someone cuts me off i just laugh and turn the radio up, I do not cut anyone off and if i do on accident i wave my hand to say thanks. I am not that type of personYour massive overreaction here suggests otherwise.
    i just wanted help without having to read because i read those java things all the time and sometimes i dont understand what it is saying.So you expected someone here to read your mind and know what you read, what you didn't understand, and why you didn't understand it, and to then offer a different explanation? Yeah, that sounds way better than the usual approach of "I read such-and-such, and it said, 'X', but I don't understand what they mean by 'X'. Can you clarify it?" Your mind-reading approach cuts through that annoying communication BS. I like it.
    Im sure this is the simplest thing but for some reason i couldnt think what to do. Ive read posts on here were people ask easier things than that and they get help and not directed to a tutorial.I doubt you've seen enough threads here to have a statistically valid sample. Almost always, if the answer is in a tutorial, the OP will be directed there. There's no reason to repeat what's already been said.
    Not to mention the fact that your question makes no sense whatsoever.
    w/e im going to ask my teacher who helped make java, smarter than anyone here. Odd that you didn't ask him/her in the first place then. And where did you get hold of our IQ test results?

  • How could I pass object to the other object

    Hi,
    How could I pass an object to the new initializing object, so that I can reference to the first object later?

    You mean something like
    MyClass1 myclass1 = new MyClass1();
    MyClass2 myclass2 = new MyClass2(myclass1); // <-- myclass1 is being passed to the constructor of myclass2                                                                                                                                                                                                                                                                                                                                                       

  • How to find object use in other object

    Hi All,
    I want to find one object for example procedure which is used in other object like function,procedure or view.
    How can i find it?
    Thanks in advance.

    user647572 wrote:
    Hi All,
    I want to find one object for example procedure which is used in other object like function,procedure or view.
    How can i find it?
    Thanks in advance.Use DBA_DEPEDENCIES view :
    SQL> create table my_tab (id number);
    Table created.
    SQL> create or replace procedure my_proc
      2  as
      3  p_id number;
      4  begin
      5  select id into p_id from my_tab;
      6  end;
      7  /
    Procedure created.
    SQL> select owner, name, referenced_name from dba_dependencies where referenced_name='MY_TAB';
    OWNER      NAME                 REFERENCED_NAME
    SYS        MY_PROC              MY_TAB
    SQL>

  • How to make GUI components feel the state of other objects?

    I need my JButtons in any place of GUI be enabled or disabled depend on states of several objects or events generated by some other objects. Would you recommend the common approach of how it can be implemented in Swing?

    Sorry for the delay, but the job that pay my bills is keeping me very busy today (taking a short break to reply to you) :)
    Yes, the observers observable pattern is a good way to decouple this (but it could be overkill if you only want to update the status of one button). You will need to have references to the button variable so you can enable it / disable it from another place. For example, let's say you have an Class that extends the Observable and performs your heavy processing on a separate thread (Please not than I don't use generics here, just trying to quickly show you how you may want to do this):
    import java.util.Observable;
    public class TaskMan extends Observable {
        private List comp; 
        public void TaskMan (final List aComp) {
            comp = aComp; // Keep track of the components you want to to toggle on / off
        public void notifyObservers(Object arg) {
                setChanged(true);
                super.notifyObservers(arg);
        public void doIt() {
            new Thread (new Runnable() {
                 public void run() {
                         notifyObservers(comp); // Dissable
                         // Your long consumming task here
                        notifyObservers(comp); // Enable
    }Then you have the Observer class that enable / dissable the buttons and other components:
    import java.util.Observer;
    import java.awt.Component;
    public class MyObserver implements Observer {
         public void update(Object observable, Object arg) {
                 if (! (arg instanceof List)) {
                     return;
                 List list = (List) arg;
                 for (Object elem: list) {
                        Component comp = (Component) elem;
                        EventQueue.invokeLater(new Runnable() {
                               public void run() {
                                     comp.setEnabled(! comp.isEnabled());
    }And finally your main class, where you create and put together your GUI, register your observers and you call your long time consuming job
    import java.util.*;
    public class MyApp {
        public static void main(String [] args) throws Exception {
                  List comps = new ArrayList();
                  JButton aBtn = new JButton("Hey dude!");
                  comps.add(aBtn);
                  TaskMan task = new TaskMan(comps);
                  task.addObserver(new MyObserver());
                  task.doIt();
    }Looks like you have several use cases there, maybe you want to try this approache first for some of them, adding more logic to the observer.
    Please reply back, let me know what you think.
    Regards,
    Jose.

  • How not to rotate relative to the object?

    hi,
    currently i am rotating transformgroups like this:
           Transform3D currenttrans = new Transform3D();
           objTrans.getTransform(currenttrans);
           Vector3f currentVector = new Vector3f();
           currenttrans.get(currentVector);
           currenttrans.setTranslation(new Vector3f(0,0,0));
           objTrans.setTransform(currenttrans);
           Transform3D rotateclockwise = new Transform3D();
           rotateclockwise.rotX(-Math.PI/10);
           currenttrans.mul(rotateclockwise);
           currenttrans.setTranslation(currentVector);
           objTrans.setTransform(currenttrans);But that does not feel right. It always rotates relative to the object. But I want to rotate it relative to the universe (or to my view).
    That means I for example: I want to be able to rotate the object like a head that looks to the right, no matter what its current state is. This means in my example: If the "head" is currently "looking down" then it should still look down at the same angle after I rotated it to the right.
    I hope u understand (its hard to explain without pictures).

    To find where any node is relative to the rest of the universe you can use it's getLocalToVworld method. That should save you a bit of extraneous calculation at least.

  • How to dump your database including other objects like views, sequence,etc

    hi.
    is it possible to generate a sql file that contains your database structure including the values in it and other objects. I have tried generating just the tables and that's the only way I know to dump a database using jdeveloper. but is there a way to generate a sql file with your db structure and also other objects like views, triggers, sequences and etc.
    thanks.. :D

    You may need to use utility(which may come with your DB) for creating DB dump

  • How do I save a custom fill and stroke setup to use on other objects?

    I created a customized stroke and fill for an item that looks like stitching on a square.  Isnt there a way to save that particular set of strokes and fills as something so I just have to click on another object and say "apply" without having to do each part of it one at a time?

    Simply drag the object to the Graphic Styles panel. It's now available to apply to other objects within the same document with one click.
    If the object to which you want to apply the style is in another document entirely:
    1. Copy/paste the original object to the new file, or better
    2. From the new document's Graphic Styles panel, choose Open Graphic Style Library>Other Library from the flyout, then navigate to the original document. A panel will open with your graphic style present. Now select the new object and click on your graphic style.

  • How to Populate the JTable Object programatically with SQL Results

    I'm wondering if someone could help me on how to populate the JTable Object with SQL Results wherein the Row of tjhe JTable object is automatically adjusted depending on how many records you have queried.
    Thanks in advance and God bless! (",)
    * frmMain.java
    * Created on October 4, 2006, 6:15 AM
    package tds;
    import java.io.*;
    import java.awt.Toolkit;
    import javax.swing.JFrame;
    import javax.imageio.*;
    import javax.swing.JFrame;
    import java.sql.*;
    import javax.swing.table.DefaultTableModel;
    * @author Dexter.Carlit
    public class frmMain extends javax.swing.JFrame {
    private Connection connection = null;
    private DefaultTableModel model;
    /** Creates new form frmMain */
    public frmMain() {
    initComponents();
    /** 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.
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
    jSplitPane = new javax.swing.JSplitPane();
    jScrollPane1 = new javax.swing.JScrollPane();
    jPanel3 = new javax.swing.JPanel();
    jScrollPane2 = new javax.swing.JScrollPane();
    jTree1 = new javax.swing.JTree();
    jTabbedPane1 = new javax.swing.JTabbedPane();
    jPanel1 = new javax.swing.JPanel();
    jPanel4 = new javax.swing.JPanel();
    jLabel1 = new javax.swing.JLabel();
    jLabel2 = new javax.swing.JLabel();
    jTextField1 = new javax.swing.JTextField();
    jTextField2 = new javax.swing.JTextField();
    jLabel3 = new javax.swing.JLabel();
    jTextField3 = new javax.swing.JTextField();
    jLabel4 = new javax.swing.JLabel();
    jTextField4 = new javax.swing.JTextField();
    jPanel5 = new javax.swing.JPanel();
    jScrollPane3 = new javax.swing.JScrollPane();
    jGrid = new javax.swing.JTable();
    jButton1 = new javax.swing.JButton();
    jButton2 = new javax.swing.JButton();
    jProgressBar1 = new javax.swing.JProgressBar();
    jPanel2 = new javax.swing.JPanel();
    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
    addWindowListener(new java.awt.event.WindowAdapter() {
    public void windowOpened(java.awt.event.WindowEvent evt) {
    formWindowOpened(evt);
    getAccessibleContext().setAccessibleName("frmMain");
    jSplitPane.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
    jSplitPane.setDividerLocation(200);
    jSplitPane.setDividerSize(10);
    jScrollPane2.setViewportView(jTree1);
    org.jdesktop.layout.GroupLayout jPanel3Layout = new org.jdesktop.layout.GroupLayout(jPanel3);
    jPanel3.setLayout(jPanel3Layout);
    jPanel3Layout.setHorizontalGroup(
    jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
    .add(jPanel3Layout.createSequentialGroup()
    .add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 916, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
    .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    jPanel3Layout.setVerticalGroup(
    jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
    .add(jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 410, Short.MAX_VALUE)
    jScrollPane1.setViewportView(jPanel3);
    jSplitPane.setLeftComponent(jScrollPane1);
    jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
    jLabel1.setText("First Name:");
    jLabel2.setText("Last Name:");
    jLabel3.setText("Position :");
    jLabel4.setText("Department:");
    jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder("Search Results"));
    jGrid.setModel(new javax.swing.table.DefaultTableModel(
    new Object [][] {
    new String [] {
    "LName", "FName", "Position", "Department", "Office No", "Local No", "Office Mobile No", "Home No", "MobileNo", "Email Address"
    jGrid.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
    jGrid.setColumnSelectionAllowed(true);
    jGrid.setName("");
    jGrid.setTableHeader(jGrid.getTableHeader());
    jScrollPane3.setViewportView(jGrid);
    jScrollPane3.getAccessibleContext().setAccessibleName("rset");
    org.jdesktop.layout.GroupLayout jPanel5Layout = new org.jdesktop.layout.GroupLayout(jPanel5);
    jPanel5.setLayout(jPanel5Layout);
    jPanel5Layout.setHorizontalGroup(
    jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
    .add(jScrollPane3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 386, Short.MAX_VALUE)
    jPanel5Layout.setVerticalGroup(
    jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
    .add(jScrollPane3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 175, Short.MAX_VALUE)
    jButton1.setText("Find");
    jButton1.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jButton1ActionPerformed(evt);
    jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mouseClicked(java.awt.event.MouseEvent evt) {
    jButton1MouseClicked(evt);
    jButton2.setText("Clear");
    jButton2.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mouseClicked(java.awt.event.MouseEvent evt) {
    jButton2MouseClicked(evt);
    org.jdesktop.layout.GroupLayout jPanel4Layout = new org.jdesktop.layout.GroupLayout(jPanel4);
    jPanel4.setLayout(jPanel4Layout);
    jPanel4Layout.setHorizontalGroup(
    jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
    .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel4Layout.createSequentialGroup()
    .addContainerGap()
    .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
    .add(org.jdesktop.layout.GroupLayout.LEADING, jPanel5, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    .add(org.jdesktop.layout.GroupLayout.LEADING, jPanel4Layout.createSequentialGroup()
    .add(jLabel1)
    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
    .add(jTextField1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 343, Short.MAX_VALUE))
    .add(org.jdesktop.layout.GroupLayout.LEADING, jPanel4Layout.createSequentialGroup()
    .add(jLabel2)
    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
    .add(jTextField2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 343, Short.MAX_VALUE)
    .add(1, 1, 1))
    .add(org.jdesktop.layout.GroupLayout.LEADING, jPanel4Layout.createSequentialGroup()
    .add(jLabel3)
    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
    .add(jTextField3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 138, Short.MAX_VALUE)
    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
    .add(jLabel4)
    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
    .add(jTextField4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 138, Short.MAX_VALUE))
    .add(jPanel4Layout.createSequentialGroup()
    .add(jButton1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 66, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
    .add(jButton2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 66, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
    .addContainerGap())
    jPanel4Layout.linkSize(new java.awt.Component[] {jButton1, jButton2}, org.jdesktop.layout.GroupLayout.HORIZONTAL);
    jPanel4Layout.setVerticalGroup(
    jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
    .add(jPanel4Layout.createSequentialGroup()
    .addContainerGap()
    .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
    .add(jLabel1)
    .add(jTextField1))
    .add(18, 18, 18)
    .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
    .add(jLabel2)
    .add(jTextField2))
    .add(16, 16, 16)
    .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
    .add(jLabel3)
    .add(jTextField3)
    .add(jLabel4)
    .add(jTextField4))
    .add(14, 14, 14)
    .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
    .add(jButton2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    .add(jButton1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
    .add(jPanel5, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(
    jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
    .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1Layout.createSequentialGroup()
    .addContainerGap()
    .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
    .add(org.jdesktop.layout.GroupLayout.LEADING, jPanel4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    .add(org.jdesktop.layout.GroupLayout.LEADING, jProgressBar1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 438, Short.MAX_VALUE))
    .addContainerGap())
    jPanel1Layout.setVerticalGroup(
    jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
    .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1Layout.createSequentialGroup()
    .addContainerGap()
    .add(jPanel4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
    .add(jProgressBar1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
    jTabbedPane1.addTab("Search", jPanel1);
    org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2);
    jPanel2.setLayout(jPanel2Layout);
    jPanel2Layout.setHorizontalGroup(
    jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
    .add(0, 458, Short.MAX_VALUE)
    jPanel2Layout.setVerticalGroup(
    jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
    .add(0, 401, Short.MAX_VALUE)
    jTabbedPane1.addTab("Directory", jPanel2);
    jSplitPane.setRightComponent(jTabbedPane1);
    org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
    layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
    .add(jSplitPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 675, Short.MAX_VALUE)
    layout.setVerticalGroup(
    layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
    .add(jSplitPane)
    pack();
    }// </editor-fold>//GEN-END:initComponents
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    }//GEN-LAST:event_jButton1ActionPerformed
    private void jButton2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton2MouseClicked
    jGrid.setModel(new javax.swing.table.DefaultTableModel(
    new Object [][] {
    {null, null, null, null, null, null, null, null, null, null},
    {null, null, null, null, null, null, null, null, null, null},
    {null, null, null, null, null, null, null, null, null, null},
    {null, null, null, null, null, null, null, null, null, null}
    new String [] {
    "LName", "FName", "Position", "Department", "Office No", "Local No", "Office Mobile No", "Home No", "MobileNo", "Email Address"
    jGrid.updateUI();
    }//GEN-LAST:event_jButton2MouseClicked
    private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton1MouseClicked
    try {
    //Load and register SQL Server driver
    Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
    //Establish a connection
    Connection connection = DriverManager.getConnection("jdbc:microsoft:sqlserver://X.X.X.X:1433","MyAccount","MyPassword");
    //Create a Statement object
    Statement sql_stmt = connection.createStatement();
    //Create a ResultSet object, execute the query and return a
    // resultset
    ResultSet rset = sql_stmt.executeQuery("SELECT * FROM EpxDirectory..Directory Order By LName");
    // Populates a JTABLE Object
    int i=0;
    while (rset.next()){
    String LName = rset.getString(1);
    String FName = rset.getString(2);
    String Position = rset.getString(3);
    String Dept_Code = rset.getString(4);
    String OffPhoneNo = rset.getString(5);
    String LocalNo = rset.getString(6);
    String OffMobileNo = rset.getString(7);
    String HomePhoneNo = rset.getString(8);
    String MobileNo = rset.getString(9);
    String Email = rset.getString(10);
    jGrid.updateUI();
    jGrid.setValueAt(rset.getString(1).trim(),i,0);
    jGrid.setValueAt(rset.getString(2).trim(),i,1);
    jGrid.setValueAt(rset.getString(3).trim(),i,2);
    jGrid.setValueAt(rset.getString(4).trim(),i,3);
    jGrid.setValueAt(rset.getString(5).trim(),i,4);
    jGrid.setValueAt(rset.getString(6).trim(),i,5);
    jGrid.setValueAt(rset.getString(7).trim(),i,6);
    jGrid.setValueAt(rset.getString(8).trim(),i,7);
    jGrid.setValueAt(rset.getString(9).trim(),i,8);
    jGrid.setValueAt(rset.getString(10).trim(),i,9);
    i++;
    //Close the ResultSet and Statement
    rset.close();
    sql_stmt.close();
    //Close the database connection
    connection.close();
    System.out.println(Integer.toString(i) + " rows found");
    } catch(Exception e) {
    System.out.println("Failed to connect; Please view Stack Trace");
    e.printStackTrace();
    }//GEN-LAST:event_jButton1MouseClicked
    private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
    }//GEN-LAST:event_formWindowOpened
    public static void run(){
    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
    frmMain frmMain = new frmMain();
    frmMain.setLocationRelativeTo(null); // Center the JFrame on the
    frmMain.setVisible(true);
    private void exitApplication() {
    // try {
    // //gui.putStatus("Closing the connection....please wait.....");
    // if(connection != null) {
    // // connection.close(); //Closing the connection object.
    // } catch(SQLException ex) { //Trap SQLException
    // //gui.putStatus(ex.toString());
    System.exit(0); //Exit the aplication
    * @param args the command line arguments
    public static void main(String args[]) {
    run();
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JTable jGrid;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JProgressBar jProgressBar1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JSplitPane jSplitPane;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JTextField jTextField3;
    private javax.swing.JTextField jTextField4;
    private javax.swing.JTree jTree1;
    // End of variables declaration//GEN-END:variables
    }

    Use code tags.
    Don't mix GUI and JDBC together. Split them out into separate classes.
    You have a good start, but you will need to loop through your resultset and also pull the ResultSet metaData for you column headings

Maybe you are looking for

  • Problems with Install: Full Version / Full - JDK

    It's been a long day but ... Trying to install both the full version and full -JDK. Both extracts contain several duplicate file versions some with same date/time, others different file sizes and date/time stamps. The creation of the folder: sqldevel

  • No pictures in Gallery

    I have not deleted any pictures in my gallery.  Tried to open gallery, and no pictures.  All pictures were gone.  What could have happened?  How can I recover?  

  • After Effects CC 2014 friert kurzzeitig ein

    Hallo, ich habe das Problem, das After Effects CC 2014 jedesmal kurzzeitig (10-20 Sekunden) einfriert, sobald ich aus einem anderen Fenster (Browser, Windows Explorer, andere Software) zurück nach After Effects wechsel. Dabei ist die Menüleiste (File

  • Elements 12 will not launch (either)

    I have been using Elements since version 3. It has been a great program - until version 10 arrived. It works, but not satisfactorily. If I quit the program it will not launch unless I reboot, and the welcome screen does not launch at all. Version 11

  • Two finger tap not activating right-cick menu Windows 8.1

    Hi  I was a happy Ideapad U310 touch user until I upgraded to Windows 8.1. I've been facing a couple of issues since then. One of them releates to my touchpad. Previously, I could bring up the pop up menu/right click menu by quickly tapping two finge