#Cannot alter size on JFrame Eclipse
1 messages · Page 1 of 1 (latest)
<@&987246399047479336> please have a look, thanks.
Here is an AI assisted attempt to answer your question 🤖. Maybe it helps! In any case, a human is on the way 👍. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.
It sounds like you may have accidentally set the layout manager of your JFrame to null, which would prevent you from being able to move or resize components.
To fix this, make sure you are using a layout manager for your JFrame. You can set a layout manager by calling the setLayout() method on your JFrame object and passing in a layout manager object such as BorderLayout, FlowLayout, GridLayout, etc.
Here is an example of how you can set a BorderLayout for your JFrame:
import javax.swing.JFrame;
import java.awt.BorderLayout;
public class MyFrame extends JFrame {
public MyFrame() {
// Set the layout manager to BorderLayout
setLayout(new BorderLayout());
// Add your components here
// Set other properties of the JFrame
setSize(500, 500);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
}
public static void main(String[] args) {
new MyFrame();
}
}
By setting a layout manager for your JFrame, you should be able to move and resize components as needed. Let me know if you need further assistance.
I don't remember changing anything here.
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 849, 569);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
Detected code, here are some useful tools:
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 849, 569);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null );