Assalamu'alaikum warohmatulloh wabarokaatuh Sobat Setia Catatan Sederhana Dipagi hari ini saya akan Membagikan File Java saya belum sempat mengotak ngatik nya Jika sobat ahli dalam program java silahkan Dimanfaatkan
Berikut Sekilas info nya
Folder database
1 sql
Folder TestBarcode
folder setting
folder bin
folder src
classpath
projecj
Salah satu code java nya
Koneksi java
package PkgBarcode;
import java.sql.DriverManager;
import java.sql.Connection;
public class Koneksi
{
private static Connection koneksi;
public static Connection getKoneksi()
{
if(koneksi == null)
{
try
{
String url = "jdbc:mysql://localhost/barcode";
String username = "root";
String password = "root";
DriverManager.registerDriver(new com.mysql.jdbc.Driver());
koneksi = DriverManager.getConnection(url,username,password);
}
catch(Exception ex)
{
System.out.println(ex);
}
}
return koneksi;
}
}
FrmBarcode.java
package PkgBarcode;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.UIManager;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.sql.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.Font;
import javax.swing.ImageIcon;
import java.awt.Color;
@SuppressWarnings("serial")
public class FrmBarcode extends JFrame {
private JPanel contentPane;
private JLabel lblId;
private JTextField txtID;
private JLabel lblNama;
private JTextField txtNama;
private JLabel lblHarga;
private JTextField txtHarga;
private JButton btnSimpan;
private JButton btnRefresh;
private JLabel lblWall;
private JLabel lblNewLabel;
/**
* Create the frame.
*/
public FrmBarcode() {
setTitle("Tes Barcode");
setResizable(false);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 628, 309);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
lblId = new JLabel("ID : ");
lblId.setFont(new Font("Droid Sans", Font.BOLD, 13));
lblId.setBounds(12, 15, 70, 15);
contentPane.add(lblId);
txtID = new JTextField();
txtID.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
try {
Connection konek = Koneksi.getKoneksi();
Statement state = konek.createStatement();
String sql = "SELECT nama, harga FROM data WHERE id = '"
+ txtID.getText() + "'";
ResultSet rs = state.executeQuery(sql);
while (rs.next()) {
txtNama.setText(rs.getString(1));
txtHarga.setText("" + rs.getInt(2));
}
rs.close();
state.close();
} catch (Exception ex) {
System.out.println(ex);
}
}
});
txtID.setBounds(125, 10, 319, 25);
contentPane.add(txtID);
txtID.setColumns(10);
lblNama = new JLabel("Nama : ");
lblNama.setFont(new Font("Droid Sans", Font.BOLD, 13));
lblNama.setBounds(12, 54, 70, 15);
contentPane.add(lblNama);
txtNama = new JTextField();
txtNama.setBounds(125, 49, 470, 25);
contentPane.add(txtNama);
txtNama.setColumns(10);
lblHarga = new JLabel("Harga : ");
lblHarga.setFont(new Font("Droid Sans", Font.BOLD, 13));
lblHarga.setBounds(12, 94, 70, 15);
contentPane.add(lblHarga);
txtHarga = new JTextField();
txtHarga.setBounds(125, 89, 300, 25);
contentPane.add(txtHarga);
txtHarga.setColumns(10);
btnSimpan = new JButton("Simpan");
btnSimpan.setIcon(new ImageIcon(FrmBarcode.class
.getResource("/PkgBarcode/db_comit.png")));
btnSimpan.setBackground(new Color(102, 153, 255));
btnSimpan.setFont(new Font("Droid Sans", Font.BOLD, 13));
btnSimpan.setBounds(125, 173, 117, 42);
contentPane.add(btnSimpan);
btnRefresh = new JButton("Refresh");
btnRefresh.setIcon(new ImageIcon(FrmBarcode.class
.getResource("/PkgBarcode/document-quick_restart.png")));
btnRefresh.setBackground(new Color(204, 255, 0));
btnRefresh.setFont(new Font("Droid Sans", Font.BOLD, 13));
btnRefresh.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
txtID.setText("");
txtNama.setText("");
txtHarga.setText("");
txtID.requestFocus();
}
});
btnRefresh.setBounds(264, 173, 128, 42);
contentPane.add(btnRefresh);
lblNewLabel = new JLabel("");
lblNewLabel.setIcon(new ImageIcon(FrmBarcode.class
.getResource("/PkgBarcode/printer.png")));
lblNewLabel.setBounds(497, 173, 117, 101);
contentPane.add(lblNewLabel);
lblWall = new JLabel("");
lblWall.setIcon(new ImageIcon(FrmBarcode.class
.getResource("/PkgBarcode/morning.jpg")));
lblWall.setBounds(0, 0, 626, 286);
contentPane.add(lblWall);
setLocationRelativeTo(null);
}
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
UIManager
.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
FrmBarcode frame = new FrmBarcode();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
}
Semua File tersebut saya jadikan satu file Rar Jika Sobat Mau Dibawah ini link Donlod nya
DOWNLOAD
Alhamdulillah Catatan Sederhana Download Barcode Scanner App Java telah selesai Mohon maaf Jika ada kesalahan Wasalamu'alaikum warohmatulloh wabarokaatuh
No comments:
Post a Comment