Package pharmacy; import javax swing. RowFilter


Download 44.71 Kb.
Sana03.02.2023
Hajmi44.71 Kb.
#1148594
Bog'liq
AppPharm



package pharmacy;

import javax.swing.RowFilter;


import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableRowSorter;

/**
*


* @author Nursulton
*/
public class PharmacyForm extends javax.swing.JFrame {

DefaultTableModel dtm, dtm2;


public PharmacyForm() {
initComponents();
}

@SuppressWarnings("unchecked")


//
private void initComponents() {

jScrollPane1 = new javax.swing.JScrollPane();


jTable1 = new javax.swing.JTable();
jButton1 = new javax.swing.JButton();
jTextField1 = new javax.swing.JTextField();
jScrollPane2 = new javax.swing.JScrollPane();
jTable2 = new javax.swing.JTable();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jTable1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
jTable1.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{ new Integer(1), "Analgin, 25%i", "O'zkimyofarm", new Double(2500.0)},
{ new Integer(2), "Mezim 10000", "Berlin-Chemie AG", new Double(36000.0)},
{ new Integer(3), "Ampitsilin, 1,0 г", "SANAVITA PHARMACEUTICALS", new Double(5000.0)},
{ new Integer(4), "Dimedrol, 10 мг/мл", "Борисовский завод медицинских ", new Double(3000.0)},
{ new Integer(5), "Aspirin, 100 мг", "Bayer Bitterfeld GmbH", new Double(16800.0)},
{ new Integer(6), "Trimol, 10 таб", "Ajanta Pharma Limited (Индия)", new Double(4000.0)},
{ new Integer(7), "Travamaks ", "Marion Biotech", new Double(11500.0)},
{ new Integer(8), null, null, null},
{ new Integer(9), null, null, null},
{ new Integer(10), null, null, null},
{ new Integer(11), null, null, null},
{ new Integer(12), null, null, null},
{ new Integer(13), null, null, null}
},
new String [] {
"id", "name", "manufacturer", "price"
}
) {
Class[] types = new Class [] {
java.lang.Integer.class, java.lang.String.class, java.lang.String.class, java.lang.Double.class
};

public Class getColumnClass(int columnIndex) {


return types [columnIndex];
}
});
jScrollPane1.setViewportView(jTable1);

jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pharmacy/button (17).png"))); // NOI18N


jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

jTextField1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

jTable2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
jTable2.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null}
},
new String [] {
"id", "name", "manufacturer", "price"
}
) {
Class[] types = new Class [] {
java.lang.Integer.class, java.lang.String.class, java.lang.String.class, java.lang.Double.class
};

public Class getColumnClass(int columnIndex) {


return types [columnIndex];
}
});
jScrollPane2.setViewportView(jTable2);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());


getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 798, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addGap(192, 192, 192)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 169, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(26, 26, 26)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 189, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 243, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(28, 28, 28)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(43, 43, 43))
);

pack();
}//

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
String txt = jTextField1.getText().toLowerCase();
dtm = (DefaultTableModel)jTable1.getModel();
TableRowSorter tr = new TableRowSorter<>(dtm);
String search = jTextField1.getText();
tr.setRowFilter(RowFilter.regexFilter(search));
dtm2 = (DefaultTableModel)jTable2.getModel();
jTable2.setRowSorter(tr);
}

/**
* @param args the command line arguments


*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(PharmacyForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(PharmacyForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(PharmacyForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(PharmacyForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//

/* Create and display the form */


java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new PharmacyForm().setVisible(true);
}
});
}

// Variables declaration - do not modify


private javax.swing.JButton jButton1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JTable jTable1;
private javax.swing.JTable jTable2;
private javax.swing.JTextField jTextField1;
// End of variables declaration
}
Download 44.71 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling