Win a copy of Get Programming with Java (MEAP only) this week in the Beginning Java forum!

Amruta sriram

Greenhorn
+ Follow
since Dec 28, 2018
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Amruta sriram

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.
1 week ago
I am doing project in swing . Is anyone knows ? please post a sample code for this.
1 week ago
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.
1 week ago
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.
1 week ago
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.

1 week ago
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.

1 week ago
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();}

 });

   }
}

1 week ago
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 :




2 weeks ago
@ Rob camick , Did you have that code? can you please share that is it very usefull for me . I am troubling to solve this
3 weeks ago
Sir, is it possible to modify this code. Because i did'nt get it . what you told. i am trying to read that. But unfortunately i want this code within 2 days.
3 weeks ago
I want it displayed in jtable with specific rows and columns.
3 weeks ago


Here is my code :
i am not getting error .

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.table.DefaultTableModel;

public class TestTable5 {

   public TestTable5() {
       String[] defaultCols = {"Id", "Username", "Password", "email","Name","Age","Gender"};
       DefaultTableModel model = new DefaultTableModel(defaultCols, 0);
       JTable table = new JTable(model);

       JButton button = createButton(table);
       JFrame frame = new JFrame();
       frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
       frame.add( new JScrollPane(table));
       frame.add(button, BorderLayout.SOUTH);
       frame.pack();
       frame.setLocationByPlatform(true);
       frame.setVisible(true);
   }

   private JButton createButton(final JTable table) {
       JButton button = new JButton("Get File");
       button.addActionListener(new ActionListener() {
           public void actionPerformed(ActionEvent e) {
               JFileChooser chooser = new JFileChooser();
               int result = chooser.showOpenDialog(table);
               if (result == JFileChooser.APPROVE_OPTION) {
                   File file = chooser.getSelectedFile();
                   DefaultTableModel model = createModel(file);
                   table.setModel(model);
               }
           }
       });
       return button;
   }

   private DefaultTableModel createModel(File file) {
       DefaultTableModel model = null;

       try {
           BufferedReader txtReader = new BufferedReader(
                   new FileReader(file));
           String header = txtReader.readLine();
           model = new DefaultTableModel(header.split("\\s+"), 0);
           String line;
           while ((line = txtReader.readLine()) != null) {
               model.addRow(line.split("\\s+"));
           }
       } catch (IOException ex) {
           ex.printStackTrace();
       }

       return model;
   }

   public static void main(String[] args) {
       SwingUtilities.invokeLater(new Runnable() {
           public void run() {
               new TestTable5();
           }
       });
   }
}

And my text file values : ( i saved in sampleinput.txt)

I uploaded here ( filename : 1c.png)

But my ouput is :

3 weeks ago
If Anyone Knows , can you please help me how to read the text file to JTable by using JFilechooser ?
Even the text file contains the specific charecters line length
eg: idUsernamePasswordEmailAgeGender         ( ID = 2 Chars, Username = 10 chars ( if username not having 10 chars means, it include space for that, password = 5 chars, email = 5 chars, Age = 2 chars, Gender = 1 chars)


     01Amruta          12345email24F
3 weeks ago