Go Back   Java Programming Forums > Java Standard Edition Programming Help > Java IDEs

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 30-01-2009, 10:28 PM
Junior Member
 

Join Date: Jan 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
jcc285 is on a distinguished road
Default Linking Database Projects in NetBeans

Working in NetBeans 6.1 IDE. I have created a database with 4 tables. I have then, following the NetBeans tutorials, created 4 projects which each provide basic CRUD access to the tables. These projects are simple to create as, using the Java Desktop/Database Application templates all the work is done for you, however... What I cannot track down how to do is create a simple 'Switchboard' type front end which, in an application would run first and present the user with a set of 4 JButtons which, when clicked, will bring up the appropriate table access form. I have created a fifth project which contains the 'switchboard' form but how do I link this to the other four 'projects'. Is it an import or do I code the action on each button to open the relevant project ? Any help gratefully received, thanks.
John



Reply With Quote Share this thread on Facebook
Sponsored Links
  #2 (permalink)  
Old 02-02-2009, 01:55 PM
JavaPF's Avatar
mmm.. coffee
 
5 Highscores

Join Date: May 2008
Location: United Kingdom
Posts: 1,210
Thanks: 60
Thanked 66 Times in 64 Posts
JavaPF is someone you want to know!JavaPF is someone you want to know!JavaPF is someone you want to know!

I'm feeling Inspired
Default Re: Linking Database Projects in NetBeans

Hello jcc285 and welcome to the Java Programming Forums

Hopefully this tutorial will be able to help you somewhere along the line.

Lesson: Using the NetBeans GUI Builder (The Java™ Tutorials > JavaBeans(TM))
__________________
Don't forget to add code tags around your code:

Forum Tip: Add to peoples reputation () by clicking the button on their useful posts.
Reply With Quote
  #3 (permalink)  
Old 02-02-2009, 05:41 PM
Junior Member
 

Join Date: Jan 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
jcc285 is on a distinguished road
Default Re: Linking Database Projects in NetBeans

No that doesn't help at all I'm afraid but thanks for the effort. If I add the .jar file for one of my database table access 'projects' to the classpath for my 'Swithcboard' form do you have any idea how I run the library .jar file from a JButton click on a form ?

thanks

John
Reply With Quote
  #4 (permalink)  
Old 08-06-2009, 09:51 AM
r12ki's Avatar
Junior Member
 

Join Date: May 2009
Posts: 8
Thanks: 1
Thanked 0 Times in 0 Posts
r12ki is on a distinguished road
Question Re: Linking Database Projects in NetBeans


I have the same problem in it. Can somebody give me an advice or show me where the tutorial is ?
Thanx
Reply With Quote
  #5 (permalink)  
Old 08-06-2009, 02:08 PM
JavaPF's Avatar
mmm.. coffee
 
5 Highscores

Join Date: May 2008
Location: United Kingdom
Posts: 1,210
Thanks: 60
Thanked 66 Times in 64 Posts
JavaPF is someone you want to know!JavaPF is someone you want to know!JavaPF is someone you want to know!

I'm feeling Inspired
Default Re: Linking Database Projects in NetBeans

Quote:
Originally Posted by jcc285
Working in NetBeans 6.1 IDE. I have created a database with 4 tables. I have then, following the NetBeans tutorials, created 4 projects which each provide basic CRUD access to the tables. These projects are simple to create as, using the Java Desktop/Database Application templates all the work is done for you, however... What I cannot track down how to do is create a simple 'Switchboard' type front end which, in an application would run first and present the user with a set of 4 JButtons which, when clicked, will bring up the appropriate table access form. I have created a fifth project which contains the 'switchboard' form but how do I link this to the other four 'projects'. Is it an import or do I code the action on each button to open the relevant project ? Any help gratefully received, thanks.
John
I think I understand what you mean. Try this code.

There are 2 classes. MyClass1 & MyClass2. When the button on MyClass1 is clicked, MyClass2 is opened and vise versa. You can replicate this on your Switchboard program.

To hide the previous window use frame1.setVisible(false);

MyClass1
Java Code
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;

/**
 * JavaProgrammingForums.com
 */

public class MyClass1 {
    
    public static JFrame frame1 = new JFrame("JAVA WINDOW 1");

