How to hide jTable at jFrame - java

How to hide jTable at jFrame in java GUI, not just hide the column, but entire jTable?
I was try to use table.setVisible(false), but just hide a column not entire table

You cannot hide the table, but you can hide your panel containing the table
instead.
yourPanel.setVisible(false);
Whenever you want to show the table do yourPanel.setVisible(true);

Related

How to hide Jtable in netbeans?

I hide the table usingaccountTable.setVisible(false); but now it it not showing whenver accountTable.setVisible(true);is called. please tell me how to solve it or give an alternative option for hiding Jtable.The jtable is in a jpanel already
try calling the jpanel (where the jTable is on) revalidate() and repaint() functions after setting the table visible
an alternative option for hiding Jtable.
A JTable is typically displayed in a JScrollPane. So one approach would be:
scrollPane.setViewportView( null ); // to hide the table
and then:
scrollPane.setViewportView( table ); // to show the table.
This assumes that you have space on the panel to actually show the table. If there is no space on the panel to reshow the table then you may need to pack() the frame as well.

implementing drag and drop swing JList to JTable

I have a jlist of table names from a database and I was wondering if it is possible to drag and drop the table name to another jpanel and for that panel to execute the sql to retrieve store the information of that Table. I am not too savvy with swing. a class or method in which I can get a table to load from a drag and dropped jlist.
Hope this is legible.

Hide title of JTable when form is loading?

I need to hide the JTable from frame, when its loading, and it's visible based on some contition(ex: when click the textfield, then JTable will show).
i tried, but i don't have a luck.
code:
jTable1.setvisible(false);
(or)
jTable1.hide();

Insert/add data to JTable & Database using a popup frame after clicking the "add" button

May I know how do I make a popup frame to do the insert of data since I'd like my GUI to popup another frame to ask for user input to the database and as well as the JTable? Thank you!
What I don't get is how to make use of the add button, then insert the entry and make the listener notice about "e.getType()==TableModelEvent.INSERT".
Edit:
At the same panel as the JTable, I would have an add button at the bottom. This add button would then in another 'frame' ask users to enter the items to add to the database as well as adding and refreshing the JTable.
you must use a DataModel with your JTable, and add item to your datamodel and then update your JTable with yout DataModel.
DefaultTableModel model = new DefaultTableModel();
JTable table = new JTable(model);
// Create a couple of columns
model.addColumn("Col1");
model.addColumn("Col2");
// Append a row
model.addRow(new Object[]{"v1", "v2"});
inserting new data from external class into jtable
Have a look at this , I hope your problem will be solved , Pass the Table reference in the constructor of your JFame/JDialogue (Better if you use JDialogue Instead of JFrame click here to know some good reasons) and modify table model accordingly

Display values of a selected row from a dynamically varying JTable

I have to develop a front end in Swing.I have a JFrame in Netbeans with 3 panes in it.
JScrollPane 1:it contains a JTable
JScrollPane 2: It should display the value of the fields of the selected row
ListPane : which contains the list of tables from which a user chooses a table to be displayed.
Now since the content of JTable varies(the no of rows and columns also vary) dynamically based on the table chosen by user I can't drag and drop the TextBoxes in the 3rd scroll pane to display the selected row's values.It would be helpful if anybody can suggest a way to do it or any pointers to problems that deal with similar issue
Add a ListSelectionListener to your JList. When a particular table is selected from the list, use setModel() to change the TableModel of your JTable to one that is correct for the chosen table. A related example using setModel() is shown here.

Categories