I used a jTable from Swing Controls in my program(Drag and Drop). I want to know if there is any tutorials for jTables so that I can learn how to code for jTable. I saw many coding examples but couldn't identify where I should implement.
For example when I need to change a cell value after initializing, I don't know the place where I should implement the code.
Can anyone give me an answer?
I think it is a good idea to go through Oracle Documentation at:
How to Use Tables
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.
Is there any grid equivalent object in java ?
I tried using j tables but they don't have all the functionalities needed.
in C# there is a grid object which saves a lot of work. i was wondering if there is any similar object in java.
As far as I know, there is no grid like data structure or collection available in Java. Though you can implement a grid like structure in Java with help of a two-dimensional array.
In case of AWT you might want to use the GridLayout class. Hope this helps.
Definitively the equivalent is JTable, however, if you're trying to create functionalities seems to Grid in C#, you will need to do a little bit extra effort, with swing you should focus on events and add the corresponding listeners in order to add the desired features on it.
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.
As a way of learning Java, I'm writing this little application for grade schoolers to practice basic math. The idea is that the kid does any number of math problems, as long as they are in the app, it just continues to throw problems at them until they click a 'Done' button. When they decide to be done, I want a new JFrame to come up that will show them all of the problems they attempted, along with their answer, and whether they got the problem right or wrong.
The advice that I am looking for is what is the best way for me present these results. I looked into the GridLayout and the GroupLayout, but I don't think that these are exactly right. I did something similar in VBA for Excel, and there I just ran a for loop with one iteration for every problem they attempted. Each iteration would add a row of labels to the frame with the elements of the problem displayed in the various labels. I tried this in Java, but I'm not even able to get the labels to even display.
So before I get all specific and start posting my code, I want to ask a bigger question, which is "what is the best method to create a view like this?" Often, I go off in one direction only to waste time before somebody suggests a totally different (and better) approach.
Thanks!
(edit: here's an image of how I did this in Excel. I'm trying to repeat basically the same thing in Java)
One simple way to make that design would be to use a mix of components. You could have a bunch of JLabels and JPanels stacked in a vertical FlowLayout. The grid you have described would be best designed in a JTable, something like the below:
If you like tables like Excel then, Java provides JTable class to create tables, if you want.
Tutorial : http://docs.oracle.com/javase/tutorial/uiswing/components/table.html
I'm trying to do something quite simple, but I'm having a hard time finding good examples on the net to what I want specifically.
I'd like to somehing very similer to what it's here:
Dao
It's a simple game called DAO and I just need to have a background image with 16 squares (4x4) and drag and drop the images (pieces) on each square to the others. I'm developing the interface using swing and I simply want to know a good place to find tutorials for such implementations or a simple suggestion on how to do it.
Thanks in advance
Shameless plug:
have a look at my simple example via my google project
http://code.google.com/p/jchronos/
There is code to drag list item across list boxes. Same should be applicable to JLabel
Look at sources
http://code.google.com/p/jchronos/source/browse/trunk/src/org/jchronos/ui/QuadrantPanel.java
http://code.google.com/p/jchronos/source/browse/trunk/src/org/jchronos/ui/ArrayListTransferHandler.java