combine int and string

hi all,
using netbeans with mySQL. how can i cobime data from two tables to get and entry on third column eg
table one called patients has
IDint(auto primary),patient_name(string),patient_numb(string).
on my GUI
enter name eg smith
i want this to be generated Smi-0001
0001 being the IDint
i can achieve this in eclipse but don't know how to go about it in netbeans environment; if u run this u c what i mean ...
package utils;

import java.awt.Container;

import javax.swing.*;
import java.awt.event.*;
import java.text.DecimalFormat;

public class CombineFields extends JFrame implements ActionListener{

private static final long serialVersionUID = 1L;

private JTextField txtRegion,txtId_number,txtResult ;
private JLabel lblRegion, lblId_number, lblResult;
String reg, id ,temp_reg, temp_result, dash = "-" ;
double temp_id, to_deci = 0.00001;

public CombineFields(){

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setTitle("Generate work number");

Container cont = getContentPane();
cont.setLayout(null);

lblRegion = new JLabel("Region: ",SwingConstants.RIGHT);
lblId_number = new JLabel("Id Numb: ",SwingConstants.RIGHT);
lblResult = new JLabel("WorkNumb: ",SwingConstants.RIGHT);

txtRegion = new JTextField();
txtId_number = new JTextField();
txtResult = new JTextField();

txtResult.setEditable(false);


cont.add(lblRegion);
cont.add(txtRegion);
cont.add(lblId_number);
cont.add(txtId_number);
cont.add(lblResult);
cont.add(txtResult);

txtId_number.addActionListener(this);

lblRegion.setBounds(10,40,90,25);
txtRegion.setBounds(100,40,90,25);
lblId_number.setBounds(10,80,90,25);
txtId_number.setBounds(100,80,90,25);
lblResult.setBounds(10,120,90,25);
txtResult.setBounds(100,120,90,25);

setSize(300,350);
setVisible(true);

}

public void actionPerformed(ActionEvent event){

DecimalFormat precision = new DecimalFormat( "0.00000" );

reg = txtRegion.getText();
temp_reg = reg.substring(0,3);
temp_reg = temp_reg.concat(dash);

id = txtId_number.getText();
temp_id = Integer.parseInt(id);

to_deci = to_deci * temp_id;
String shortString = (precision.format(to_deci));
temp_result = shortString.substring(2);
temp_reg = temp_reg.concat(temp_result);
txtResult.setText(temp_reg);

}

public static void main(String args[]){

new CombineFields();

}


}

any help pls.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories