Comments (15)
I've updated the code according to the discussion on stackoverflow
. Both, the old and the new variants work on my Mac. Please test and let me know.
Also, the best way to suggest a change is to simply send a pull request :)
from oxbow.
Hey thanks for the prompt response, The stackoverflow suggestion does not work. The ancestor window returned by menu.getTopLevelAncestor()
is of the jtable. Attempts to drag and resize the popupmenu changes the dimensions of the entire jtable in my case. I still have not found a fix for this. A possible reason is addressed by MadProgrammer in my stackoverflow post.
This is for the old variant:
"A call to setPopupSize
, calls showPopup
, this will close the current popup (if one is visible) and recreate the window based on the new preferredSize of the popup. How the window is actually created is dependent on a number of system critieria. the MouseListeners remain intact, but, because the window is made visible, the mouse events are no longer been sent to it, but to the window beneath it, and, well, the whole thing explodes in flames. This is a bug that the author of SwingBits is going to have to address"
from oxbow.
This is the code that i'm using to test the swing bits filter. Would be interesting to know if it is possible for you to resize the jpopupmenu that appears on a column header right click.
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import com.ezware.oxbow.swingbits.table.filter.TableRowFilterSupport;
public class TableExample extends JFrame
{
private JPanel topPanel;
private JPanel btnPanel;
public TableExample() throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException
{
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
//headers for the table
String[] columns = new String[] {
"Id", "Name", "Hourly Rate", "Part Time"
};
//actual data for the table in a 2d array
Object[][] data = new Object[][] {
{1, "John", 40.0, false },
{2, "Rambo", 70.0, false },
{3, "Zorro", 60.0, true },
};
topPanel = new JPanel();
btnPanel = new JPanel();
add(topPanel, BorderLayout.CENTER);
add(btnPanel, BorderLayout.SOUTH);
//create table with data
JTable table = new JTable(data, columns);
TableRowFilterSupport.forTable(table).searchable(true).apply();
JButton button = new JButton();
button.setText("save");
//add the table to the frame
topPanel.add(new JScrollPane(table));
btnPanel.add(button);
this.setTitle("Table Example");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.pack();
this.setVisible(true);
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae){
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
table.getColumnModel().getColumn(0).setPreferredWidth(15);
table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
}
});
}
public static void main(String[] args)
{
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
try {
new TableExample();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UnsupportedLookAndFeelException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
}
}
from oxbow.
Does the TableFilterTest
example produces the same issue?
from oxbow.
Yes
from oxbow.
Which Java version are you running under? Under my 1.8.0_65
I see no issue at all anymore.
from oxbow.
Your example also works
from oxbow.
Well look at that! I was running java 1.8.0_25 (x64), updated to 1.8.0_66 (x64) and the issue is no longer there. Both the old and new variants work fine. Thank you for the quick responses and apologies for any inconveniences caused.
from oxbow.
Glad to hear that! Last commit actually makes popup resizing smoother, so thank you for making me look into the issue :)
from oxbow.
There is a problem with the latest commit, Re-sizing works fine if part of the popupmenu is outside of the table. But if the popupmenu is entirely inside the table, menu.getTopLevelAncestor()
returns the window of the jtable which causes the table to resize and not the jpopupmenu.
from oxbow.
Just tested and don't see any issues :)
from oxbow.
Try maximizing the TableFilterTest
table and re-sizing the jpopupmenu?
My code is as below.
...
if ( newDim.width >= minDim.width && newDim.height >= minDim.height) {
//menu.setPopupSize(newDim);
resizeMenu(newDim);
}
}
private void resizeMenu(Dimension dim) {
final Window window = (Window) menu.getTopLevelAncestor();
// window.pack();
window.setSize(dim);
// window.validate();
}
from oxbow.
The old variant menu.setPopupSize(newDim)
works fine. Windows 8, jdk 1.8.0_66
from oxbow.
Pretty strange... both work well no my machine with OSX. Also old variant produces a flicker, but the new one does not
from oxbow.
Updated the code to use resizing method based on OS
from oxbow.
Related Issues (20)
- Support custom ActionListeners for Command Buttons
- ComponentOrientation problem HOT 4
- Maven repository ? HOT 5
- firetablestructurechanged preserves filter state but resets the table header renderer
- TableRowFilterSupport only sorting not filtering? HOT 3
- Support for custom rendering of DistinctColumnItem in TableFilterColumnPopup HOT 2
- Icon lost in TableHeader when Column is sorted HOT 2
- Broken download links (latest releases) HOT 1
- No compatibility with latest miglayout version HOT 2
- How can change foreground in the header? HOT 3
- Add custom actions
- How get and set Filter table? HOT 1
- Filtering with RegExp
- When is next release? HOT 3
- Table flicker on refresh when filter or sort applied
- Choice dialog - focus problem on java >= 9 HOT 1
- Lack of license HOT 4
- Travis Build fails HOT 1
- How to clear all filters HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from oxbow.