Пример #1
0
 private JTextField createColorField(boolean hex) {
   final NumberDocument doc = new NumberDocument(hex);
   int lafFix = UIUtil.isUnderWindowsLookAndFeel() || UIUtil.isUnderDarcula() ? 1 : 0;
   UIManager.LookAndFeelInfo info = LafManager.getInstance().getCurrentLookAndFeel();
   if (info != null
       && (info.getName().startsWith("IDEA") || info.getName().equals("Windows Classic")))
     lafFix = 1;
   final JTextField field;
   if (SystemInfo.isMac && UIUtil.isUnderIntelliJLaF()) {
     field = new JTextField("");
     field.setDocument(doc);
     field.setPreferredSize(new Dimension(hex ? 60 : 40, 26));
   } else {
     field = new JTextField(doc, "", (hex ? 5 : 2) + lafFix);
     field.setSize(50, -1);
   }
   doc.setSource(field);
   field.getDocument().addDocumentListener(this);
   field.addFocusListener(
       new FocusAdapter() {
         @Override
         public void focusGained(final FocusEvent e) {
           field.selectAll();
         }
       });
   return field;
 }
Пример #2
0
  public GraphicsUI() {

    questionPool = new QuestionPool();

    setTitle("Question Pool");
    setSize(WIDTH, HEIGHT);

    fileL = new JLabel("Location of Question Pool File:");
    fileTF = new JTextField(10);

    checkB = new JButton("Check File");

    log = new JTextArea(6, 30);

    Container pane = getContentPane();
    pane.setLayout(null);

    // set locations and sizes for the elements
    fileL.setLocation(90, 15);
    fileL.setSize(ELEMENT_WIDTH, 30);
    fileTF.setLocation(90, 65);
    fileTF.setSize(ELEMENT_WIDTH, 30);
    checkB.setLocation(90, 105);
    checkB.setSize(300, 35);
    log.setLocation(90, 145);
    log.setSize(300, 30);

    // add listener to button
    CheckButtonHandler cbHandler = new CheckButtonHandler();
    checkB.addActionListener(cbHandler);
    fileTF.addActionListener(cbHandler);

    // add elements to pane
    pane.add(fileL);
    pane.add(fileTF);
    pane.add(checkB);
    pane.add(log);

    setLocation(100, 60);
    setVisible(true);
    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
  }
