Hola sadfud,
con control de pestañas me refiero a Tabcontrol.
Gracias y saludos
con control de pestañas me refiero a Tabcontrol.
Gracias y 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ú
System.out.println("Introduzca el crédito: ");
Scanner teclado = new Scanner(System.in);
double credito = teclado.nextDouble();
Maquina maquina = new Maquina(3, 0.5, premio1, premio2);
if (getCredito() >= precJug) {
credDisp = credDisp - precJug;
Random generador = new Random();
Fruta[] frutas;
frutas = new Fruta[casillas];
Fruta[] frutas_aleatorias=Fruta.values();
for (int i = 0;i<casillas; i++){
int index = generador.nextInt(5);
frutas[i]=frutas_aleatorias[index];
}
int n = 1; // n = numero de premios
for (int i = 0; i <= n; i++) {
//comprueba si combinación esta en premios registrados
if (Arrays.equals(frutas, coleccion[i].getCombGanad()) == true){
credDisp = credDisp + coleccion[i].getPremio();
}
}
return frutas;
}
return null;
public Maquina(int nCasillas, double precio, Premio... premio) {
precJug=precio;
casillas=nCasillas;
coleccion=premio;
}
public double incrementarCredito(double incremento) {
return credDisp + incremento;
}
public void setCredDisp(double credito) {
credDisp = credito;
}
public Premio(Fruta[] combinacion, int p) {
CombGanad=combinacion;
premio=p;
}
System.out.println("Retirando "+credDisp+" euros de la maquina");
credDisp = 0;
return credDisp;
}
public int getnCasillas() {
return casillas;
}
public Premio[] getColeccion() {
return coleccion;
}
public double getPrecJug() {
return precJug;
}
if (Arrays.equals(frutas, coleccion[i].getCombGanad()) == true){
...
}
if (Arrays.equals(frutas, coleccion[i].getCombGanad())){
...
}
public class Cifrar {
private final String alfabeto;
public Cifrar(String alfabeto) {
this.alfabeto = alfabeto;
}
public String cifrar(String key, String phrase) {
return rot(key, phrase, true);
}
public String decifrar(String key, String phrase) {
return rot(key, phrase, false);
}
private String rot(String key, String phrase, boolean avanzar) {
char[] fuera = new char[phrase.length()];
for(int i = 0; i < phrase.length(); i++) {
char c = phrase.charAt(i);
int indexAlfa = alfabeto.indexOf(c);
// Solo reemplaza caracteres en el alfabeto
if (indexAlfa >= 0) {
// Determina la cantidad de cambios del i'th char en la frase
int keyIndex = i % key.length();
int llave = Integer.parseInt(key.substring(keyIndex, keyIndex + 1));
if(!avanzar)
llave = -llave;
// Obtener el índice de reemplazo en el alfabeto
int reemplazarIndex = (indexAlfa + llave) % alfabeto.length();
if (reemplazarIndex < 0)
reemplazarIndex = alfabeto.length() + reemplazarIndex;
// Reemplazar
c = alfabeto.charAt(reemplazarIndex);
}
fuera[i] = c;
}
return new String(fuera);
}
}
// Da caracteres soportados como cadena, pueden aparecer en cualquier orden.
Cifrar c = new Cifrar(
"abcdefghijklmnopqrstuvwxyz" +
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
"1234567890"
);
// key es una secuencia numérica
String key = "123456789";
// Frase y estados codificados/decodificados
String phrase = "aaaaaaaaaa abc def ghi jkl mno pqr stu vwxyz 123 456 7890 -_=+*&^%$#@! () [] {}";
String codificado = c.cifrar(key, phrase);
String decodificado = c.decifrar(key, codificado);
// Imprimir valores
System.out.println(phrase);
System.out.println(codificado);
System.out.println(decodificado);
aaaaaaaaaa abc def ghi jkl mno pqr stu vwxyz 123 456 7890 -_=+*&^%$#@! () [] {}
bcdefghijb dfh kmo ikm prt npr uwy Buw zBDFH 246 9ac f9ac -_=+*&^%$#@! () [] {}
aaaaaaaaaa abc def ghi jkl mno pqr stu vwxyz 123 456 7890 -_=+*&^%$#@! () [] {}
Cita de: DeBobiPro
ea
Cita de: Adalher
Retazo
public String cifrar(String key, String phrase) throws InvalidKeySpecException {
verificar(key);
return rot(key, phrase, true);
}
public String decifrar(String key, String phrase) throws InvalidKeySpecException {
verificar(key);
return rot(key, phrase, false);
}
private void verificar(String key)throws InvalidKeySpecException {
if (!key.matches("\\d+"))
throw new InvalidKeySpecException("La clave solo debe contener una secuencia de dígitos");
}
public String cifrar(int[] key, String phrase) {
return rot(key, phrase, true);
}
public String decifrar(int[] key, String phrase) {
return rot(key, phrase, false);
}
private String rot(int[] key, String phrase, boolean avanzar) {
char[] fuera = new char[phrase.length()];
for(int i = 0; i < phrase.length(); i++) {
char c = phrase.charAt(i);
int indexAlfa = alfabeto.indexOf(c);
// Solo reemplaza caracteres en el alfabeto
if (indexAlfa >= 0) {
// Determina la cantidad de cambios del i'th char en la frase
int keyIndex = i % key.length;
int llave = key[keyIndex];
if(!avanzar)
llave = -llave;
// Obtener el índice de reemplazo en el alfabeto
int reemplazarIndex = (indexAlfa + llave) % alfabeto.length();
if (reemplazarIndex < 0)
reemplazarIndex = alfabeto.length() + reemplazarIndex;
// Reemplazar
c = alfabeto.charAt(reemplazarIndex);
}
fuera[i] = c;
}
return new String(fuera);
}
String resultado = switch (opcion) {
case "protocol" -> url.getProtocol();
case "authority" -> url.getAuthority();
case "host" -> url.getHost();
case "port" -> String.valueOf(url.getPort());
case "path" -> url.getPath();
...
default -> throw new IllegalArgumentException("Opción no soportada!");
};







import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
public class Main {
private static final String _URL = "http://ddosthegame.com/index.php", _NOMBREUSUARIO = "/*nombreusuario*/", _CONTRASENA = "/*contrasena*/";
static WebDriver driver;
static WebElement element;
public static final void imprimir(final String s)
{
System.out.println(s);
}
public static void main(String[] args)
{
imprimir("Conectando...");
conectar(_URL);
}
public static void conectar(String url)
{
driver = new HtmlUnitDriver();
driver.get(url);
String usuarioEl = "nombreusuario", passEl = "contrasena";
imprimir("Estableciendo datos de nombreusuario... (" + _NOMBREUSUARIO + ")");
element = driver.findElement(By.name(usuarioEl));
element.sendKeys(_NOMBREUSUARIO);
imprimir("Estableciendo datos de la contraseña... (" + _CONTRASENA + ")");
element = driver.findElement(By.name(passEl));
element.sendKeys(_CONTRASENA);
imprimir("Iniciando seción ");
driver.findElement(By.name("login_today")).click();
if (driver.getTitle().contains("- index"))
{
imprimir("Ha iniciado sesión correctamente!");
}
driver.get("http://ddosthegame.com/index.php?page=resolve");
imprimir(driver.getTitle());
driver.close();
}
public static void resolverBot(String nombreusuario, int cantidad)
{
imprimir("Resolviendo " + nombreusuario + " " + amount + "veces");
for (int i = 0; i < 100; i++)
{
element = driver.findElement(By.name("userid"));
element.sendKeys(nombreusuario);
driver.findElement(By.name("resolve_user")).click();
}
}
<!DOCTYPE html>
<html>
<head>
<title>Ejemplo de javascript</title>
<meta charset="UTF-8">
</head>
<body>
<!-- Presentado por javascripts-gratis.de -->
<script type='text/javascript'>
<!--
var obj1 = new Array(100), mc,mc1, cur_obj, total_sel, win = false, cpu_sel, ost, user_sel, game = true;
function RemoveElementByNum(num) {
document.getElementById("ch"+num).style.display = 'none';
document.getElementById("im"+num).style.display = 'none';
}
function RemoveCpuSel(num) {
del = num;
for ( i=0; i<mc1; i++ ) {
ename = document.getElementById("ch"+i);
if (del!=0) {
if (ename.style.display != 'none') {
ename.style.display = 'none';
document.getElementById("im"+i).style.display = 'none';
del-=1;
}
}
}
}
function GetClickedElement(){
total=0;
result=false;
for (i=0; i<mc1; i++) {
ename = document.getElementById("ch"+i);
if ((ename.style.display != 'none') && (ename.checked)) {
total++;
}
}
if (total>3) {
alert('Demasiados fosforos seleccionados. No puedes seleccionar mas de tres fosforos!');
result=false;
} else {
result=true;
}
document.getElementById("maderalog").value = "Tu tomas "+total+" pieza/s.";
total_sel=total;
user_sel=total;
return result;
}
function AI() {
if ( (mc>1) && (win==false) ) {
game = true;
}
if (game == true) {
if ( (mc-user_sel)==1 ) {
win=true;
game=false;
}
if ( (mc%4)!=1 ) {
ost=(mc-user_sel)%4;
if (ost==0) {
ost=4;
}
if (ost>1) {
cpu_sel=ost-1;
} else {
cpu_sel=Math.floor( (3*Math.random()) );
cpu_sel++;
if (cpu_sel>mc) {
cpu_sel=mc;
}
}
}
else {
cpu_sel=4-user_sel;
}
RemoveCpuSel(cpu_sel);
mc=mc-(cpu_sel+user_sel);
document.getElementById("maderalog").value='La computadora toma '+cpu_sel+' pieza/s.';
}
if ( (mc==1) || (mc<1)) {
game = false;
if (win == true) {
document.getElementById("maderalog1").style.visibility='hidden';
document.getElementById("maderalog").style.visibility='hidden';
document.getElementById("eliminar").style.visibility='hidden';
alert('Felicitaciones! Tu has ganado!!!!');
game=false;
} else {
document.getElementById("maderalog1").style.visibility='hidden';
document.getElementById("maderalog").style.visibility='hidden';
alert('Tu has perdido. La inteligencia artificial ha ganado!!!! JA - JA - JA!!!!');
game=false;
document.body.innerHTML = ""
}
}
document.getElementById("maderalog1").value = "Sobra/n " +mc+ " pieza/s";
}
function RemoveSelected(){
if ((total_sel!=0) && (total_sel<4)) {
user_sel=total_sel;
for (i=0; i<mc1; i++) {
ename = document.getElementById("ch"+i);
if ((ename.style.display != 'none') && ename.checked) {
RemoveElementByNum(i);
}
total_sel=0;
}
AI();
} else {
if (total_sel>3) {
alert("Demasiados fosforos seleccionados.");
} else {
alert('Nada seleccionado');
}
}
}
function initMadera() {
mc = prompt("Cantidad de fosforos?. La cantidad debe hallarse entre 7 y 50", "23");
if (mc<7) mc=7;
if (mc>50) mc=50;
mc1 = mc;
document.write('<center><table border="0" cellspacing="0" cellpadding="0"><tr>');
for (i=0; i<mc; i++) {
document.write('<td align="center"><div style="height: 70px; width: 7px; background-color: #C0C077;" name="im'+i+'" id="im'+i+'"><div style="height: 7px; width: 7px; background-color: #FF3300;"></div></div></td>');
obj1[i]=1;
}
document.write('</tr><tr>');
for (i=0; i<mc; i++) {
document.write('<td><input type="checkbox" onclick="GetClickedElement();" name="ch'+i+'" id="ch'+i+'" /></td>');
}
document.write('</tr></table>');
document.write('<br /><input type="button" value="Eliminar fosforos seleccionados" onclick="RemoveSelected();" id="eliminar" />');
document.write('<br /><br /><br /><br />');
document.write('<input type="text" name="maderalog" id="maderalog" size="30" /><br />');
document.write('<input type="text" name="maderalog1" id="maderalog1" size="30" /><br />');
document.write('</center>');
}
//-->
</script>
<script type="text/javascript">initMadera();</script>
<!-- Presentado por javascripts-gratis.de -->
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Ejemplo de javascript</title>
<meta charset="UTF-8">
</head>
<body>
<!-- Presentado por javascripts-gratis.de -->
<script type='text/javascript'>
<!--
// Script by Freddus
// visit my site: http://www.friederklein.de
/////////////////////
var altura = 60; // Configurar aqui la altura original de la imagen
var anchura = 468; // Configurar aqui la anchura original de la imagen
var imagensita = "https://media.giphy.com/media/l41lLf17l7YCZ4Tjq/giphy.gif"; // Dirección hacia la imagen
/////////////////////
var contador=0;
function emboque(){
var pixels;
document.getElementById("miimagenzoom").height = document.getElementById("miimagenzoom").height+altura/20;
document.getElementById("miimagenzoom").width = document.getElementById("miimagenzoom").width+anchura/20
if (contador<20){
setTimeout("emboque()",50);
}// Fin del if
contador++;
}//Fin del emboque
function initimagen() {
document.write('<div align="center">');
document.write('<img height="0" width="0" id="miimagenzoom" src="'+imagensita+'" onload="emboque();">');
document.write('</div>');
}
//-->
</script>
<script type="text/javascript">initimagen();</script>
<!-- Presentado por javascripts-gratis.de -->
</body>
</html>