Creating JTable inside node of JTree - java

I know that this question is being asked before but I did not get proper solution.
I read about outline but that was just opposite of what I want i.e. JTable inside JTree
I want to display data in a JTable but it is stored as different groups,so these groups
are node of JTree when I expend one group(node) the JTable of that group is shown.
I went through this article in oracle :Creating TreeTables in Swing:part 1
This was pretty old and not working on my version of java(I don't know why !),so I went
through the next part of TreeTable :Creating TreeTables in Swing: Part 2
The whole code was comparatively new, as it was using "javax.swing" in place of
"com.sun.java.swing" but the problem I faced here was one file named as
"FileSystemModel2.java" was missing it is modified from previous version so I can't work
with old one.There are some method added to new "FileSystemModel.java".How do I inform
them about this missing file or if you have different approach please let me know.
What I want to achieve is shown in picture below :
This image was from "LastPass" and I want to make my own password manager as my project
So please help me with this I am so close but yet I can't move further.

The SwingX project contains a ready-made TreeTable
http://swingx.java.net/
The downloads are a bit hard to find, so here is the link:
http://java.net/downloads/swingx/releases/1.6.2/
A short article about using that component can be found here:
http://sandarenu.blogspot.com/2008/02/treetable-in-java-using-swingx.html

Related

Trying to Change Dojogrid Rowcolor based on Content

I have a function that generates a Dgrid and fills it with content which it receives from Javaside.
I tried to do dojo-css to handle this like here:
Style Dojox Grid Row depending on data
After this didn´t work I tried to work with Dojo.connect to change the color of the row when the grid is being built and filled.
After that didn´t work I tried to use dojo.on or dojo.aspect.after but since I am a total Newbie in Dojo I have no clue where you can intersect in the code and do theses things.
with a code like so :
require(["dojo/request/xhr","dojo/dom-form", "dojo/dom", "dojo/_base/array", "dojo/json",'dgrid/Grid','dgrid/Selection',"dijit/registry","dojo/_base/declare","dojo/domReady!"],
function(xhr,domForm,dom, array, json, grid, selection,registry, declare){
..... Here the grid and data is declared java function called
}.then(function(data, array, grid, selection,registry, declare){
.....Here the dgrid is filled
}
Where/when should i use Dojo.Connect , Dojo.on or Dojo.after?
I´ve spent mutiple days trying to figure this out but the program either stops working or ignores my changes.
The link you mention above is for dojox grid, which is different to dgrid. Here is the link to css styling for dgrid.
It won't answer your question though which is about changing a row color based on content. The way I do this is cell by cell, using a custom renderCell function.
Documentation on renderCell can be found here, and an example can be found here.
ps: a bit of caution. The learning curve for dojo 1.x is quite steep. When looking for documentation, make sure you get the latest possible (1.10). If you find a link which is about version 1.6 or less, be careful: many 1.6 and before features have been deprecated in version 1.7.

Eclipse Standard Property View - PropertyDescriptor - how to make a property row grey

Hello there fellow SO members!
I am writing a plugin for a Eclipse RCP application, and when I am selecting a row from a TreeViewer its properties appear in the Properties View.
Initially I was looking for a way I could make certain properties read-only, and found this SO question.
Now what I am asking is, how can I make these properties grey? I ask this because I'd like it to be more evident that they are read-only.
Any help/opinions are appreciated.
If I look at the createItem method from the PropertySheetViewer (org.eclipse.ui.views.properties.PropertySheetViewer) , it doesn't look too good for you, I guess. The only attributes updated from the TreeItems are the text and the image. There is no coloring done based on any attribute.
Edit: You asked for suggestions too, so I should finish it correctly: If you look at Properties View, then its not more than a simple view with a two-column table, which is wired to the SelectionService. So, I guess with a little effort you may implement your own Properties view visualizing the current selection in a proper way.

How to present a hierarchical String list with checkboxes in Java Swing?

So. The ideas have been a few.. no good ones.. So here is the problem i have incountered and can not figure out a solution for.
I need to have a txt file containing a hierarchical list of things to do, looking something like this:
Ask a question
Before question asked, check similar questions
Formulate the question so that the problem is clearly shown.
Post the question
Hold your thumbs that this might save your day.
The txt file should in the program fill a list shown in a JPanel and after each step have a checkbox to comfirm "I have been a good boy and done this".
The list can change over time and grow and shrink, so the solution needs a scrollbar.
The list should also contaion a capability to show more the one row.
The solution im working on is done in Jave compiler 1.6 and im using Swing for my layout.
Ideas i have had so far are:
Modified JTable... and the other solutions i am asshamed of..
And thats about it.. ..
JTree with custom renderer. The renderer should be a panle with checkbox and text area.
have look at JTree
have to override JTree Renderer and Editor (comcept is similair for JTable and JTree)
all data are stored in the DefaultTreeModel
examples about Tree Model,Tree Renderer Editor, Tree and here
Also consider org.netbeans.swing.outline.Outline, discussed here and illustrated below. It's not apparent in the screenshot, but the the Outline instance has been added to a JScrollPane.
I would say JTreeTable is a right choice. It will provide a lot of power and flexibility. Please see some very basic examples:
http://www.ibm.com/developerworks/java/library/j-5things14/index.html
http://www.java2s.com/Code/Java/Swing-Components/JTreeTablecomponent.htm
For any serious purpose please use a mature implementation provided, for example, by a SwingLab project:
http://swingx.java.net/
http://java.net/projects/swinglabs
Please also see the following answer:
Java Swing table tree

Dynamically changing the shown form on tree selection

I'm currently learning the adf framework, and while doing this I found myself in a situation I am not able to solve.
I have a tree component that works fine. I also have different forms, corresponding to different levels of the tree. Rather than having all of the forms visible at one time, I would like to only show the one that corresponds to the selected item in the tree.
To solve this, I created af:switcher, created facets and moved the forms there. Here is where I am lost, how do I tell the switcher to change the form? I tried to link them together using the facetName on the switcher, but no success. I suspect I did not link the right thing there, but I could not find anything helpful from the tree either! I assume it has something to do with the selectionListener and a bean, but I could not figure out a way to do this. Any clues?
See Sample #50 of http://www.oracle.com/technetwork/developer-tools/adf/learnmore/index-101235.html#CodeCornerSamples
Frank

JTable with jgoodies sorting trouble

I've got a blocking problem with the sorting functionality of a JTable; this made stall the development of the spare time open source project for 4 months now. Hope to be pointed into the right direction here.
Context: I'm working on extending the functionality of the ps3mediaserver to add a media library with pms-mlx. The UI of the media server has been done using swing.
Problem: When clicking on a column header in the JTable, a seemingly random column gets sorted instead of the one having been clicked.
Current implementation: Here's the description of the different components and classes being used for the implementation:
ETable: As alternate row colours aren't supported by default in the JTable, I've switched to the ETable extending the JTable. Source comes from here
FileDisplayTable: This is the class creating the table. In the init() method, the sorting is being enabled with 'table.setAutoCreateRowSorter(true);'
FileDisplayTableCellRenderer: Exists to always align cell content on the left
FileDisplayTableColumnModel: Does some mapping between internal types and column names
FileDisplayTableAdapter: This class implements com.jgoodies.binding.adapter.AbstractTableAdapter to map the objects with the table columns.
Possible solutions:
Preferably, I'd like to keep the current implementation and figure out how to correct the sorting, but I doubt someone can help me out with that!? Additionally their are some bits of code I had to add because of strange behaviours; they're commented in the code
The alternate option would be to change the JTable for another control altogether. I've made some research but didn't find the solution I was hoping for. The constraints are that
it must be embeddable in a swing UI
preferably it should support data bindings
support alternate row colours
row sorting
At some point it will be possible to open an editing dialogue, where the content of the row has to be retrieved, can be edited and when saved the row has to be updated.
Before reworking the entire thing I'd like to be sure the component will be able to handle all I want to do with it.
I'm more used to create GUIs using .NET in Visual Studio. It's quite different and a lot more difficult to do the same with swing. Please show me I'm wrong :)
[edit] If someone is willing to reproduce the problem, either get the source or the binaries, launch the application, navigate to the media library tab. In the Genral section import some videos by adding some video files. Go to the library section, click on apply to refresh the list and try to sort the table.
It may be useful to know that JTable columns can be dragged by the user. As a result, the view (JTable or a subclass) and model (an implementation of TableModel) may have different column numbers. Similarly, a RowSorter may affect the order or number of rows in the view as compared to the model. The related conversion methods are mentioned in How to Use Tables: Sorting and Filtering. In particular: "When using a sorter, always remember to translate cell coordinates."
Addendum: As an alternative, consider org.netbeans.swing.etable.ETable or it's subclass org.netbeans.swing.outline.Outline, depicted here.

Categories