Java buttons 🛎️

  Рет қаралды 177,215

Bro Code

Bro Code

Күн бұрын

Пікірлер: 188
@BroCodez
@BroCodez 4 жыл бұрын
//**************************************************** public class Main{ public static void main(String[] args) { // JButton = a button that performs an action when clicked on new MyFrame(); } } //**************************************************** import java.awt.*; import java.awt.event.*; import javax.swing.*; public class MyFrame extends JFrame implements ActionListener{ JButton button; JLabel label; MyFrame(){ ImageIcon icon = new ImageIcon("point.png"); ImageIcon icon2 = new ImageIcon("face.png"); label = new JLabel(); label.setIcon(icon2); label.setBounds(150, 250, 150, 150); label.setVisible(false); button = new JButton(); button.setBounds(100, 100, 250, 100); button.addActionListener(this); button.setText("I'm a button!"); button.setFocusable(false); button.setIcon(icon); button.setHorizontalTextPosition(JButton.CENTER); button.setVerticalTextPosition(JButton.BOTTOM); button.setFont(new Font("Comic Sans",Font.BOLD,25)); button.setIconTextGap(-15); button.setForeground(Color.cyan); button.setBackground(Color.lightGray); button.setBorder(BorderFactory.createEtchedBorder()); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setLayout(null); this.setSize(500,500); this.setVisible(true); this.add(button); this.add(label); } @Override public void actionPerformed(ActionEvent e) { if(e.getSource()==button) { System.out.println("poo"); button.setEnabled(false); label.setVisible(true); } } } //****************************************************
@keichionizuka
@keichionizuka 3 жыл бұрын
How to Copy
@arijitghosh3358
@arijitghosh3358 3 жыл бұрын
@@keichionizuka long press u will see a blue box on that word , now drag till where u want to copy
@omar_42
@omar_42 3 жыл бұрын
@@keichionizuka shift plus direction buttons
@ronnygamerz88
@ronnygamerz88 2 жыл бұрын
How add multiple buttions ???
@ronnygamerz88
@ronnygamerz88 2 жыл бұрын
@@arijitghosh3358 how to add multiple buttion can u plz tell mr
@ryoma8402
@ryoma8402 2 жыл бұрын
You probably won't see this but your videos saved my semester. One of my java projects was a GUI based Sudoku game and there isn't a chance in hell I would have been able to make it without your tutorials on swing components.
@TheSlimeKilling_Minecart
@TheSlimeKilling_Minecart 6 ай бұрын
He saw it, you're both legends
@MiroZvqra0809
@MiroZvqra0809 Жыл бұрын
If for some reason your image is not loading by simply writing its name with ".png", just write the whole terminal name \image.png For example: C:\Users\User\Desktop\image.png
@Smile-ih5xf
@Smile-ih5xf Жыл бұрын
I like how it was at the beginning a button called “I’m a butt” which was printing out the word poo.
@childofhonor
@childofhonor 4 жыл бұрын
Just started learning how to make a GUI for the first time and these videos have been so helpful!
@BroCodez
@BroCodez 4 жыл бұрын
thanks for watching bro! I hope they will serve u well
@ghasthordegd1201
@ghasthordegd1201 4 жыл бұрын
@@BroCodez hey there bro code. i really want to code on mobile. But I can't find a free coding editor for android that will do the import stuff. If there is one, can you give me suggestions?
@reubenkiwi
@reubenkiwi 4 жыл бұрын
@@ghasthordegd1201 I recommend to use your PC or laptop (if you have one) because building GUI on mobile is more difficult (not impossible) than doing it on your computer. There are some great Java IDEs for mobile e.g. AIDE, Dcoder
@SewerShorts
@SewerShorts 2 жыл бұрын
@@ghasthordegd1201 tbh a computer would be 10x better and easier, if you can't afford your own maybe the library will allow you to download a ide? Or a computer cafe?
@colettekeurentjes1597
@colettekeurentjes1597 Жыл бұрын
Thanks for you videos, they are great. You always explain a relatively 'straight to the point' concept but while doing that you touch upon many details and why they work the way they work. They help me loads :)
@pavelkvasnicka6856
@pavelkvasnicka6856 Жыл бұрын
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
@orlandohunter2785
@orlandohunter2785 3 жыл бұрын
This channel is really good Bro!
@YTSHANKY
@YTSHANKY 4 жыл бұрын
Even i dont like java i watch your videos to help you.. i watch the same video with my 2 accounts.😊😊
@BroCodez
@BroCodez 4 жыл бұрын
thanks man! You don't have to do that. I do appreciate the views and watch time
@YTSHANKY
@YTSHANKY 4 жыл бұрын
@@BroCodez i know how hard it is to get those 4000 hours watch time.. i wil just play your video in my chrome.. and start my video editing... so benifit for both of us...
@BroCodez
@BroCodez 4 жыл бұрын
Yeah we actually hit 4000 hours of watchtime already! Took a while, but we made it 😃
@YTSHANKY
@YTSHANKY 4 жыл бұрын
@@BroCodez bro you indian ?
@BroCodez
@BroCodez 4 жыл бұрын
no
@Amangupta-rh7cy
@Amangupta-rh7cy 4 жыл бұрын
Good teaching
@BroCodez
@BroCodez 4 жыл бұрын
Thanks for watching Aman!
@soniasmelodiousland
@soniasmelodiousland Жыл бұрын
Such a nice video. Really good teaching. Will watch all your videos
@Garrison86
@Garrison86 Жыл бұрын
as always, great tutorial 👍👍
@clordz
@clordz 4 жыл бұрын
Just started uni and started doing an assignment for it. This helped.
@BroCodez
@BroCodez 4 жыл бұрын
thanks for watching C Lordz!
@millejadecabrera4544
@millejadecabrera4544 3 жыл бұрын
It was really helpful for those who don't have no experience in coding
@DrinkableWater
@DrinkableWater 4 жыл бұрын
Always Helpful! Thank you!
@Skibbi198
@Skibbi198 Жыл бұрын
I love the super oldschool swing look.
@dianamilenaarchilacordoba4632
@dianamilenaarchilacordoba4632 3 ай бұрын
great video!!! I'm infinitely grateful for your dedication and big heart to share this knowledge with the world. Thank you soo much
@jowyli4362
@jowyli4362 3 жыл бұрын
Hey Bro nice Video Can you help me pls? I can't put a picture in it. How does it work?
@brogaming796
@brogaming796 2 жыл бұрын
ive been following all your steps in this video, cracked up laughing when i saw that if you set the text in the button "I'm a button" and run the program, the button only contains "I'm a butt..." and when you click it it says poo.. hilarious touch my guy
@eugenezuev7349
@eugenezuev7349 8 ай бұрын
Bro is just the java killa
@checkmate8015
@checkmate8015 3 жыл бұрын
Very useful stuff bro subscribed!!
@helpfulsquid2502
@helpfulsquid2502 3 жыл бұрын
Awsome! I wish every tutorial would be like that...
@jonathanlee4653
@jonathanlee4653 3 жыл бұрын
Awesome tutorial, by the way at around 1:38, how did you quickly shortcut those lines of code in? cheers
@DemHP.
@DemHP. 3 жыл бұрын
I think he just had them copied before hand for the vid. If he didn't however I'd love to know this too.
@sforsuraj7255
@sforsuraj7255 Жыл бұрын
I wanted to add new game button after game over in snake game designed by you. I am trying but not able to get the logic. Can you make a video on it ??? Your videos are gems for non IT students.
@maheshbh1
@maheshbh1 4 жыл бұрын
You're awesome 😎
@lallanyadav8507
@lallanyadav8507 2 жыл бұрын
Literally best tutorial I subbed and liked
@mirzababarhussain2336
@mirzababarhussain2336 2 жыл бұрын
Sir, I want to draw a rectangle at the push of a button. By entering its length and width. So can you make a video on it? Or can you send me the code?
@maxwong1768
@maxwong1768 2 жыл бұрын
You recall me the lessons about android studio in school . So similar .
@andifaimos
@andifaimos 3 жыл бұрын
thanks adding it to my java presets
@danny.3036
@danny.3036 3 жыл бұрын
Thanks, Bro! ☕ You're awesome!
@sigmastudio9853
@sigmastudio9853 2 жыл бұрын
bro i need to learn mobile app developing with java pls do a course regarding that, you are teaching gratefully,
@markgimarangan8344
@markgimarangan8344 Жыл бұрын
Hi sir, can you make a short video, example you have button in your first class and in the second class you also have button, if you want to disabled/enabled button in your second class you need to go in first class to click the button in the first class to disabled/enabled the button in second class. in Java swing eclipse I hope you notice me its really important.
@jesusguijarro5192
@jesusguijarro5192 3 жыл бұрын
This video was really useful, I was looking how to do visible a lable using the ActionListener, thanks jiji
@letsthinkit
@letsthinkit 3 жыл бұрын
How would we make round buttons in java?
@StriveforGainz
@StriveforGainz Жыл бұрын
Keep up the good work Bro Code!!!
@balasaasthab4044
@balasaasthab4044 6 күн бұрын
simply wow
@optimisticalamin4474
@optimisticalamin4474 2 жыл бұрын
these vedios for learn java so good
@曾毓哲-b1t
@曾毓哲-b1t Жыл бұрын
Thank you very much!!
@نمبروان-ع5م
@نمبروان-ع5م 2 жыл бұрын
I would say i love your videos
@elionayzuridasilveira4140
@elionayzuridasilveira4140 6 ай бұрын
Comment dropped here. Thank you!❤
@ziyahosseini55
@ziyahosseini55 4 жыл бұрын
Thank you very much that was useful
@draft_fusion
@draft_fusion 11 ай бұрын
Why is it that everyone makes a new class when making a JFrame? Am I missing out on something?
@peter00000
@peter00000 4 жыл бұрын
How to only increase size of content in jubutton.
@Amelia-darthmeow
@Amelia-darthmeow 3 жыл бұрын
These videos are really really great! Thank you so much! :)
@mojeebullahazami2676
@mojeebullahazami2676 4 жыл бұрын
Bro , Make a video How to build a calculator using java :)
@BroCodez
@BroCodez 4 жыл бұрын
Got one right here: kzbin.info/www/bejne/mpfLnoevh7l2ibM&ab_channel=BroCode
@jaymob5037
@jaymob5037 3 жыл бұрын
I appreciate your videos man! I hope you dont vanish
@techtalk9548
@techtalk9548 3 жыл бұрын
You are a hero!
@strong25
@strong25 2 жыл бұрын
Thanks bro 💕💕💕💕
@bomapdich
@bomapdich Жыл бұрын
If I didn't set the button in a different class. Instead of this, what can I put in as an argument for the addActionListener()?
@warriorninja51
@warriorninja51 4 жыл бұрын
How do you add 2 buttons though? Can you please tell me because I really want to know.
@BroCodez
@BroCodez 4 жыл бұрын
It's the same process, you would just have to create another button with a different name and follow the same steps JButton button2 = new JButton();
@warriorninja51
@warriorninja51 4 жыл бұрын
@@BroCodez Once I add the new button, do I need to add another actionPerformed(ActionEvent e) class, because I cant seem to get it work and you are my only hope now.
@BroCodez
@BroCodez 4 жыл бұрын
you could create a second if statement to check to see if button2 was selected within the same if actionperformed method if(e.getSource()==button2){ //do something else }
@warriorninja51
@warriorninja51 4 жыл бұрын
@@BroCodez thanks Man
@samuelaudric5204
@samuelaudric5204 2 жыл бұрын
@@BroCodez woah thanks
@s404pain
@s404pain 10 ай бұрын
can you do Tutorials with Intellij or do you only use eclipse?
@peterwheler7005
@peterwheler7005 Жыл бұрын
Hi Bro Code where do you get your emoji images from?
@robertdraxel7175
@robertdraxel7175 3 жыл бұрын
Just a thought. I'm watching these tutorials and I think that is a lot of work to fit all those elements into the frame by coding, coding is about logic, not beauty of a gui, aren't there IDE 's or app dev environments that let you insert buttons where you want and add features as you like by dragging them easily and the underlying code will be generated? I know there is Xamarin in C# for Android, what about environments for JAVA? Thanks.
@johnconnor2626
@johnconnor2626 3 жыл бұрын
You can start with Processing. It's a java based IDE for exactly this.
@robertdraxel7175
@robertdraxel7175 3 жыл бұрын
@@johnconnor2626 thank you very much
@7_ajinkya
@7_ajinkya 2 жыл бұрын
man just install Java Window Builder in your IDE. It's available in Visual Studio by default. For Eclipse you'll need to install it separately. Saves hell lot of time
@alexshepel5599
@alexshepel5599 4 жыл бұрын
Nice, bro!
@speklex779
@speklex779 Жыл бұрын
nice video
@DS-kx1il
@DS-kx1il Жыл бұрын
thank you bro .
@MinhLe-qp1lo
@MinhLe-qp1lo Жыл бұрын
what the "This" key word in addActionListener(this) actually is? Is it the MyFrame Obj or what
@karljanssendeguzman3107
@karljanssendeguzman3107 2 жыл бұрын
Hey bro, I have a question. Is it ok to implement an encapsulation to GUI like in Jbuttons?
@talk_kurdish
@talk_kurdish Жыл бұрын
the best thanks bro
@geocojonnrigor
@geocojonnrigor 2 жыл бұрын
Bro where do you get those Icons?
@swampus2016
@swampus2016 2 жыл бұрын
"Because we can ~~Bro Code, 2021
@colonelh.s.l.3834
@colonelh.s.l.3834 2 жыл бұрын
Is there a way to return a boolean of whether or not a button is clicked??
@MajorMonogram
@MajorMonogram 2 жыл бұрын
You mean something like: boolean isClicked = button.isClicked()? If so that would make no sense because the use of a button is to recieve a click/hover/... event. Not an action over time!
@Simis999
@Simis999 2 жыл бұрын
ačiū, brolau, labai padėjai! (LT)
@Quidoute
@Quidoute 3 жыл бұрын
this guy: making a button class javaScript devs : LOL let button = document.createElement('button');
@tib8569
@tib8569 2 жыл бұрын
Is it posible to change the position of a button without using setBounds()? I ve been trying to do it with all the setAlignments functions but i failed. I also tried searching it up on google but nothing worked.
@aladdinsane581
@aladdinsane581 3 жыл бұрын
thank you!
@soumelee5661
@soumelee5661 2 жыл бұрын
that was a lot of new things
@RohitKumar-jf1dt
@RohitKumar-jf1dt 3 жыл бұрын
A good tutorial😎😎
@ibrahimylmaz8378
@ibrahimylmaz8378 2 жыл бұрын
thanks bro
@rodmcmahon4829
@rodmcmahon4829 2 жыл бұрын
Using your code to learn from. but in buttons/labels etc I cannot get a dude.png file to show. Loaded using import/File System Any idea why? Great tutorials by the way
@hananokashipl9549
@hananokashipl9549 Жыл бұрын
For my work when i click right icon and click "copy path/reference" and copy long text where my icon find.
@user-fn3xp7mk3e
@user-fn3xp7mk3e 4 жыл бұрын
Is java swing still used by people for small or large projects?
@BroCodez
@BroCodez 4 жыл бұрын
Yes it's still used heavily. JavaFX is as well
@videogrin
@videogrin 4 жыл бұрын
Intellij idea uses swing
@HarryPotter-bd2qb
@HarryPotter-bd2qb 3 жыл бұрын
Bro,need ya help man. Imma currently developing a quiz app, I need to fix a 15 second timer to click the button.If time ends automatic transfer to next frame.
@Sorjen108
@Sorjen108 2 жыл бұрын
Hello Bro Code I was wondering, is there a way of displaying the text on the button, on the icon itself? The text on my button disappeared as soon as I inserted an image(icon) Thank you
@akshaykumarsharma
@akshaykumarsharma 4 жыл бұрын
How to set a background image in a button or a frame
@BroCodez
@BroCodez 4 жыл бұрын
I haven't done that myself yet, but this is what I found online: btn.setBackgroundResource(R.drawable.new_todo_image);
@akshaykumarsharma
@akshaykumarsharma 4 жыл бұрын
@@BroCodez Hey bro, there is no function like setBackgroundResource( ) in java for windows. It is a function in android java. I have jdk 15 but there is no function like this in it.
@saul-gone-z3o
@saul-gone-z3o 4 жыл бұрын
Hey bro, the setBorder method didn't work with me Do you have an idea why
@arijitghosh3358
@arijitghosh3358 3 жыл бұрын
sir how can we assume the size and location in pixel without any measurement?
@rakibulislamrakib856
@rakibulislamrakib856 3 жыл бұрын
How can I create two buttons ?
@floogle355
@floogle355 Жыл бұрын
The this.set... is not getting recognized. Someone help me
@alexbalan681
@alexbalan681 3 жыл бұрын
How can I make more buttons? I am creating button2, but it only shows the first button
@soltan4566
@soltan4566 3 жыл бұрын
Hi bro Can these codes be run inside Android Studio? Doesn't it matter ?? !!!!
@mohammedAli7106
@mohammedAli7106 Жыл бұрын
Next Chat app please sir❤❤❤❤
@jaymob5037
@jaymob5037 3 жыл бұрын
can you smooth the edges?
@Reece_may
@Reece_may 11 ай бұрын
Why this.set Rather than frame.set, what's the difference
@fiona7651
@fiona7651 2 жыл бұрын
Yooo, this is so cool
@mozd1729
@mozd1729 3 жыл бұрын
My button is taking up the space of my whole JFrame. Why?
@TheFanfan7
@TheFanfan7 2 жыл бұрын
hello how to fit the JButton with the JPanel in X AXIS ??
@016632
@016632 Жыл бұрын
what about a button in the real world how do i have java listen to it?
@muzamilzaman7463
@muzamilzaman7463 2 жыл бұрын
Can we make app with this Java code in Android studio
@dhanushetty2908
@dhanushetty2908 5 ай бұрын
I have a problem when i click the button it wont work means action does not perform anything can u please give a solution for this problem 😢
@gabriellabete617
@gabriellabete617 4 жыл бұрын
thanks a lot
@marcosdidierdrogbachagaslo286
@marcosdidierdrogbachagaslo286 Жыл бұрын
how can i do it, no using a subclasse ?
@tngflash2814
@tngflash2814 3 жыл бұрын
Why does my button take up the whole screennnnnn?!?!?!?!
@MrLoser-ks2xn
@MrLoser-ks2xn 2 жыл бұрын
Thanks
@jobincjesty9638
@jobincjesty9638 3 жыл бұрын
Hey bro, I'm not able to get my icon on jbutton can you please help me out
@adolfjamesurian6510
@adolfjamesurian6510 4 жыл бұрын
How do you remove the annoying highlight effect of jbutton when pressed? (Turns sky blue color everytime pressed) whatever the background of button is.
@adolfjamesurian6510
@adolfjamesurian6510 4 жыл бұрын
Without disabling the button
@emilsvensson7609
@emilsvensson7609 2 жыл бұрын
@@adolfjamesurian6510 if you mean the highlight around the button text you can try use "button.setFocusable(false);"
@centrophorous4353
@centrophorous4353 4 жыл бұрын
Sir, what is this.setLayout(null) is all about.??
@dominocoding
@dominocoding 3 жыл бұрын
Removing the Layout Manager, he will/has made a tutorial on Layout Managers I think..
@kingkock1
@kingkock1 2 жыл бұрын
too cool for skool
@C__MehrabEvan
@C__MehrabEvan 3 жыл бұрын
Hey bro could you please explain the button.addActionListener(this); I understood that addActionListener function is used in button but why I have to pass this parameter? Please help
@dominocoding
@dominocoding 3 жыл бұрын
because the class implements the action lister class, and the param needs a action listener instance
@teachercm8309
@teachercm8309 2 жыл бұрын
I tried your code, my images with display T_T
@SaphiraBlauauge
@SaphiraBlauauge 11 ай бұрын
-1000 HP to the algorithm! 👊👊💥💣
Java BorderLayout 🧭
11:40
Bro Code
Рет қаралды 71 М.
Java panels 🟥
13:26
Bro Code
Рет қаралды 111 М.
Don’t Choose The Wrong Box 😱
00:41
Topper Guild
Рет қаралды 62 МЛН
Леон киллер и Оля Полякова 😹
00:42
Канал Смеха
Рет қаралды 4,7 МЛН
JButton | Java Swing Tutorial for Beginners
13:12
Java Code Junkie
Рет қаралды 23 М.
31 nooby C++ habits you need to ditch
16:18
mCoding
Рет қаралды 846 М.
Java GUI 🖼️
12:45
Bro Code
Рет қаралды 136 М.
Modern Graphical User Interfaces in Python
11:12
NeuralNine
Рет қаралды 1,6 МЛН
This Is Why Python Data Classes Are Awesome
22:19
ArjanCodes
Рет қаралды 821 М.
Java GUI Tutorial - Make a Login GUI #100
19:49
Alex Lee
Рет қаралды 565 М.
ActionListener | Java Swing Tutorial for Beginners
8:23
Java Code Junkie
Рет қаралды 50 М.
Sound - How to Make a 2D Game in Java #9
17:00
RyiSnow
Рет қаралды 55 М.