Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Aplikasi Pendeteksi USB Drive
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import java.io.File;
import javax.swing.JLabel;
import javax.swing.ImageIcon;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.Font;
import java.awt.Color;
@SuppressWarnings("serial")
public class FrmDetectUSB extends JFrame {
private JPanel contentPane;
private JLabel lblNewLabel;
private JLabel lblNewLabel_1;
private JLabel lblWall;
private JLabel label;
private JLabel lblNewLabel_2;
/**
* Create the frame.
*/
public FrmDetectUSB() {
setTitle("Cek Flashdisk App");
setResizable(false);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 314, 235);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
label = new JLabel("");
label.setForeground(Color.WHITE);
label.setFont(new Font("Comic Sans MS", Font.BOLD, 12));
label.setBounds(178, 93, 117, 22);
contentPane.add(label);
lblNewLabel = new JLabel("");
lblNewLabel.setIcon(new ImageIcon(FrmDetectUSB.class
.getResource("/DetectUSB/computer-2.png")));
lblNewLabel.setBounds(40, 0, 147, 148);
contentPane.add(lblNewLabel);
lblNewLabel_1 = new JLabel("");
lblNewLabel_1.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
File f = new File("/media");
for (File fls : f.listFiles()) {
label.setText("" + fls);
lblNewLabel_2.setVisible(true);
}
}
});
lblNewLabel_1.setIcon(new ImageIcon(FrmDetectUSB.class
.getResource("/DetectUSB/media-flash-usb.png")));
lblNewLabel_1.setBounds(80, 141, 42, 45);
contentPane.add(lblNewLabel_1);
lblNewLabel_2 = new JLabel("");
lblNewLabel_2.setIcon(new ImageIcon(FrmDetectUSB.class
.getResource("/DetectUSB/dialog-ok-2.png")));
lblNewLabel_2.setBounds(214, 58, 42, 36);
contentPane.add(lblNewLabel_2);
lblWall = new JLabel("");
lblWall.setIcon(new ImageIcon(FrmDetectUSB.class
.getResource("/DetectUSB/Gambar.jpg")));
lblWall.setBounds(0, 0, 312, 210);
contentPane.add(lblWall);
lblNewLabel_2.setVisible(false);
}
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
FrmDetectUSB frame = new FrmDetectUSB();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment