The Artima Developer Community
Sponsored Link

Java Answers Forum
GUI problem - Fields not showing

1 reply on 1 page. Most recent reply: Jun 8, 2012 3:16 AM by Stephanie Dijkstra

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Stephanie Dijkstra

Posts: 2
Nickname: stephanie
Registered: Jun, 2012

GUI problem - Fields not showing Posted: Jun 8, 2012 2:31 AM
Reply to this message Reply
Advertisement
Hey guys,

I really hope you can help me. I'm using eclipse indigo with the windowbuilder.


Now, I made most off this code by myself without the builder but when I run it, it doesnt show any fields until I move my mouse over it. it doesnt show the labels at all.(while it does in the builder)


I really hope you can help me, here is my code: (I'm dutch so the labels and names won't make much sense to you)


package boundary;
 
import java.awt.*;
import javax.swing.*;
 
public class Guihartigehap2 extends JFrame{
 
	private JTextField txtOmschrijving;
	private JTextField txtTafelNr;
	private JTextArea txtRekening;
	private JLabel lblActiesToevoegen;
	private JLabel lblActieType;
	private JLabel lblProduct;
	private JLabel lblOmschrijving;
	private JLabel lblRekening;
	private JLabel lblTafelNummer;
	private JButton btnVoegToe;
	private JButton btnToonRekening;
	private JComboBox cmbActieType;
	private JComboBox cmbProduct;
	private static JFrame HoofdFrame;
	private static Frame Frame;
	private Container cp;
 
	public Guihartigehap2() {
		MakeGUI();
	}
 
	public void setframe(){
		new Frame();
		cp.validate();
	}
 
	public static JFrame getJframe(){
 
		return HoofdFrame;
	}
 
 
	public void MakeGUI(){
 
		HoofdFrame = new JFrame("Acties");
		HoofdFrame.setResizable(false); 
		HoofdFrame.setSize(750, 300);
		HoofdFrame.setVisible(true);
		HoofdFrame.setDefaultCloseOperation(EXIT_ON_CLOSE); // Programma volledig afsluiten
 
 
		cp = HoofdFrame.getContentPane();
 
		txtOmschrijving = new JTextField("2 halen 1 betalen");
		txtOmschrijving.setBounds(103, 165, 150, 20);
 
		txtRekening = new JTextArea("Rekening");
		txtRekening.setBounds(375, 35, 300, 145);
 
		txtTafelNr = new JTextField("22");
		txtTafelNr.setBounds(447, 190, 50, 20);
 
 
 
		lblActiesToevoegen = new JLabel("Actie Toevoegen:");
		lblActiesToevoegen.setBounds(10, 10, 88, 14);
 
		lblRekening = new JLabel("Rekening");
		lblRekening.setBounds(375, 10, 88, 14);
 
		lblActieType = new JLabel ("Actie type:");
		lblActieType.setBounds(10, 91, 58, 14);
 
		lblProduct = new JLabel ("Product:");
		lblProduct.setBounds(10, 129, 46, 14);
 
		lblOmschrijving = new JLabel ("Omschrijving");
		lblOmschrijving.setBounds(10, 168, 88, 14);
 
		lblTafelNummer = new JLabel ("Tafelnummer");
		lblTafelNummer.setBounds(375, 193, 62, 14);
 
 
 
		btnToonRekening = new JButton ("Toon rekening");
		btnToonRekening.setBounds(582, 200, 100, 30);
 
		HoofdFrame.getContentPane().setLayout(null);
 
		btnVoegToe = new JButton("Voeg toe");
		btnVoegToe.setBounds(153, 200, 100, 30);
 
 
		cmbActieType = new JComboBox();
		cmbActieType.setBounds(103, 88, 150, 20);
 
		cmbProduct = new JComboBox();
		cmbProduct.addItem("Koffie");
		cmbProduct.addItem("Pizza");
		cmbProduct.setBounds(103, 126, 150, 20);
 
		cp.add(txtOmschrijving);
		cp.add(txtRekening);
		cp.add(txtTafelNr);
 
		cp.add(lblActiesToevoegen);
		cp.add(lblRekening);
		cp.add(lblActieType);
		cp.add(lblProduct);
		cp.add(lblOmschrijving);
		cp.add(lblTafelNummer);
 
		cp.add(btnToonRekening);
		cp.add(btnVoegToe);
 
		cp.add(cmbProduct);
		cp.add(cmbActieType);
 
		cp.validate();
	}	
 
}
 


Stephanie Dijkstra

Posts: 2
Nickname: stephanie
Registered: Jun, 2012

Re: GUI problem - Fields not showing Posted: Jun 8, 2012 3:16 AM
Reply to this message Reply
never mind, fixed it.

just had to dispose() after the last line

Flat View: This topic has 1 reply on 1 page
Topic: generate a random number Previous Topic   Next Topic Topic: New JSON tool for front end developers

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use