This week's book giveaway is in the Python forum.
We're giving away four copies of Python Continuous Integration and Delivery and have Moritz Lenz on-line!
See this thread for details.
Win a copy of Python Continuous Integration and Delivery this week in the Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Devaka Cooray
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Tim Holloway
  • Claude Moore
  • Stephan van Hulst
Bartenders:
  • Winston Gutkowski
  • Carey Brown
  • Frits Walraven

how to add Jtabbedpane in Jtable?  RSS feed

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, can you anyone please help me,
I  have done import my file in JTable with the help of JDBC.

And here i attached code for DATABASE CONNECTION.



Here i attached for whole program :




1AA.png
[Thumbnail for 1AA.png]
Here i attched my output .CREATE 2 TABS. This will display in 1 TAB , ANOTHER TAB IS EMPTY.
1BB.png
[Thumbnail for 1BB.png]
Here is another output by selecting the file and import in table and gets message from database.
 
Master Rancher
Posts: 1161
18
Firefox Browser Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And your question is...?
 
Rancher
Posts: 3010
20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A JTable is designed to display data in each cell, not components.

I don't know why you would be attempting to display a tabbed pane in the cell of a JTable and I also have no idea how you would do this.

Create a JTabbedPane with two tabs and display a separate table on each tab.
 
Amruta sriram
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have to create 2 JTabbedpane . In 1 tab that 1AA.png picture insert in JTabbedpane.Another is empty. Even i am having JTabbedpane code also.

import java.awt.GridLayout;
import java.awt.Label;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
public class CreateJTabbedPaneExample {
private static void createAndShowGUI() {
final JFrame frame = new JFrame(" Example");
frame.setSize(500, 300);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(new GridLayout(1, 1));
JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
tabbedPane.addTab("SMS", makePanel("SMS tab"));
tabbedPane.addTab("DMS", makePanel("DMS tab"));
frame.getContentPane().add(tabbedPane);
}

private static JPanel makePanel(String text) {

       JPanel p = new JPanel();

       p.add(new Label(text));

       p.setLayout(new GridLayout(1, 1));

       return p;

   }
public static void main(String[] args) {

 javax.swing.SwingUtilities.invokeLater(new Runnable() {

public void run() {

   createAndShowGUI();}

 });

   }
}

1TABpic.png
[Thumbnail for 1TABpic.png]
Here i attched JTabbedpane output pic.
 
Amruta sriram
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry for the inconvenience.
I did'nt get any error.
I created JTABBEDPANE seperately. And i done to IMPORT THE FILE IN DATABASE.Previous post i posted all.
My question is how to  add JTabbedpane and i attached the image(1a.png) that form will display on 1 tab.Another tab is empty.
Can anyone help , to this project.

 
Rob Camick
Rancher
Posts: 3010
20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

that form will display on 1 tab.Another tab is empty



There is no trick. You create 2 panels and add each panel as a separate tab in the tabbed pane.

The last code you posted works fine for me, except you should set the layout manager BEFORE you add the component top the panel and you didn't specify any "constraints" for the GridBagLayout.

So you just need to debug your code to see what is different from your working example. We don't have access to your database so we can't help with that.

Read the section from the Swing tutorial on How to Use Tabbed Panes for more working examples to get you started. The tutorial also has a section on "How to Use GridBagLayout".
 
Amruta sriram
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here i attached my file to import. That part also i done. Can you please how to add JTable in JTabbedpane to import the file in database.

Capture.PNG
[Thumbnail for Capture.PNG]
 
Rob Camick
Rancher
Posts: 3010
20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I still don't understand your question.

Here i attached my file to import. That part also i done.



We don't care what is already working.

You question should state exactly one problem that you are trying to solve.

Can you please how to add JTable in JTabbedpane to import the file in database.



You add the JScrollPane (containing the JTable) to the JTabbedPane the same way you add a JLabel to the JTabbedPane.

to import the file in database.



How is this relevant? Are you now asking how to sue SQL??

A posting should have one simple clear question.

Your topic title and all the images you have posted in the question are completely confusing. I have no idea what your actual question is.

We don't care about your real application.

