为什么该程序的界面在右侧消失?

时间:2019-07-30 13:50:48

标签: java resize

我正在与朋友们一起进行小组项目,以完成学校作业。不幸的是,我的小组成员中的一位制定了该计划,这比以前要糟糕得多(我试图解决大多数主要问题)。现在唯一的问题是,该程序不会在右侧加载所有文本,而是保留省略号(...)。

我尝试过修改和删除setBounds,setSize和contentPane,但事实证明所有这些方法均无效。我对Java还是很陌生,所以请根据我的经验轻松一点。

public class HomeMenu extends JFrame  {

    private JPanel contentPane;
    private JTextField textField;

    public HomeMenu() {
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setSize(1366, 768);
        setBounds(100, 100, 954, 712);
        contentPane = new JPanel();
        contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
        setContentPane(contentPane);

        setBackground(new Color(255, 255, 255));
        getContentPane().setLayout(null);
        contentPane.setLayout(null);

        JPanel panel = new JPanel();
        panel.setBackground(Color.BLACK);
        panel.setForeground(Color.WHITE);
        panel.setBounds(0, 0, 236, 671);
        getContentPane().add(panel);
        panel.setLayout(null);

        JPanel panel_3 = new JPanel();
        panel_3.setBounds(44, 5, 1, 1);
        panel.add(panel_3);
        panel_3.setLayout(null);

        JPanel panel_1 = new JPanel();
        panel_1.setBackground(new Color(0, 0, 102));
        panel_1.setBounds(233, 240, 705, 431);
        getContentPane().add(panel_1);
        panel_1.setLayout(null);

        JPanel panel_6 = new JPanel();
        panel_6.setBackground(SystemColor.controlDkShadow);
        panel_6.setBounds(307, 235, 285, 164);
        panel_1.add(panel_6);

        JLabel lblWED = new JLabel("Weddings\r\n");
        panel_6.add(lblWED);
        lblWED.setForeground(Color.WHITE);
        lblWED.setFont(new Font("Sitka Subheading", Font.PLAIN, 23));
        lblWED.setBackground(Color.WHITE);

        JLabel lblNewLabel_4 = new JLabel("");
        panel_6.add(lblNewLabel_4);
        lblNewLabel_4.setIcon(new ImageIcon("C:\\Users\\HP\\Downloads\\groupwork_src_index2.jpg"));

        JPanel panel_4 = new JPanel();
        panel_4.setBackground(SystemColor.controlDkShadow);
        panel_4.setBounds(43, 25, 189, 298);
        panel_1.add(panel_4);

        JLabel lblBirthdayPartiesl = new JLabel("Birthday Partiesl");
        panel_4.add(lblBirthdayPartiesl);
        lblBirthdayPartiesl.setFont(new Font("Snap ITC", Font.PLAIN, 18));
        lblBirthdayPartiesl.setForeground(Color.WHITE);
        lblBirthdayPartiesl.setBackground(Color.WHITE);

        JLabel lblNewLabel_3 = new JLabel("");
        panel_4.add(lblNewLabel_3);
        lblNewLabel_3.setIcon(new ImageIcon("C:\\Users\\HP\\Downloads\\groupwork_src_index.jpg"));  

        JLabel lblWeDoIt = new JLabel("WE DO nothing at ALL !");
        lblWeDoIt.setBounds(68, 359, 212, 40);
        panel_1.add(lblWeDoIt);
        lblWeDoIt.setForeground(Color.WHITE);
        lblWeDoIt.setFont(new Font("Tahoma", Font.PLAIN, 28));
        lblWeDoIt.setBackground(Color.WHITE);

        JPanel panel_5 = new JPanel();
        panel_5.setBounds(297, 25, 358, 185);
        panel_1.add(panel_5);
        panel_5.setBackground(SystemColor.controlDkShadow);

        JLabel lblMeetings = new JLabel("Meetings");
        panel_5.add(lblMeetings);
        lblMeetings.setForeground(Color.WHITE);
        lblMeetings.setFont(new Font("Tahoma", Font.PLAIN, 20));
        lblMeetings.setBackground(Color.WHITE);

        JLabel lblNewLabel_6 = new JLabel("");
        panel_5.add(lblNewLabel_6);
        lblNewLabel_6.setIcon(new ImageIcon("C:\\Users\\HP\\Downloads\\groupwork_src_index(1)"));

        JLabel lblNewLabel_5 = new JLabel("");
        panel_5.add(lblNewLabel_5);
        lblNewLabel_5.setIcon(new ImageIcon("C:\\Users\\18060327\\Desktop\\index 3.jpg"));


        JPanel panel_2 = new JPanel();
        panel_2.setBounds(235, 54, 703, 188);
        contentPane.add(panel_2);
        panel_2.setBackground(new Color(204, 204, 204));
        panel_2.setLayout(null);

        JLabel lblNewLabel = new JLabel("ShadEvents");
        lblNewLabel.setFont(new Font("Segoe UI Light", Font.PLAIN, 36));
        lblNewLabel.setBounds(61, 24, 286, 58);
        panel_2.add(lblNewLabel);

        JLabel label = new JLabel("Here to make your life harder");
        label.setFont(new Font("Segoe UI Light", Font.PLAIN, 13));
        label.setBounds(78, 84, 188, 16);
        panel_2.add(label);

        textField = new JTextField();
        textField.setBounds(297, 11, 123, 24);
        contentPane.add(textField);
        textField.setColumns(10);

        JLabel lblNewLabel_2 = new JLabel("");
        lblNewLabel_2.setIcon(new ImageIcon("C:\\Users\\HP\\Downloads\\icons8-user-24.png"));
        lblNewLabel_2.setBounds(851, 11, 29, 32);
        contentPane.add(lblNewLabel_2);

        JLabel lblUser = new JLabel("Welcome!"); //fix this user shit //unfixable
        lblUser.setBounds(890, 19, 38, 24);
        contentPane.add(lblUser);
        lblUser.setFont(new Font("Segoe UI Light", Font.PLAIN, 15));

        JLabel lblNewLabel_1 = new JLabel();
        lblNewLabel_1.setBounds(258, 11, 29, 24);
        contentPane.add(lblNewLabel_1);
        lblNewLabel_1.setBackground(Color.BLUE);
        lblNewLabel_1.setIcon(new ImageIcon("C:\\Users\\HP\\Downloads\\groupwork_src_icons8-search-24.png"));
    }
}

它应该显示“我们什么都不做!”,而不是“ WE NOT nothin ...”和“ Wel ...”(在右上角)。 (另外,请让我知道代码是否无效。)

0 个答案:

没有答案