简体   繁体   中英

how to build a JFrame window with a graphic area paintComponent with JTextField, JButton and JLabel?

I've been searching in google how to build something that looks like in the image. Text boxes, labels, buttons with actions and a graphic area all in one JFrame, but I only can find them separated. I mean, I understand how to build them separated but no how to put them together. I've been reading about using GridBagConstraints but is very confusing. I would appreciate any tip.

图像描述简介

The easiest way is to use the BorderLayout and include your panels ("separated components") at the regions (north, south, east, west, or center) you want.

    JFrame frame = new JFrame();

    JPanel actions = new JPanel();
    JPanel graph = new JPanel();

    frame.setLayout(new BorderLayout());
    frame.getContentPane().add(actions, BorderLayout.SOUTH);
    frame.getContentPane().add(graph, BorderLayout.CENTER);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM