Java labels ‍

Java labels ‍

Bro Code

3 года назад

93,437 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@anjapietralla5767
@anjapietralla5767 - 24.01.2024 13:14

Ответить
@maryamhussein2192
@maryamhussein2192 - 29.12.2023 01:10

you are the goat! T ^ T :DDD

Ответить
@ADJOLU91
@ADJOLU91 - 10.12.2023 08:01

This was soo difficult to understand at school but somehow you make it sooo easy. Thank you! 🙏🏼

Ответить
@user-ie7bt3hk3h
@user-ie7bt3hk3h - 06.12.2023 13:16

nice

Ответить
@user-ob2iv6cb9m
@user-ob2iv6cb9m - 15.11.2023 19:46

like, subscribe. Thanks!

Ответить
@caidenhiles
@caidenhiles - 26.10.2023 05:16

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

Ответить
@blankcoder235
@blankcoder235 - 18.08.2023 08:32

ImageIcon doesn't work. Give some suggestion

Ответить
@mahorodivin2979
@mahorodivin2979 - 03.08.2023 18:47

thx bro

Ответить
@raulmartinez2361
@raulmartinez2361 - 23.05.2023 21:44

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);
}
}

Ответить
@pavelkvasnicka6856
@pavelkvasnicka6856 - 08.04.2023 18:03

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

Ответить
@user-zq6yx7of5f
@user-zq6yx7of5f - 17.03.2023 18:07

Thank you very much

Ответить
@user-it4zp4ny6s
@user-it4zp4ny6s - 05.02.2023 09:05

thank you bro myhero

Ответить
@BISAMARKSMANDOANG
@BISAMARKSMANDOANG - 16.01.2023 18:05

GG

Ответить
@sophieguelfi8193
@sophieguelfi8193 - 14.01.2023 21:23

how can i make the image smaller on my screen?

Ответить
@Iischeese
@Iischeese - 01.01.2023 02:52

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*);'

Ответить
@WajdAlhuzaym
@WajdAlhuzaym - 21.12.2022 15:44

thank you very much bro, you're more helpfulI than university lectures

Ответить
@sairos4057
@sairos4057 - 09.12.2022 05:15

thanks bro

Ответить
@yahyakhawaja88
@yahyakhawaja88 - 22.11.2022 16:44

How can I resize the image in a label. I palced a random image it only a part of it appeared in the label

Ответить
@Maximiliano706
@Maximiliano706 - 21.11.2022 14:45

Thank You !

Ответить
@rentv6447
@rentv6447 - 19.11.2022 14:33

Thankyou Bro😍

Ответить
@thedevbek
@thedevbek - 14.11.2022 12:34

@Bro Code I am learning more from you than I am my professors. Thanks Bro~~

Ответить
@raghavkonda6175
@raghavkonda6175 - 07.11.2022 15:02

Isnt doing all this in Java , a little complicated. Can be done with less effort with CSS and Front end Javascript ...
Whats your opinion ?

Ответить
@soumelee5661
@soumelee5661 - 21.10.2022 06:59

(⊙o⊙)(✿◡‿◡)

Ответить
@George-et8sx
@George-et8sx - 18.09.2022 02:51

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();

}
}

Ответить
@manuelgonzalezpalafox2627
@manuelgonzalezpalafox2627 - 13.09.2022 21:57

Ly 2 bro

Ответить
@Simis999
@Simis999 - 10.09.2022 23:38

we're gettin higher bro!!

Ответить
@geocojonnrigor
@geocojonnrigor - 09.09.2022 05:40

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.

Ответить
@mamaafrica2512
@mamaafrica2512 - 27.08.2022 11:48

how can I add second label?

Ответить
@maxwong1768
@maxwong1768 - 29.07.2022 19:25

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() ;
}
}

Ответить
@kamalkhashoggi2374
@kamalkhashoggi2374 - 27.07.2022 17:43

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❤

Ответить
@pythonfan3447
@pythonfan3447 - 26.07.2022 09:24

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);
}
}

Ответить
@fiona7651
@fiona7651 - 19.07.2022 02:59

Thanks!!

Ответить
@abishekk.j3773
@abishekk.j3773 - 16.07.2022 18:29

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?

Ответить
@zari_723
@zari_723 - 15.07.2022 14:06

(●'◡'●)

Ответить
@user-ki2mr7vl7j
@user-ki2mr7vl7j - 02.07.2022 17:41

where i can find fonts types for label

Ответить
@MrLoser-ks2xn
@MrLoser-ks2xn - 11.06.2022 19:18

Thanks

Ответить
@siriusleto3758
@siriusleto3758 - 17.05.2022 19:49

2. comment

Ответить
@honoredegg
@honoredegg - 17.04.2022 00:18

50th. Thank you, ma Bro Sensei

Ответить
@ibrahimylmaz8378
@ibrahimylmaz8378 - 31.03.2022 04:25

thanks bro

Ответить
@UnderArea51
@UnderArea51 - 15.02.2022 15:09

Awesome! I love the broke down videos - learn Java in smaller sections

Ответить
@kingkock1
@kingkock1 - 11.02.2022 12:26

Label of love

Ответить
@mbekezelisibanda3641
@mbekezelisibanda3641 - 04.02.2022 02:35

bro your tutorials are so much helpfull its well detailed for a beginner like me .

Ответить
@tinczo1178
@tinczo1178 - 26.01.2022 21:43

yo its me fellow bro

Ответить
@mahmodmardani7535
@mahmodmardani7535 - 04.01.2022 04:28

perfect

Ответить
@bobzerotz5539
@bobzerotz5539 - 05.12.2021 14:31

random comment

Ответить
@kemann3815
@kemann3815 - 27.11.2021 17:07

Wow. Awesome.

Ответить