TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 04-21-2009, 01:14 PM   #1 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default Anyone here knows Java?

Heya!
I don't know where to post this, so the Lounge it is!

Anyway, I have a problem with my Java script(not JavaScript - Java script), and I'm wondering if someone could help me out what the problem(s) is(/are)?

With syntax highlighting: http://pastebin.com/m4666a6ed
With no syntax highlighting:
Code:
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;

public class GUI extends JFrame implements ActionListener
{
	
	private static final String FRAME_TITLE = "Bank";
	
	private static final int FRAME_WIDTH = 600;
	private static final int FRAME_HEIGHT = 400;
	
	private static final int FRAME_X_ORIGIN = 300;
	private static final int FRAME_Y_ORIGIN = 350;
	
	private JMenu fileMenu;
	private JMenuBar menuBar;
	
	private Container cont;
	
	private JTextField addCust_socNr;
	private JTextField addCust_name;
	private JButton addCust_add;
	
	public static void main(String[] args)
	{
		
		GUI frame = new GUI();
		frame.setVisible(true);
		
	}
	
	public GUI()
	{
		
		this.initiate();
		this.build();
		
	}
	
	public void initiate()
	{
		
		this.cont = this.getContentPane();
		this.menuBar = new JMenuBar();
		setJMenuBar(this.menuBar);
		
	}
	
	public void build()
	{
		
		this.buildFileMenu();
		
		this.setTitle(FRAME_TITLE);
		this.setSize(FRAME_WIDTH, FRAME_HEIGHT);
		this.setLocation(FRAME_X_ORIGIN, FRAME_Y_ORIGIN);
		this.setResizable(false);
		
		this.setDefaultCloseOperation(EXIT_ON_CLOSE);
		
	}
	
	public void actionPerformed(ActionEvent event)
	{
		
		String option;
		
		option = event.getActionCommand();
		if(option.equals("Quit"))
		{
			
			System.exit(0);
			
		}
		
		else if(option.equals("New customer"))
		{
			
			this.addCustomer();
			
		}
		
		else if(option.equals("Import customer"))
		{
			
			JOptionPane.showMessageDialog(null, "This is not supported yet.");
			
		}
		
	}
	
	public void buildFileMenu()
	{
		
		this.fileMenu = new JMenu("File");
		
		
		JMenuItem newCustomer = new JMenuItem("New customer");
		newCustomer.addActionListener(this);
		
		JMenuItem openCustomer = new JMenuItem("Import customer");
		openCustomer.addActionListener(this);
		
		JMenuItem closeProgram = new JMenuItem("Quit");
		closeProgram.addActionListener(this);
		
		this.fileMenu.add(newCustomer);
		this.fileMenu.add(openCustomer);
		this.fileMenu.addSeparator();
		this.fileMenu.add(closeProgram);
		
		this.menuBar.add(this.fileMenu);
		
	}
	
	public void addCustomer()
	{
		
		this.cont.setLayout(new BorderLayout());
		
		
		JPanel mainContainer = new JPanel();
		mainContainer.setLayout(new GridLayout(2, 1));
		
		JPanel leftContainer = new JPanel();
		leftContainer.setLayout(new GridLayout(2, 1));
		
		
		this.addCust_socNr = new JTextField();
		this.addCust_socNr.setColumns(22);
		
		this.addCust_name = new JTextField();
		this.addCust_name.setColumns(22);
		
		this.addCust_add = new JButton("Add");
		this.addCust_add.addActionListener(this);
		
		mainContainer.add(this.addCust_socNr);
		mainContainer.add(this.addCust_name);
		leftContainer.add(this.addCust_add);
		
		this.cont.add(leftContainer, BorderLayout.WEST);
		this.cont.add(mainContainer, BorderLayout.CENTER);
		
	}
	
}
When I click "New customer" it should show a complete layout.. but it doesn't show anything. I tried just doing this.setTitle to change the title when I'm in addCustomer method - it works, so it gets directed to the method properly.. it just doesn't add the layout..

Anyone?
__________________
Tanax is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
passing a java variable to php pipesportugal Advanced PHP Programming 11 08-27-2009 10:49 PM
Should I drop PHP for Java? webosb General 11 04-05-2009 06:58 AM
Bit of a java question Enfernikus The Lounge 3 08-09-2008 11:18 AM
Java Server Pages really worth it? Orc The Lounge 6 03-24-2008 08:04 PM
Where do start Java from? Haris The Lounge 23 01-23-2008 11:02 PM


All times are GMT. The time now is 08:32 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design