 |
Home | Changes | Index | Search | Go
I've been contributing some components to the SwingX? project but so far did not really used the other
components in a project. Well, time has come for me to look into the other members of the SwingX?
component set. I want to write a small tool which will go over my bookmarks, report deadlinks, generate an html page with
all links together with a snapshot of the page, ...
The current progress of the tool can be tracked by launching this Java WebStart enabled application:
MoreLinks!
I want to use the treetable to show the bookmarks and the bookmark folders.
It is very easy to make a JXTreeTable searchable by creating a JXFindBar? and binding it to the JXTreeTable. What I want to do is to make the search bar appears using a JXCollapsiblePane?.
JXTreeTable treeTable = new JXTreeTable();
JXCollapsiblePane collapsible = new JXCollapsiblePane();
JXFindBar findBar = new JXFindBar(treeTable.getSearchable());
collapsible.add(findBar);
collapsible.setCollapsed(true);
JPanel rightComponent = new JPanel(new BorderLayout(0, 0));
rightComponent.add(new JScrollPane(treeTable), BorderLayout.CENTER);
rightComponent.add(collapsible, BorderLayout.PAGE_END);
When I press "ctrl F", I want the find bar to show and if I press "ESCAPE" while in the search field, I want to dismiss the search bar. This is very easy to achieve because both JXTreeTable and JXFindBar? already have actions bound to these keyboard shortcuts. I just need to replace the default with my custom actions:
Action showFindBar = new AbstractAction("showFind") {
public void actionPerformed(ActionEvent e) {
// show find panel
collapsible.setCollapsed(false);
}
};
treeTable.getActionMap().put("find", showFindBar);
Action hideFindBar = new AbstractAction("hideFind") {
public void actionPerformed(ActionEvent e) {
collapsible.setCollapsed(true);
}
};
findBar.getActionMap().put("close", hideFindBar);
One annoying thing with the current implementation (as of this writing) is the dialog which pops up everytime the search finds no result. But this behavior can be changed by subclassing the JXFindBar?. I wanted to implement something close to Firefox - change the textfield background when search fails:
JXFindBar findBar = new JXFindBar(treeTable.getSearchable()) {
Color previousBackgroundColor;
Color previousForegroundColor;
Color notFoundBackgroundColor = Color.decode("#FF6666");
Color notFoundForegroundColor = Color.white;
@Override
protected int doSearch() {
if (previousBackgroundColor != null) {
searchField.setBackground(previousBackgroundColor);
searchField.setForeground(previousForegroundColor);
}
return super.doSearch();
}
@Override
protected void showNotFoundMessage() {
previousBackgroundColor = searchField.getBackground();
previousForegroundColor = searchField.getForeground();
searchField.setForeground(notFoundForegroundColor);
searchField.setBackground(notFoundBackgroundColor);
}
};
The effect is close from what I expected. Enough for the Search part.
Not sure about Wikettiquette, but I'm adding a comment anyway:
the preferred way to customize the find action to the JXTreeTable (or any other search-enabled JX*)) is to register your custom action directly in the widget's ActionMap:
treeTable.getActionMap().put("find", showFindAction);
The "control F" is bound to the "find" by default. Definitely needs to be documented
-- Main.kleopatra - 15 Sep 2005
JXTaskPaneContainer? and JXTaskPane?
I'm more comfortable with these two, I contributed them. With the JXTaskPanes?, I want to have tasks I can trigger on the bookmarks.
JXTaskPaneContainer taskPaneContainer = new JXTaskPaneContainer();
JXTaskPane mainTasks = new JXTaskPane();
mainTasks.setTitle("Folders and Bookmarks");
mainTasks.add(context.getActions().get("tools.check"));
taskPaneContainer.add(mainTasks);
The context in this code is a small container found in my "common components", not a big deal.
Issues I encounter
[FIXED] I got a ClassCastException? if I configure my treeTable to show the ColumnControlButton. It happens only if I register the "ctrl F" action on the treeTable. https://swingx.dev.java.net/issues/show_bug.cgi?id=153
|