import java.awt.Color;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
public class Frame extends JFrame{
Frame(){
//set title of the frame
this.setTitle("Frame Test nº 1");
//exit out of application
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//define o tamanho da janela
this.setSize(420, 420);
this.setResizable(true);
//create an icon
ImageIcon logo = new ImageIcon("\\\\wsl.localhost\\Ubuntu\\home\\tech\\Java_Codes\\GUI_test\\d6ede8c8-a316-488b-8d87-60dcb1cdbe06.png");
//change icon frame
this.setIconImage(logo.getImage());//get the image created above
//change the colour fron the background
this.getContentPane().setBackground(new Color(0x123456));
this.setVisible(true);
}
}
< /code>
import java.awt.Color;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class gui{
public static void main (String[] args){
Frame frame = new Frame();
JLabel label = new JLabel();
label.setText("h");
frame.add(label);
}
}
< /code>
I have tried to change the label inside the Frame class, but it didn't help... I also tried to put frame.setVisible(true);
Я пытаюсь сделать кадр с меткой (я создал отдельный класс для кадра), но я не знаю, почему этикетка не отображается в кадре ... < /p> [code]import java.awt.Color; import javax.swing.ImageIcon; import javax.swing.JFrame;
public class Frame extends JFrame{
Frame(){
//set title of the frame this.setTitle("Frame Test nº 1");
//exit out of application this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//define o tamanho da janela this.setSize(420, 420); this.setResizable(true);
//create an icon ImageIcon logo = new ImageIcon("\\\\wsl.localhost\\Ubuntu\\home\\tech\\Java_Codes\\GUI_test\\d6ede8c8-a316-488b-8d87-60dcb1cdbe06.png");
//change icon frame this.setIconImage(logo.getImage());//get the image created above
//change the colour fron the background this.getContentPane().setBackground(new Color(0x123456));
public class gui{ public static void main (String[] args){ Frame frame = new Frame(); JLabel label = new JLabel(); label.setText("h"); frame.add(label);
}
} < /code> I have tried to change the label inside the Frame class, but it didn't help... I also tried to put frame.setVisible(true);[/code] в последней строке основного ...