/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.joshondesign.arduinox;
import com.joshondesign.arduino.common.Device;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.SwingUtilities;
/**
*
* @author josh
*/
public class DeviceInfoPanel extends javax.swing.JPanel {
private Device device;
/**
* Creates new form DeviceInfoPanel
*/
public DeviceInfoPanel() {
initComponents();
}
public DeviceInfoPanel(Device device) {
initComponents();
this.device = device;
this.deviceName.setText( device.getName());
deviceMaxSize.setText(device.getMaxSize()+" bytes");
deviceUploadSpeed.setText(device.getUploadSpeed() + " bps");
closeButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Window win = SwingUtilities.getWindowAncestor(DeviceInfoPanel.this);
win.setVisible(false);
win.dispose();
}
});
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
deviceName = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
deviceMaxSize = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
deviceUploadSpeed = new javax.swing.JLabel();
closeButton = new javax.swing.JButton();
jLabel1.setText("Device Info:");
jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel2.setText("name:");
deviceName.setText("-- name --");
jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel3.setText("max size:");
deviceMaxSize.setText("---");
jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel5.setText("upload speed:");
deviceUploadSpeed.setText("jLabel6");
closeButton.setText("Close");
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(37, 37, 37)
.add(jLabel5))
.add(jLabel1)
.add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 84, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 84, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(18, 18, 18)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(deviceName)
.add(deviceMaxSize)
.add(deviceUploadSpeed))
.addContainerGap(177, Short.MAX_VALUE))
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
.addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(closeButton)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(jLabel1)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel2)
.add(deviceName))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel3)
.add(deviceMaxSize))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel5)
.add(deviceUploadSpeed))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 171, Short.MAX_VALUE)
.add(closeButton)
.addContainerGap())
);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton closeButton;
private javax.swing.JLabel deviceMaxSize;
private javax.swing.JLabel deviceName;
private javax.swing.JLabel deviceUploadSpeed;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel5;
// End of variables declaration//GEN-END:variables
}