We only care about the one specific problem you are trying to solve.


 
Amruta sriram
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have two Jtabbedpane, one were there is my Jtable and my Jbutton ( Open File chooser, Save ), what i want is, when i click on " Open File chooser  ", a file will choose in our laptop to import the file .The file is in text file , that same data and charecters will enter into DB Table it has 7 columns.After that Save button will click means, the message pop up will generate (" IMPORT DATA SUCCESSFULLY") . I tried to mingle on 1 tab tabpane and jtable and my button, it does'nt work.


If anyone know means , please respond with sample code as soon as possible.
 
Daniel Demesmaecker
Master Rancher
Posts: 1161
18
Firefox Browser Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're reading from a textfile, why do you need a databaseconnection?
 
Amruta sriram
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After reading , that same data i have to import in DB Table . If you know this problem means can you please post the sample code for this.
 
Daniel Demesmaecker
Master Rancher
Posts: 1161
18
Firefox Browser Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah db table... I tought you where taking about a jTable called db...
'm not familiar with swing, I could write an example in javaFx though...
 
Amruta sriram
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am doing project in swing . Is anyone knows ? please post a sample code for this.
 
Daniel Demesmaecker
Master Rancher
Posts: 1161
18
Firefox Browser Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please post some sample code..., pleace post some sample code... There should at least be a minimal amount of effort on your part, if you can't figure it out and don't want to follow a tutorial or do some research, maybe this project is not for you
 
Amruta sriram
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to mingle , even i did'nt get clear view of this.
I tried lot but it displaying only JTable and button part things. I am not able to view JTabbedpane in my output. But i code it.
 
Daniel Demesmaecker
Master Rancher
Posts: 1161
18
Firefox Browser Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just cause I'm such a nice guy , here's you're example
FormClass:

UserClass:

DatabaseClass:

To make this work you will need to add rs2xml to your classpath
I did it in a single pane, which was originally the idea, right? If you have any questions feel free to ask


 
Daniel Demesmaecker
Master Rancher
Posts: 1161
18
Firefox Browser Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you really want to set your table in a second tab, that's easily done.
As you can see in the video, I just added an extra tab, moved my table that's wrapped in a scrollpane from the first tab to the second, added an button with an actionEventListener and moved:
to the method called by the actionEventListener

 
Rob Camick
Rancher
Posts: 3010
20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I still have no idea what your problem is.
 
Rob Camick
Rancher
Posts: 3010
20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the pictures it looks like you:

1. know how to read data from a file and load it into a JTable

2. know how to use a JTabbedPane since you posted a simple example

3. know how to use a file chooser since data is loaded in the JTable, so why keep talking about it.

There is so much confusing misleading information I still don't know what the actual problem is.

You need to learn how to simplify problems when you want to problem solve or get help from a forum

I still have no idea why you need a tabbed pane? What information do you expect to be in the tabbed pane?

The code posted is too complex because we don't have access to the database. We can't see what is actually happening.

The code posted should be a simplified version of what you are trying to do.

For example. Here is a SSCCE as I understand the problem:


It allows anybody to run the code to see exactly what happens. It demonstrates the "flow" of the question while keeping the logic simple.

Now the question is which step of the above process are you having trouble with?

Why do you want a tabbed pane? What do you expect to see on the tabbed pane?

Make changes to the presented SSCCE so it works as you expect, then make the change to your real application.
 
Daniel Demesmaecker
Master Rancher
Posts: 1161
18
Firefox Browser Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Rob Camick wrote:

Your solution seems to duplicate the code the OP has already posted except you still don't use a JTabbedPane, so it doesn't seem to solve the problem.


I haven't duplicated anything, I wrote it from scratch and yes I do use a tabpane, just look at the secondmessage

Rob Camick wrote:
I still have no idea why you need a tabbed pane? What information does the OP expect to be in the tabbed pane?


If you go to the beginning of the thread you see the use of a tabbed pane was sugested to him by I believe Carey Brown, but I'm not sure, that's why in the first example I didn't use one, but hends the threadtitle, I updated my solution
The code posted is too complex because we don't have access to the database.
I do agree that it's not clear what his original question was, I was also the first to question it, same for expecting us to post a sample quote, where I also maded a remark about

From the pictures it looks like you: ...


I don't think the pictures are from his program, I think it's part of the assignment and shows the student how it's suposed to look
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!