Foros del Web » Programación para mayores de 30 ;) » Java »

Intentando imitar a facebook

Estas en el tema de Intentando imitar a facebook en el foro de Java en Foros del Web. tengo un applet el cual es un mini file browse muy similar al que usa facebook para subir imagenes a un albun de algun usuario ...
  #1 (permalink)  
Antiguo 07/07/2008, 16:36
Avatar de GreatDanton  
Fecha de Ingreso: mayo-2008
Ubicación: en la 3ra habitacion a la izquierda
Mensajes: 30
Antigüedad: 16 años
Puntos: 0
Exclamación Intentando imitar a facebook

tengo un applet el cual es un mini file browse muy similar al que usa facebook para subir imagenes a un albun de algun usuario

en fin el punto es que no he logrado colocar los checkbox y aun que lo intentnado de mas de 1 forma no logro hacer que se coloquen en donde deven solo me aparecen todos regados asi que si alguien me puede ayudar con los chekcbox lo agreciria aki les dejo mi codigo para que le den una mirida


esta es la clase principal [osea el mini file browse xDD]
Código PHP:
import javax.swing.*;
import javax.swing.event.TreeExpansionEvent;
import javax.swing.event.TreeExpansionListener;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.*;
import java.io.*;
import java.net.URL;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.*;

