button = new JButton("Pick a color"); button.addActionListener(this);
label = new JLabel(); label.setBackground(Color.white); label.setText("This is some text :D"); label.setFont(new Font("MV Boli",Font.PLAIN,100)); label.setOpaque(true);
Practicing... public class Main{ public static void main(String[]args){ new MyFrame(); } } ******************* import java.awt.Color; import java.awt.FlowLayout; import java.awt.Font; import java.awt.event.*; import javax.swing.*; public class MyFrame extends JFrame implements ActionListener{ JButton button; JLabel label;
MyFrame(){ this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setLayout(new FlowLayout()); button =new JButton("Choose a color"); label = new JLabel(); label.setBackground(Color.black); label.setText("Write something"); label.setFont(new Font("Sans Serif", Font.PLAIN,18)); label.setOpaque(true);//To display background color this.add(button); this.add(label); this.pack(); this.setVisible(true);
} @Override public void actionPerformed(ActionEvent e){ if(e.getSource()==button){ JColorChooser colorChooser = new JColorChooser(); Color color = JColorChooser.showDialog(null, "What color do you want?", Color.green); //label.setForeground(color); label.setBackground(color); } } }
This is the best Java tutorial for beginners, so you can learn Java and English in one hit. Please keep going! I vote for Java advance tutorial. Thanks a lot Bro
Thank you so, so much for your efforts, bro, your videos are amazing! I was wondering what was the point of creating an instance of JColorChooser when we only use a static method of JColorChooser. I removed the line "(JColorChooser colorChooser = new JColorChooser()" and the program works just as fine.
Thanks you very much for all your support with sharing idea about java programming language.... I am your family.... But We want to learn Android studio basics as a beginner if you can please share....
public class Main{
public static void main(String[] args) {
// JColorChooser = A GUI mechanism that let's a user choose a color
new MyFrame();
}
}
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.event.*;
import javax.swing.*;
public class MyFrame extends JFrame implements ActionListener{
JButton button;
JLabel label;
MyFrame(){
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLayout(new FlowLayout());
button = new JButton("Pick a color");
button.addActionListener(this);
label = new JLabel();
label.setBackground(Color.white);
label.setText("This is some text :D");
label.setFont(new Font("MV Boli",Font.PLAIN,100));
label.setOpaque(true);
this.add(button);
this.add(label);
this.pack();
this.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
if(e.getSource()==button) {
JColorChooser colorChooser = new JColorChooser();
Color color = JColorChooser.showDialog(null, "Pick a color...I guess", Color.black);
label.setForeground(color);
//label.setBackground(color);
}
}
}
bro browser and musicplayer in swing please
THANK U SO MUCH
Practicing...
public class Main{
public static void main(String[]args){
new MyFrame();
}
}
*******************
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.event.*;
import javax.swing.*;
public class MyFrame extends JFrame implements ActionListener{
JButton button;
JLabel label;
MyFrame(){
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLayout(new FlowLayout());
button =new JButton("Choose a color");
label = new JLabel();
label.setBackground(Color.black);
label.setText("Write something");
label.setFont(new Font("Sans Serif", Font.PLAIN,18));
label.setOpaque(true);//To display background color
this.add(button);
this.add(label);
this.pack();
this.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e){
if(e.getSource()==button){
JColorChooser colorChooser = new JColorChooser();
Color color = JColorChooser.showDialog(null, "What color do you want?", Color.green);
//label.setForeground(color);
label.setBackground(color);
}
}
}
Hey man i have a question, what was the point of initializing the JColorChooser class if we were never going to use it?
Kudos your the best
This is the best Java tutorial for beginners, so you can learn Java and English in one hit. Please keep going! I vote for Java advance tutorial. Thanks a lot Bro
Thank you so, so much for your efforts, bro, your videos are amazing!
I was wondering what was the point of creating an instance of JColorChooser when we only use a static method of JColorChooser. I removed the line "(JColorChooser colorChooser = new JColorChooser()" and the program works just as fine.
amazing video as usual!
thank you very much for this tutorial - very useful (as usual ;), brief, to the point. Hope to watch more like this )) please do keep making them
thank you for another vid
Thanks great job
Great Work!
awesome
good job , bro
Thank you for the content, really appreciate it.
hey YOur doing great work thanks bro for sharing :)
Thanks for watching Saber!
Ooo shiny!
thanks bro! i don't need the google color picker now!
this is great !
Thanks !
thanks bro
damn, cool
Nice! Bro
Thank you very much
Thanks
I did all 3 my lord
Thanks you very much for all your support with sharing idea about java programming language.... I am your family.... But We want to learn Android studio basics as a beginner if you can please share....
JColorChooser colorChooser = new JColorChooser(); why ??? I don't think it's necessary
yeah lol it makes no sense
Indeed, I removed that line and it worked just fine.
nice haha
Great video. I have a question. Can you select the text in the label? If yes, how?
thank you
Hey what laptop are you using, you must need a good proccesor
It's an Asus laptop
My processor is a: Intel(R) Core(TM) i5-7200 CPU @ 2.50GHz
How save color in databases and show in Jpanel after save
bro browser and musicplayer in swing please
Can the color picker be resized?
droppin a comment down below
Hmmm can this be applied to a mouse event such as clicked
Bro you made an object but used the static method
Sit...can u creat chat application using java🙏
JColorChooser colorChooser = new JColorChooser(); This line is redundant
Hii bro
Can you help me out to do this
Actually i am making a notepad in that i have implement color pallet
Only legends know that this is a re-upload
actually it's a remake but close lol
Thanks
Thanks