Taking a little break from the Swing layout managers, in this video we look at the JButton. Please Like, Comment and Subscribe! Cheers!
@Chronor16 күн бұрын
so many infor but really helpful
@kavishkamadhudhan19433 жыл бұрын
Great Content and Thank you for this video.
@JavaCodeJunkie3 жыл бұрын
@Kavishka Madhudhan - My pleasure! Glad you enjoyed it! Cheers!
@adodoes8770 Жыл бұрын
Hello, first i love your classes, really making my uni project easier. But i have a question: why does the png not show up in a button, in fact it also moves my word "Print" to the side so not all characters are visible in the button. Why does this happen? should i change button size for a workarouond? Edit: i changed the size with Dimension, but the png is not visible. Another edit: i removed the Dimension code and changed print.png save folder. Now it displays the image (though far too large, but that's not a problem), eclipse seems to not be able to read a .png file, since the image shows with white/gray squares behind it. Am i doing it wrong?
@vedarthjoshi2166 Жыл бұрын
any update lol?
@vedarthjoshi2166 Жыл бұрын
oh found it you can use this ImageIcon printIcon = new ImageIcon(MainFrame.class.getResource("print.png")); button.setIcon(printIcon); NOTE: the file print png should be in same dir as mainframe class and I am using vs code so it should work on other ide s anyway
@chaimaelbesri31263 ай бұрын
Thank you @@vedarthjoshi2166
@luizalves23083 жыл бұрын
could you make a video of how to round the edges of a jbutton?
@JavaCodeJunkie3 жыл бұрын
@Luiz Alves - Have you looked at the Nimbus look and feel?
@luizalves23083 жыл бұрын
@@JavaCodeJunkie I'll look. Is this what NetBeans uses by default? I really liked the content of the channel, I've already subscribed!
@JavaCodeJunkie3 жыл бұрын
@Luiz Alves - Yes, Nimbus is the Netbeans default look and feel. Thank you for the kind words and the sub! Cheers!
@philipT89893 жыл бұрын
hi, where can I find the different font styles like arial etc?
@JavaCodeJunkie3 жыл бұрын
@philip8989 - Available Fonts are specific to the computer that you are using. Try the code on the following page to list the fonts on your computer: alvinalexander.com/blog/post/jfc-swing/swing-faq-list-fonts-current-platform/ Cheers!
@christianlimiwijaya39426 ай бұрын
Hello, why my img isn't loaded to the button, the name is already correct.
2 ай бұрын
Hi. I had same problem. The solution was for me: ImageIcon printIcon = new ImageIcon("src/print_small.png");
@chanuperera3 жыл бұрын
how to place the button into a specific place?
@JavaCodeJunkie3 жыл бұрын
@Chanu Perera - Thank you for the question. You can use absolute positioning as follows: JFrame frame = new JFrame(); JPanel panel = new JPanel(); panel.setLayout(null); JButton jbutton = new JButton("Click"); jbutton.setBounds(10, 10, 75, 25); // x, y, width, height panel.add(jbutton); frame.add(panel); Hope this helps, Cheers!
@chanuperera3 жыл бұрын
@@JavaCodeJunkie wow, this helped . 😌❤ thank you Master.
@JavaCodeJunkie3 жыл бұрын
@Chanu Perera - You are very welcome! I am happy that my suggestion helped you! 🙏
@rezahajivand7498 Жыл бұрын
Thank you
@amstig_org3382 жыл бұрын
but not show how to change the shape of button
@JavaCodeJunkie2 жыл бұрын
@amstig_org - This is not really a topic for a beginner but check out the following link for more info. Cheers! harryjoy.me/2011/08/21/different-button-shapes-in-swing/