Académique Documents
Professionnel Documents
Culture Documents
/****************************************************************/
/* Login */
/* */
/****************************************************************/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/**
* Summary description for Login
*
*/
public class Login extends JFrame
{
// Variables declaration
private JLabel title;
private JLabel nodnam;
private JLabel image;
private JTextField nod_txt;
private JButton submit;
private JPanel contentPane;
// End of variables declaration
public Login()
{
super();
initializeComponent();
//
// TODO: Add any constructor code after initializeComponent call
//
this.setVisible(true);
}
// title
// nodnam
nodnam.setText("Node Name");
nodnam.setBackground(new Color(50, 106, 168));
nodnam.setForeground(new Color(255,153,153));
nodnam.setFont(new Font("helvetica", Font.BOLD, 15));
//nodnam.setOpaque(true);
//image
image.setIcon(new ImageIcon("login.jpg"));
// nod_txt
nod_txt.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
nod_txt_actionPerformed(e);
}
});
// submit
submit.setText("Login");
submit.setBackground(new Color(86,86,86));
submit.setForeground(new Color(254,60,0));
submit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
submit_actionPerformed(e);
}
});
// contentPane
contentPane.setLayout(null);
contentPane.setBackground(new Color(84, 120, 176));
contentPane.setForeground(new Color(111, 213, 232));
addComponent(contentPane, title, 240,130,315,58);
addComponent(contentPane, nodnam, 255,221,90,29);
addComponent(contentPane,image, -15,-35,453,534);
addComponent(contentPane, nod_txt, 355,221,100,22);
addComponent(contentPane, submit, 359,290,83,34);
// Login frame
Sample coding—2
/****************************************************************/
/* nodelogin */
/* */
/****************************************************************/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
/**
* Summary description for nodelogin
*
*/
public class NodeLogin extends JFrame
{
// Variables declaration
private JLabel title;
private JLabel nodename;
private JLabel portno;
private JLabel image;
private JLabel systemname;
private JTextField jTextField1_node;
private JTextField jTextField2_port;
private JTextField jTextField3_system;
private JButton jButton1_login;
private JButton jButton2_clear;
private JPanel contentPane;
int topo_size,j=1;
String str_node="",str_sysname="";
int port;
//Database db=new Database();
//Statement st_obj=db.connect();
ResultSet rs;
// End of variables declaration
image.setText("image");
image.setIcon(new ImageIcon("nodes.jpg"));
//
// title
//
title.setText(" Node Login Details");
//
// jTextField1_node
//
jTextField1_node.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
jTextField1_node_actionPerformed(e);
}
});
//
// jTextField2_port
//
jTextField2_port.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
jTextField2_port_actionPerformed(e);
}
});
//
// jTextField3_system
//
jTextField3_system.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
jTextField3_system_actionPerformed(e);
}
});
// jButton1_login
//
jButton1_login.setText("Login");
jButton1_login.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
});
//
// jButton2_clear
//
jButton2_clear.setText("Clear");
jButton2_clear.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
jButton2_clear_actionPerformed(e);
}
});
//
// contentPane
//
contentPane.setLayout(null);
}
private void jButton1_login_actionPerformed(ActionEvent e)
{
System.out.println("\njButton1_login_actionPerformed(ActionEvent e)
called.");
jTextField1_node.setText("");
jTextField2_port.setText("");
jTextField3_system.setText("");
}
//============================= Testing
================================//
//= =//
//= The following main method is just for testing this class you built.=//
//= After testing,you may simply delete it. =//
//==============================================================
========//
public static void main(String[] args)
{
JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true);
try
{
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"
);
new NodeLogin(3);
}
catch (Exception ex)
{
System.out.println("Failed loading L&F: ");
System.out.println(ex);
}
//new NodeLogin();
}
//= End of Testing =
}
//============================= Testing
================================//
//= =//
//= The following main method is just for testing this class you built.=//
//= After testing,you may simply delete it. =//
//==============================================================
========//
public static void main(String[] args)
{
JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true);
try
{
//UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.Mot
ifLookAndFeel");
}
catch (Exception ex)
{
System.out.println("Failed loading L&F: ");
System.out.println(ex);
}
new Login();
}