Hola, eso, quería saber si existe alguna librería o similar para java, de antemano gracias, saludos!
Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.
Mostrar Mensajes MenúCita de: (2004) Php 5 And Mysql Bible
The relationship between PHP and Java has changed significantly
with each new release. Unsurprisingly, given the source code, PHP
initially had much more in common with C. PHP4 supported integration
of PHP and Java using a Java Servlet environment or, more experimentally,
directly into PHP. Finally, with the overhaul of the object
model in PHP5, there's a distinctly Java feel to the PHP approach to
object oriented programming. Java users will find much of PHP5's
new object model very familiar, though with important differences.
Given these changes, as PHP takes on a more Java-like cast, there are
two possibilities for which a discussion of PHP and Java might be
pertinent. You might need to work on a project that requires PHP and
Java or Java Server Pages (JSP) to work in tandem. Or you may be
approaching PHP from a Java background and want to know about
the similarities and differences in order to learn PHP faster. We will
deal with both needs in this chapter.
If you don't have a need to use Java, or aren't already
Cita de: (2004) Php 5 And Mysql Bible
Java Server Pages and PHP
PHP can fulfill many functions similarly to Java Server Pages (JSP). The JSP servlet engine
serves as a scripting language for use with Java, and, just as PHP, is often used in front end
applications.
Embedded HTML
PHP is more similar to JSP than Java itself in that you are allowed to write HTML directly
rather than using endless print statements. Unlike Java, but like JSP, variables can also be
referenced from within a block of HTML. A simple HTML page using JSP script might look
like this:
<%
String greeting = "Hello, world";
%>
<HTML>
<HEAD>
<TITLE>Fun with JSP</TITLE>
</HEAD>
<BODY>
<H1><%= greeting %></H1>
</BODY>
</HTML>
Similarly, using PHP, you can write:
<?php
$greeting = "Hello, World";
?>
<HTML>
<HEAD>
<TITLE>Fun with PHP</TITLE>
722 Part IV ✦ Connections
</HEAD>
<BODY>
<H1><?php echo $greeting ?></H1>
</BODY>
</HTML>
Pages can freely alternate between HTML and JSP, just as in using HTML and PHP.
import java.net.ServerSocket;
import java.net.Socket;
import java.io.ObjectOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import javax.swing.JOptionPane;
public class XServer {
private ServerSocket ss;
private Socket s;
private ObjectOutputStream oos;
private boolean isRunning=true;
private ObjectInputStream ois;
private volatile Command cmd=null;
XServer(){
try{
ss = new ServerSocket(9999);
s = ss.accept();
oos=new ObjectOutputStream(s.getOutputStream());
ois=new ObjectInputStream(s.getInputStream());
}catch(IOException ioex){
ioex.printStackTrace();
}
this.sender();
this.receiver();
this.dealReceive();
this.autoClose();
}
void sender(){
Thread t=new Thread(new Runnable(){
public void run(){
while(XServer.this.isRunning){
int type=0;
try{
String msg=JOptionPane.showInputDialog("Mensaje para el Cliente");
Command c=new Command();
c.setMsg(msg);
type=(msg.equalsIgnoreCase("Close"))? 0:1;
c.setType(type);
oos.writeObject(c);
}catch(IOException ex) {
ex.printStackTrace();
}
if(type==0){
break;
}
}
}
});
t.start();
}
void receiver(){
Thread t=new Thread(new Runnable(){
public void run(){
while(XServer.this.isRunning){
try{
Thread.sleep(1000);
Object aux=ois.readObject();
if(aux!=null && aux instanceof Command){
XServer.this.cmd = (Command) aux;
}
}catch(InterruptedException intex){
intex.printStackTrace();
}catch(IOException ioex){
ioex.printStackTrace();
}catch(ClassNotFoundException classex){
classex.printStackTrace();
}
}
}
});
t.start();
}
void dealReceive(){
Thread t=new Thread(new Runnable(){
public void run(){
while(XServer.this.isRunning){
try{
Thread.sleep(1000);
Command c=XServer.this.cmd;
if(c.getType().equals("Message")){
System.out.println(c.getMsg());
}else if(c.getType().equals("Action") && c.getMsg().equals("Close")){
XServer.this.isRunning=false;
}
}catch(InterruptedException intex){
intex.printStackTrace();
}catch(NullPointerException nullex){
}finally{
XServer.this.cmd=null;
}
}
}
});
t.start();
}
void autoClose(){
Thread t=new Thread(new Runnable(){
public void run(){
while(true){
try{
Thread.sleep(200);
if(!XServer.this.isRunning){
XServer.this.ois.close();
XServer.this.oos.close();
XServer.this.s.close();
}
}catch(InterruptedException intex){
intex.printStackTrace();
}catch(IOException ioex){
ioex.printStackTrace();
}
}
}
});
t.start();
}
}
import java.net.Socket;
import java.io.ObjectOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import javax.swing.JOptionPane;
public class XClient {
private Socket s;
private ObjectOutputStream oos;
private boolean isRunning=true;
private ObjectInputStream ois;
private volatile Command cmd=null;
XClient(){
try{
s=new Socket("10.5.4.124", 9999);
oos=new ObjectOutputStream(s.getOutputStream());
ois=new ObjectInputStream(s.getInputStream());
}catch(IOException ioex){
ioex.printStackTrace();
}
this.sender();
this.receiver();
this.dealReceive();
this.autoClose();
}
void receiver(){
Thread t=new Thread(new Runnable(){
public void run(){
while(XClient.this.isRunning){
try{
Thread.sleep(1000);
Object aux=ois.readObject();
if(aux!=null && aux instanceof Command){
XClient.this.cmd = (Command) aux;
}
}catch(InterruptedException intex){
intex.printStackTrace();
}catch(IOException ioex){
ioex.printStackTrace();
}catch(ClassNotFoundException classex){
classex.printStackTrace();
}
}
}
});
t.start();
}
void dealReceive(){
Thread t=new Thread(new Runnable(){
public void run(){
while(XClient.this.isRunning){
try{
Thread.sleep(1000);
Command c=XClient.this.cmd;
if(c.getType().equals("Message")){
System.out.println(c.getMsg());
}else if(c.getType().equals("Action") && c.getMsg().equals("Close")){
XClient.this.isRunning=false;
}
}catch(InterruptedException intex){
intex.printStackTrace();
}catch(NullPointerException nullex){
}finally{
XClient.this.cmd=null;
}
}
}
});
t.start();
}
void sender(){
Thread t=new Thread(new Runnable(){
public void run(){
while(XClient.this.isRunning){
int type=0;
try{
String msg=JOptionPane.showInputDialog("Mensaje para el Server");
Command c=new Command();
c.setMsg(msg);
type=(msg.equalsIgnoreCase("Close"))? 0:1;
c.setType(type);
oos.writeObject(c);
}catch(IOException ex) {
ex.printStackTrace();
}
if(type==0){
break;
}
}
}
});
t.start();
}
void autoClose(){
Thread t=new Thread(new Runnable(){
public void run(){
while(true){
try{
Thread.sleep(200);
if(!XClient.this.isRunning){
XClient.this.ois.close();
XClient.this.oos.close();
XClient.this.s.close();
}
}catch(InterruptedException intex){
intex.printStackTrace();
}catch(IOException ioex){
ioex.printStackTrace();
}
}
}
});
t.start();
}
}
import java.io.Serializable;
public class Command implements Serializable{
private String[] types={"Action", "Message", "Dialog", "Input", "Warning", "Error"};
private String[] actions={"Close"};
private String type="";
private String msg="";
Command(){
this.type= types[1];
}
Command(String msg){
this.type=this.types[0];
this.msg=msg;
}
Command(String msg, int type){
this.type=this.types[type];
this.msg=msg;
}
public String getMsg() {
return msg;
}
void setDialog(String msg){
this.msg=msg;
this.type=types[2];
}
void setInput(String msg){
this.msg=msg;
this.type=types[3];
}
void setWarning(String msg){
this.msg=msg;
this.type=types[4];
}
void setError(String msg){
this.msg=msg;
this.type=types[5];
}
public void setMsg(String msg) {
this.msg = msg;
}
public void setType(int i){
this.type=this.types[i];
}
public String getType(){
return this.type;
}
}
create database if not exists verduleros;
drop table if exists ventas2;
create table ventas2(
idventa int not null primary key,
vendedor varchar(255) not null,
producto varchar(255) not null,
fecha date not null,
kilos int not null
)engine=innodb;
select v.vendedor, v.producto,
sum(v.kilos)
from ventas2 as v
where v.kilos in
(select kilos from ventas2 where vendedor=v.vendedor and
producto=v.producto)
group by vendedor
;
<html>
<head>
</head>
<body>
<?php
mysql_connect("localhost", "root", "sr388");
$b=mysql_query("
create procedure pedir(in strCodBicicleta varchar(255), in strCodPeticion varchar(255), in strCodUsuario varchar(255))
begin
update bicicleta set estado='usando' where cod_bicicleta=strCodBicicleta;
insert into peticion(cod_peticion, usuario, fecha, hora)values(strCodPeticion, strCodUsuario, current_date, current_time);
end
");
if($b){
echo "funka";
}else{
echo "T_T";
}
?>
</body>
</html>
create table usuario(
username varchar(255) not null primary key,
permisos varchar(4) not null, -- 'ADM' o 'USER'
password varchar(255) not null,
e_mail varchar(255) not null
)engine=innodb;
create table bicicleta(
cod_bicicleta varchar(255) not null primary key,
estado varchar(6) not null -- 'usando' o 'libre'
)engine=innodb;
create table peticion(
cod_peticion int unsigned not null primary key,
usuario varchar(255) not null references usuario(username),
fecha date not null,
hora time not null
)engine=innodb;
mysql_connect("localhost", "root", "");
mysql_query("use providencia");
function getAvailableBicicles(){
$r = mysql_query("select * from b_disponibles");
return $r;
}
$row2=getAvailableBicicles();
while($fila = mysql_fetch_array($row2)){
$val = $fila['cod_bicicleta'];
echo $val," <br>";
}
create table bicicleta(
cod_bicicleta varchar(255) not null primary key,
estado varchar(6) not null -- 'usando' o 'libre'
)engine=innodb;
create view b_disponibles as
select * from bicicleta where estado ='libre';
insert into bicicleta(cod_bicicleta, estado)values('bc1', 'usando');
insert into bicicleta(cod_bicicleta, estado)values('bc2', 'usando');
insert into bicicleta(cod_bicicleta, estado)values('bc3', 'libre');
drop database if exists providencia;
create database providencia;
use providencia;
package horario;
import java.util.HashMap;
import java.util.Calendar;
import java.util.GregorianCalendar;
/**
* Clase para obtener los datos necesarios para construir la interfaz grafica <code> Meses </code>
*
* @param año Los datos del objeto se crearan a pertir del año dado
* @param mes Los datos del objeto se crearan a pertir del mes dado
* @author Zero
*/
public class ZCalendar extends GregorianCalendar{
Calendar g=GregorianCalendar.getInstance();
int[] dias={g.MONDAY, g.TUESDAY, g.WEDNESDAY,g.THURSDAY,g.FRIDAY,g.SATURDAY,g.SUNDAY};
/**
* Arreglo utilizado para saber que día termina cada mes del año
*/
int[] last={31, 28, 31,30,31,30,31,31,30,31,30,31};
/**
* Indica el año con que se construye este objeto
*/
int y=0;
/**
* Usado para conocer que indice tendra cada mes del año en el arreglo <code>last[]</code>
*/
HashMap<Integer, String> mez=null;
/**
* Indica el mes con que se construye este objeto
*/
int m=0;
/**
* Indica el primer día del mes
*/
int first=0;
ZCalendar(int año, int mes){
this.set(ZCalendar.YEAR, año);
this.set(ZCalendar.MONTH, mes);
m=mes;
mez=new HashMap<Integer, String>();
y=año;
int w=0;
mez.put(w, "Enero"); w++;
mez.put(w, "Febrero"); w++;
mez.put(w, "Marzo"); w++;
mez.put(w, "Abril"); w++;
mez.put(w, "Mayo"); w++;
mez.put(w, "Junio"); w++;
mez.put(w, "Julio"); w++;
mez.put(w, "Agosto"); w++;
mez.put(w, "Septiembre"); w++;
mez.put(w, "Octubre"); w++;
mez.put(w, "Noviembre"); w++;
mez.put(w, "Diciembre"); w++;
}
/**
* Devuelve la posicion del <code>ZLabel</code> desde donde empezarán los días del mes
*/
int getFirstDayOfMonth(){
int d=0;
this.set(this.DAY_OF_MONTH, this.DAY_OF_MONTH - this.DAY_OF_MONTH);
d=this.get(this.DAY_OF_WEEK);
d++;
first=d;
return d;
}
/**
* Devuelve la posicion del <code>ZLabel</code> en donde terminarán los días del mes
*/
int getLastDayOfTheMonth(){
int x=0;
if(m==1){
return inFeb();
}
if(last[m]==30){
return in30();
}
if(last[m]==31){
return in31();
}
return x;
}
private int in30(){
switch(first){
case 0:
return 29;
case 1:
return 30;
case 2:
return 31;
case 3:
return 32;
case 4:
return 33;
case 5:
return 34;
case 6:
return 35;
case 7:
return 36;
}
return 10;
}
private int in31(){
switch(first){
case 0:
return 30;
case 1:
return 31;
case 2:
return 32;
case 3:
return 33;
case 4:
return 34;
case 5:
return 35;
case 6:
return 36;
case 7:
return 37;
}
return 10;
}
private int inFeb(){
if(isBis(y)){
switch(first){
case 0:
return 28;
case 1:
return 29;
case 2:
return 30;
case 3:
return 31;
case 4:
return 32;
case 5:
return 33;
case 6:
return 34;
case 7:
return 35;
}
}else{
switch(first){
case 0:
return 27;
case 1:
return 28;
case 2:
return 29;
case 3:
return 30;
case 4:
return 31;
case 5:
return 32;
case 6:
return 33;
case 7:
return 34;
}
}
return 10;
}
/**
* Devuelve <code>true</code> si <code>x</code> es multiplo de 4
*
* @param x Representa el año que se desea saber si es bisiesto
*/
boolean isBis(int x){
if(x%4==0){
return true;
}else{
return false;
}
}
/**
* Devuelve el nombre del mes correspondiente
*
* @return m El nombre del mes con el que se construye este objeto
*/
String getMonthName(){
return mez.get(this.m);
}
/**
* Devuelve el año correspondiente
*
* @return m El año con el que se construye este objeto
*/
String getYearName(){
return y+"";
}
}
set ie=createobject("internetexplorer.application")
'se crea un objeto para manipular el internetexplorer
ie.navigate("http://www.google.com")
'como podran imaginar se navega en la url dada
s=inputbox("Ingresa tu busqueda")
' se abre un cuadro de dialogo para ingresar un valor del usuario
ie.visible=true
'se hace visible la ventana del explorer
do
'ok este bucle sirve para que, si el internetexplorer se está cargando, esperar
'nada más
if ie.busy then
wscript.sleep 5000
else
exit do
end if
loop
set b=ie.document.getelementbyid("lst-ib")
'se obtiene la barra de texto de google
b.value=s
'se escribe lo que el usuario ingresó en la barra
set b2=ie.document.getelementbyid("btnG")
'se obtiene el boton "buscar con google"
b2.click()
'se hace click en el boton "buscar con google"
dim ie 'as object
set ie=createobject("internetexplorer.application")
ie.navigate "www.google.com"
coleccion = ie.getElementsByClass("BUTTON") 'aqui me manda un error 80004005
'bla bla bla
set exc=createobject("excel.application")
for x=0 to 99 step 1
exc.cells(1, x).value = "texto de prueba" 'aqui me salta error desconocido en tiempo de ejecucion
wscript.sleep 200
exc.cells(1, x).value = ""
next
public class hilo{
volatile int c=0;
Thread t=null;
public hilo(){
init_hilo();
}
public void init_hilo(){
t=new Thread(new Runnable(){
public void run(){
while(true){
c++;
System.out.println(c);
}
}
});
}
public static void main(String[] args){
new hilo();
try{
t.wait();
t.notify();
//si uso suspend(); y resume(); no me da problemas =/
}catch(InterruptedException ex){
}
}
}
import javax.swing.*;
public class clase{
boolean ctp;
int[][] vec = new int[3][3];
int[] a = new int[9];
int[] b = new int[9];
int[] c = new int[9];
int ia = 0, ib = 0, ic = 0;
public clase(int ctrl){
switch(ctrl){
case 1:
sub_principal();
break;
case 2:
sub_numeros();
break;
case 3:
sub_arreglos();
break;
case 4:
System.exit(0);
break;
}
}
public static void Main(String[] args){
}
void sub_principal(){
ctp=true;
while(ctp){
int m = Integer.parseInt(JOptionPane.showInputDialog(null, "1- Ingresar una frase para contar sus caracteres \n\n 2- Ingresar un Nombre para mostrar en minúsculas o mayúsculas \n\n 3- Volver \n\n 4- Salir"));
switch(m){
case 1:
String frase = JOptionPane.showInputDialog(null, "Ingrese una frase");
JOptionPane.showMessageDialog(null, "La frase tiene " + frase.length() + " caracteres");
break;
case 2:
String nombre = JOptionPane.showInputDialog(null, "Ingrese un nombre");
JOptionPane.showMessageDialog(null, nombre.toUpperCase());
break;
case 3:
ctp=false;
break;
case 4:
new clase(4);
break;
}
new clase(1);
}
}
void sub_numeros(){
ctp=true;
while(ctp){
int s = Integer.parseInt(JOptionPane.showInputDialog(null, "1- Ver si el numero es primo \n\n 2- Ver si el numero es perfecto \n\n 3- Calcular MCM entre dos numeros \n\n 4- Volver 5- Salir"));
switch(s){
case 1:
int op = Integer.parseInt(JOptionPane.showInputDialog(null, "Ingrese el numero"));
if (esPrimo(op)){
JOptionPane.showMessageDialog(null, s + "Es primo");
}else{
JOptionPane.showMessageDialog(null, s + "No es primo");
}
break;
case 2:
int op2 = Integer.parseInt(JOptionPane.showInputDialog(null, "Ingrese el numero"));
if (esPerfecto(s)){
JOptionPane.showMessageDialog(null, s + "Es perfecto");
}else{
JOptionPane.showMessageDialog(null, s + "No es perfecto");
}
break;
case 3:
JOptionPane.showMessageDialog(null, "Aun no implementada XD");
break;
case 4:
ctp=false;
break;
case 5:
new clase(4);
break;
}
new clase(1);
}
}
void sub_arreglos(){
ctp=true;
while(ctp){
int in = Integer.parseInt(JOptionPane.showInputDialog(null, "1- Ingresar numeros para la matriz \n\n 2- Volver \n\n 3-Salir"));
switch (in){
case 1:
int c=1;
for (int x=0;x<3;x++){
for (int y=0;y<3;y++){
vec[x][y] = Integer.parseInt(JOptionPane.showInputDialog(null, "Ingrese numero " + c));
c++;
if(vec[x][y]%2==0){
a[ia] = vec[x][y];
ia++;
}else if (vec[x][y]%2!=0){
b[ib] = vec[x][y];
ib++;
}
if (vec[x][y]<0){
c[ic] = vec[x][y];
ic++;
}
}
}
String pares="";
for (int valor:a){
pares += "[" + Integer.toString(valor) + "]";
}
JOptionPane.showMessageDialog(null, "Los numeros pares son \n\n" + pares);
String impares="";
for (int valor:a){
impares += "[" + Integer.toString(valor) + "]";
}
JOptionPane.showMessageDialog(null, "Los numeros impares son \n\n" + impares);
String negativos="";
for (int valor:a){
negativos += "[" + Integer.toString(valor) + "]";
}
JOptionPane.showMessageDialog(null, "Los numeros negativos son \n\n" + negativos);
break;
case 2:
ctp = false;
break;
case 3:
new clase(4);
break;
}
}
new clase(1);
}
boolean esPrimo(int p){
int c;
for (int x=p;x>0;x--){
if (p%x==0){
c++;
}
}
if (c==2){
return true;
}else{
return false;
}
}
boolean esPerfecto(int p){
int res=0;
for(int y=1;y<=p/2;y++){
if (p%y==0){
res = res + y;
}
}
if (res == p) {
return true;
}else{
return false;
}
}
}
set exc=createobject("excel.application")
set wss=createobject("wscript.shell")
exc.visible = true
' preparando el archivo
set ambiente = exc.workbooks.add()
wss.sendkeys "+({f11})"
wscript.sleep 200
wss.sendkeys "+({f11})"
wscript.sleep 200
wss.sendkeys "+({f11})"
wscript.sleep 200
wss.sendkeys "+({f11})"
wscript.sleep 200
'preparando la hoja PCs
set fecha1 = exc.range("B2")
fecha1.interior.colorindex = 28
fecha1.formula = "Ingrese fecha"
fecha1.borders.colorindex = 1
set fecha2 = exc.range("C2")
fecha2.interior.colorindex = 28
fecha2.borders.colorindex = 1
fecha2.formula = "01-01-2012"
fecha2.select
wss.sendkeys "{f2}"
wss.sendkeys "{enter}"
set fecha3 = exc.range("C8")
fecha3.interior.colorindex = 28
fecha3.borders.colorindex = 1
fecha3.formula = "=C2+1"
fecha3.select
wss.sendkeys "{f2}"
wss.sendkeys "{enter}"
set rango1 = exc.range("C10:H10")
rango1.interior.colorindex = 1
rango1.font.colorindex = 4
rango1.font.bold = true
exc.range("c10").formula = "PC 1"
exc.range("d10").formula = "PC 2"
exc.range("e10").formula = "PC 3"
exc.range("f10").formula = "PC 4"
exc.range("g10").formula = "PC 5"
exc.range("h10").formula = "PC 6"
set rango2 = exc.range("C11:h19")
rango2.interior.colorindex = 15
rango2.borders.colorindex = 1
set rangof = exc.range("C20:H20")
rangof.interior.colorindex = 28
rangof.borders.colorindex = 1
rangof.select
set f1 = exc.range("C20")
f1.formula = "=suma(C11:C19)"
f1.select
wss.sendkeys "{f2}"
wss.sendkeys "{enter}"
wscript.sleep 666
wss.sendkeys "{up}"
wss.sendkeys "^(c)"
wss.sendkeys "+({right})"
wss.sendkeys "+({right})"
wss.sendkeys "+({right})"
wss.sendkeys "+({right})"
wss.sendkeys "+({right})"
wss.sendkeys "{enter}"
wscript.sleep 200
set total = exc.range("H22")
total.formula = "=suma(C11:H19)"
total.select
wss.sendkeys "{f2}"
wss.sendkeys "{enter}"
' -------------------------
'copiando el cuadro al resto de la hoja
set stotal = exc.range("G22")
stotal.formula = "Total"
set rango3 = exc.range("C8:H22")
rango3.select
wss.sendkeys "^(c)"
dim control
control=1
' bajar 16 y pegar
do
for i=1 to 20 step 1
wss.sendkeys "{down}"
if control = 32 then
exit do
end if
next
wss.sendkeys "^(v)"
wscript.sleep 200
control = control + 1
loop
exc.columns("B").entirecolumn.autofit
' eso, el resto está listo para pasar a la siguiente hoja
for x=8 to 628 step 20
if x>8 then
resta= x-20
exc.cells(x, 3).formula = "=C"&resta&"+1"
exc.cells(x, 3).select
wss.sendkeys "{f2}"
wss.sendkeys "{enter}"
wscript.sleep 200
end if
fecha2.formula = ""
next
exc.range("C8").formula = "=C2"
exc.range("c8").select
wss.sendkeys "{f2}"
wss.sendkeys "{enter}"
'*****************************************
'*****************************************
' SEGUNDA HOJA
'*****************************************
'*****************************************
wss.sendkeys "^{pgdn}"
more archivo.txt | debug
e97 98
nasds.bat
rcx
129
w
q
debug < archivo.txt
㈠渾汵䀊琨瑩敬䔣琇䘣
import java.io.File;
import java.util.Map;
import java.io.File.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javazoom.jlgui.basicplayer.BasicController;
import javazoom.jlgui.basicplayer.BasicPlayer;
import javazoom.jlgui.basicplayer.BasicPlayerEvent;
import javazoom.jlgui.basicplayer.BasicPlayerException;
import javazoom.jlgui.basicplayer.BasicPlayerListener;
public class rep extends JFrame implements BasicPlayerListener, ActionListener{
private JButton b1, b2, b3, b4, b5, b6, b7, b8,b9, b10;
private JLabel l1, l2, l3, l4, l5, l6, l7, l8, l9, l10;
private JFileChooser sel;
public rep(){
setSize(700, 500);
setLocation(200, 50);
setTitle("title");
Container panel = getContentPane();
panel.setLayout(new GridBagLayout());
panel.setBackground(Color.black);
b1 = new JButton("Abrir...>>");
l1 = new JLabel("<html><H1><FONT COLOR=GREEN>Titulo por defecto</FONT><H1>");
GridBagConstraints size1 = new GridBagConstraints();
size1.gridx = 0;
size1.gridy = 0;
size1.gridheight = 1;
size1.gridwidth = 1;
size1.weightx = 0.0;
size1.weighty = 0.0;
size1.fill = size1.NONE;
size1.anchor = size1.CENTER;
panel.add(l1, size1);
GridBagConstraints size2 = new GridBagConstraints();
size2.gridx = 0;
size2.gridy = 1;
size2.gridheight = 1;
size2.gridwidth = 1;
size2.weightx = 0.0;
size2.weighty = 0.0;
size2.fill = size1.NONE;
size2.anchor = size1.CENTER;
panel.add(b1, size2);
b1.addActionListener(this);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public static void main(String[] args){
new rep();
}
public void actionPerformed(ActionEvent click){
if (click.getSource() instanceof JFileChooser){
// para el showopen
JOptionPane.showMessageDialog(null, "funka");
}
if (click.getSource() instanceof JButton){
// para los botones
JButton b0 = (JButton) click.getSource();
JRootPane panel0 = b0.getRootPane();
JFrame frame0 = (JFrame) panel0.getParent();
String prompt0 = b0.getText();
if (prompt0.equals("Abrir...>>")){
abrir();
}
}
}
public void abrir(){
sel = new JFileChooser();
sel.addActionListener(this);
sel.setCurrentDirectory(new File(System.getProperty("user.dir")));
sel.showOpenDialog(null);
}
public void setController(BasicController ctrl){
}
public void stateUpdated(BasicPlayerEvent chg){
}
public void progress(int Vint, long Vlong, byte[] Vbyte, Map Vmap){
}
public void opened(Object Vob, Map Vmap2){
}
}
jar -cvf test.jar avg.class
jar -cmf Manifest.txt F_tets.jar Main.class
Main-Class: Main
Main-Class: avg
java -jar test.jar ni con java -jar Main.jar
C:\Documents and Settings\usolibre\Escritorio>jar -cfm test.jar Main.class Manif
est.txt >> error.txt
java.io.IOException: invalid header field
at java.util.jar.Attributes.read(Attributes.java:389)
at java.util.jar.Manifest.read(Manifest.java:167)
at java.util.jar.Manifest.<init>(Manifest.java:52)
at sun.tools.jar.Main.run(Main.java:123)
at sun.tools.jar.Main.main(Main.java:903)
C:\Documents and Settings\usolibre\Escritorio>
set wss=createobject("wscript.shell")
set bloc=wss.exec("notepad")
msgbox "minimiza si quieres el bloc de notas, en 5 segundos mas se maximizara (para este ejemplo no lo cierres)"
wscript.sleep 5000
wss.appactivate bloc.processid
wss.sendkeys "funciona"