Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 2nd, 2012, 11:07 AM
cgodfrey987 cgodfrey987 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 28 cgodfrey987 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 14 m 21 sec
Reputation Power: 0
Using Java Swing class, how do I make my window bigger!?

can someone help me figure out how to make my window bigger on this program? I know it's not complete, but should at least be able to make the window larger, I'd think! And how to get it to open and start in the center of the screen!?

here is my code so far:

Code:
package financialCalc;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class FinancialCalc extends JFrame
{
	private JPanel welcomePanel, greetingPanel, buttonPanel, blank, blank2;
	private JLabel message;
	private JButton autoPmt, mortPmt, homeAfford, costOfMin, exit;
	
	
	public FinancialCalc()
	{
		super("Financial Calculator Application");
		
		
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		setLayout(new BorderLayout());
		
		
		
		
		
		buildWelcomeMenu();
		
		add(greetingPanel, BorderLayout.NORTH);
		add(welcomePanel, BorderLayout.CENTER);
		add(buttonPanel, BorderLayout.SOUTH);
		add(blank, BorderLayout.EAST);
		add(blank2, BorderLayout.WEST);
		
		
		pack();
		setVisible(true);
		
		
		
		
	}
		
	
	public void buildWelcomeMenu()
	{
		welcomePanel = new JPanel();
		welcomePanel.setLayout(new GridLayout(4,1));
		//welcomePanel.setSize(720, 1080);
		
		
		autoPmt = new JButton("Auto loan payment calculator");
		autoPmt.setMnemonic(KeyEvent.VK_A);
		autoPmt.addActionListener(new AutoButtonListener());
		
		mortPmt = new JButton("Mortgage payment calculator");
		mortPmt.setMnemonic(KeyEvent.VK_M);
		mortPmt.addActionListener(new MortButtonListener());
		
		homeAfford = new JButton("How much home can you afford?");
		homeAfford.setMnemonic(KeyEvent.VK_H);
		homeAfford.addActionListener(new HomeButtonListener());
		
		costOfMin = new JButton("True cost of paying the minimum payment");
		costOfMin.setMnemonic(KeyEvent.VK_C);
		costOfMin.addActionListener(new CostMinButtonListener());
		
		buttonPanel = new JPanel();
		exit = new JButton("Exit");
		exit.setMnemonic(KeyEvent.VK_E);
		exit.addActionListener(new ExitButtonListener());
		buttonPanel.add(exit);
		
		welcomePanel.add(autoPmt);
		welcomePanel.add(mortPmt);
		welcomePanel.add(homeAfford);
		welcomePanel.add(costOfMin);
	
		
		greetingPanel = new JPanel();
		message = new JLabel("Welcome to the Financial Calculations Application");
		greetingPanel.add(message);
		
		blank = new JPanel();
		blank2 = new JPanel();
		
	}
	
	
	private class AutoButtonListener implements ActionListener
	{
		public void actionPerformed(ActionEvent e)
		{
	
			
			
		}
	
	}
	
	private class MortButtonListener implements ActionListener
	{
		public void actionPerformed(ActionEvent e)
		{
	
			
			
		}
	
	}
	
	private class HomeButtonListener implements ActionListener
	{
		public void actionPerformed(ActionEvent e)
		{
	
			
			
		}
	
	}
	
	private class CostMinButtonListener implements ActionListener
	{
		public void actionPerformed(ActionEvent e)
		{
	
			
			
		}
	
	}
	
	
	private class ExitButtonListener implements ActionListener
	{
		public void actionPerformed(ActionEvent e)
		{
			System.exit(0);			
		}
	
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	public static void main(String[] args) 
	{
		new FinancialCalc();

	}

}


thanks so much for your help in advance!

Reply With Quote
  #2  
Old December 2nd, 2012, 03:41 PM
NormR's Avatar
NormR NormR is offline
Contributing User
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Aug 2010
Location: SW Missouri
Posts: 3,048 NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 16 h 53 m 14 sec
Reputation Power: 346
You can set the size of the window by calling a Window class method.

The setLocationRelativeTo(null) method will center the window.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > Using Java Swing class, how do I make my window bigger!?

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap