Комментарии:
you are the goat! T ^ T :DDD
ОтветитьThis was soo difficult to understand at school but somehow you make it sooo easy. Thank you! 🙏🏼
Ответитьnice
Ответитьlike, subscribe. Thanks!
ОтветитьKnowing that you made a video about labels actually exited me to learn about labels and I thought about it all day today and yesterday until I finally got a chance to watch it tonight. Gotta say, it's my favorite tutorial i've watched
ОтветитьImageIcon doesn't work. Give some suggestion
Ответитьthx bro
Ответитьidk why but my code wont load any image some of the var names are diffrent then the video but it just wont load and idk why
package Main;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class mayn {
public static void main(String[] args) {
ImageIcon bg = new ImageIcon("computationalemulatorr calc2.png");
JLabel textz = new JLabel();
textz.setText("GOD HELP ME PLEASE, GIVE ME STRENGTH");
textz.setIcon(bg);
JFrame window = new JFrame();
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.setSize(32*48,32*24);
window.add(textz);
window.setVisible(true);
}
}
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 very much
Ответитьthank you bro myhero
ОтветитьGG
Ответитьhow can i make the image smaller on my screen?
ОтветитьIf the Image Icon is not showing up you can try:
'ImageIcon name = new ImageIcon(getClass().getResource("*FilePath*"));'
instead of
'ImageIcon *name * = new ImageIcon(*FilePath*);'
thank you very much bro, you're more helpfulI than university lectures
Ответитьthanks bro
ОтветитьHow can I resize the image in a label. I palced a random image it only a part of it appeared in the label
ОтветитьThank You !
ОтветитьThankyou Bro😍
Ответить@Bro Code I am learning more from you than I am my professors. Thanks Bro~~
ОтветитьIsnt doing all this in Java , a little complicated. Can be done with less effort with CSS and Front end Javascript ...
Whats your opinion ?
(⊙o⊙)(✿◡‿◡)
ОтветитьHi, any idea why my image isn't showing up?
import javax.swing.*;
import java.awt.*;
public class JLabelLesson {
//Instantiating components
ImageIcon image = new ImageIcon("Icon.jpg");
JFrame frame = new JFrame();
JLabel label = new JLabel();
//Creating constructor
public JLabelLesson(){
label.setText("Default");
label.setIcon(image);
label.setForeground(new Color(0,200,250,100));
label.setVerticalTextPosition(JLabel.TOP); // sets text position (CENTER) of the image icon
label.setHorizontalTextPosition(JLabel.CENTER);// sets text position (BOTTOM) of the image icon
label.setFont(new Font("MV Boli", Font.ITALIC, 30)); // set text font
label.setBackground(Color.black); // sets background color (if not defined, the entire window will be the label's hitbox)
label.setOpaque(true); // needed to display background color
frame.setResizable(false);
frame.setSize(800,400);
frame.add(label);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.setVisible(true);
}
//JLabel is GUI are for a text / image or both
public static void main(String[] args){
//executing the code
new JLabelLesson();
}
}
Ly 2 bro
Ответитьwe're gettin higher bro!!
ОтветитьThanks for the tutorial. But I have a question. Why is it when I run the program the GUI's Appearance doesn't update, it's just empty/blank white window. It just gets updated or fixed whenever I just resize the window's size or hit maximize or minimize button. I mean it's not a big deal, but just annoying since I have to do that whenever I need to run the code.
Ответитьhow can I add second label?
ОтветитьThis lesson has much more information than usual .
I have made some references for each code and would like to share with you guys .
Hope this will make it more clear to you .
package testing;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.ImageIcon;
import javax.swing.border.Border;
import javax.swing.BorderFactory;
import java.awt.Color;
import java.awt.Font;
public class Main {
public static void main(String[] args) {
// create an image for label .
ImageIcon image = new ImageIcon("src/烈日戰士.png") ;
// create boundary lines for label and set their color and size .
Border border = BorderFactory.createLineBorder(new Color(0x000000) , 5) ;
// Setup the label
// create a label .
JLabel label = new JLabel() ;
label.setBackground(new Color(0xABF095)) ;
// It is used after setting the background color .
// true : paint every pixel within the bounds of label .
label.setOpaque(true) ;
// Apply the boundary lines to the label .
label.setBorder(border) ;
// set the position and dimensions of label bounds within the frame .
// Before using the code below , add <frame.setLayout(null) ;> to set a layout for label first .
label.setBounds(0 , 0 , 500 , 500) ; // (x , y , width , height)
// Text of label
// Another style : <JLabel label = new JLabel("Nice to meet you !") ;>
label.setText("Nice to meet you !");
// set "type of font" , font style , font size .
// ("MV Boli" , "Helvetica" , "Futura" , ……) , (plain, bold, italic)
label.setFont(new Font("MV Boli" , Font.PLAIN , 20)) ;
// set the font color .
label.setForeground(new Color(0x4878F5)) ;
// Position of components in label
// add the image into the label .
label.setIcon(image) ;
// set the position of label text within the label bounds .
label.setHorizontalTextPosition(JLabel.CENTER) ; // Left or CENTER or RIGHT
label.setVerticalTextPosition(JLabel.TOP) ; // TOP or CENTER or BOTTOM
// set the position of label image within the label bounds .
label.setHorizontalAlignment(JLabel.CENTER) ;
label.setVerticalAlignment(JLabel.CENTER) ;
// set the distance between the text block and the image .
// negative and positive are both available .
label.setIconTextGap(0) ;
// Setup the frame .
// we need a frame to hold components(e.g. label) .
JFrame frame = new JFrame() ;
frame.setVisible(true) ;
// exit when you click [X] on the top-right corner .
// "JFrame.HIDE_ON_CLOSE" : hide but still running in the background thread .
//"JFrame.DO_NOTHING_ON_CLOSE" : disable the [X] button .
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) ;
frame.setSize(500 , 500) ; // still manually resizable .
// Add component to the frame .
frame.add(label) ;
// set a layout for the label to set bounds .
frame.setLayout(null) ;
// By using the code below , system will auto-resize the frame in order to accommodate all the components you add to the frame , no matter if size of components change .
// use <frame.add()> to add all your components to your frame first , disable <frame.setLayout(null)> and <label.setBounds()> before you use the code below .
// frame.pack() ;
}
}
Thank yo brother I understand now what is a Label is ow to create a label and what is a frame and how to create a Frame. Millions Thanks and god bless you❤
ОтветитьMy Image won't display, can you guys see if something's wrong with my code?
package frame;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class Frame1 {
public static void main(String[] args) {
JFrame frame = new JFrame();
JLabel label = new JLabel();
ImageIcon image = new ImageIcon("Amogus.png");
label.setText("Sussy baka time");
label.setIcon(image);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
frame.setSize(1000,600);
frame.add(label);
}
}
Thanks!!
ОтветитьI Coded on my VS but its not getting any effect in Frame even though I added label to Frame? Anyone know why that is happening?
Ответить(●'◡'●)
Ответитьwhere i can find fonts types for label
ОтветитьThanks
Ответить2. comment
Ответитьthanks bro
ОтветитьAwesome! I love the broke down videos - learn Java in smaller sections
ОтветитьLabel of love
Ответитьbro your tutorials are so much helpfull its well detailed for a beginner like me .
Ответитьyo its me fellow bro
Ответитьperfect
Ответитьrandom comment
ОтветитьWow. Awesome.
Ответить