The StudentForm Class


Listing 16.3 StudentForm.java


import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.rmi.*;
import java.sql.*;

//Student entry form 
class StudentForm extends JInternalFrame{

  //instance variables
  private JTextField
    txtRollNumber = null,
    txtName = null,
    txtCourse = null;
  
  // reference to the remote object.	
  private DatabaseInterface server = null;
	
  //constructor
  public StudentForm(){
	
	//Create a JInternalFrame with 
	//the specified title 
	//and with resizability, closability, 
	//maximizability, 
	//and iconifiability specified. 
	super("Student Form",true,true,false,true);
		
	//method used to create components and to get
	//a reference to the remote object.
	setup();
		
	//Set the operation that will 
	//happen by default when 
	//the user initiates a 
	//"close" on this frame		
	this.setDefaultCloseOperation(
		JInternalFrame.DISPOSE_ON_CLOSE);
		
	//pack() causes subcomponents of this 
	//JInternalFrame to be laid 
	//out at their preferred size.
	pack();
		
	//Move this component to a new location. 
	setLocation(10,10);
		
	//Show this internal frame.
	show();

}

//Method used to create components and to get //a remote reference. private void setup(){ //get the content pane object. Container cp = getContentPane(); //Panels for placing different components. JPanel topPanel,centerPanel,btnPanel; //create panels topPanel = SwingComp.createPanel( cp,BorderLayout.NORTH,new GridLayout(1,1)); centerPanel = SwingComp.createPanel( cp,BorderLayout.CENTER,new GridLayout(3,2)); //Create a new ButtonPanel object. btnPanel = new ButtonPanel(new ButtonHandler()); //add the component to this //container(s) layout using the //specified constraints object. cp.add(btnPanel,BorderLayout.SOUTH); //Set the border of this panel centerPanel.setBorder( BorderFactory.createEmptyBorder(35,20,35,20)); //{{Create labels, text boxes}} // JLabel lblTitle,lblRollNumber,lblName,lblCourse; lblTitle = SwingComp.createLabel( topPanel,"STUDENT INFORMATION",JLabel.CENTER); lblRollNumber = SwingComp.createLabel( centerPanel,"Roll Number"); txtRollNumber = SwingComp.createTextField(centerPanel,10); lblName = SwingComp.createLabel(centerPanel,"Name"); txtName = SwingComp.createTextField(centerPanel,10); lblCourse = SwingComp.createLabel(centerPanel,"Course"); txtCourse = SwingComp.createTextField(centerPanel,10); // get a reference to the remote object. try{ server = MDI.getServerObject(); }catch(Exception ex){ System.out.println(ex.getMessage()); } }

 

 

RMI BOOK MAIN PAGE                Top

  
Copyright © 2001 www.universalteacher.com