Skip to content

Commit

Permalink
improved GUI - use SpringLayout
Browse files Browse the repository at this point in the history
  • Loading branch information
heptan committed Jul 25, 2008
1 parent 79774ed commit 4b2d1a0
Showing 1 changed file with 43 additions and 19 deletions.
62 changes: 43 additions & 19 deletions beamercontrol/src/ch/bergernet/beamerControl/BeamerControlGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

import java.awt.Container;
import java.awt.EventQueue;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.SpringLayout;

import ch.bergernet.plugins.infocus.InfocusControlPlugin;

Expand All @@ -21,49 +21,73 @@ public class BeamerControlGUI {
private JTextField fieldURL = new JTextField();

private BeamerControlPlugin control;

/**
* Initialize the contents of the frame
*/
private void createContents() {
frame = new JFrame();
//frame.setBounds(100, 100, 500, 375);
frame.setBounds(100, 100, 300, 100);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

Container container = frame.getContentPane();
container.setLayout( new GridLayout(1, 3) );
SpringLayout layout = new SpringLayout();
container.setLayout(layout);

btnConnect.setText("Connect");
btnConnect.setSize(100, 20);

lblURL.setText("URL");
lblURL.setSize(50, 20);

fieldURL.setText("tcp://localhost:8888");
fieldURL.setSize(150, 20);

ActionListener btnConnectActionListener = new AnActionListener();
btnConnect.addActionListener(btnConnectActionListener);
btnConnect.addActionListener(btnConnectActionListener);

container.add(lblURL);
container.add(fieldURL);
container.add(btnConnect);

frame.pack();

// Adjust constraints for the label so it's at (5,5).
layout.putConstraint(SpringLayout.WEST, lblURL, 5, SpringLayout.WEST,
container);

layout.putConstraint(SpringLayout.NORTH, lblURL, 5, SpringLayout.NORTH,
container);

// Adjust constraints for the text field so it's at
// (<label's right edge> + 5, 5).
layout.putConstraint(SpringLayout.WEST, fieldURL, 5, SpringLayout.EAST,
lblURL);

layout.putConstraint(SpringLayout.WEST, btnConnect, 5,
SpringLayout.EAST, fieldURL);

layout.putConstraint(SpringLayout.NORTH, fieldURL, 5,
SpringLayout.NORTH, container);

layout.putConstraint(SpringLayout.NORTH, btnConnect, 5,
SpringLayout.NORTH, container);

// frame.pack();
frame.setVisible(true);
}
class AnActionListener implements ActionListener{
public void actionPerformed(ActionEvent actionEvent){

class AnActionListener implements ActionListener {
public void actionPerformed(ActionEvent actionEvent) {
String url = fieldURL.getText();
System.out.println("connection url: " + url);
control.connect(url);
System.out.println("connection state: " + control.getConnectionState().isConnected());
}
}

System.out.println("connection state: "
+ control.getConnectionState().isConnected());
}
}

/**
* Launch the application
*
* @param args
*/
public static void main(String args[]) {
Expand All @@ -84,6 +108,6 @@ public void run() {
*/
public BeamerControlGUI() {
createContents();
control = new InfocusControlPlugin();
control = new InfocusControlPlugin();
}
}

0 comments on commit 4b2d1a0

Please sign in to comment.