I am currently creating a GUI with internalFrame. This is how my code looks like:
import javax.swing.*;
public class GUI extends JFrame {
private JDesktopPane desktop;
private JMenuBar menuBar;
private JMenu startMenu;
private JMenuItem travelInfo;
private JButton updateData;
public GUI()
{
desktop = new JDesktopPane();
updateData = new JButton("Update");
createFrame();
setContentPane(desktop);
setJMenuBar(buildMenu());
}
private JMenuBar buildMenu()
{
menuBar = new JMenuBar();
startMenu = new JMenu("Start");
menuBar.add(startMenu);
travelInfo = new JMenuItem("TravelInfo");
startMenu.add(travelInfo);
return menuBar;
}
protected void createFrame()
{
NewFrame frame = new NewFrame();
frame.add(updateData);
frame.setVisible(true);
desktop.add(frame);
}
}
And then my other class:
import javax.swing.JInternalFrame;
class NewFrame extends JInternalFrame {
public NewFrame() {
setSize(800, 600);
}
}
And my main:
import javax.swing.JFrame;
public class Main {
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
private static void createAndShowGUI()
{
GUI frame = new GUI();
frame.setSize(800, 600);
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
What I want to do is to make the internalFrame that I create unsizeable so that it will always be as big as the JDesktopPane which is unsizeable. I am then going to add different menu option so that I can switch between the different frames so it kinda looks like a website. I am also wondering how I change the size of my button inside my internalFrame. I tried setting the frame.setResizable(false);
for the internalFrame but it didn't work. Setting a size on the button didn't work out either... Somebody got an idea on how to solve this?