swing

How to add any Component in the JFrame TitleBar

橙三吉。 提交于 2021-01-29 02:40:38
问题 How to add any Component like a JButton on the JFrame TitleBar in java swing. 回答1: I assume by "title bar" you think of the header with the window menu button, document or program title and buttons for (typical) maximize, minimize, close. The window borders are drawn by the operating system (whatever part, e.g. with XServer it would be a window manager most of the time) - usually. And this is what the user wants - usually. Then this part of the window is outside the reach of Swing, you need

How to add any Component in the JFrame TitleBar

狂风中的少年 提交于 2021-01-29 02:39:24
问题 How to add any Component like a JButton on the JFrame TitleBar in java swing. 回答1: I assume by "title bar" you think of the header with the window menu button, document or program title and buttons for (typical) maximize, minimize, close. The window borders are drawn by the operating system (whatever part, e.g. with XServer it would be a window manager most of the time) - usually. And this is what the user wants - usually. Then this part of the window is outside the reach of Swing, you need

How to restore column widths in a JTable?

一世执手 提交于 2021-01-29 00:40:43
问题 My question is clear. Is there any way to restore the width of the columns automatically after user has resized them? Every time the button is clicked, I want the column widths to be restored. public class TableTest { public static void main(String[] args) { SwingUtilities.invokeLater(() -> { JFrame frame = new JFrame(""); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new BorderLayout()); JTable table = new JTable(new Object[][] { { "something", "something else" } },

How to restore column widths in a JTable?

天大地大妈咪最大 提交于 2021-01-29 00:35:48
问题 My question is clear. Is there any way to restore the width of the columns automatically after user has resized them? Every time the button is clicked, I want the column widths to be restored. public class TableTest { public static void main(String[] args) { SwingUtilities.invokeLater(() -> { JFrame frame = new JFrame(""); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new BorderLayout()); JTable table = new JTable(new Object[][] { { "something", "something else" } },

How to restore column widths in a JTable?

强颜欢笑 提交于 2021-01-29 00:34:49
问题 My question is clear. Is there any way to restore the width of the columns automatically after user has resized them? Every time the button is clicked, I want the column widths to be restored. public class TableTest { public static void main(String[] args) { SwingUtilities.invokeLater(() -> { JFrame frame = new JFrame(""); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new BorderLayout()); JTable table = new JTable(new Object[][] { { "something", "something else" } },

Swing - How to imitate the why my look and feel draws disabled icons?

心不动则不痛 提交于 2021-01-28 21:46:57
问题 When you set the icon for a Swing control (say a JButton ), a disabled icon with grayed-darker colors automatically generates. I want to be able to imitate the way the icon colors are changed for the disabled state, so I can create my own disabled icon with a little twist, and set it as the disabled button. Is there a way to achieve this (other then first instantiating the control and retrieving it's icon, I'm looking for more straight-forward less hacky way)? 回答1: Is there a way to achieve

Swing - How to imitate the why my look and feel draws disabled icons?

若如初见. 提交于 2021-01-28 20:59:06
问题 When you set the icon for a Swing control (say a JButton ), a disabled icon with grayed-darker colors automatically generates. I want to be able to imitate the way the icon colors are changed for the disabled state, so I can create my own disabled icon with a little twist, and set it as the disabled button. Is there a way to achieve this (other then first instantiating the control and retrieving it's icon, I'm looking for more straight-forward less hacky way)? 回答1: Is there a way to achieve

MigLayout: how to resize the height proportionally to the width (keeping the aspect ratio)?

南笙酒味 提交于 2021-01-28 18:50:20
问题 I'm arranging images in a grid with MigLayout. I could get the width to take the whole space available in the column, but then I want the height to grow accordingly so the proportion of the image still fixed. What is the best approach for this? Could I do that with an expression in the constraint or I have to override the getPreferredSize()? Thanks! 回答1: After a lot of researching, I realize that there is no nice way of doing this with Swing. The problem is not only coming from MigLayout but

foo.jar is not marked as executable

不打扰是莪最后的温柔 提交于 2021-01-28 18:05:48
问题 I am new to Ubuntu. I am trying to make a simple Java swing app(lets call it foo) that displays a hello message followed by a user name.I am using Eclipse .Till here everything works fine.When I press the "Run" button my app shows app without a problem.Now I export my app as a runnable jar but when I try to double click the generated jar to execute the following message: Blocked: /usr/bin/java -jar The file 'home/user/java projects/foo.jar' is not marked as executable. However if I run this

Limit the amount of characters typed into a JTextField [duplicate]

别等时光非礼了梦想. 提交于 2021-01-28 15:26:36
问题 This question already has answers here : Limiting TextField inputs (2 answers) Closed 6 years ago . I figured this would be a simple search on the web but I can't figure this out. Here is what I'm working with so far. Ignore the eventHandler, I know its empty. I want to limit the charField JTextField so that the user can only type one character. I figured this would be easy because of all the apps that limit the amount of numbers you can type when entering State or Zipcode. To be clear, I'm