I need some help with choosing the right swing component to print the records from database, to be honest I was thinking its going to be easy with
http://mysql.aldenwebhosting.com/JAVAtutorial/uiswing/components/table.html
BUT it doesnt cache, its just prints raw code into tabel. Can someone help me?
In its final stage, my app would download records after I press the button, then print them into some form of label, tabel,field whatever (bassicaly I dont know which swing component choose) . Next step is going to be editing one of the column parameter (binary-like yes/no) and saving it to database - I don know if thats important - im writing it just in case, so you can see the whole "picture"
Greetings!
To build an editable table in swing, I would suggest you to use a JTable with a custom table model and choose a JTextField component for your cells.
If you are not using any JPA frameworks like Hibernate, IBatis.., etc. I would recommend to use one because it helps lot in dynamic persistence in this case.
Related
What I have in mind is to make a JTable. The model will use the 2D array's columncount and rowcount to set the JTable's rows and columns.
What I cant figure out is how do I go around making fields for these cells in the table?
Example fields like - Status(boolean), Image etc. So by having these fields I want to edit the cells when the application is running and show the user the updates.
I have tried to make a 2D object and add fields in there. But it doesnt seem to work.
What would be a good way to build this?
I am using swing to build this.
This isn't a very specific question so that limits the answer I can give - from what you want to do, I'd suggest
Making sure you understand how the Model-View-Controller paradigm works in Swing
Looking into the Observer / Observable framework and how it fits in with MVC
Extending some sort of Swing Component to reflect changes in your model.
Once you've covered the above you should find that implementing what you want to do is reasonably trivial, and that you can ask more directed questions that will get better responses.
we're building a small chat app for an assignement in our university. I have a question regarding how I can implement something.
This is our ui. The big white part is a jTabbedPane where conversations the user is participating in will appear. The two small ones are where active groups and active users will appear.
I found out that I can populate a jcombobox from a linkedlist using .toArray. I don't know what ui element to use, in order to display the list elements one under the other, and being "selectable" (only one at a time). The concept is that the user will select a group and press "Join", to, well, join.
This is what I have in my as to how it will look in the end.
Any pointers and advice in general would be greatly appreciated.
It looks like you're wanting to use either a JTable or a JList -- one with a custom renderer, a renderer that displays both the group name and its "status"(?).
If a JTable, then your key job is to create a TableModel that will accept your data well, either by using the DefaultTableModel (the easiest way to do this), or by creating your own model derived from the AbstractTableModel (a little more difficult, but more flexible).
For a more detailed answer, consider providing pertinent code, preferably as a minimal example program or MCVE.
I am beginner in Java, only know basic stuff.
I would like to know how to edit and search data inserted to jTable? So like I type some data in textbox and added to jTable and then type in a search text box to find a specific word in jTable so it'll show up in jLabel.
Then for editing, i don't even know how to do it. No idea. Plus, this all should be in a separate java class, not in .form (design) part in GUI. A sample GUI Java application would be very much appreciated.
Read the section from the Swing tutorial on How to Use Table for the basics of using tables. There are sections on:
Concepts: Editor and Renderers
Sorting and Filtering. You might want to use filtering to search for a string.
I'm working on my first java program. I'm making a Project Manager program.
The base idea is that i have a JList which contains the names of the Co-workers. If you double click one of the names a JTabbedPane will pop up a new tab and will be populated a JTable what is containing the specific persons tasks.
And here comes the tricky part. I want to use this JTable to modify the datas so i need to give a specific name to the JTable so i can use that later on in my methods to call it.
The question is how can i create dynamic names to these tables so i can call it later (something like this: table+tabID).
OR
Is there a better solution to my problem?
Any help or advice is greatly appreciated.
I solved it. The solution was:
I made an ArrayList<JTables> to store the tables and I'm using the tab indexes to get the proper table.
Is there any way of loading complete table from DB into a Swing Cardlayout's Jpanel?
My try was by creating a label for each line, but then things looked very faulty as if I had a column that had more text it was shifting the next column text and whole thing is messy.
Any ideas?
Note: I found that there is something called Jtable, and it might help, but I do not know if I can do that my table cells will be transparent and will reflect a background image?
A JTable will definitely help, but there's a bit of a learning curve. You'll want to learn how to create and populate a TableModel, and then pass that model to an instance of JTable.
If you're trying to build a simple database browsing tool, you might try using SQL Squirrel: http://www.squirrelsql.org