Пример #3
0
  private void makeTopPanel() {
    flowPanel = new JPanel(new BorderLayout());
    gridPanel = new JPanel(new GridLayout(2, 1, 5, 5));
    topPanel = new JPanel(new GridLayout(1, 1, 5, 5));
    topLabel = new JLabel();
    pathLabel = new JLabel("DIR:   ");
    pathTextField = new JTextField(Downloads.directory + "   ");
    pathTextField.setEditable(false);
    pathTextField.setSize(450, 20);
    confirmButton = new JButton("Get path");

    flowPanel.add(pathLabel, BorderLayout.LINE_START);
    flowPanel.add(pathTextField, BorderLayout.CENTER);
    flowPanel.add(confirmButton, BorderLayout.LINE_END);

    gridPanel.setBorder(BorderFactory.createEtchedBorder(Color.lightGray, Color.darkGray));
    gridPanel.add(topLabel);
    gridPanel.add(flowPanel);
    topPanel.add(gridPanel);
  }
 /**
  * Sets the height of the table cell in which this is displayed
  *
  * @param h cell height
  */
 public void setHeight(int h) {
   setSize(getWidth(), h);
   m_numer.setSize(m_numer.getWidth(), h);
   m_divider.setSize(m_divider.getWidth(), h);
   m_denom.setSize(m_denom.getWidth(), h);
 }
  /** Creates panel with function logo and some utilities */
  private Container createTopPanel() {
    JPanel topContainer = new JPanel(new BorderLayout());

    Box logoContainer = Box.createHorizontalBox();
    logoContainer.add(new JLabel(logo));

    topContainer.add(logoContainer, BorderLayout.WEST);

    Box toolBox = Box.createHorizontalBox();

    toolBox.add(new JLabel(toolboxIcon));

    final JLabel highlightGroups = new JLabel(highlightOffIcon);
    highlightGroups.addMouseListener(
        new MouseAdapter() {

          public void mouseEntered(MouseEvent mouseEvent) {
            highlightGroups.setIcon(isHighlighted ? highlightOnOver : highlightOffOver);
          }

          public void mouseExited(MouseEvent mouseEvent) {
            highlightGroups.setIcon(isHighlighted ? highlightOnIcon : highlightOffIcon);
          }

          public void mousePressed(MouseEvent mouseEvent) {
            if (isHighlighted) {

              transposedSpreadsheetSubform.changeTableRenderer(
                  transposedSpreadsheetSubform.getLockedTable(), null);
              transposedSpreadsheetSubform.changeTableRenderer(
                  transposedSpreadsheetSubform.getScrollTable(), null);
            } else {

              transposedSpreadsheetSubform.changeTableRenderer(
                  transposedSpreadsheetSubform.getLockedTable(),
                  new CustomRowRenderer(
                      transposedSpreadsheetModel.getRowToColour(), UIHelper.VER_11_BOLD));

              transposedSpreadsheetSubform.changeTableRenderer(
                  transposedSpreadsheetSubform.getScrollTable(),
                  new CustomRowRenderer(
                      transposedSpreadsheetModel.getRowToColour(), UIHelper.VER_11_PLAIN));
            }

            SwingUtilities.invokeLater(
                new Runnable() {
                  public void run() {
                    transposedSpreadsheetSubform.validate();
                    transposedSpreadsheetSubform.repaint();
                    highlightGroups.setIcon(isHighlighted ? highlightOnIcon : highlightOffIcon);
                  }
                });
            isHighlighted = !isHighlighted;
          }
        });

    toolBox.add(highlightGroups);

    final JLabel goToRecordButton = new JLabel(goToRecord);
    goToRecordButton.addMouseListener(
        new MouseAdapter() {
          public void mouseEntered(MouseEvent mouseEvent) {
            goToRecordButton.setIcon(goToRecordOver);
          }

          public void mouseExited(MouseEvent mouseEvent) {
            goToRecordButton.setIcon(goToRecord);
          }
        });

    toolBox.add(goToRecordButton);

    Box goToRecordEntryField = Box.createVerticalBox();

    final JTextField field = new JTextField("row #");
    UIHelper.renderComponent(field, UIHelper.VER_10_PLAIN, UIHelper.LIGHT_GREY_COLOR, false);

    Dimension fieldSize = new Dimension(60, 16);
    field.setPreferredSize(fieldSize);
    field.setSize(fieldSize);

    goToRecordEntryField.add(Box.createVerticalStrut(5));
    goToRecordEntryField.add(field);
    goToRecordEntryField.add(Box.createVerticalStrut(5));

    final JLabel goButton = new JLabel(go);
    goButton.addMouseListener(
        new MouseAdapter() {

          public void mouseEntered(MouseEvent mouseEvent) {
            goButton.setIcon(goOver);
          }

          public void mouseExited(MouseEvent mouseEvent) {
            goButton.setIcon(go);
          }

          public void mousePressed(MouseEvent mouseEvent) {
            goToColumn(field);
          }
        });

    Action locateColumn =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            goToColumn(field);
          }
        };

    field.getInputMap().put(KeyStroke.getKeyStroke("ENTER"), "LOCATE_COLUMN");
    field.getActionMap().put("LOCATE_COLUMN", locateColumn);

    toolBox.add(goToRecordEntryField);
    toolBox.add(goButton);
    goToRecordEntryField.add(Box.createVerticalStrut(5));

    topContainer.add(toolBox, BorderLayout.EAST);

    information = UIHelper.createLabel("", UIHelper.VER_11_PLAIN, UIHelper.LIGHT_GREY_COLOR);
    information.setHorizontalAlignment(SwingConstants.RIGHT);

    topContainer.add(UIHelper.wrapComponentInPanel(information), BorderLayout.SOUTH);

    return topContainer;
  }
Пример #6
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);
  }