コード例 #1
0
ファイル: gui.java プロジェクト: kristofvanmoffaert/LightsOff
  /** Creates new form gui */
  public gui() {
    super(new BorderLayout());
    initComponents();

    // Load user list and images
    images = new ImageIcon[userStrings.length];
    Integer[] intArray = new Integer[userStrings.length];
    for (int i = 0; i < userStrings.length; i++) {
      intArray[i] = new Integer(i);
      images[i] = createImageIcon("images/" + userStrings[i] + ".png");
      if (images[i] != null) {
        images[i].setDescription(userStrings[i]);
      }
    }
    users = new JComboBox(intArray);
    Color bg = (Color) UIManager.get("ComboBox.background");
    Color fg = (Color) UIManager.get("ComboBox.foreground");
    UIManager.put("ComboBox.selectionBackground", bg);
    UIManager.put("ComboBox.selectionForeground", fg);
    users.setUI(new MetalComboBoxUI());
    // ComboBoxRenderer renderer = new ComboBoxRenderer();
    ComboBoxRenderer renderer = new ComboBoxRenderer(userStrings, images);
    renderer.setPreferredSize(new Dimension(650, 150));
    users.setRenderer(renderer);
    users.setSize(renderer.getPreferredSize());
    users.setMaximumRowCount(4);
    users.setBounds(150, 250, 650, 200);
    add(users);
    // setBorder(BorderFactory.createEmptyBorder(20,20,20,20));

    // Set the user satisfaction labels
    jSlider1.setPaintTicks(true);
    Hashtable labelTable = new Hashtable();
    for (int i = 0; i < labels.length; i++) {
      labelTable.put(new Integer(i), new JLabel(labels[i]));
    }

    jSlider1.setLabelTable(labelTable);

    jSlider1.setPaintLabels(true);

    socket = new generalSocket(machine, 1099);

    statusThread thread = new statusThread(socket, jLabel4);
    Thread theThread = new Thread(thread);
    theThread.start();
  }
コード例 #2
0
  public BorrowerSearchPanel(BorrowerView borrowerView, Controller mySession) {
    super(new BorderLayout());
    parent = borrowerView;
    this.mySession = mySession;

    listModel = new DefaultListModel();

    // Create the list and put it in a scroll pane.
    list = new JList(listModel);
    list.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    list.setSelectedIndex(0);
    list.addListSelectionListener(this);
    list.setVisibleRowCount(5);
    JScrollPane listScrollPane = new JScrollPane(list);
    /*
    employeeName = new JTextField(10);
    employeeName.addActionListener(hireListener);
    employeeName.getDocument().addDocumentListener(hireListener);
    String name = listModel.getElementAt(
                          list.getSelectedIndex()).toString();*/

    // Create a panel that uses BoxLayout.
    JPanel buttonPane = new JPanel();
    buttonPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    add(listScrollPane, BorderLayout.CENTER);

    JPanel panel = new JPanel();
    listScrollPane.setColumnHeaderView(panel);

    JLabel lblSearchForBooks = new JLabel("Search For Books");
    panel.add(lblSearchForBooks);
    add(buttonPane, BorderLayout.PAGE_END);
    buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.X_AXIS));

    JSplitPane splitPane = new JSplitPane();
    splitPane.setContinuousLayout(true);
    splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
    buttonPane.add(splitPane);

    JPanel panel_1 = new JPanel();
    splitPane.setLeftComponent(panel_1);

    cmboKeyWords = new JComboBox();
    cmboKeyWords.setModel(new DefaultComboBoxModel(new String[] {"Title", "Author", "Subject"}));
    cmboKeyWords.setSize(100, 75);
    panel_1.add(cmboKeyWords);

    searchArgument = new JTextField();
    panel_1.add(searchArgument);
    searchArgument.setColumns(10);

    JPanel panel_2 = new JPanel();
    splitPane.setRightComponent(panel_2);

    btnSearch = new JButton("Search");
    btnSearch.addActionListener(new SearchListener());
    panel_2.add(btnSearch);

    btbPlaceOnHold = new JButton("Place Hold Request");
    btbPlaceOnHold.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            System.out.println("yep");
            PlaceHoldRequestDialog test =
                new PlaceHoldRequestDialog(
                    getInstance(), getLoggedInUserBID(), getInstance().mySession);
            test.setVisible(true);
          }
        });
    panel_2.add(btbPlaceOnHold);
  }
コード例 #3
0
  // private void createComponent(){
  //
  // }
  public void init() {

    fLogin = new JFrame("Login");
    Container fc = fLogin.getContentPane();

    JPanel jpBtn = new JPanel(); // add jpanel, contains 2 buttons
    JButton btnLogin = new JButton("Login");
    JButton btnQuit = new JButton("Quit");
    btnLogin.setActionCommand("Login");
    btnQuit.setActionCommand("Quit");

    jpBtn.add(btnLogin);
    jpBtn.add(btnQuit);

    JPanel jpTextField = new JPanel(); // add jpanel contains 2label and 2 textfield

    jlName = new JLabel("User Name:");
    jlPwd = new JLabel("Password :"******"User001", 15);
    jfPwd = new JTextField("user001", 15);
    jlTips = new JLabel("");
    jlTips.setForeground(Color.red);
    jlTips.setSize(15, 15);
    jpTextField.add(jlName);
    jpTextField.add(jfName);
    jpTextField.add(jlPwd);
    jpTextField.add(jfPwd);
    jpTextField.add(jlTips);
    // f

    String output[] = {"GUI", "Konsole"};
    try {
      jfIp = new JTextField(InetAddress.getLocalHost().getHostAddress().toString());
    } catch (UnknownHostException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      jfIp.setText("127.0.0.1");
    }
    jfIp.setSize(20, 10);
    Jclass = new JComboBox(output);
    Jclass.setSize(150, 80);
    JPanel jcontainer = new JPanel();

    JLabel jblServer = new JLabel("Server Ip");
    JPanel jServer = new JPanel();
    jServer.add(jblServer);
    jServer.add(jfIp);

    jcontainer.setLayout(new BorderLayout());
    jcontainer.add(jpTextField, "Center");

    jcontainer.add(Jclass, "South");
    jcontainer.add(jServer, "North");

    // fc.add(jpTextField,"North");
    fc.add(jpBtn, "South");
    fc.add(jcontainer, "Center");
    // Event for window closing
    fLogin.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    /*fLogin.addWindowListener(new WindowAdapter(){

    	public void windowClosing(WindowEvent e){
    	//	fLogin.dispose();
    		System.exit(0);
    	}

    });*/

    btnQuit.addActionListener(this);
    btnLogin.addActionListener(this);
    fLogin.setSize(300, 200);
    setFrameCenter(fLogin, false);
    fLogin.setVisible(true);
  }