我有一个应该创建我的UI的方法,它可以工作。然而,当我将标签名称更改为简单文本ex“Bed6a”时,最低面板(当前命名为面板)不显示我的图标,也不会显示文本。
有人能在这里找到我吗?
public static void showUI() {
int bedCount = getBedCount();
bedCount = bedCount - 5;
Toolkit tk = Toolkit.getDefaultToolkit();
int xSize = ((int) tk.getScreenSize().getWidth());
int ySize = ((int) tk.getScreenSize().getHeight());
ImageIcon maleBed = new ImageIcon("Images/Male.png");
ImageIcon femaleBed = new ImageIcon("Images/Female.png");
ImageIcon emptyBed = new ImageIcon("Images/Empty.png");
ImageIcon logo = new ImageIcon("Images/Medicalistics_Logo.png");
ImageIcon mlogo = new ImageIcon("Images/Medicalistics_Logo.png");
JFrame window = new JFrame("Ft Lauderdale");
window.setVisible(true);
window.setSize(1049, 710);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JMenuBar menuBar = new JMenuBar();
window.setJMenuBar(menuBar);
JMenu mnFile = new JMenu("File");
menuBar.add(mnFile);
JMenuItem mntmPrint = new JMenuItem("Print");
mnFile.add(mntmPrint);
JMenuItem mntmExit = new JMenuItem("Exit");
mntmExit.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent arg0) {
}
});
mnFile.add(mntmExit);
window.getContentPane().setLayout(null);
Panel infoPanel = new Panel();
infoPanel.setBackground(Color.orange);
infoPanel.setBounds(371, 0, 671, 160);
window.getContentPane().add(infoPanel);
infoPanel.setLayout(new GridLayout(1, 0, 0, 0));
JPanel panel = new JPanel();
panel.setBounds(0, 161, 1041, 499);
window.getContentPane().add(panel);
SpringLayout sl_panel = new SpringLayout();
panel.setLayout(sl_panel);
JLabel lblBeda = new JLabel(emptyBed);
sl_panel.putConstraint(SpringLayout.NORTH, lblBeda, 10, SpringLayout.NORTH, panel);
sl_panel.putConstraint(SpringLayout.WEST, lblBeda, 10, SpringLayout.WEST, panel);
panel.add(lblBeda);
JLabel lblBeda_1 = new JLabel(emptyBed);
sl_panel.putConstraint(SpringLayout.WEST, lblBeda_1, 0, SpringLayout.WEST, lblBeda);
sl_panel.putConstraint(SpringLayout.SOUTH, lblBeda_1, -374, SpringLayout.SOUTH, panel);
panel.add(lblBeda_1);
JLabel lblBeda_2 = new JLabel(emptyBed);
sl_panel.putConstraint(SpringLayout.NORTH, lblBeda_2, 84, SpringLayout.SOUTH, lblBeda_1);
sl_panel.putConstraint(SpringLayout.WEST, lblBeda_2, 0, SpringLayout.WEST, lblBeda);
panel.add(lblBeda_2);
JLabel lblBedb = new JLabel(emptyBed);
sl_panel.putConstraint(SpringLayout.NORTH, lblBedb, 0, SpringLayout.NORTH, lblBeda);
sl_panel.putConstraint(SpringLayout.WEST, lblBedb, 39, SpringLayout.EAST, lblBeda);
sl_panel.putConstraint(SpringLayout.EAST, lblBedb, 76, SpringLayout.EAST, lblBeda);
panel.add(lblBedb);
JLabel lblBedb_1 = new JLabel(emptyBed);
sl_panel.putConstraint(SpringLayout.NORTH, lblBedb_1, 0, SpringLayout.NORTH, lblBeda_1);
panel.add(lblBedb_1);
JLabel lblBedb_2 = new JLabel("Bed3B");
sl_panel.putConstraint(SpringLayout.NORTH, lblBedb_2, 0, SpringLayout.NORTH, lblBeda_2);
panel.add(lblBedb_2);
JSeparator separator = new JSeparator();
sl_panel.putConstraint(SpringLayout.WEST, separator, 28, SpringLayout.EAST, lblBedb);
sl_panel.putConstraint(SpringLayout.EAST, lblBedb_2, -28, SpringLayout.WEST, separator);
sl_panel.putConstraint(SpringLayout.EAST, lblBedb_1, -28, SpringLayout.WEST, separator);
sl_panel.putConstraint(SpringLayout.NORTH, separator, 10, SpringLayout.NORTH, panel);
sl_panel.putConstraint(SpringLayout.SOUTH, separator, -3, SpringLayout.SOUTH, panel);
separator.setBackground(Color.RED);
separator.setOrientation(SwingConstants.VERTICAL);
panel.add(separator);
JLabel lblBeda_3 = new JLabel("Bed4A");
sl_panel.putConstraint(SpringLayout.NORTH, lblBeda_3, 84, SpringLayout.SOUTH, lblBeda_2);
sl_panel.putConstraint(SpringLayout.WEST, lblBeda_3, 0, SpringLayout.WEST, lblBeda);
panel.add(lblBeda_3);
JLabel lblBedb_3 = new JLabel("Bed4B");
sl_panel.putConstraint(SpringLayout.WEST, lblBedb_3, 39, SpringLayout.EAST, lblBeda_3);
sl_panel.putConstraint(SpringLayout.SOUTH, lblBedb_3, 0, SpringLayout.SOUTH, lblBeda_3);
panel.add(lblBedb_3);
JLabel lblBeda_4 = new JLabel("Bed5A");
sl_panel.putConstraint(SpringLayout.WEST, lblBeda_4, 10, SpringLayout.WEST, panel);
sl_panel.putConstraint(SpringLayout.SOUTH, lblBeda_4, -74, SpringLayout.SOUTH, panel);
panel.add(lblBeda_4);
JLabel lblBedb_4 = new JLabel("Bed5B");
sl_panel.putConstraint(SpringLayout.SOUTH, lblBedb_4, 0, SpringLayout.SOUTH, lblBeda_4);
sl_panel.putConstraint(SpringLayout.EAST, lblBedb_4, -28, SpringLayout.WEST, separator);
panel.add(lblBedb_4);
JLabel lblBeda_5 = new JLabel("Bed6A");
sl_panel.putConstraint(SpringLayout.WEST, lblBeda_5, 160, SpringLayout.WEST, panel);
sl_panel.putConstraint(SpringLayout.SOUTH, lblBeda_5, 0, SpringLayout.SOUTH, lblBeda);
panel.add(lblBeda_5);
JLabel lblBeda_6 = new JLabel("Bed7A");
sl_panel.putConstraint(SpringLayout.NORTH, lblBeda_6, 0, SpringLayout.NORTH, lblBeda_1);
sl_panel.putConstraint(SpringLayout.EAST, lblBeda_6, 0, SpringLayout.EAST, lblBeda_5);
panel.add(lblBeda_6);
JLabel lblBeda_7 = new JLabel("Bed8A");
sl_panel.putConstraint(SpringLayout.NORTH, lblBeda_7, 0, SpringLayout.NORTH, lblBeda_2);
sl_panel.putConstraint(SpringLayout.WEST, lblBeda_7, 0, SpringLayout.WEST, lblBeda_5);
panel.add(lblBeda_7);
JLabel lblBeda_8 = new JLabel("Bed9A");
sl_panel.putConstraint(SpringLayout.NORTH, lblBeda_8, 0, SpringLayout.NORTH, lblBeda_3);
sl_panel.putConstraint(SpringLayout.WEST, lblBeda_8, 0, SpringLayout.WEST, lblBeda_5);
panel.add(lblBeda_8);
JLabel lblBeda_9 = new JLabel("Bed10A");
sl_panel.putConstraint(SpringLayout.NORTH, lblBeda_9, 0, SpringLayout.NORTH, lblBeda_4);
sl_panel.putConstraint(SpringLayout.WEST, lblBeda_9, 0, SpringLayout.WEST, lblBeda_5);
panel.add(lblBeda_9);
panel.setVisible(true);
}