¿Dentro del directorio con el código fuente no hay un README o un INSTALL con las instrucciones a instalar?
No siempre son los mismos pasos para instalar un módulo.
No siempre son los mismos pasos para instalar un módulo.
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úimport java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class CaballosForm {
private JFrame frmCaballos;
private JTextField numeroTxt;
// TODO ...
private HiloCaballo []hiloCaballos = null;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
CaballosForm window = new CaballosForm();
window.frmCaballos.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public CaballosForm() {
initialize();
}
private void initialize() {
frmCaballos = new JFrame();
frmCaballos.setTitle("Caballos");
frmCaballos.setBounds(100, 100, 450, 300);
frmCaballos.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frmCaballos.getContentPane().setLayout(null);
JLabel lblNewLabel = new JLabel("Caballos");
lblNewLabel.setDisplayedMnemonic('C');
lblNewLabel.setBounds(12, 12, 70, 15);
frmCaballos.getContentPane().add(lblNewLabel);
numeroTxt = new JTextField();
lblNewLabel.setLabelFor(numeroTxt);
numeroTxt.setBounds(104, 10, 114, 19);
frmCaballos.getContentPane().add(numeroTxt);
numeroTxt.setColumns(10);
JButton btnNewButton = new JButton("Ok");
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
int n = Integer.parseInt(numeroTxt.getText());
int y_factor = 39;
hiloCaballos = new HiloCaballo[n];
for(int i = 0; i < n; i++) {
hiloCaballos[i] = new HiloCaballo();
hiloCaballos[i].start();
hiloCaballos[i].getCaballo().setBounds(12, y_factor, 256, 14);
frmCaballos.getContentPane().add(hiloCaballos[i].getCaballo());
y_factor += 15;
}
frmCaballos.revalidate();
frmCaballos.pack();
frmCaballos.setBounds(100, 100, 450, 300);
}
});
btnNewButton.setMnemonic('O');
btnNewButton.setBounds(230, 7, 117, 25);
frmCaballos.getContentPane().add(btnNewButton);
JButton btnStop = new JButton("Stop");
btnStop.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
for(int i = 0; i < Integer.parseInt(numeroTxt.getText()); i++) {
hiloCaballos[i].detenerHilo();
}
}
});
btnStop.setBounds(364, 7, 70, 25);
frmCaballos.getContentPane().add(btnStop);
}
}
import javax.swing.JProgressBar;
public class HiloCaballo extends Thread {
private boolean stopFlag = false;
private JProgressBar progressCaballo = null;
public HiloCaballo() {
progressCaballo = new JProgressBar();
progressCaballo.setValue(0);
}
public JProgressBar getCaballo() {
return progressCaballo;
}
@Override
public void run() {
while(!stopFlag) {
progressCaballo.setValue((int)(Math.random() * 100.0));
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
throw new RuntimeException(e.getMessage());
}
}
}
public void detenerHilo() {
stopFlag = true;
}
}
Cita de: jhonatanAsm en 12 Julio 2012, 07:17 AM
que imaginativo...
salu2.
for(double x : costo) {
comboBox.insertItemAt(x, comboBox.getItemCount());
}
public boolean isNumeric(String s) {
try {
Integer.parseInt(s);
return true;
} catch(NumberFormatException ex) {
return false;
}
}
if(!textField.getText().isEmpty()) {
if(isNumeric(textField.getText())) {
for(int i = 0; i < textField.getText().length(); i++) {
// Convertir el digito a double:
double value = Double.parseDouble(textField.getText().charAt(i) + "");
textArea.setText(textArea.getText() + "\n" + textField.getText().charAt(i));
}
}
}