How to color cells from JTable? [duplicate] - java

This question already has answers here:
JTable Cell Color
(4 answers)
Closed 9 years ago.
I am kind of a newbie in Java, so my question is.
If for example I have a JTable which represents a 2D array of Color
Color [][] array = new ...
So then when I run the JFrame it shows
So how do I color it?

You can attach a cellrenderer to your JTable and adjust the color with it:
http://docs.oracle.com/javase/tutorial/uiswing/components/table.html#renderer

Related

How to rotate a JButton? [duplicate]

This question already has answers here:
Rotating a JTextField vertically
(2 answers)
Closed 7 years ago.
Is it possible to rotate a JButton? In other words, I want to change the JButton's angle, for example to 45°. Is there a particular method for this? Thank you in advance.
As i know you can get absolution position of button with layouts.You can set any position of your elemnt in frame.AS i know it's impossible to rotate a button. You can implements Component and try to create your , and try to draw as you want. But i think rotating button is absolutely unreal.

Changing the color of the text on JButton object [duplicate]

This question already has an answer here:
How to change text color of a JButton
(1 answer)
Closed 7 years ago.
I have a JButton object: JButton button;
I add text onto it using: button.setText("XYZ");
However, I want to set a particular color to the text. How do I do it?
button.setForeground( Color.RED );
All Swing components support this method.

JavaFX - How to apply different colors for words in Label [duplicate]

This question already has an answer here:
Javafx Text multi-word colorization
(1 answer)
Closed 9 years ago.
I am new to JavaFX. I want to make the text of Label with different colors.
For Example:
Label : "sourav ganguly"
Ouput: sourav(as red color) ganguly(as blue color)
I tried but i didn't get it. Please can anyone help me.
Or you could possibly use setStyle for Label and set the color you need.
label.setStyle("-fx-color: red");
see more

How to assign the JPanel to JTable cell? [duplicate]

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.

How to make the background of a JTable transparent? [duplicate]

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...

Categories

Resources