--Situation--Невозможно отобразить JLabel на JFrame
Я хотел сделать JLabel на JFrame. Я использовал 3 класса:
1) Window.java - Window (JFrame);
2) Main.java - Программа запускаемым скрипт
3) GUI.java - TextFields, этикетки, кнопки
--Question--
Все я это JFrame. На нем нет ярлыков.
--source Code--
Window.java:
package GUI;
import java.awt.FlowLayout;
import javax.swing.JFrame;
public class Window extends JFrame {
private static final long serialVersionUID = 1L;
public Window(int width, int height, String title, boolean resizable, int operation) {
JFrame gui = new JFrame();
gui.setLayout(new FlowLayout());
gui.setDefaultCloseOperation(operation);
gui.setSize(width, height);
gui.setVisible(true);
gui.setTitle(title);
gui.setResizable(resizable);
gui.setLocationRelativeTo(null);
}
}
Main.java:
package Main;
import javax.swing.JFrame;
import javax.swing.JLabel;
import Func.Func;
import GUI.GUI;
import GUI.Window;
public class Main{
/**
*
*/
static Func func = new Func();
static GUI gui = new GUI();
static Window window1 = new Window(1200, 800, "JFrame Example", false, JFrame.EXIT_ON_CLOSE);
public static void main(String[] args) {
JLabel label = gui.createLabel("Hi dude!!!!!", 0, 0);
window1.add(label);
}
}
GUI.java:
package GUI;
import javax.swing.*;
import java.awt.*;
public class GUI extends JFrame {
/**
* Author Sculptor86
*/
public GUI() {
}
private static final long serialVersionUID = 1L;
public JLabel createLabel(String text, int AY, int AX) {
JLabel label = new JLabel(text, JLabel.CENTER);
label.setAlignmentX(AX);
label.setAlignmentY(AY);
label.setVisible(true);
return label;
}
public JTextField createTextBox(String text, Color fg, Color bg, int Max) {
JTextField textField;
textField = new JTextField(text, Max);
textField.setForeground(fg);
textField.setBackground(bg);
textField.setVisible(true);
return textField;
}
public JButton createButton(String text, Color fg, Color bg) {
JButton button;
button = new JButton(text);
button.setForeground(fg);
button.setBackground(bg);
button.setVisible(true);
return button;
}
}
Надежда кто-то может помочь, Влад
Не полагайтесь на статические – MadProgrammer