@
SuppressWarnings("serial")
public class 
ArbolFinal extends JApplet implements TreeSelectionListenerTreeExpansionListenerActionListener {
    
    private 
JScrollPane skrullist
    private 
JScrollPane skrull3;
    private 
JList lista_archivos;
    private 
JTree arbol;
    private 
DefaultListModel archivos//ARRAY DE ARCHIVOS PARA LA LISTA
    
private JSplitPane split;
    private 
JButton boton;

    
PreparedStatement stmt;
    public 
void init() {
         if( 
WIDTH 200 || HEIGHT 200 
                
resize1040,458);
    }
    
    public 
ArbolFinal(){
        
File d_raiz = new File("/");// DIRECTORIO INICIAL     
        
DefaultMutableTreeNode raiz = new DefaultMutableTreeNode(d_raiz);
        
remover_nodos(raizd_raiz);
        
this.setLayout(new BorderLayout());
        
arbol = new JTree(raiz);
        
arbol.getSelectionModel().addTreeSelectionListener(this);
        
arbol.addTreeExpansionListener(this);
        
skrull3 = new JScrollPane(arbol);
        
skrull3.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
        
archivos = new DefaultListModel();
        
lista_archivos = new JList(archivos);
        
lista_archivos.setCellRenderer(new relleno());
        
lista_archivos.setLayoutOrientation(JList.HORIZONTAL_WRAP);
        
lista_archivos.setVisibleRowCount(-3);
        
lista_archivos.setSize(500600);
        
skrullist = new JScrollPane(lista_archivos);
        
skrullist.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
        
split = new JSplitPane();
        
split.setLeftComponent(skrull3);
        
split.setRightComponent(skrullist);
        
split.setSize(500600);
        
split.setOneTouchExpandable(true);
        
boton = new JButton("Subir Imagenes");
        
boton.setEnabled(true);
        
boton.addActionListener(new ActionListener(){
            public 
void actionPerformed(ActionEvent e) {
                if(
e.getSource()== boton){
                    
//System.out.println("El boton funciona");
                    
WardarImagen();
                }
            }
        });
        
getContentPane().add(splitBorderLayout.CENTER);
        
getContentPane().add(botonBorderLayout.NORTH);
        
setVisible(true);
    }

    public 
void WardarImagen(){
        
int index[];
        
String archivo,nombre,ubicacion;
        
index lista_archivos.getSelectedIndices();
        for(
int i 0i<index.length;i++){
            
archivo archivos.getElementAt(index[i]).toString();
            
File niu = new File(archivo);
            
nombre niu.getName();
            
ubicacion niu.getAbsolutePath();
            
//ext = nombre.substring(nombre.lastIndexOf('.') + 1, nombre.length());
            
probando(ubicacion,nombre);
        }
    }    
    
//itn tamaño, int id_album, string ext, string nombre, string ubicacion, string accion)
    
private void probando(String ubicacionString nombre){
        try{
            
getAppletContext().showDocument(new URL("http://localhost/Edy/Applet_Uploader/copy.php?ubi="+ubicacion+"&nom="+nombre), "_blank");
        }catch(
Exception e){        }
    }
      

    @
SuppressWarnings("unused")
    private 
boolean remover_nodos(DefaultMutableTreeNode nodoFile directorio ){
        
nodo.removeAllChildren();
        return 
remover_nodos(nodo,directorio,2);
    }
    
    private 
boolean remover_nodos(DefaultMutableTreeNode nodoFile directorioint ind) {
        
File[] dir directorio.listFiles(new FileFilter(){
            public 
boolean accept(File ubicacion){
                return 
ubicacion.isDirectory();
            }
        });
//CREAMOS UNA LISTA SOLO CON LOS DIRECTORIOS Y NO CON EL CONTENIDO
        
        
if(dir != null && ind 0){
            for(
int i 0i<dir.lengthi++){
                
DefaultMutableTreeNode cursor = new DefaultMutableTreeNode(dir[i]);
                
remover_nodos(cursor,dir[i],ind -1);
                
nodo.add(cursor);
            }
//RELLENAMOS EL ARBOL CON LOS DIRECTORIOS Y CREAMOS LA FUNCION RECURISVA
        
}
        return 
true;
    }

    public 
void valueChanged(TreeSelectionEvent e){
        
DefaultMutableTreeNode nodo = (DefaultMutableTreeNode
        
arbol.getLastSelectedPathComponent();
        
        if(
nodo == null) return;
            
        
File f = (Filenodo.getUserObject();
        
File[] arch f.listFiles(new FileFilter(){
            public 
boolean accept(File dir){
                return 
dir.isFile();
            }
        });
//CREAMOS UN LIST FILES PERO SOLO CON ARCHIVOS 
        
        
String nombreext;
        
archivos.removeAllElements();
        if(
arch !=null){
            for(
int i i<arch.lengthi++){
                
nombre arch[i].getName();//OBTENEMOS EL NOMBRE DEL ARCHIVO
                
ext nombre.substring(nombre.lastIndexOf('.') + 1nombre.length()); //OBTENEMOS LA EXTENCION
                
if(ext.equals("jpg") || ext.equals("gif") || ext.equals("png")){
                    
archivos.addElement(arch[i]);//WARDAMOS SOLO LAS IMAGENES 
                
}
            }
        }
    }
    
    public 
void treeExpanded(TreeExpansionEvent event) {    
        
TreePath direc event.getPath();
        
DefaultMutableTreeNode nodo = (DefaultMutableTreeNodedirec.getLastPathComponent();
        if(
nodo == null) return;
        
        
setCursor(new Cursor(Cursor.WAIT_CURSOR));
            
        
File f = (Filenodo.getUserObject();
        
remover_nodos(nodo,f);
        
JTree arbolito = (JTreeevent.getSource();
        
DefaultTreeModel modelo = (DefaultTreeModelarbolito.getModel();
        
modelo.nodeStructureChanged(nodo);
            
        
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    }
    
    public 
void treeCollapsed(TreeExpansionEvent event){/*_*/}
    public 
void actionPerformed(ActionEvent e){/*_*/}

y esta clase la uso para colocar imagenes en el jlist

Código PHP:
import java.awt.Color;
import java.awt.Component;
import java.awt.Image;
import java.io.File;
import java.awt.Toolkit;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;

@
SuppressWarnings("serial")
public class 
relleno extends JLabel implements ListCellRenderer {

    public 
Component getListCellRendererComponent(JList listaObject valores,
            
int indexboolean isSelectedboolean cellHasFocus) {
            
        
Image img;
        
ImageIcon icono null;
        
        
File f = (Filevalores;
        
img Toolkit.getDefaultToolkit().getImage(f.getAbsolutePath());
        
icono = new ImageIcon(img.getScaledInstance(128128Image.SCALE_SMOOTH));
        
        
setIcon(icono);
        
setText(f.getName());;
        
setOpaque(true);
        
         if (
isSelected){
               
setBackground(Color.darkGray);
               
setForeground(Color.green);
           }     
           else{
               
setBackground(Color.WHITE);
               
setForeground(Color.BLACK);                     
           }
        
        return 
this;
    }
    


y aqui el codigo de php que uso para colocar las imagenes en el server

Código PHP:
<?php 
    $file 
$_GET['ubi'];
    
$nombre $_GET['nom'];
    
$newfile "imagen/".$nombre;
    if (!
copy($file$newfile)) {
        echo 
"failed to copy $file...\n";
    }
    else
    {
        echo 
"copy Done!!!";
    }
    
    
?>
bueno ahy esta eso es lo que he logrado hacer hasta el momento si alquien me pudise ayudar a colocar los checkbox o proponer alguna otra solucion lo agreseria

a si quieren darme una ayudadita con el diseño [aun que el aspecto visual es lo menos importaten por el momento] no hay problema

gracias
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 12:29.