Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Help with running JFrame(Program running fine, but GUI not displayed)
Help with running JFrame [message #1046556] Mon, 22 April 2013 04:15 Go to next message
Vineet Dhar is currently offline Vineet DharFriend
Messages: 1
Registered: April 2013
Junior Member
Hi,

I am trying to build a GUI. I used JFormsDesigner, made a small GUI, and transferred the code to Eclipse, However running the code in Eclipse, doesn't start GUI.

I put certain print statments, all are executed, but the GUI is not displayed.

Any help would be welcome....

Thanks in advance !!
cheers!!





import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.GroupLayout;
/*
 * Created by JFormDesigner on Sun Apr 21 23:16:31 SGT 2013
 */



/**
 * @author vineet dhar
 */
public class MainPage extends JFrame {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	public MainPage() {
		initComponents();
		System.out.println("mainpage");
	}

	private void textField1ActionPerformed(ActionEvent e) {
		// TODO add your code here
	}

	private void initComponents() {
		// JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
		// Generated using JFormDesigner Evaluation license - vineet dhar
		label1 = new JLabel();
		label2 = new JLabel();
		textField1 = new JTextField();
		checkStatus = new JButton();
		button1 = new JButton();

		//======== this ========
		Container contentPane = getContentPane();
		//contentPane.setVisible(true);

		//---- label1 ----
		label1.setText("First GUI");
		label1.setFont(new Font("Tahoma", Font.PLAIN, 20));

		//---- label2 ----
		label2.setText("Enter Account Number");
		label2.setFont(label2.getFont().deriveFont(label2.getFont().getSize() + 3f));

		//---- textField1 ----
		textField1.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				textField1ActionPerformed(e);
			}
		});

		//---- checkStatus ----
		checkStatus.setText("Check Status");

		//---- button1 ----
		button1.setText("Write");
		System.out.println("wrb");

		GroupLayout contentPaneLayout = new GroupLayout(contentPane);
		contentPane.setLayout(contentPaneLayout);
		contentPaneLayout.setHorizontalGroup(
			contentPaneLayout.createParallelGroup()
				.addGroup(contentPaneLayout.createSequentialGroup()
					.addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.TRAILING)
						.addGroup(contentPaneLayout.createSequentialGroup()
							.addGap(117, 117, 117)
							.addComponent(checkStatus, GroupLayout.PREFERRED_SIZE, 112, GroupLayout.PREFERRED_SIZE)
							.addGap(58, 58, 58)
							.addComponent(button1, GroupLayout.PREFERRED_SIZE, 108, GroupLayout.PREFERRED_SIZE))
						.addGroup(contentPaneLayout.createParallelGroup()
							.addGroup(contentPaneLayout.createSequentialGroup()
								.addGap(134, 134, 134)
								.addComponent(label1))
							.addGroup(contentPaneLayout.createSequentialGroup()
								.addGap(61, 61, 61)
								.addComponent(label2)
								.addGap(70, 70, 70)
								.addComponent(textField1, GroupLayout.PREFERRED_SIZE, 123, GroupLayout.PREFERRED_SIZE))))
					.addContainerGap(147, Short.MAX_VALUE))
		);
		contentPaneLayout.setVerticalGroup(
			contentPaneLayout.createParallelGroup()
				.addGroup(contentPaneLayout.createSequentialGroup()
					.addGap(20, 20, 20)
					.addComponent(label1)
					.addGap(35, 35, 35)
					.addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
						.addComponent(label2)
						.addComponent(textField1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
					.addGap(46, 46, 46)
					.addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
						.addComponent(checkStatus, GroupLayout.DEFAULT_SIZE, 42, Short.MAX_VALUE)
						.addComponent(button1, GroupLayout.DEFAULT_SIZE, 42, Short.MAX_VALUE))
					.addContainerGap(123, Short.MAX_VALUE))
		);
		pack();
		setLocationRelativeTo(getOwner());
		//contentPaneLayout.setHonorsVisibility(true);
		// JFormDesigner - End of component initialization  //GEN-END:initComponents
	}

	// JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables
	// Generated using JFormDesigner Evaluation license - vineet dhar

	private JLabel label1;
	private JLabel label2;
	private JTextField textField1;
	private JButton checkStatus;
	private JButton button1;
	// JFormDesigner - End of variables declaration  //GEN-END:variables
}



public class Test {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new MainPage();
	
	}

}














The output is
wrb
mainpage
Re: Help with running JFrame [message #1048617 is a reply to message #1046556] Wed, 24 April 2013 18:27 Go to previous message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4435
Registered: July 2009
Senior Member

Does the same behavior occur outside of Eclipse?

_
Nitin Dahyabhai
Eclipse Web Tools Platform
Previous Topic:Eclipse RCP
Next Topic:*SOLVED* SWT not contained in the Eclipse IDE for Java developers
Goto Forum:
  


Current Time: Fri Apr 26 12:56:12 GMT 2024

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

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

Back to the top