    public static void createAndShowGUI()  {
        
        frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        JButton button = new JButton(" >> Open myClass2 Application <<");
        //Add action listener to button
        button.addActionListener(new ActionListener() {
               
            public void actionPerformed(ActionEvent e)
            {
                //Execute when button is pressed
                javax.swing.SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                        frame1.setVisible(false);
                        MyClass2.createAndShowGUI();
                        
                    }
                });
            }
        });      

        frame1.getContentPane().add(button);
        frame1.pack();
        frame1.setVisible(true);
    }
     

    public static void main(String[] args) {
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                createAndShowGUI();
            }
        });
    }
}
MyClass2
Java Code
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;

/**
 * JavaProgrammingForums.com
 */

public class MyClass2{
    
    public static JFrame frame1 = new JFrame("JAVA WINDOW 2");

    public static void createAndShowGUI()  {
 
        frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        JButton button = new JButton(" >> Open myClass1 Application <<");
        //Add action listener to button
        button.addActionListener(new ActionListener() {
               
            public void actionPerformed(ActionEvent e)
            {
                //Execute when button is pressed
                javax.swing.SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                        frame1.setVisible(false);
                        MyClass1.createAndShowGUI();
                    }
                });
            }
        });      

        frame1.getContentPane().add(button);
        frame1.pack();
        frame1.setVisible(true);
    }

}
__________________
Don't forget to add code tags around your code:

Forum Tip: Add to peoples reputation () by clicking the button on their useful posts.
Reply With Quote
  #6 (permalink)  
Old 09-06-2009, 06:43 AM
r12ki's Avatar
Junior Member
 

Join Date: May 2009
Posts: 8
Thanks: 1
Thanked 0 Times in 0 Posts
r12ki is on a distinguished road
Default Re: Linking Database Projects in NetBeans

Thank you....

You helped me...

But, Now, I have another problem. I have made a database in SQL. I don't know how to call it when I press jButton (I named GO).
I made a simple application using NetBeans, I use a form, some jButton, and Text field.
Some command such as [ SELECT group FROM dbOwner ] didn't work when I press GO>> button.

Can you solve this ??

Thank's for your kindness
Reply With Quote
  #7 (permalink)  
Old 09-06-2009, 08:23 AM
JavaPF's Avatar
mmm.. coffee
 
5 Highscores

Join Date: May 2008
Location: United Kingdom
Posts: 1,210
Thanks: 60
Thanked 66 Times in 64 Posts
JavaPF is someone you want to know!JavaPF is someone you want to know!JavaPF is someone you want to know!

I'm feeling Inspired
Default Re: Linking Database Projects in NetBeans

Hello r12ki,

To connect to a database and run SQL queries you need to read up on JDBC.

Java: Java JDBC: JDBC 101: How to connect to an SQL database with Java JDBC.

If you require more help with this, please start a new thread in our Database forum:

Database - Java Programming Forums
__________________
Don't forget to add code tags around your code:

Forum Tip: Add to peoples reputation () by clicking the button on their useful posts.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



Similar Threads
Thread Thread Starter Forum Replies Last Post
Desktop Database Application TCoomer JDBC & Databases 2 04-06-2009 08:51 PM
J2ME Application Database Synchronization jeremyraj Mobile Applications 0 13-05-2009 07:11 AM
[SOLVED] linking two different classes John Object Oriented Programming 11 27-04-2009 07:57 PM
Are We seriously Ignoring NetBeans? javacrazed Java IDEs 4 12-11-2008 10:08 PM
struts & database for eclipse kirman Java IDEs 2 17-10-2008 12:26 PM


100 most searched terms
Search Cloud
2 dimensional arraylist java 2d arraylist java actionlistener actionlistener in java actionlistener java actionlistener jbutton addactionlistener addactionlistener java avatar hardware id convert double to integer java double format java double to int java double to integer in java double to integer java eclipse shortcut keys eclipse tutorial for beginners exception in thread "awt-eventqueue-0" java.lang.outofmemoryerror: java heap space exception in thread "main" java.lang.outofmemoryerror: java heap space format double java get mouse position java hardware id avatar java 2 dimensional arraylist java 2d arraylist java actionlistener java addactionlistener java button actionlistener java convert double to int java double format java double to int java double to integer java for beginner eclippse java format double java forum java forums java get mouse position java ipod touch java list to map java mouse position java programming forum java programming forums java sendkeys java.lang.reflect.invocationtargetexception java.util.arraylist jbutton actionlistener jbutton java jtextarea font color programming forums string to int java two dimensional arraylist java writing apps for ipod touch

All times are GMT. The time now is 01:29 AM.
Powered by vBulletin® Copyright ©2000-2009, Jelsoft Enterprises Ltd.