The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> Java Help
|
Using Java Swing class, how do I make my window bigger!?
Discuss Using Java Swing class, how do I make my window bigger!? in the Java Help forum on Dev Shed. Using Java Swing class, how do I make my window bigger!? Java Help forum discussing all Java platforms - J2ME, J2SE and J2EE - as well as relevant standards, APIs and frameworks such as Swing, Servlets, JSPs, Applets, Struts, Spring, Hibernate, ANT, EJB, and other Java-related topics.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

December 2nd, 2012, 11:07 AM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 28
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!
|

December 2nd, 2012, 03:41 PM
|
 |
Contributing User
|
|
Join Date: Aug 2010
Location: SW Missouri
|
|
|
You can set the size of the window by calling a Window class method.
The setLocationRelativeTo(null) method will center the window.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|