Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » How can I make Window Builder parse an inherited JFrame?
How can I make Window Builder parse an inherited JFrame? [message #1753690] Thu, 09 February 2017 00:01 Go to next message
Jesse SURNAME is currently offline Jesse SURNAMEFriend
Messages: 2
Registered: February 2017
Junior Member
I have a class BaseWindow with a JFrame mainFrame, and a bunch of methods that work on mainFrame. Actual windows in my app are made by extending BaseWindow.

The class extending BaseWindow inherits mainFrame, and that somehow prevents window builder from "seeing" it when it parses the code. All I see in window builder's design tab is an empty window, but when I run the code everything works fine.

How can I make this approach work with window builder, or "trick" window builder into parsing mainFrame? Here is an example class extending BaseWindow:


package GUIApp;

//took out the imports to save space

class SampleWindowOne extends BaseWindow{


    public JLabel txtSampleText;
    public JButton btnMagicButton;

    public SampleWindowOne() {
        initialize();
    }

    public void run(){
        mainFrame.setBounds(getCenteredBounds());
        mainFrame.setVisible(true);
    }

    private void initialize() {

        mainFrame = new JFrame();
        mainFrame.setBounds(100,100,700,525);
        mainFrame.setTitle("Sample Window One");
        mainFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        mainFrame.getContentPane().setLayout(null);

        txtSampleText = new JLabel();
        txtSampleText.setFont(new Font("Dialog", Font.PLAIN, 25));
        txtSampleText.setHorizontalAlignment(SwingConstants.CENTER);
        txtSampleText.setText("Sample Window");
        txtSampleText.setBounds(12, 50, 674, 51);
        mainFrame.getContentPane().add(txtSampleText);

        JTextArea txtrLoremIpsumDolor = new JTextArea();
        txtrLoremIpsumDolor.setEditable(false);
        txtrLoremIpsumDolor.setFont(new Font("Dialog", Font.PLAIN, 16));
        txtrLoremIpsumDolor.setForeground(Color.DARK_GRAY);
        txtrLoremIpsumDolor.setWrapStyleWord(true);
        txtrLoremIpsumDolor.setLineWrap(true);
        txtrLoremIpsumDolor.setText("Lorem ipsum dolor sit amet...");
        txtrLoremIpsumDolor.setBounds(57, 131, 609, 296);
        mainFrame.getContentPane().add(txtrLoremIpsumDolor);

        btnMagicButton = new JButton("End Program");
        btnMagicButton.setEnabled(false);
        btnMagicButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                requestTerminate();
            }
        });
        btnMagicButton.setBounds(257, 451, 175, 25);
        mainFrame.getContentPane().add(btnMagicButton);

    }
}


Note: My current workaround is to put the line JFrame mainFrame; at the beginning of the class, do what I need to do in window builder, then remove that line again before I run the code.
Re: How can I make Window Builder parse an inherited JFrame? [message #1753758 is a reply to message #1753690] Thu, 09 February 2017 18:56 Go to previous message
Jesse SURNAME is currently offline Jesse SURNAMEFriend
Messages: 2
Registered: February 2017
Junior Member
This is a crosspost from stack overflow, I solved my problem and posted the answer there.
Previous Topic:Launch new Eclipse session, import & build project with JAVA class
Next Topic:Eclipse Call Hierarchy plugin
Goto Forum:
  


Current Time: Fri Apr 26 08:21:20 GMT 2024

Powered by FUDForum. Page generated in 0.02380 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top