|
||
|
|||
|
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
|
|
||||
|
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 syntax highlighted code tags around your code: [highlight=Java] code here [/highlight] Forum Tip: Add to peoples reputation ( ) by clicking the button on their useful posts.
|
|
|||
|
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 |
|
||||
|
Quote:
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();
}
});
}
}
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 syntax highlighted code tags around your code: [highlight=Java] code here [/highlight] Forum Tip: Add to peoples reputation ( ) by clicking the button on their useful posts.
|
|
||||
|
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 syntax highlighted code tags around your code: [highlight=Java] code here [/highlight] Forum Tip: Add to peoples reputation ( ) by clicking the button on their useful posts.
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 09:08 PM |
| struts & database for eclipse | kirman | Java IDEs | 2 | 17-10-2008 12:26 PM |
|
100 most searched terms
Search Cloud
|
| 2d arraylist java actionlistener actionlistener in java actionlistener java addactionlistener addactionlistener in java addactionlistener java applications of oops could not create java virtual machine xp double format java double to int 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.nullpointerexception exception in thread "main" java.lang.outofmemoryerror: java heap space format double java get mouse position java java 2d arraylist java actionlistener java addactionlistener java convert list to map java double format java double formatting java double to int java double to integer java format double java forum java forums java get mouse position java list to map java mouse position java programming forum java programming forums java programming help java sendkeys java two dimensional arraylist java.lang.classformaterror: truncated class file java.lang.outofmemoryerror: java heap space java.util.arraylist jbutton actionlistener jtextarea font jtextfield font size jxl.read.biff.biffexception: unable to recognize ole stream programming mutators and generics two dimensional arraylist java writing ipod apps |