nievi escribió:Hola, por mi parte no logré ver info que se ciña del todo a estos problemas, pero quería dejarte lo más aproximado por si te sirviera, a ver si alguien pudiera orientarte con conocimiento de causa, ánimo.
https://stackoverflow.com/questions/109 ... ery-slowly
https://stackoverflow.com/questions/707 ... -very-slow
https://stackoverflow.com/questions/167 ... o-unable-t
https://www.forosdelweb.com/f45/jtextfi ... ra-891426/
https://es.stackoverflow.com/questions/ ... o-funciona
https://stackoverflow.com/questions/408 ... ui-is-slow
https://stackoverflow.com/questions/286 ... -jtextpane
https://es.stackoverflow.com/questions/ ... a-variable
https://www.youtube.com/watch?v=2WVLWxAf-1o
import javax.swing.*;
import java.awt.*;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
public class FocoEvento {
public static void main(String[] args) {
Marco5 marco1 = new Marco5();
marco1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
marco1.setTitle("Probando el foco...");
marco1.setBounds(Marco5.ancho/4, Marco5.alto/3, Marco5.ancho/4, Marco5.alto/4);
}
}
class Marco5 extends JFrame {
static int ancho, alto;
public Marco5(){
Dimension pantalla = Toolkit.getDefaultToolkit().getScreenSize();
ancho = pantalla.width;
alto = pantalla.height;
setVisible(true);
setResizable(false);
add(new Lamina());
}
}
class Lamina extends JPanel{
JTextField campo1, campo2;
public void paintComponent(Graphics g){
super.paintComponent(g);
setLayout(null);
campo1=new JTextField();
campo2=new JTextField();
campo1.setBounds(120,10,150,20);
campo2.setBounds(120,50,150,20);
add(campo1);
add(campo2);
ObtenerFoco foco1=new ObtenerFoco();
ObtenerFoco foco2=new ObtenerFoco();
campo1.addFocusListener(foco1);
campo2.addFocusListener(foco2);
}
private class ObtenerFoco implements FocusListener {
@Override
public void focusGained(FocusEvent e) {
System.out.println("He ganado el foco");
}
@Override
public void focusLost(FocusEvent e) {
String email=campo1.getText();
System.out.println(email);
}
}
}
nievi escribió:Buenas, lo siento, sólo he picado un poco de código con PSeint y Visual Studio Code, pero fué sólo una completa toma de contacto.
Todo lo que ví diría gira en torno a los enlaces que ya examinamos, pero si tuvieras tiempo -y paciencia- tal vez recabes algún detalle junto a lo que puedan comentarte los compañeros, ánimo.
https://intellij-support.jetbrains.com/ ... is-Slowwww
https://stackoverflow.com/questions/229 ... erformance
https://stackoverflow.com/questions/677 ... -very-slow
https://stackoverflow.com/questions/627 ... ading-java
https://youtrack.jetbrains.com/issue/JB ... meta-issue
https://stackoverflow.com/questions/563 ... beans-11-0
import javax.swing.*;
import java.awt.*;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
public class FocoEvento {
public static void main(String[] args) {
try (Marco5 marco1 = new Marco5()) {
marco1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
marco1.setTitle("Probando el foco...");
marco1.setBounds(Marco5.ancho/4, Marco5.alto/3, Marco5.ancho/4, Marco5.alto/4);
}
}
}
class Marco5 extends JFrame {
static int ancho, alto;
public Marco5(){
Dimension pantalla = Toolkit.getDefaultToolkit().getScreenSize();
ancho = pantalla.width;
alto = pantalla.height;
setVisible(true);
setResizable(false);
add(new Lamina());
}
}
class Lamina extends JPanel{
JTextField emailField, passwordField;
public Lamina(){
setLayout(new BorderLayout());
emailField = new JTextField();
passwordField = new JTextField();
add(emailField, BorderLayout.NORTH);
add(passwordField, BorderLayout.SOUTH);
emailField.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
System.out.println("Email field has gained focus");
}
@Override
public void focusLost(FocusEvent e) {
String email = emailField.getText();
System.out.println("Email entered: " + email);
}
});
passwordField.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
System.out.println("Password field has gained focus");
}
@Override
public void focusLost(FocusEvent e) {
String password = passwordField.getText();
System.out.println("Password entered: " + password);
}
});
}
}
Newton escribió:@DonVito has probado el siguiente código? Es la recomendación de una de las inteligencias artificiales que están tan de modaimport javax.swing.*;
import java.awt.*;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
public class FocoEvento {
public static void main(String[] args) {
try (Marco5 marco1 = new Marco5()) {
marco1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
marco1.setTitle("Probando el foco...");
marco1.setBounds(Marco5.ancho/4, Marco5.alto/3, Marco5.ancho/4, Marco5.alto/4);
}
}
}
class Marco5 extends JFrame {
static int ancho, alto;
public Marco5(){
Dimension pantalla = Toolkit.getDefaultToolkit().getScreenSize();
ancho = pantalla.width;
alto = pantalla.height;
setVisible(true);
setResizable(false);
add(new Lamina());
}
}
class Lamina extends JPanel{
JTextField emailField, passwordField;
public Lamina(){
setLayout(new BorderLayout());
emailField = new JTextField();
passwordField = new JTextField();
add(emailField, BorderLayout.NORTH);
add(passwordField, BorderLayout.SOUTH);
emailField.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
System.out.println("Email field has gained focus");
}
@Override
public void focusLost(FocusEvent e) {
String email = emailField.getText();
System.out.println("Email entered: " + email);
}
});
passwordField.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
System.out.println("Password field has gained focus");
}
@Override
public void focusLost(FocusEvent e) {
String password = passwordField.getText();
System.out.println("Password entered: " + password);
}
});
}
}