Outline ·
[ Standard ] ·
Linear+
Displaying database result, In Java!
|
TSfelixwhoals
|
Feb 2 2006, 12:50 AM, updated 20y ago
|
|
Hey guys, this is pretty simple:
rs = stmt.executeQuery("SELECT * FROM Customers") ; printResultSet(System.out, rs) ; rs.close() ;
When I put this, my java program display all it all on the screen (command line) I'm not sure how to put them into GUI but is there anyway I could use message box to display that result?
I tried to do JOptionPane.showMessageDialog(null, rs); but i can't display the results.. any ideas?
|
|
|
|
|
|
TSfelixwhoals
|
Feb 2 2006, 07:57 AM
|
|
I'm just a beginner in this GUI stuff... If anyone suggesting me to use GUIs.. how shall I put it in there? Any source code that I can copy? I've searched from google and yahoo but I just can't think of how to put that 'rs' into the GUI itself.. can someone help me? I have used this Jframe:
WindowUtilities.setNativeLookAndFeel(); JFrame f = new JFrame("This is a test"); f.setSize(400, 150); Container content = f.getContentPane(); content.setBackground(Color.white); content.setLayout(new FlowLayout()); content.add(new JButton("Button 1")); f.addWindowListener(new ExitListener()); f.setVisible(true);
This adds Button to it, is there anyway I could add that rs into it?
|
|
|
|
|
|
TheUrbNorm
|
Feb 2 2006, 10:10 PM
|
|
QUOTE JLabel label = new JLabel("Add your resultset here"); frame.getContentPane().add(label);
You just need to add the label component and put your resultset there. Of course you can iterate the resultset first and create new JLabel instance for each row of your resultset. Hope that's help. Happy learning. Try google around for answer and tutorial. It will be easier that posting here in the forum.....
|
|
|
|
|