elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: AIO elhacker.NET 2021 Compilación herramientas análisis y desinfección malware


  Mostrar Mensajes
Páginas: 1 2 3 4 5 6 7 [8] 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 ... 79
71  Programación / Java / Re: Eliminar Fila De Jtable(Jtabla Sin Model) en: 28 Noviembre 2011, 16:11 pm
para eliminar datos de una tabla es recomendable que uses DefaultTableModel o AbstractTableModel
72  Programación / Java / Re: matriz nxm numeros, como imprimir segunda fila que mamada en: 27 Noviembre 2011, 23:40 pm
guiate del segundo :xD

1 es 2
73  Programación / Java / Re: Filtrar resultados de JTable que no sea Case Sensitive (ni mayus, ni minus) en: 27 Noviembre 2011, 19:10 pm
Código
  1. RowFilter<Object, Object> filter = new RowFilter<Object, Object>() {
  2.      public boolean include(Entry<?, ?> entry) {
  3.            int numberOfColumn=0;//
  4.            String value= String.valueOf(entry.getValue(numberOfColumn));
  5.       return value.equalsIgnoreCase(jtxtfBuscarInv.getText());
  6.        }
  7. };

en el metodo insertUpdate colocas

Código
  1. ordenador.setRowFilter(filter);
74  Programación / Java / Re: matriz nxm numeros, como imprimir segunda fila. en: 27 Noviembre 2011, 18:18 pm
lo habia escrito mal :xD
75  Programación / Java / Re: matriz nxm numeros, como imprimir segunda fila. en: 27 Noviembre 2011, 18:02 pm
en el metodo para imprimir la ultima c<matriz[0].length :xD
76  Programación / Programación C/C++ / Re: try catch en c++ (dev c++) en: 27 Noviembre 2011, 17:10 pm
algo asi

Código
  1. #include <iostream>
  2. using namespace std;
  3. int main(){
  4.   cout << "Start\n";
  5.   int n=0;
  6.   int *p;
  7.   try {
  8.   cout<<"Digite El Tamano Del Vector \n";
  9.   cin>>n;//Obtencion del tamaño de datos
  10.   if(n<=0)
  11. throw 0;
  12.   p =new int[n];//Creacion del vector
  13.    for(int i=0; i<n; i++) {//llenado
  14.            cout<<"Numeros : "<<i;
  15.            cin>>p[i];
  16.       }
  17.  }catch (int i) {                    
  18.    cout << "ERROR"<<i;
  19.  }
  20.  return 0;
  21. }
77  Foros Generales / Foro Libre / Re: Cuentra Premium Megaupload/Megavideo en: 26 Noviembre 2011, 03:59 am
yo quiero una ;D
78  Programación / Java / Re: Problema Con Selección De Fila En Jtable Y Evento en: 24 Noviembre 2011, 18:57 pm
Wow no he visto el código bien, pero a penas busco un dato Bum! Loop infinito! XD. Solo aviso.
--EDIT--
Solo da problemas al buscar el dato d3.
--EDIT 2--
El problema solo se dá cuando recorro la lista varias veces y busco un dato. Es en reaidad un problema algo dificil de reproducir.

Saludos

cierto, era el ListSelectionListener que le habia colocado

