I want my frame components to always adjust on screen, regardless of screen size. I draw a frame on my laptop (small screen), and when I run my application on another machine (jar file) with a large screen, the frame components do not change!
How can I make my frame resize its components when I put the frame in full screen on any computer?
Current location

the code
package package_MSM; import java.awt.Color; public class MSMGui extends JFrame { private static final long serialVersionUID = 1L; private JPanel contentPane; private JTextArea textArea; private JPanel pnlLogo1; private JLabel lblLogo1;; private static JButton btnSmpd1; private static JButton btnSmpd2; private static JButton btnSmpd3; private static JButton btnSmpd4; private static JButton btnSmpd5; private static JButton btnSmpd6; private static JButton btnSmpd7; public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { MSMGui frame = new MSMGui(); frame.setExtendedState(Frame.MAXIMIZED_BOTH); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); } public MSMGui() { setResizable(true); setTitle("MSM"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 841, 334); contentPane = new JPanel(); contentPane.setBackground(Color.BLACK); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(null); JPanel panelSmpd = new JPanel(); panelSmpd.setBounds(10, 69, 804, 105); panelSmpd.setBackground(Color.BLACK); contentPane.add(panelSmpd); panelSmpd.setLayout(null); JMenuBar menuBar = new JMenuBar(); menuBar.setBackground(UIManager.getColor("MenuBar.background")); menuBar.setFont(new Font("Segoe UI", Font.PLAIN, 12)); setJMenuBar(menuBar); JMenu mnMenu = new JMenu("Menu"); menuBar.add(mnMenu); JMenuItem mntmAlarmStop = new JMenuItem("Stop alarm sound"); mntmAlarmStop.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { stopAlarm(); textArea.append(dateTime()+ " Alarm cleared by the Operator from the Menu Bar\n"); writeTofile(dateTime()+ " Alarm cleared by the Operator from the Menu Bar\n"); } }); mnMenu.add(mntmAlarmStop); JMenuItem mntmExit = new JMenuItem("Exit"); mntmExit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) {
source share