final static String download_command = "download";
final static String download_label = "Download";
+ static final String[][] download_menu_entries = new String[][] {
+ { download_label, download_command }
+ };
+
MicroPeak SetData(MicroData data) {
MicroPeak mp = this;
if (this.data != null) {
private void DownloadData() {
AltosDevice device = MicroDeviceDialog.show(this);
+ MicroSerial serial = null;
+ try {
+ serial = new MicroSerial(device);
+ } catch (FileNotFoundException fe) {
+ JOptionPane.showMessageDialog(this,
+ fe.getMessage(),
+ "Cannot open device",
+ JOptionPane.ERROR_MESSAGE);
+ return;
+ }
- if (device != null)
- new MicroDownload(this, device);
+ new MicroDownload(this, device, serial);
}
private void no_data() {
}
- private JMenu make_menu(String label, String[][] items) {
+ private void make_menu(String label, String[][] items) {
JMenu menu = new JMenu(label);
for (int i = 0; i < items.length; i++) {
if (MAC_OS_X) {
add_menu(menu, items[i][0], items[i][1]);
}
menu_bar.add(menu);
- return menu;
}
public MicroPeak() {
menu_bar = new JMenuBar();
setJMenuBar(menu_bar);
- JMenu file_menu = make_menu("File", file_menu_entries);
+ make_menu("File", file_menu_entries);
- JButton download_button = new JButton (download_label);
- download_button.setActionCommand(download_command);
- download_button.addActionListener(this);
- menu_bar.add(download_button);
+ if (MAC_OS_X) {
+ make_menu(download_label, download_menu_entries);
+ } else {
+ JButton download_button = new JButton (download_label);
+ download_button.setActionCommand(download_command);
+ download_button.addActionListener(this);
+ menu_bar.add(download_button);
+ }
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
addWindowListener(new WindowAdapter() {
container.validate();
doLayout();
validate();
+ Insets i = getInsets();
+ Dimension ps = pane.getPreferredSize();
+ ps.width += i.left + i.right;
+ ps.height += i.top + i.bottom;
+ setSize(ps);
pack();
setVisible(true);
}