SwingBits is a collection of useful components and utilities for Java Swing Toolkit.
The documentation can be found in the Project Wiki.
Here are some of its features:
Swing UI Enhacements
License: BSD 3-Clause "New" or "Revised" License
SwingBits is a collection of useful components and utilities for Java Swing Toolkit.
The documentation can be found in the Project Wiki.
Here are some of its features:
Hello there,
I would like to download latest release of SwingBits (v0.5.0), but actually the link is broken. Would it be possible to someone upload it again and share the link? I will appreciate it a lot!
Best!
1.1. Add TableRowSorter (A) to table (tab)
1.2. Add fillters - TableRowFilterSupport.forTable(tab).searchable(true).actions(true)
2. Sort any column
3. Use TableFilterColumnPopup and fillter any column
4. Now try do this:
for (int i =0; i < tab.getModelAlarm(); i++){
A.convertRowIndexToModel(index);
}
you will get error like this:
java.lang.ArrayIndexOutOfBoundsException: 6
at javax.swing.DefaultRowSorter.convertRowIndexToModel(Unknown Source)
at my.table.model.xml.getDocument(AExcel.java:66)
at my.listners.AExcel.mouseClicked(AExcel.java:24)
at java.awt.AWTEventMulticaster.mouseClicked(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
...
I think the right definition of No-CommandTag must to be NO("no", KS_ESCAPE, true) and not NO("yes", KS_ESCAPE, true)
Currently the rendering of values in the Checklist popup when you right click over a column renders the text by calling Object.toString(). This is not very useful for tables that use, for example, columns that contain Date objects, since you rarely ever want the toString() representation in your table. Is it possible to implement a custom way of rendering that? I am not entirely sure where to start touching the code. I've managed to make it do what I want by directly changing the method CheckListRenderer.getObjectAsText but that's certainly not a good solution.
Would adding a custom CheckListRenderer to TableRowFilterSupport be a good solution?
this works well when the row count is modest. in my use case, the row count is quite large - 100k or so. With so many rows, the the 'right click' on the column simply does not return. The number of variants for that column are roughly 100k as well.
Basically, I need to filter from 100k rows down to something more manageable.
Ideally, one would like to type in some filter condition, for a given column, and filter the rows down consistent with that filter condition. The current API is pretty reasonable except that it seems to require the reading/displaying of all 100k variants in the filter popup.
When the row number and/or unique items in a column is very high, the current approach no longer works since that popup is not displayed.
Hi,
I added the filter to my JTable. Thank You for this project.
I want to use regular expression as searchfilter. Our clients needs escpecially regexps that contains | (pipe), but always you press Alt-Gr for typing this, the popup closes.
Have you any suggestions to solve this?
Thankyou.
Juliane
Thanks for your beautiful work
in our project we have a table that one of its columns is Date and we want to filter that column by specifying a period between two dates.
I'm really interested in your work and I want to help to improve it If I can.
Just it does not have enough documentations and that slows me.
What you suggest me to do. (I already have your project set up in eclipse.)
Thanks once more for your nice filter component.
#11 in this issue you wrote about implementing custom actions. Is that currently a feature? otherwise, could you add some documentation so I can create some myself? I would like the <> just like he did.
I have noticed that all Builds fail due to a failed installation of the JDK. This kind of looks like a Travis issue, but could we maybe mitigate the issue by changing the way of installing the JDK?
First, thank you very much for the great work. We are using TableRowFilterSupport with a JXTable. We would like to enable tri-state sorting, i.e.
First click on column header: sort ascending
Second click on column header: sort descending
Third click on column header: remove sorting
We are using the following to enable it.
table.setSortOrderCycle(SortOrder.ASCENDING, SortOrder.DESCENDING, SortOrder.UNSORTED);
It works fine with JXTable without TableRowFilterSupport. However, when we use
TableRowFilterSupport.forTable(table).apply();
on the same table. The tri-state sorting behavior disappears and we can only do bi-state sorting. BTW, we tried call setSortOrderCycle either before or after TableRowFilterSupport.forTable(table).apply().
Our table keeps add new rows that are received from a server. Suppose we have column values 0, 1, 2, 3 when we work on a column (say integers) for filter. If we deselect "0" in the filter popup window, it works fine for current values. However, if we receive new rows with values 4, 5, 6, they won't show up due to the filtering. Can you add a control on the popup windows to allow (or disallow) showing new values? Thanks!
Hi
I have added code to add excel type filter using tablerow filtersupport at header. It is working but sort icon is not visible after that.
I am able to sort columns but there is no sort icon displayed at header.
If i remove the filter code then i can see sort icon.
Could you please help me to show sort icon alongwith filter code from utility ?
It will be great help.
Thanks
Shubham
[email protected]
when i set the table to table.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
the swingbit UI stops working
Table does not filter on row updates. If a table row model is updated with a column value that should cause it to be filtered out we would expect the row to disappear.
Changing code in JTableFilter from:
public void modelChanged( TableModel model ) {
getTable().setRowSorter( new TableRowSorter<TableModel>( model ));
}
to
public void modelChanged( TableModel model ) {
TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>( model );
sorter.setSortsOnUpdates(true);
getTable().setRowSorter( sorter );
}
fixes the problem.
I need to clear all columns filters before reload my JTable data. There are a way to do this?
The TaskDialog's location is currently set relative to the window which has keyboard focus at the time setVisible is called. Consider the following scenario: A user initiates an action which takes some time before resulting in a TaskDialog. Between the time of initiating the action and the TaskDialog becoming visible, the user may start using another window in the application on another monitor, thus changing the keyboard focus window before the TaskDialog's setVisible is called. As a result, the TaskDialog appears on the wrong monitor. Perhaps the location should be set relative to its parents location, not the active window. It would be nice to have an option to do so.
Hello,
i have noticed, that this project doesn't have any license, meaning that by default, the original author / owner should have the copyright and retain all rights. However, I believe this originally wasn't your project, but a project by a company or individual called EzWare
. The version by EzWare, was licensed with the BSD License, meaning that this repository should theoretically have at least a BSD-License or a BSD-Compatible License. However, I have checked the previous revisions of this repository and wasn't able to find any license.
Could you provide any information on this projects history? Have you manually removed the license? Did you take over the project officially, meaning that you are the owner now?
Regards
Marcel
Hello,
I have the following java code. I wanted to add column filters, so I've added the TableRowFilterSupport.forTable to my code.
However when clicking on a column header, I'm now able to sort the values in the column, but I don't see a possibility to filter. What is wrong?
private void updateTable() {
Object[] header = data.getHeaderForTable();
Object[][] content = data.getContentForTable();
jTable1 = new JTable(content, header);
TableRowFilterSupport.forTable(jTable1).apply();
jTable1.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
jTable1.setRowSelectionAllowed(true);
jTable1.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
jTable1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
classifyMenu.setEnabled(true);
}
});
jScrollPane2.setViewportView(jTable1);
repaint();
}
When tabbing through elements of a taskDialog until the cancel button is focused, all links must be unselected.
As the choices method is doing to much (for my taste :-) anyway, I would suggest to move the focusListener into the commandLinkButton and let it select/unselect itself on focusGained/Lost.
addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent e) {
setSelected(true);
}
@Override
public void focusLost(FocusEvent e) {
// NOTE: if we really are de-selected is controlled by the
// ButtonGroup.
setSelected(false);
}
});
Then implement a custom ButtonGroup which supports all-unselected in setSelected(model, boolean):
public static class XButtonGroup extends ButtonGroup {
@Override
public void setSelected(ButtonModel model, boolean selected) {
if (model == null) return;
if (selected) {
super.setSelected(model, selected);
} else {
if (isSelected(model)) {
clearSelection();
}
}
}
}
Then let the choices method use that custom group instead of core
Cheers
Jeanette
PS: might you consider to not use tabs in your code? can live with that awful read, but it's worth a try to swing you :-)
The filter popup does not show the correct values which are now in the column
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import org.oxbow.swingbits.table.filter.IFilterChangeListener;
import org.oxbow.swingbits.table.filter.ITableFilter;
import org.oxbow.swingbits.table.filter.JTableFilter;
import org.oxbow.swingbits.table.filter.TableRowFilterSupport;
import java.awt.event.*;
public class TableFilter {
final JTable table;
JTableFilter tableFilter;
public TableFilter() {
final String[] cols = { "Checkbox", "Ints", "Strings", "Bools", "test" };
Object[][] data = { { false, 1, "A", false, "hide" },
{ false, 1, "B", false, "hide" },
{ false, 1, "C", false, "hide" } ,{false, 3, "C", false, "hide" }};
final DefaultTableModel model = newModel(cols, data);
table = new JTable(model) {
@Override
public boolean isCellEditable(int row, int col) {
return true;
}
};
table.getTableHeader().setReorderingAllowed(false);
tableFilter = new JTableFilter(table);
tableFilter.addChangeListener(new IFilterChangeListener(){
@Override
public void filterChanged(ITableFilter<?> arg0) {
System.out.println("Fitler Event");
}
});
TableRowFilterSupport.forFilter(tableFilter).searchable(true).apply();
JButton newDataButton = new JButton("New Data");
newDataButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
for(int i = 0;i<table.getRowCount();i++){
table.setValueAt(i+5, i, 1);
}
}
});
JPanel buttonPanel = new JPanel();
buttonPanel.add(newDataButton);
JPanel panel = new JPanel(new BorderLayout());
panel.add(new JScrollPane(table), BorderLayout.CENTER);
panel.add(buttonPanel, BorderLayout.SOUTH);
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(panel);
frame.pack();
frame.setVisible(true);
}
public void updateNewFilter(){
tableFilter = new JTableFilter(table);
}
private DefaultTableModel newModel(final String[] cols, Object[][] data) {
return new DefaultTableModel(data, cols) {
@Override
public Class<?> getColumnClass(int column) {
Class returnValue;
if ((column >= 0) && (column < getColumnCount())
&& getRowCount() > 0 && getValueAt(0, column) != null) {
returnValue = getValueAt(0, column).getClass();
} else {
returnValue = Object.class;
}
return returnValue;
}
};
}
public static void main(String[] args) {
new TableFilter();
}
}
Hi, I completely forgot the issue I opened a while back, ie: http://code.google.com/p/oxbow/issues/detail?id=51&can=1.
As my users want french but we are not in France (and don't want their weird Localization stuff about calendar and other stuff) I think you should create (copy) the properties files and leave the country out of the file name.
In my case, I copied in your library task-dialog_fr_FR.properties to task-dialog_fr.properties so I can still use my Locale.setDefault(Locale.FRENCH) as usual. This way you can support language locales when the country is not specified.
I ran into a small problem once a firetablestructurechanged event is called. The filter state is preserved, but the header renderer (which resets to default on firetablestructurechanged) does not get set back. As a result the funnel icon obviously does not appear again.
My workaround is to set the column filters again whenever firetablestructurechanged is called, but this obviously resets the filters. I was wondering if this could be fixed. thanks
Hello people,
I like to know, how to change the color of the letter in the header?
I have tried creating a constructor and modifying properties. This is my code, but does nothing:
public class TableHeaderRenderer extends JComponent implements TableCellRenderer
{
private static final long serialVersionUID = 1L;
public TableHeaderRenderer()
{
setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null));
setForeground(Constantes.VERDE_NETZSCH);
}
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
{
return table.getTableHeader().getDefaultRenderer().getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
}
@Override
public void validate() {}
@Override
public void revalidate() {}
@Override
public void firePropertyChange(String propertyName, boolean oldValue, boolean newValue) {}
@Override
public void firePropertyChange(String propertyName, Object oldValue, Object newValue) {}
}
Thank you for advance.
More info at http://code.google.com/p/oxbow/issues/detail?id=44
Hi! great work
Are upload your project on maven ?
When I execute a fireTableDataChanged on a table that is currently filtered or sorted I get a momentary flicker of only the first row where it initially shows what the unfiltered/sorted value would be and then applies the filter. Is there anything I can do to delay the redrawing of the table until after the filters/sorts are applied?
From google code issue
I have a particular need add some custom fitering to an existing JXTable and while swing-bits-0.5.0 works spendidly for some columns, it lacks a few custom actions for others e.g.: ability to filter a numeric column > 0, < 0 (and perhaps a user entered value?), or a date column filter based on date > now, date < now.
I guess it would be neat to associate the actions included with the TableColumnRenderer class and include default actions on that basis but with the option to customise the actions on a per column basis.
Publish the oxbow artifacts (Swing Bits, Task Dialog) to Maven Central (via Sonatype OSS, perhaps). The only version of Task Dialog currently in Maven Central is 1.0.0.
I need in my dialog to choice between yes, no and cancel commands. Is it possible to extend the StandardCommand enum to match all CommandTags?
Currently it is not possible to use TaskDialogs in an JInternalFrame without dirty hacks. Main problem is, that the TaskDialogContent is strong-bounded to the JDialog instance inside TaskDialog class, see TaskDialogContent.setCommands(Set<? extends TaskDialog.Command>, boolean) which uses the getOwner() method.
A simple API like TaskDialogs for JInternalFrames would be nice and/or an ability to get the TaskDialogContent which is independent of JDialog or JInternalFrame class.
In TaskDialogs.java line 253:
text.setFont( UIManager.getFont("Label.font"));
Can throw a null pointer exception in Java 7 where it didn't in Java 6.
In MacWidgets I fixed this with code that looks like:
Is it possible to define a TaskDialogs.choice function which creates a dialog like on this image:
http://2.bp.blogspot.com/-lAE4SyQM3Q4/Tx-tcwS0i8I/AAAAAAAAAI0/NNHar0L2YqA/s1600/WindowTaskDialog.png?
Thanks
Hello,
I need to save the applied filter.
Any idea?
Thank you in advance.
I noticed that a lot of the files have mixed indentation (i.e. both tabs and spaces). That leaves me with a few questions:
The jpopupmenu that appears on a column header right click does not re-size properly. The problem appears to be with the menu.setPopupSize(newDim) method called inside the mouseDragged() listener method. This causes the mouseDragged() method to execute only once, and not repeatedly which it should, if it is to re-size the menu on a click and drag. I have described the problem in detail here.
http://stackoverflow.com/questions/34478414/resize-jpopupmenu-using-mouse-adapter
As far as I can see - the uxguide doesn't explicitly mention it as the CommandLinkButton is a standard win widget, so just looking at native examples - the size of the instruction should be the same a the size of the mainInstruction of the task dialog.
I've seen that there is already an issue over at google concerning the not quite fitting blue, just reminding you :-). Additionally, the explaining text should be blue as well (instead of black, as it is right now).
Cheers
Jeanette
Is there a way to save/restore filter settings? The idea is to users don't need to set up filters for a large table when they restart the application. Thanks!
I know this library isn't supported anymore, but I'm trying to debug the following, but I can't find what's wrong...
The focus of CommandLinkButtons in the choice dialog doesn't work anymore on Java releases 9 and 11.
You can still click on them, but you can't TAB on them.
Anyone has any ideas ?
There’s only one release, should I just clone and build jars from the project clone? I want some of the new features specifically the custom cell rendering.
Hi,
when i sort a column which is filtered. The renderer registers the sort icon an creates a compoundicon with the funnel icon an the sorticon. But the table shows only the sort icon. The funnel icon is lost.
Is it possible to show both icons?
regards dbausnnd
In LinuxContentDesign at line 55 you put an Integer object, not the SystemColor. Should be "SystemColor.control".
Same issue in MacOsContentDesign at line 59 and 60.
Getting COLOR_MESSAGE_BACKGROUND via UIManager.getColor( IContentDesign.COLOR_MESSAGE_BACKGROUND ) will return null, so the background of the pMessage JPanel will be null and most likely the TaskDialogContent background, too. This leads to strange UI painting.
Reason is the fix to #3 - my suggestion doesn't work in your setup because now that triggers an actionEvent at the same time changes the selection (to false...). (My suggestion works fine in my local, SwingX-based experiments which use actions to configure the commandLinkButton: those do their stuff directly, without relying on an intermediate which is selection-based)
Sorry, didn't fully understand the implications at the time of reporting the issue :-( You'll need another way to fix the mis-behaviour as reported in the other issue
In some scenarios you show a dialog which displays a progress of a background task. If those dialogs have a cancel button it should signal the background task to stop and the dialog should remain open till the background task terminates. Currently not possible without dirty hacks.
You can add a PropertyChangeListener for the TaskDialog result, but you can not wait in EDT for the termination of the background task, therefore a new Thread has to be created that closes the dialog when the background task terminates, but once the result changes to a result that is marked as "closing" (see TaskDialogContent.CommandAction.actionPerformed(ActionEvent) ) the dialog will disappear.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.