Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JTable has inconsistent design between different themes #750

Closed
ghost opened this issue Oct 19, 2023 · 2 comments
Closed

JTable has inconsistent design between different themes #750

ghost opened this issue Oct 19, 2023 · 2 comments
Milestone

Comments

@ghost
Copy link

ghost commented Oct 19, 2023

Dear Friends,

I've come to realize that the JTable component isn't fully consistent and stable between different themes.

I'm not entirely sure of how I could describe the issue but here's a GIF of what I've been able to recreate:
FlatLafTableIssue-GIF
(Please ignore the low quality of the GIF)

I'm not allowed to show the production code here but this is the single-method example that I used for the GIF:

public final class FlatLafTableIssue {
	
	public static void main(final String... args) {
		{
			FlatLightLaf.setup();
			UIManager.put("TitlePane.unifiedBackground", false);
		}
		
		boolean dark[] = new boolean[] { false };
		
		final JFrame frame = new JFrame();
		frame.setSize(680, 400);
		frame.setTitle("FlatLafTableIssue");
		frame.setResizable(false);
		frame.setLocationRelativeTo(null);
		frame.setJMenuBar(new JMenuBar());
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		final JPanel panel = (JPanel) frame.getContentPane();
		panel.setLayout(new BorderLayout());
		
		final JTable table = new JTable();
		table.setModel(new DefaultTableModel(200, 5));
		table.setIntercellSpacing(new Dimension(1, 1));
		table.setShowHorizontalLines(true);
		
		final JPanel tablePanel = new JPanel(new BorderLayout());
		tablePanel.setBorder(BorderFactory.createEmptyBorder(20, 20, 5, 20));
		tablePanel.add(new JScrollPane(table));
		
		final JButton button = new JButton();
		button.setText("Toggle");
		button.addActionListener((event) -> {
			dark[0] = !dark[0];
			FlatAnimatedLafChange.showSnapshot();
			
			FlatLaf.setup(dark[0] ? new FlatDarkLaf() : new FlatLightLaf());
			FlatLaf.updateUI();
			
			FlatAnimatedLafChange.hideSnapshotWithAnimation();
		});
		
		final JPanel buttonPanel = new JPanel(new BorderLayout());
		buttonPanel.setBorder(BorderFactory.createEmptyBorder(5, 20, 20, 20));
		buttonPanel.add(button);
		
		panel.add(tablePanel);
		panel.add(buttonPanel, BorderLayout.SOUTH);
		
		frame.setVisible(true);
		
	}
	
}

I used FlatLaf-3.2.1 and FlatLaf-Extras-3.2.1 as well, but the Issue is also replicable without the usage of the FlatAnimatedLafChange class that is provided by the FlatLaf-Extras module, I only used it for the smooth switching between themes. I also tried out the same example with the FlatTable component provided by FlatLaf-Extras but nothing changed. Everything has been compiled using Java 21.

Here's a ZIP archive that contains the .jar file used for the example (If you don't want to compile it yourself):
FlatLaf-3.2.1-Table-Issue.zip

You can run the .jar it with

java -jar FlatLaf-3.2.1-Table-Issue.jar

or just by double clicking the file (If you have Java installed)

@ghost
Copy link
Author

ghost commented Oct 22, 2023

Found out that this issue is related to #733

@DevCharly
Copy link
Collaborator

yes, same as #733

fixed in latest 3.3-SNAPSHOT: https://github.com/JFormDesigner/FlatLaf#snapshots

@DevCharly DevCharly added this to the 3.3 milestone Oct 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant