📄 fileclient.java
字号:
import javax.swing.*; import java.awt.*;import java.awt.event.*;import javax.microedition.io.*;import java.io.*;public class FileClient implements ActionListener{ JLabel spacerlabel = new JLabel(" "); JButton deviceButton = new JButton("Discover Devices "); JButton serviceButton = new JButton("Search for Services"); JButton connButton = new JButton("Connect "); JTextArea textarea = new JTextArea("",20, 40); DeviceDiscoverer deviceDiscoverer = null; ServiceDiscoverer serviceDiscoverer = null; public FileClient(){ //Give it the Java look and feel JFrame.setDefaultLookAndFeelDecorated(true); JFrame frame = new JFrame("FileClient "); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JScrollPane scrollPane = new JScrollPane(textarea); textarea.setEditable(false); Container cp = frame.getContentPane(); cp.setLayout(new BoxLayout(cp, BoxLayout.Y_AXIS)); deviceButton.setAlignmentX(Component.CENTER_ALIGNMENT); deviceButton.addActionListener(this); cp.add(deviceButton); serviceButton.setAlignmentX(Component.CENTER_ALIGNMENT); serviceButton.addActionListener(this); serviceButton.setEnabled(false); cp.add(serviceButton); connButton.setAlignmentX(Component.CENTER_ALIGNMENT); connButton.addActionListener(this); connButton.setEnabled(false); cp.add(connButton); spacerlabel.setAlignmentX(Component.CENTER_ALIGNMENT); cp.add(spacerlabel); scrollPane.setAlignmentX(Component.CENTER_ALIGNMENT); cp.add(scrollPane); frame.pack(); frame.setVisible(true); } public void actionPerformed(ActionEvent e) { if( e.getSource() == deviceButton){ textarea.setText(""); deviceDiscoverer = new DeviceDiscoverer(this); } if( e.getSource() == serviceButton){ textarea.setText(""); serviceDiscoverer = new ServiceDiscoverer(this, deviceDiscoverer.remoteDevices); serviceDiscoverer.start(); } if( e.getSource() == connButton){ textarea.setText(""); ObjectPusher objectPusher = new ObjectPusher(this, serviceDiscoverer.connectionURL); objectPusher.start(); connButton.setEnabled(false); } } public void updateStatus(String message){ textarea.append("\n" + message); } public static void main(String[] args) { new FileClient(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -