1,105,363 Community Members

Help for java Programs that includes GUI

Member Avatar
archie.herbias
Junior Poster in Training
55 posts since Sep 2011
Reputation Points: -2 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Can you suggest a program that i can submit?
I need your help for suggestions..
any programs that involves GUI..
simple programs could be..

Thank you!

Member Avatar
stevanity
Posting Whiz
304 posts since Oct 2010
Reputation Points: 4 [?]
Q&As Helped to Solve: 28 [?]
Skill Endorsements: 0 [?]
 
0
 

Write a GUI program that has 3 text fields. Get two values in the two text fields and display sum in the third field. ANd Use a button to do this...
(assuming ure just starting out)

Member Avatar
Taywin
Posting Maven
2,632 posts since Apr 2010
Reputation Points: 134 [?]
Q&As Helped to Solve: 378 [?]
Skill Endorsements: 17 [?]
 
1
 

GUI is just a shell wrapping around your real work. In other words, it is more like a presentation. If you have done any program that displays results on monitor, you can add GUI to it, such as replace how you enter inputs or display the output.

Member Avatar
archie.herbias
Junior Poster in Training
55 posts since Sep 2011
Reputation Points: -2 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Write a GUI program that has 3 text fields. Get two values in the two text fields and display sum in the third field. ANd Use a button to do this...
(assuming ure just starting out)

It is just my first time.. we have a project in school.. can you suggest any simple but useful program that i can submit? thank you for helping.. i really need this..

Member Avatar
archie.herbias
Junior Poster in Training
55 posts since Sep 2011
Reputation Points: -2 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

GUI is just a shell wrapping around your real work. In other words, it is more like a presentation. If you have done any program that displays results on monitor, you can add GUI to it, such as replace how you enter inputs or display the output.

i have done some GUI examples but i do not know how to arrange the buttons i made... can you help me on how to code in making specific location of the buttons i made? i really need it for my project.. thank you so much for your reply..

Member Avatar
stevanity
Posting Whiz
304 posts since Oct 2010
Reputation Points: 4 [?]
Q&As Helped to Solve: 28 [?]
Skill Endorsements: 0 [?]
 
0
 

Use a LayoutManager of your choice. Hard Coding components to specific locations is tough and not recommended. Use the LayoutManagers.

Look here:

http://download.oracle.com/javase/tutorial/uiswing/layout/visual.html
Member Avatar
archie.herbias
Junior Poster in Training
55 posts since Sep 2011
Reputation Points: -2 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Use a LayoutManager of your choice. Hard Coding components to specific locations is tough and not recommended. Use the LayoutManagers.

Look here:

http://download.oracle.com/javase/tutorial/uiswing/layout/visual.html

What program can i made?? i'm just a beginner.. please help..

Member Avatar
leiger
Junior Poster in Training
91 posts since Jun 2010
Reputation Points: 14 [?]
Q&As Helped to Solve: 7 [?]
Skill Endorsements: 0 [?]
 
1
 

Try BorderLayout. I'll try to give you a step-by-step walkthrough:

  1. Create a JFrame - public class MyFrame extends JFrame { ... }
  2. Get the content pane - JPanel contentPane = (JPanel) this.getContentPane()
  3. Set layout manager to BorderLayout - contentPane.setLayout(new BorderLayout())
  4. Add a text area in the centre of the frame - contentPane.add(new JTextArea("my text"), BorderLayout.CENTER)
  5. Add a button to the top of the frame - contentPane.add(new JButton("my button"), BorderLayout.NORTH)
  6. Make the frame visible so you can actually see all of this - this.setVisible(true)

Some slightly more difficult things to try:

  • Create the JButton and JTextArea outside of the method call so that you can reference them with a variable later - private JButton myButton = new JButton("my button");
  • Create a listener for the button, that changes the text in the JTextArea when it is clicked - myButton.addActionListener(this) , and put code into an actionPerformed(...) method
You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: