It's not a secret anymore!
The moose likes Swing / AWT / SWT and the fly likes Won't Display Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Won Watch "Won New topic

Won't Display

Chase Becicka

Joined: Feb 16, 2004
Posts: 23
I have been trying to figure out why when I execute this code all I get is a little bar at the top of the screen without any of my Labels or Buttons please help with a debug

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.text.*;

public class inventFrame extends JFrame
public void BankingGUIFrame()
setTitle("Teller Program");
Toolkit tk = Toolkit.getDefaultToolkit();
Dimension d = tk.getScreenSize();
int height = 200;
int width = 267;
setBounds((d.width-width)/2, (d.height-height)/2, width, height);
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
Container contentPane = getContentPane();
JPanel panel = new BankingGUIPanel();

public static void main(String[] args)
JFrame frame = new inventFrame();;

class BankingGUIPanel extends JPanel implements ActionListener
private JTextField custNumTF, custNameFTF, custNameMITF, custNameLTF;
private JLabel custNumL, custNameFL, custNameMIL, custNameLL;
private JButton exitButton;

public BankingGUIPanel()
JPanel displayPanel = new JPanel();
displayPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));

custNumL = new JLabel("Customer Number: ");
custNameFL = new JLabel("First Name: ");
custNameMIL = new JLabel("Middle Inital: ");
custNameLL = new JLabel("Last Name: ");

custNumTF = new JTextField(10);
custNameFTF = new JTextField(10);
custNameMITF = new JTextField(10);
custNameLTF = new JTextField(10);


JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
exitButton = new JButton("Exit");


setLayout(new BorderLayout());
add(displayPanel, BorderLayout.CENTER);
add(buttonPanel, BorderLayout.SOUTH);
public void actionPerformed(ActionEvent e)
Object source = e.getSource();

if (source == exitButton)


Ransika deSilva
Ranch Hand

Joined: Feb 18, 2003
Posts: 524
I figured out why it is not appearing. You have to change the main method.

BankingGUIFrame() is a method and it is not a constructor, so it will not be automatically created when you create an object of the class inventFrame. To call that you need an instance of the class inventFrame, you can't have Frame frame = new inventFrame(); and use that frame instance to call the BankingGUIFrame() cause that reference can't call that method.
Hope you got the point. BTW, it's better you name the classes according to the Hungerian Notation (the 1st letter of all the words should be in capital, example: InventFrame), Have a nice day...

SCJP 1.4, SCMAD 1.0<br />SCWCD, SCBCD (in progress)
Chase Becicka

Joined: Feb 16, 2004
Posts: 23
Okay I can see my JFrame now but I can't see my panels I created unless I resize my JFrame but I don't want my JFrame to be resizeable in the end. Should I just switch to a easier Layout Manager or is there an easy fix

what I am trying to get this to do is go gown vertically like this

Label TF
Label TF
Label TF


Heres the cod eupdated again
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
I agree. Here's the link:
subject: Won't Display
It's not a secret anymore!