Varie ed eventuali.....
Diventa un utente di Giorgione's Site, adesso!
Menu Sito
Tempo libero
Articoli
Tutorials
SmartFAQ is developed by The SmartFactory (http://www.smartfactory.ca), a division of InBox Solutions (http://www.inboxsolutions.net)

FINESTRA LOGIN (MYSQL)
Proposta e Risposta da Admin il 01-May-2007 01:09 (285 letture)
package cont_pack;
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.table.*;
import javax.swing.event.*;
import javax.swing.border.*;
/**
*
* @author giorgio
*/
public class login implements LayoutManager{

static String[] ConnectOptionNames = { "Connetti" };
static String ConnectTitle = "Informazioni Connessione";
JButton fetchButton;
JButton showConnectionInfoButton;
Dimension origin = new Dimension(0, 0);
JPanel connectionPanel;
JFrame frame;
JLabel userNameLabel;
JTextField userNameField;
JLabel passwordLabel;
JTextField passwordField;
JLabel databaseLabel;
JTextField databaseField;
// JLabel queryLabel;
JTextArea queryTextArea;
JComponent queryAggregate;
JLabel serverLabel;
JTextField serverField;
JLabel driverLabel;
JTextField driverField;
JPanel mainPanel;
JScrollPane tableAggregate;

/**
* Brigs up a JDialog using JOptionPane containing the connectionPanel.
* If the user clicks on the 'Connect' button the connection is reset.
*/
void activateConnectionDialog() {
if(JOptionPane.showOptionDialog(tableAggregate, connectionPanel, ConnectTitle,
JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE,
null, ConnectOptionNames, ConnectOptionNames[0]) == 0) {
System.out.println("Login effettuato");
//frame.setVisible(true);
}
else if(!frame.isVisible())
System.exit(0);
}
/** Creates a new instance of login */
/**
* Creates the connectionPanel, which will contain all the fields for
* the connection information.
*/
public void createConnectionDialog() {
// Create the labels and text fields.
userNameLabel = new JLabel("User name: ", JLabel.RIGHT);
userNameField = new JTextField("root");

passwordLabel = new JLabel("Password: ", JLabel.RIGHT);
passwordField = new JTextField("");

databaseLabel = new JLabel("Database: ", JLabel.RIGHT);
databaseField = new JTextField("mycash");

serverLabel = new JLabel("Database Host: ", JLabel.RIGHT);
serverField = new JTextField("localhost");

driverLabel = new JLabel("Driver: ", JLabel.RIGHT);
driverField = new JTextField("com.mysql.jdbc.Driver");


connectionPanel = new JPanel(false);
connectionPanel.setLayout(new BoxLayout(connectionPanel,
BoxLayout.X_AXIS));

JPanel namePanel = new JPanel(false);
namePanel.setLayout(new GridLayout(0, 1));
namePanel.add(userNameLabel);
namePanel.add(passwordLabel);
namePanel.add(databaseLabel);
namePanel.add(serverLabel);
namePanel.add(driverLabel);

JPanel fieldPanel = new JPanel(false);
fieldPanel.setLayout(new GridLayout(0, 1));
fieldPanel.add(userNameField);
fieldPanel.add(passwordField);
fieldPanel.add(databaseField);
fieldPanel.add(serverField);
fieldPanel.add(driverField);

connectionPanel.add(namePanel);
connectionPanel.add(fieldPanel);

}
public login() {
mainPanel = new JPanel();


// Create the panel for the connection information
createConnectionDialog();

// Create the buttons.
showConnectionInfoButton = new JButton("Configuration");
showConnectionInfoButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
activateConnectionDialog();
}
}
);
activateConnectionDialog();
}

//public static void main(String s[]) {
// new login();
// }

public Dimension preferredLayoutSize(Container c){
return origin;
}
public Dimension minimumLayoutSize(Container c){
return origin;
}
public void addLayoutComponent(String s, Component c) {
}
public void removeLayoutComponent(Component c) {
}
public void layoutContainer(Container c) {
Rectangle b = c.getBounds();
int topHeight = 90;
int inset = 4;
showConnectionInfoButton.setBounds(b.width-2*inset-120, inset, 120, 25);
fetchButton.setBounds(b.width-2*inset-120, 60, 120, 25);
// queryLabel.setBounds(10, 10, 100, 25);
queryAggregate.setBounds(inset, inset, b.width-2*inset - 150, 80);
tableAggregate.setBounds(new Rectangle(inset,
inset + topHeight,
b.width-2*inset,
b.height-2*inset - topHeight));

}

}


I commenti sono proprietą dei rispettivi autori. Non siamo in alcun modo responsabili del loro contenuto.
Cerca
Download recenti
Login
Nome utente:

Password:


Hai perso la password?

Registrati ora!
Lascia un commento