Wrox Programmer Forums
|
Java GUI Discussions specific to programming Java GUI.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java GUI section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 20th, 2003, 02:42 PM
Registered User
 
Join Date: Aug 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default very basic gui

I'm very new to Java and would like to make a simple GUI. It should have a text message and two buttons: one that closes the window, and one that opens a file on my hard drive. My question is what kind of object would be best suited to this purpose: JFrame, Window, JDialog, etc. Thanks in advance!

 
Old August 27th, 2003, 12:14 PM
Authorized User
 
Join Date: Aug 2003
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to egolileopablo Send a message via Yahoo to egolileopablo
Default

Sample of what you want?
Try using JFrame,JButton,JPanel, or try this codes and see.

//import java's core pakage
import java.awt.*;

//import java's extensive pakage
import javax.swing.*;

//class definition
public class SimpleGui extends JFrame {

  JButton cbtn; //close button
  JButton obtn; //open button
  JPanel panel;

  //setting the GUI window
  public SimpleGui() {
    super("Simple GUI");
    Container c = getContentPane();
    c.setLayout(new BorderLayout());

    panel = new JPanel();
    panel.setLayout(new FlowLayout());

    cbtn = new JButton("Open");
    panel.add(cbtn);

    obtn = new JButton("Close");
    panel.add(obtn);

    c.add(panel, BorderLayout.SOUTH);


    setSize(200,200);
    setVisible(true);
    //pack();
  }

  public static void main(String args[]) {

    SimpleGui sg = new SimpleGui();
    sg.setDefaultCloseOperation(EXIT_ON_CLOSE);

  }
}






Similar Threads
Thread Thread Starter Forum Replies Last Post
Gui program P.Wheat Windows Server 0 February 23rd, 2008 11:06 PM
visual basic n GUI enggenius Visual Basic 2005 Basics 1 January 23rd, 2007 08:39 AM
GUI question hlchuah77 C++ Programming 2 October 4th, 2004 07:10 PM
GUI questions hlchuah77 Java GUI 2 August 24th, 2004 09:23 AM
help in GUI khfarooq Java GUI 5 August 22nd, 2004 05:00 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.