📄 deviceselectpanel.java
字号:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import javax.bluetooth.*;
public class DeviceSelectPanel extends JPanel implements ActionListener{
JButton nextButton = new JButton("Next");
JComboBox comboBox = null;
File file = null;
JFrame frame = null;
Vector remoteDevices = null;
public DeviceSelectPanel(JFrame frame, File file, Vector remoteDevices){
this.frame = frame;
this.file = file;
this.remoteDevices = remoteDevices;
Font font = new Font("Arial", Font.PLAIN, 12);
setBackground(Color.WHITE);
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
ImageIcon headerIcon = new ImageIcon("header1.gif","image header");
JLabel headerLabel = new JLabel(headerIcon);
headerLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
add(headerLabel);
ImageIcon spacerIcon1 = new ImageIcon("spacer30.gif","image spacer");
JLabel spacerLabel1 = new JLabel(spacerIcon1);
spacerLabel1.setAlignmentX(Component.CENTER_ALIGNMENT);
add(spacerLabel1);
JLabel textlabel1 = new JLabel("The follwing Bluetooth device(s) were found.");
textlabel1.setAlignmentX(Component.CENTER_ALIGNMENT);
textlabel1.setFont(font);
add(textlabel1);
JLabel textlabel2 = new JLabel("Please make a selection and continue.");
textlabel2.setAlignmentX(Component.CENTER_ALIGNMENT);
textlabel2.setFont(font);
add(textlabel2);
ImageIcon spacerIcon2 = new ImageIcon("spacer30.gif","image spacer");
JLabel spacerLabel2 = new JLabel(spacerIcon2);
spacerLabel2.setAlignmentX(Component.CENTER_ALIGNMENT);
add(spacerLabel2);
Vector deviceNames = new Vector(remoteDevices.size());
RemoteDevice remoteDevice = null;
for(int i=0; i<remoteDevices.size(); i++){
try{
remoteDevice = (RemoteDevice)remoteDevices.elementAt(i);
deviceNames.addElement(remoteDevice.getFriendlyName(true)+ " (" + remoteDevice.getBluetoothAddress() + ")");
} catch(Exception e){
e.printStackTrace();
}
}
comboBox = new JComboBox(deviceNames);
comboBox.setAlignmentX(Component.CENTER_ALIGNMENT);
add(comboBox);
ImageIcon spacerIcon3 = new ImageIcon("spacer10.gif","image spacer");
JLabel spacerLabel3 = new JLabel(spacerIcon3);
spacerLabel3.setAlignmentX(Component.CENTER_ALIGNMENT);
add(spacerLabel3);
JLabel textlabel3 = new JLabel("Please click on the NEXT button to continue. ");
textlabel3.setAlignmentX(Component.CENTER_ALIGNMENT);
textlabel3.setFont(font);
add(textlabel3);
nextButton.setAlignmentX(Component.CENTER_ALIGNMENT);
nextButton.addActionListener(this);
add(nextButton);
ImageIcon spacerIcon4 = new ImageIcon("spacer10.gif","image spacer");
JLabel spacerLabel4 = new JLabel(spacerIcon4);
spacerLabel4.setAlignmentX(Component.CENTER_ALIGNMENT);
add(spacerLabel4);
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == nextButton) {
frame.setContentPane(new VerifyOBEXPanel(frame, file, (RemoteDevice)remoteDevices.elementAt(comboBox.getSelectedIndex())));
frame.pack();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -