Jframe

How to use Jframe package

Page 1 of 1

2 Replies - 682 Views - Last Post: 29 November 2009 - 10:22 AM Rate Topic: -----

#1 PAYDAY  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 29-November 09

Jframe

Post icon  Posted 29 November 2009 - 12:28 AM

Please can i be able to convert my simple program which is executing in cmd interface to simple graphical user interface program.
Is This A Good Question/Topic? 0
  • +

Replies To: Jframe

#2 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4421
  • View blog
  • Posts: 12,286
  • Joined: 18-April 07

Re: Jframe

Posted 29 November 2009 - 12:44 AM

Well sure. You just have to import the javax.swing package into your project. From there, you create your class to then extend "JFrame".

import javax.swing.*;  // Import javax.swing

public class MySwingClass extends JFrame {
	 public MySwingClass() {
		  // Code here which puts GUI elements on the JFrame
	 }

	 public static void main(String args[]) {
		  // Create an instance of our class which is of type JFrame
		  MySwingClass myprogram = new MySwingClass();

		  // Set the size, title, how to close and finally show it.
		  myprogram.setSize(300,300);
		  myprogram.setTitle("My JFrame Project");
		  myprogram.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		  myprogram.setVisible(true);
	 }
}



You can then run this from the command line as usual.... javac MySwingClass.java

:)
Was This Post Helpful? 0
  • +
  • -

#3 Dogstopper  Icon User is offline

  • The Ninjaducky
  • member icon



Reputation: 2876
  • View blog
  • Posts: 11,051
  • Joined: 15-July 08

Re: Jframe

Posted 29 November 2009 - 10:22 AM

Yes, there are several Swing tutorials in the Java tutorials section. Swing allows for an awesome GUI. (Graphical User Interface)

-- Cheers!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1