79  Programación / Java / Re: Problema Con Selección De Fila En Jtable Y Evento en: 24 Noviembre 2011, 18:30 pm
si no precionas enter no funciona :xD :xD :xD
80  Programación / Java / Re: Problema Con Selección De Fila En Jtable Y Evento en: 24 Noviembre 2011, 18:08 pm
que tal asi?
Código
  1. import java.awt.BorderLayout;
  2. import java.awt.GridLayout;
  3. import java.awt.event.KeyEvent;
  4. import java.awt.event.KeyListener;
  5. import java.awt.event.MouseEvent;
  6. import java.awt.event.MouseListener;
  7.  
  8. import javax.swing.JFrame;
  9. import javax.swing.JPanel;
  10. import javax.swing.JScrollPane;
  11. import javax.swing.JTable;
  12. import javax.swing.JTextArea;
  13. import javax.swing.JTextField;
  14. import javax.swing.SwingUtilities;
  15. import javax.swing.table.DefaultTableModel;
  16.  
  17. public class pru extends JFrame implements KeyListener,MouseListener{
  18. private static final long serialVersionUID = 1L;
  19. private JTable table = new JTable();
  20.    private JTextField textField=new JTextField(10);
  21.    private JTextArea textArea =new JTextArea();
  22.  
  23.    public pru(){
  24. this.setLayout(new GridLayout(2,0));
  25. textField.addKeyListener(this);
  26. textField.setText("Dato a buscar");
  27.        JScrollPane scpEjemplo= new JScrollPane();
  28.        JPanel panel=new JPanel(new GridLayout());
  29.        JScrollPane jScrollPane=new JScrollPane(textArea);
  30.        panel.add(jScrollPane);
  31.        textArea.setEnabled(false);
  32.        textArea.setEditable(false);
  33.        //Llenamos el modelo
  34.        DefaultTableModel dtmEjemplo = new DefaultTableModel(getFilas(), getColumnas());
  35.  
  36.        table=new JTable(dtmEjemplo){
  37. private static final long serialVersionUID = 1L;
  38. public boolean isCellEditable(int rowIndex, int vColIndex) {
  39.            return false;
  40.  
  41.        }}; //return false: Desabilitar edición de celdas.
  42.        table.setModel(dtmEjemplo);
  43.        table.addMouseListener(this);
  44.       // table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  45.        scpEjemplo.add(table);
  46.        JPanel panel2=new JPanel(new BorderLayout());
  47.        panel2.add(textField,BorderLayout.NORTH);
  48.        panel2.add(scpEjemplo,BorderLayout.CENTER);
  49.        this.add(panel2);
  50.        this.add(panel);
  51.        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
  52.        this.setSize(500, 400);
  53.        scpEjemplo.setViewportView(table);
  54.    }
  55.    //Datos de las filas
  56.    private Object[][] getFilas(){
  57.         Object fila[][]=new Object[][] {
  58.                            {"a1", "b1", "c1", "d1", "a"},
  59.                            {"a2", "b2", "c2", "d2","a"},
  60.                            {"a3", "b3", "c3", "d3","a"},
  61.                            {"a1", "b1", "c1", "d1", "a"},
  62.                            {"a2", "b2", "c2", "d2","a"},
  63.                            {"a3", "b3", "c3", "d3","a"},
  64.         {"a3", "b3", "c3", "d3","b"}};
  65.         return fila;
  66.  
  67.    }
  68.    public void search(String data) {
  69.     textArea.setText("");
  70. int numberOfRows = table.getRowCount();
  71. for (int row = 0; row < numberOfRows; row++) {
  72. for(int column=0;column<table.getColumnCount();column++){
  73. String temp = (String) table.getValueAt(row, column);
  74. if (temp.equalsIgnoreCase(data)) {
  75. table.changeSelection(row,0,false,true);
  76. int[] rows = table.getSelectedRows();
  77. String val="";
  78. for(row=0;row<rows.length;row++){
  79. for(column=0;column<table.getColumnCount();column++){
  80. val+=table.getValueAt(rows[row], column)+"                    ";
  81. }
  82. val+="\n";
  83. }
  84. System.out.println(val);
  85. textArea.append(val);
  86. break;
  87. }
  88. }
  89.  
  90. }
  91. }
  92.    //Encabezados de la tabla
  93.    private String[] getColumnas(){
  94.          String columna[]=new String[]{"A","B","C", "D", "E"};
  95.          return columna;
  96.    }
  97.    public static void main(String args[]) {
  98.     SwingUtilities.invokeLater(new Runnable() {
  99. @Override
  100. public void run() {
  101. pru obj = new pru();
  102.        obj.setVisible(true);
  103. }
  104. });
  105.    }
  106. @Override
  107. public void keyPressed(KeyEvent arg0) {
  108. if(arg0.getKeyCode() ==KeyEvent.VK_ENTER)search(textField.getText());
  109. }
  110. @Override public void keyReleased(KeyEvent arg0) {}
  111. @Override public void keyTyped(KeyEvent arg0) {}
  112.  
  113. @Override
  114. public void mouseClicked(MouseEvent arg0) {
  115. int[] rows = table.getSelectedRows();
  116. String val="";
  117. textArea.setText("");
  118. for(int row=0;row<rows.length;row++){
  119. for(int column=0;column<table.getColumnCount();column++){
  120. val+=table.getValueAt(rows[row], column)+"                    ";
  121. }
  122. val+="\n";
  123. }
  124. //System.out.println(val);
  125. textArea.append(val);
  126.  
  127. }
  128. @Override
  129. public void mouseEntered(MouseEvent arg0) {
  130. // TODO Auto-generated method stub
  131.  
  132. }
  133. @Override
  134. public void mouseExited(MouseEvent arg0) {
  135. // TODO Auto-generated method stub
  136.  
  137. }
  138. @Override
  139. public void mousePressed(MouseEvent arg0) {
  140. // TODO Auto-generated method stub
  141.  
  142. }
  143. @Override
  144. public void mouseReleased(MouseEvent arg0) {
  145. // TODO Auto-generated method stub
  146.  
  147. }
  148. }
  149.  
Páginas: 1 2 3 4 5 6 7 [8] 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 ... 79
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines