This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Java swing Table transparency
It is not so easy to make a JTable background transparent. I want to see only the text content of my cells.
The table will be transparent if neither itself nor the cells are opaque:
table.setOpaque(false);
((DefaultTableCellRenderer)table.getDefaultRenderer(Object.class)).setOpaque(false);
If the table is in a ScrollPane, it is to make transparent as well:
scrollPane.setOpaque(false);
scrollPane.getViewport().setOpaque(false);
At least, you can remove the grid lines:
table.setShowGrid(false);
Quite a big work for a simply result...
Related
This question already has an answer here:
Resizing image to fit in JLabel
(1 answer)
Closed 5 years ago.
How do you rezize an ImageIcon?
Let´s say we have a ImageIcon we want to display on a screen. But the ImageIcon is too big so we cannot see the whole picture. Then it would be desirable to be able to rezize the ImageIcon to a specific width and height, with the intention of making the displayed ImageIcon smaller so we can see the whole image on the screen. Any idea how this could be done in java?
You can use Image.getScaledInstance(...) to resize the Image to your desired fixed size. Then you create your ImageIcon and add it to a JLabel.
You can read up on The Perils of Image.getScaledInstance() blog for more information and other suggestions.
You can also try using the Stretch Icon. This Icon will dynamically resize itself based on the space available to the JLabel.
This question already exists:
UIManager.getDefaults().put() doesn´t work with colors
Closed 6 years ago.
favorite
I have a GUI with a JTabbedPane, and I want to change its Layout. I tried to do this with the UIManager:
UIManager.getDefaults().put("TabbedPane.foreground",Color.BLACK);
However, the color does not change, but when I change for example the border insets
UIManager.getDefaults().put("TabbedPane.contentBorderInsets", new Insets(0,0,0,0));
it works, but everything which needs a color doesn´t work!
The LAF from my GUI is UIManager.getSystemLookAndFeelClassName()
Use JTabbedPane.setForegroundAt():
https://docs.oracle.com/javase/7/docs/api/javax/swing/JTabbedPane.html#setForegroundAt(int,%20java.awt.Color)
This question already has answers here:
How to make JTextArea Stick to the window
(2 answers)
Closed 8 years ago.
I am designing a frame in java swing, which has 2 buttons on the end as I resize the window the gap between buttons are spread and they go far.
Please provide me solution as i want buttons to be in the bottom corner and the frame is resized the spaces should not increase.
Put the buttons in a right aligned flow layout, then add the flow layout (the panel) to the page end of a border layout.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to assign the auto complete text field to JTable cell?
I have created a class for auto complete text fields.
I want to use that class and try to include my JTable cell fields, add that controls to one panel but it won't display. please advice
You need a cellrenderer and so...
Here is an example for using a JPanel in a JTable cell.
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Making a JPanel manually resizable
I am doing a chat program with javaswing and I would like to create a separator that can adjust the dimension of 2 pannels "
The black line could reduce the height of the top panel and increase the bottom one.
How this is possiblle ? What layout sould I use ? Thank you very much.
Regards.
Try JSplitPane.
How to use SplitPanes?
Examples of JSplitPane