Java - Ayuda para principiante en java

 
Vista:

Ayuda para principiante en java

Publicado por andres2704 (5 intervenciones) el 02/07/2008 20:04:06
Necesito que x favor alguien me ayude, estoy haciendo una aplocacion java en JCreator pro, el cual transfiere archivos a otra pc usando sockets, ese no es el problema, el problema es que necesito saber como crear la tipica opcion que usamos para copiar un archivo, es decir el EXPLORAR, el cual te permite acceder a las carpetar que hay en la pc, es decir nevaga libremente x discos c, mis documentos, etc, necesito como hacer eso x favor....
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:Ayuda para principiante en java

Publicado por Rene Gonzalez (115 intervenciones) el 04/07/2008 00:47:44
Con la clase JFileChooser puedes elegir archivos al estilo de la opcion de menu "Abrir". No se si es lo que necesitas.

http://java.sun.com/docs/books/tutorial/uiswing/components/filechooser.html
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:Ayuda para principiante en java

Publicado por andres2704 (5 intervenciones) el 05/07/2008 05:55:05
gracias lo consultare, aunque ahora cambie el compilador, estoy trabajando en netbeans 6.0, sirve igua ahi?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:Ayuda para principiante en java

Publicado por Rene Gonzalez (115 intervenciones) el 06/07/2008 03:37:44
Tambien sirve. Suerte
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:Ayuda para principiante en java

Publicado por andres2704 (5 intervenciones) el 08/07/2008 20:00:10
Que Fue pana ayudame con un inveniente es que quiero agreagae un java awt un paquete que me permita instanciar un package org.desktop.layout como eso por que intente hacerlo como un import y no salio.
Este es lo que intento hacer

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.sql.*;
import java.io.*;
import java.net.*;
import javax.swing.JOptionPane;
Package org.*;

public class FileTransfer{
public static void main(String args[]){

singIn Filetr=new singIn();
Filetr.setVisible(true);

}
}

class singIn extends JFrame {
// Variables declaration - do not modify
private JButton jButton1;
private JButton jButton2;
private JButton jButton3;
private JLabel jLabel1;
private JLabel jLabel2;
private JLabel jLabel3;
private JLabel jLabel4;
private JPasswordField jPasswordField1;
private JSeparator jSeparator2;
private JTextField jTextField1;
// End of variables declaration
public singIn(){

jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jTextField1 = new javax.swing.JTextField();
jPasswordField1 = new javax.swing.JPasswordField();
jLabel4 = new javax.swing.JLabel();
jSeparator2 = new javax.swing.JSeparator();
jButton3 = new javax.swing.JButton();
// super("Login...");
setSize(250,200);
super.setResizable(false);

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setBackground(new java.awt.Color(51, 153, 255));

jLabel1.setFont(new java.awt.Font("Berlin Sans FB", 0, 24));
jLabel1.setText("Verificacion de usuario");

jLabel2.setFont(new java.awt.Font("Berlin Sans FB", 0, 18));
jLabel2.setText("Usuario:");

jLabel3.setFont(new java.awt.Font("Berlin Sans FB", 0, 18));
jLabel3.setText("Contraseña:");

jButton1.setText("INGRESAR");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

jButton2.setText("SALIR");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});

jLabel4.setText("Nuevo usuario?");

jButton3.setText("Resgistrate aqui!!");

org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(34, 34, 34)
.add(jLabel4)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jButton3)
.addContainerGap(53, Short.MAX_VALUE))
.add(org.jdesktop.layout.GroupLayout.TRAILING, jSeparator2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 284, Short.MAX_VALUE)
.add(layout.createSequentialGroup()
.add(35, 35, 35)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 239, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
.add(layout.createSequentialGroup()
.add(10, 10, 10)
.add(jButton1)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(jButton2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 87, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jLabel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 72, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel3))
.add(22, 22, 22)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
.add(jPasswordField1)
.add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 108, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))))
.addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
.addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(jLabel1)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel2)
.add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel3)
.add(jPasswordField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jButton1)
.add(jButton2))
.add(18, 18, 18)
.add(jSeparator2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 10, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel4)
.add(jButton3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 13, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(18, 18, 18))
);


pack();
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String cnx = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=(C:\datos)";
Connection con=DriverManager.getConnection("jdbc:odbc:BDD","","");
java.sql.Statement stat = con.createStatement();
if (con == null)
JOptionPane.showMessageDialog(null,"No conectado.");
}catch(ClassNotFoundException e){
System.out.println("Clase no encontrada");
}
catch (Exception ex)
{
ex.printStackTrace();
}// TODO add your handling code here:
}

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0);
}
}


El codigo lo sacamos de netbeans ya que inicialmente estabamos trabajando ahi .
Espero que me puedas ayudar.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar