How to add Hex font color to JLabel?
I have searched stackOverFlow for answers but I still cannot find it (android only. I am using command line). I want to add Hex color code as font color.
I used this for the first time, but I need to add from the JDK a given system / certain colors
g2l2.setForeground(Color.BLUE);
Something like that. But it doesn't work.
g2l2=new JLabel();
g2l2.setLocation(50,60);
g2l2.setSize(150,30);
g2l2.setText("Members");
g2l2.setTextColor(Color.parseColor("#43B7BA"));
g2l2.setFont(new Font("Calibri Light",Font.BOLD,15));
g2cont.add(g2l2);
g2l2.addMouseListener(this);
ERROR: Cannot find symbol Color.parseColor (String) in Location: class Color.
+3
source to share
2 answers
I know this is an older thread, but I believe the OP's original problem did not include correct imports. He already understood the answer correctly.
import android.graphics.Color;
To parse HEX colors in Android, you just do this ... after import:
Color.parseColor("#000000")//BLACK
Or how the OP already had it ... after import:
g2l2.setTextColor(Color.parseColor("#43B7BA"));
+1
source to share