Esempio n. 1
0
  public void initFields() {
    add = new JButton("Adauga admin");
    add.addActionListener(this);

    nume = new JTextField();
    nume.setPreferredSize(new Dimension(200, 30));
    prenume = new JTextField();
    prenume.setPreferredSize(new Dimension(200, 30));
    parola = new JTextField();
    parola.setPreferredSize(new Dimension(200, 30));
    nume_util = new JTextField();
    nume_util.setPreferredSize(new Dimension(200, 30));

    lbl1 = new JLabel("Nume Utilizator: ");
    lbl1.setOpaque(true);
    lbl1.setBorder(new EtchedBorder());

    lbl2 = new JLabel("Nume: ");
    lbl2.setOpaque(true);
    lbl2.setBorder(new EtchedBorder());

    lbl3 = new JLabel("Prenume: ");
    lbl3.setOpaque(true);
    lbl3.setBorder(new EtchedBorder());

    lbl4 = new JLabel("Parola: ");
    lbl4.setOpaque(true);
    lbl4.setBorder(new EtchedBorder());

    lbl1.setPreferredSize(new Dimension(120, 30));
    lbl2.setPreferredSize(new Dimension(120, 30));
    lbl3.setPreferredSize(new Dimension(120, 30));
    lbl4.setPreferredSize(new Dimension(120, 30));
  }
Esempio n. 2
0
  public CalcPanel() {
    setPreferredSize(new Dimension(250, 105));
    lblNbr1.setPreferredSize(new Dimension(100, 20));
    lblNbr1.setFont(fontLabels);
    add(lblNbr1);

    tfNbr1.setPreferredSize(new Dimension(100, 20));
    add(tfNbr1);

    lblNbr2.setPreferredSize(new Dimension(100, 20));
    lblNbr2.setFont(fontLabels);
    add(lblNbr2);

    tfNbr2.setPreferredSize(new Dimension(100, 20));
    add(tfNbr2);

    btnAdd.setPreferredSize(new Dimension(100, 20));
    btnAdd.setFont(fontButtons);
    add(btnAdd);

    btnSubtract.setPreferredSize(new Dimension(100, 20));
    btnSubtract.setFont(fontButtons);
    add(btnSubtract);

    lblResult.setPreferredSize(new Dimension(200, 20));
    lblResult.setFont(fontLabels);
    add(lblResult);

    btnAdd.addActionListener(this);
    btnSubtract.addActionListener(this);
  }
Esempio n. 3
0
        {
          setLayout(new GridBagLayout()); // Elrendezés beállítása
          GridBagConstraints c = new GridBagConstraints(); // Szükséges konstans

          JLabel lbUsername = new JLabel("Felhasználónév"); // A felhasználónév címkéje
          JLabel lbPassword = new JLabel("Jelszó"); // A jelszó címkéje

          lbUsername.setIcon(RM.getUsernameIcon()); // "felhasználónév" címke Ikonjának beállítása
          lbPassword.setIcon(RM.getPasswordIcon()); // "Jelszó" címke Ikonjának beállítása

          lbUsername.setPreferredSize(new Dimension(120, 25)); // Címke átméretezése
          lbPassword.setPreferredSize(new Dimension(120, 25)); // Címke átméretezése

          // [0,0]
          c.gridx = 0; // oszlop
          c.gridy = 0; // sor
          add(lbUsername, c); // a "Felhasználónév" címke hozzáadása

          // [1,0]
          c.gridx = 1;
          add(tfUsername, c); // A "felhasználónév" szövegmező hozzáadása

          // [0,1]
          c.gridx = 0;
          c.gridy = 1;
          add(lbPassword, c); // A "Jelszó" címke hozzáadása

          // [1,1]
          c.gridx = 1;
          c.gridy = 1;
          add(pfPassword, c); // A "jelszó" jelszómező hozzáadása
        }
  /**
   * public MutableStatusBar(String s1, String s2, String s3) { super(); status_1 = new JLabel(s1);
   * status_2 = new JLabel(s2); status_3 = new JLabel(s3); this.init(); }.
   */
  protected void init() {
    this.setLayout(new GridBagLayout());
    this.setBorder(BorderFactory.createEmptyBorder(3, 2, 1, 1));
    final GridBagConstraints constraints = new GridBagConstraints();

    // status_1.setHorizontalAlignment(JLabel.CENTER);
    status_1.setBorder(
        new CompoundBorder(
            new SoftBevelBorder(SoftBevelBorder.LOWERED), new EmptyBorder(0, 2, 0, 2)));
    status_1.setPreferredSize(new Dimension(180, 16));

    status_2.setBorder(
        new CompoundBorder(
            new SoftBevelBorder(SoftBevelBorder.LOWERED), new EmptyBorder(0, 2, 0, 2)));
    status_2.setPreferredSize(new Dimension(200, 16));

    status_3.setBorder(
        new CompoundBorder(
            new SoftBevelBorder(SoftBevelBorder.LOWERED), new EmptyBorder(0, 2, 0, 2)));
    status_3.setPreferredSize(new Dimension(300, 16));

    greenStatusIcon =
        new MutableImageLabel(resource.getIcon("green_off.gif"), resource.getIcon("green_on.gif"));
    greenStatusIcon.setBorder(new EmptyBorder(2, 2, 2, 1));

    redStatusIcon =
        new MutableImageLabel(resource.getIcon("red_off.gif"), resource.getIcon("red_on.gif"));
    redStatusIcon.setBorder(new EmptyBorder(2, 1, 2, 3));
    // =====================================================================

    constraints.insets = new Insets(0, 0, 0, 4);
    constraints.anchor = GridBagConstraints.EAST;
    constraints.fill = GridBagConstraints.VERTICAL;

    constraints.weightx = 1.0;
    constraints.weighty = 1.0;
    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    this.add(status_1, constraints);

    constraints.weightx = 0.0;
    constraints.gridx++;
    this.add(status_2, constraints);

    constraints.gridx = 2;
    this.add(status_3, constraints);

    constraints.gridx++;
    if (greenStatusIcon != null) {
      this.add(greenStatusIcon, constraints);
    }

    constraints.insets = new Insets(0, 0, 0, 0);
    constraints.gridx++;
    if (redStatusIcon != null) {
      this.add(redStatusIcon, constraints);
    }
  }
  /** Standardkonstruktor welcher die komplette Statusbar initialisiert. */
  public PanelStatusBar() {
    pan_east = new JPanel();
    pan_west = new JPanel();

    pan_east.setLayout(new FlowLayout(FlowLayout.RIGHT, 10, 0));
    pan_west.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 0));
    lb_multicast_selected = new JLabel("0 Multicasts Selected");
    lb_multicast_selected.setFont(MiscFont.getFont());
    lb_multicast_selected.setPreferredSize(new Dimension(125, 20));
    lb_multicast_selected.setHorizontalAlignment(SwingConstants.RIGHT);
    lb_multicast_count = new JLabel("0 Multicasts Total");
    lb_multicast_count.setFont(MiscFont.getFont());
    lb_multicast_count.setPreferredSize(new Dimension(125, 20));
    lb_multicast_count.setHorizontalAlignment(SwingConstants.RIGHT);
    lb_trafficUP = new JLabel("Traffic OUT: 0,000 Mbps");
    lb_trafficUP.setFont(MiscFont.getFont());
    lb_trafficUP.setPreferredSize(new Dimension(135, 20));
    lb_trafficUP.setHorizontalAlignment(SwingConstants.LEFT);
    // lb_trafficUP.setBorder(new LineBorder(Color.black));
    lb_trafficDown = new JLabel("IN: 0,000 Mbps");
    lb_trafficDown.setFont(MiscFont.getFont());
    lb_trafficDown.setPreferredSize(new Dimension(90, 20));
    lb_trafficDown.setHorizontalAlignment(SwingConstants.LEFT);
    // lb_trafficDown.setBorder(new LineBorder(Color.black));
    setLayout(new BorderLayout());
    setPreferredSize(new Dimension(100, 20));
    pan_east.add(lb_multicast_selected);
    pan_east.add(lb_multicast_count);
    pan_west.add(lb_trafficUP);
    pan_west.add(lb_trafficDown);

    add(pan_east, BorderLayout.EAST);
    add(pan_west, BorderLayout.WEST);
  }
Esempio n. 6
0
  /**
   * Adds a data field to the GUI.
   *
   * @param pField JTextField object.
   * @param pTargetPanel Target panel to which the data field will be added.
   * @param pLabel A label which will be displayed to the left of the field.
   * @param pUnits Units which will be displayed to the right of the field.
   */
  protected void addDataField(
      JTextField pField, JPanel pTargetPanel, String pLabel, String pUnits) {

    // Create field sub panel.
    JPanel wFieldPanel = new JPanel();
    wFieldPanel.setBackground(new Color(206, 231, 255));
    wFieldPanel.setLayout(new BoxLayout(wFieldPanel, BoxLayout.X_AXIS));
    wFieldPanel.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));

    // Add field label.
    JLabel wFieldLabel = new JLabel(pLabel + ":");
    wFieldLabel.setPreferredSize(new Dimension(100, 60));
    wFieldPanel.add(wFieldLabel);

    // Add text field.
    wFieldPanel.add(pField);

    // Add units label.
    if (pUnits != null) {
      JLabel wFieldUnit = new JLabel(" " + pUnits);
      wFieldUnit.setPreferredSize(new Dimension(55, 60));
      wFieldPanel.add(wFieldUnit);
    }

    // Add sub panel to main panel.
    pTargetPanel.add(wFieldPanel);
  }
  public StratumAttributePanel(DataColumnDefinition[] availableColumns) {
    setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
    columns = new JComboBox(availableColumns);
    // columns.setPreferredSize(new Dimension(columns.getPreferredSize().width, 20));
    conditions = new JComboBox(AtomicCondition.conds);
    // conditions.setPreferredSize(new Dimension(conditions.getPreferredSize().width, 20));
    value = new JTextField(10);
    value.setPreferredSize(new Dimension(150, 20));

    JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    JLabel label = new JLabel("Column:");
    label.setPreferredSize(new Dimension(100, 20));
    panel.add(label);
    panel.add(columns);
    add(panel);

    panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    label = new JLabel("Condition:");
    label.setPreferredSize(new Dimension(100, 20));
    panel.add(label);
    panel.add(conditions);
    add(panel);

    panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    label = new JLabel("Value:");
    label.setPreferredSize(new Dimension(100, 20));
    panel.add(label);
    panel.add(value);
    add(panel);
  }
  @Override
  public JComponent getRenderer(Object gl, int index, Object value) {
    // get or create a new object
    JLabel jl = (JLabel) getUnusedComponent();

    if (value != null) {
      if (value instanceof ScalableIcon) {
        ScalableIcon scaled = ((ScalableIcon) value);
        scaled.setSize(getItemSize());
        jl.setPreferredSize(getItemSize());
        jl.setIcon(scaled);
      } else if (value instanceof Icon) {
        ScalableImageIcon scaled = new ScalableImageIcon((Icon) value);
        scaled.setSize(getItemSize());
        jl.setPreferredSize(getItemSize());
        jl.setIcon(scaled);
      } else {
        jl.setText(value.toString());
      }
    } else {
      UnhandledExceptionManager.handleException(new Exception("rendered component is null"));
    }

    return jl;
  }
Esempio n. 9
0
  private void init() {
    setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createRaisedBevelBorder(), BorderFactory.createEmptyBorder(5, 5, 5, 5)));
    titleLabel = new JLabel();
    titleLabel.setMinimumSize(new Dimension(10, 60));
    titleLabel.setPreferredSize(new Dimension(10, 60));
    descriptionLabel = new JLabel();
    descriptionLabel.setBorder(BorderFactory.createTitledBorder("description:"));
    descriptionLabel.setMinimumSize(new Dimension(10, 100));
    descriptionLabel.setPreferredSize(new Dimension(10, 100));

    JPanel topWrapper = new JPanel(new BorderLayout());
    topWrapper.add(titleLabel, BorderLayout.NORTH);
    topWrapper.add(descriptionLabel, BorderLayout.CENTER);

    requiredSkillsPanel = new JPanel();
    requiredSkillsPanel.setLayout(new BoxLayout(requiredSkillsPanel, BoxLayout.Y_AXIS));
    requiredSkillsPanel.setBorder(BorderFactory.createTitledBorder("requirements:"));
    JPanel requiredSkillsPanelWrapper = new JPanel(new BorderLayout());
    requiredSkillsPanelWrapper.add(requiredSkillsPanel, BorderLayout.CENTER);

    attributesPanel = new JPanel();
    attributesPanel.setLayout(new BoxLayout(attributesPanel, BoxLayout.Y_AXIS));
    attributesPanel.setBorder(BorderFactory.createTitledBorder("attributes:"));
    JPanel attributesPanelWrapper = new JPanel(new BorderLayout());
    attributesPanelWrapper.add(attributesPanel, BorderLayout.CENTER);

    JPanel centerpanel = new JPanel(new GridLayout(0, 2));
    centerpanel.add(requiredSkillsPanelWrapper);
    centerpanel.add(attributesPanelWrapper);

    add(topWrapper, BorderLayout.NORTH);
    add(centerpanel, BorderLayout.CENTER);
  }
Esempio n. 10
0
  private JPanel createPanel() {
    // Create input field
    inputField = new JTextField(20);
    inputField.setText("Enter name of file");

    // Create button
    sortButton = new JButton("sort");
    sortButton.setPreferredSize(new Dimension(100, 100));
    sortButton.addActionListener(new ButtonListener());

    // Create label
    outputField = new JLabel();
    outputField.setPreferredSize(new Dimension(500, 100));

    // create chooser
    jComboBox = new JComboBox(new String[] {"Bubble_Sorter", "Random_Sorter"});
    jComboBox.setSelectedIndex(0);
    jComboBox.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {
            JComboBox b = (JComboBox) arg0.getSource();
            String classname = (String) b.getSelectedItem();
            Class c;
            try {
              c = Class.forName(classname);
              controller.setSorter((Sorter) c.newInstance());
              System.out.println("SAP: " + c.getName());

            } catch (ClassNotFoundException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            } catch (InstantiationException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            } catch (IllegalAccessException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            }
          }
        });

    timeField = new JLabel();
    timeField.setPreferredSize(new Dimension(50, 100));

    JPanel topPanel = new JPanel();
    topPanel.add(inputField);
    topPanel.add(sortButton);
    topPanel.add(jComboBox);
    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
    mainPanel.add(topPanel);
    mainPanel.add(outputField);
    mainPanel.add(timeField);

    return mainPanel;
  }
Esempio n. 11
0
  protected void setSizes() {

    l_name.setPreferredSize(textSize);
    name.setPreferredSize(textSize);
    l_numeroVal.setPreferredSize(numSize);
    l_numeroNum.setPreferredSize(numSize);
    numeroVal.setPreferredSize(numSize);
    numeroNum.setPreferredSize(numSize);
  }
Esempio n. 12
0
 @Override
 public void setDescription(JLabel label, String desc) {
   label.setText(String.format("<html>%s<html>", desc));
   label.setPreferredSize(null);
   label.setPreferredSize(
       new Dimension(
           fieldDimension.width,
           label.getPreferredSize().height
               * (label.getPreferredSize().width / fieldDimension.width + 1)));
 }
  public CommercialModel(JFrame mFrame) {
    mainFrame = mFrame;
    // Set the FlowLayout and the Dimensions for panels
    pnlName.setPreferredSize(new Dimension(450, 50));
    pnlName.setLayout(new FlowLayout());
    pnlAddress.setPreferredSize(new Dimension(450, 50));
    pnlAddress.setLayout(new FlowLayout());
    pnlContactPerson.setPreferredSize(new Dimension(450, 50));
    pnlContactPerson.setLayout(new FlowLayout());
    pnlContactPersonPhone.setPreferredSize(new Dimension(450, 50));
    pnlContactPersonPhone.setLayout(new FlowLayout());

    // Add buttons and labels to panels
    lblContactPersonPhone.setPreferredSize(new Dimension(450, 20));
    lblContactPersonPhone.setHorizontalAlignment(JLabel.CENTER);
    txtContactPersonPhone.setPreferredSize(new Dimension(250, 20));
    pnlContactPersonPhone.add(lblContactPersonPhone);
    pnlContactPersonPhone.add(txtContactPersonPhone);
    // Home
    lblContactPerson.setPreferredSize(new Dimension(450, 20));
    lblContactPerson.setHorizontalAlignment(JLabel.CENTER);
    txtContactPerson.setPreferredSize(new Dimension(250, 20));
    pnlContactPerson.add(lblContactPerson);
    pnlContactPerson.add(txtContactPerson);
    // Address
    lblAddress.setPreferredSize(new Dimension(450, 20));
    lblAddress.setHorizontalAlignment(JLabel.CENTER);
    txtAddress.setPreferredSize(new Dimension(250, 20));
    pnlAddress.add(lblAddress);
    pnlAddress.add(txtAddress);
    // Name
    lblName.setPreferredSize(new Dimension(450, 20));
    lblName.setHorizontalAlignment(JLabel.CENTER);
    txtName.setPreferredSize(new Dimension(250, 20));
    pnlName.add(lblName);
    pnlName.add(txtName);
    // Buttons
    btnAddCommercial.setPreferredSize(new Dimension(200, 30));
    btnCancel.setPreferredSize(new Dimension(200, 30));
    pnlButtons.add(btnAddCommercial);
    pnlButtons.add(btnCancel);

    // Container framePane = frame.getContentPane();
    CommercialModelWrapper.setLayout(new FlowLayout());
    CommercialModelWrapper.add(pnlButtons, FlowLayout.LEFT);
    CommercialModelWrapper.add(pnlContactPersonPhone, FlowLayout.LEFT);
    CommercialModelWrapper.add(pnlContactPerson, FlowLayout.LEFT);
    CommercialModelWrapper.add(pnlAddress, FlowLayout.LEFT);
    CommercialModelWrapper.add(pnlName, FlowLayout.LEFT);
    // Add the event handler to the button
    btnCancel.addActionListener(new btnCancel_Handler(mainFrame));
    btnAddCommercial.addActionListener(
        new CommercialModel_btnAddNew_Handler(
            mainFrame, txtName, txtAddress, txtContactPerson, txtContactPersonPhone));
  }
 private JLabel configureLabel(JComponent pane, String desc, String value) {
   JPanel smallPane = new JPanel(new BorderLayout());
   JLabel label = new JLabel(desc);
   label.setPreferredSize(new Dimension(LABEL_WIDTH, LABEL_HEIGHT));
   smallPane.add(BorderLayout.WEST, label);
   label = new JLabel(value);
   label.setPreferredSize(new Dimension(LABEL_WIDTH, LABEL_HEIGHT));
   smallPane.add(BorderLayout.CENTER, label);
   pane.add(smallPane);
   return label;
 }
  public void initlizeTimepane() {
    // timepanel的初始化
    final TimePanel timepanel = new TimePanel();
    timepanel.setBounds(530, 90, 70, 445);
    timepanel.setOpaque(true);
    // timepanel.setBackground(Color.orange);
    pane.add(timepanel);
    timejpb = new JProgressBar();
    timejpb.setStringPainted(true);
    timejpb.setBackground(Color.yellow);
    timejpb.setForeground(Color.pink);
    timejpb.setPreferredSize(new Dimension(20, 370));
    timejpb.setOrientation(JProgressBar.VERTICAL);

    // timejpb.paint(g);
    final JLabel timelabel1 = new JLabel("   ");
    timelabel1.setPreferredSize(new Dimension(50, 40));
    timepanel.add(timelabel1);
    timelabel3 = new JLabel("   " + time);
    timelabel3.setFont(new Font("微软雅黑", Font.PLAIN, 16));
    timelabel3.setPreferredSize(new Dimension(50, 15));
    timepanel.add(timelabel3);
    timepanel.add(timejpb);

    timejpb.setMaximum(time * 20);
    timerObject = new gameTimer(time * 20);
    timerObject.start(); // 计时器的启动必须等待通信的建立完成,并且使双方的时间保持一致
    doublehitCount = 0; // 同时连击数目初始化
    lastDoubleHitTime = timerObject.getTime(); // 上次连击时间初始化
    lastTwoHitTime = -1; // 倒是第二次连击时间初始化
    //	timeCaulater = new Timer(true);
    doublehitState = false;
    // System.out.println("DDD");

  }
  @Override
  protected Component createContentUI() {
    setMinimumSize(new Dimension(380, 270));

    final JLabel imageLabel = new JLabel();
    imageLabel.setPreferredSize(new Dimension(64, 64));
    imageLabel.setIcon(SwingUtils.loadIcon("connection2.png"));
    nameField = new JTextField();
    urlField = new JTextField("http://");

    loginField = new JTextField();
    passwordField = new JPasswordField();

    final JPanel jp =
        SwingUtils.createKV(
            imageLabel,
            SwingUtils.createVertical(
                new JLabel($m("ConnectionDialog.0")),
                nameField,
                new JLabel($m("ConnectionDialog.1")),
                urlField,
                new JLabel($m("ConnectionDialog.3")),
                loginField,
                new JLabel($m("ConnectionDialog.4")),
                passwordField),
            64);
    jp.setBorder(BorderFactory.createEmptyBorder(8, 0, 0, 0));
    return SwingUtils.createVertical(jp);
  }
  protected JComponent getNewComponentInstance() {
    JLabel newLabel =
        new JLabel() {

          /** */
          private static final long serialVersionUID = 1L;

          /* (non-Javadoc)
           * @see javax.swing.JComponent#paintComponent(java.awt.Graphics)
           */
          @Override
          protected void paintComponent(Graphics g) {
            Insets i = getInsets();

            Rectangle rect =
                new Rectangle(
                    i.left, i.top, getWidth() - i.left - i.right, getHeight() - i.top - i.bottom);
            Area clip = new Area(g.getClip());
            clip.intersect(new Area(rect));
            Graphics2D g2 = (Graphics2D) g;
            g2.setClip(clip);
            super.paintComponent(g);
          }
        };
    newLabel.setPreferredSize(itemSize);
    newLabel.setMinimumSize(scaleItem ? small : itemSize);
    newLabel.setMaximumSize(scaleItem ? large : itemSize);
    newLabel.setBorder(componentBorder);
    newLabel.setText("");
    newLabel.setHorizontalAlignment(JLabel.CENTER);
    newLabel.setVerticalAlignment(JLabel.CENTER);
    return newLabel;
  }
Esempio n. 18
0
  public void doIt() {
    mJFrame = new JFrame(mWindowName);
    mJFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Create the menu bar.
    mJMenuBarMain = new JMenuBar();
    mJMenuBarMain.setOpaque(true);
    mJMenuBarMain.setBackground(mMenuColor);
    mJMenuBarMain.setPreferredSize(new Dimension(X_WINDOW_SIZE, Y_MENU_SIZE));

    // Create main component
    mJMain = new JLabel();
    mJMain.setOpaque(true);
    mJMain.setBackground(mMainColor);
    mJMain.setPreferredSize(new Dimension(X_WINDOW_SIZE * 5, Y_WINDOW_SIZE * 150));

    JScrollPane scrollPane = new JScrollPane(mJMain);
    scrollPane.setPreferredSize(new Dimension(X_WINDOW_SIZE + 20, Y_WINDOW_SIZE + 20));

    // Set the menu bar and add the label to the content pane.
    mJFrame.setJMenuBar(mJMenuBarMain);
    mJFrame.getContentPane().add(scrollPane, BorderLayout.CENTER);
    mJFrame.setLocation(10, 10);

    // Display the window.
    mJFrame.pack();
    mJFrame.setVisible(true);
  }
Esempio n. 19
0
  private void show(int _current) {
    OpenDefinitionsDocument doc = _docs.get(_current);

    String text = getTextFor(doc);

    _label.setText(_displayManager.getName(doc));
    _label.setIcon(_displayManager.getIcon(doc));

    if (text.length() > 0) {
      // as wide as the text area wants, but only 200px high
      _textpane.setText(text);
      _scroller.setPreferredSize(_textpane.getPreferredScrollableViewportSize());
      if (_scroller.getPreferredSize().getHeight() > 200)
        _scroller.setPreferredSize(
            new Dimension((int) _scroller.getPreferredSize().getWidth(), 200));

      _scroller.setVisible(_showSource);
    } else _scroller.setVisible(false);

    Dimension d = _label.getMinimumSize();
    d.setSize(d.getWidth() + _padding * 2, d.getHeight() + _padding * 2);
    _label.setPreferredSize(d);
    _label.setHorizontalAlignment(SwingConstants.CENTER);
    _label.setVerticalAlignment(SwingConstants.CENTER);
    pack();
    centerH();
  }
  public LabelField(String name, int max, ChangeListener changeListener) {
    this.changeListener = changeListener;
    oldText = "";

    this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
    this.setAlignmentX(0);

    label = new JLabel(name);
    label.setMinimumSize(new Dimension(90, 21));
    label.setMaximumSize(new Dimension(90, 21));
    label.setPreferredSize(new Dimension(90, 21));
    this.add(label);

    textField = new JTextField();
    textField.setMaximumSize(new Dimension(max, 21));
    textField.addFocusListener(
        new FocusListener() {
          @Override
          public void focusGained(FocusEvent e) {}

          @Override
          public void focusLost(FocusEvent e) {
            if (oldText.equals(getText())) return;
            oldText = getText();
            notifyChanged();
          }
        });
    this.add(textField);
  }
Esempio n. 21
0
  private JPanel createWaitingPanel() {
    logger.entry();
    JPanel panel = new JPanel();
    panel.setBorder(BorderFactory.createEmptyBorder(0, 50, 10, 50));
    panel.setOpaque(false);

    panel.add(new JLabel(getLocalized(AUTHORIZE)));

    try {
      BufferedImage myPicture = ImageIO.read(ResourceLoader.getURL(Template.AUTHORIZE));
      JLabel picLabel = new JLabel();
      ImageIcon icon = new ImageIcon(myPicture);
      picLabel.setIcon(icon);
      picLabel.setPreferredSize(new Dimension(PANEL_WIDTH, LIST_HEIGHT));
      panel.add(picLabel);
    } catch (IOException e) {
    }

    nextButton = new ModernButton(getLocalized(NEXT_BUTTON_NAME));
    nextButton.setPreferredSize(new Dimension(PANEL_WIDTH, 30));
    nextButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {
            requestAccessToken();
          }
        });
    panel.add(nextButton);

    return logger.exit(panel);
  }
Esempio n. 22
0
 /**
  * JBuilder自动生成的初始化界面方法
  *
  * @throws Exception
  */
 private void jbInit() throws Exception {
   jPanel1.setLayout(borderLayout1);
   jPanel3.setPreferredSize(new Dimension(10, 30));
   jPanel4.setPreferredSize(new Dimension(30, 10));
   jPanel5.setPreferredSize(new Dimension(30, 10));
   jPanel6.setPreferredSize(new Dimension(10, 30));
   jPanel2.setLayout(verticalFlowLayout1);
   MoneyDuom.setBackground(Color.white);
   MoneyDuom.setFont(new java.awt.Font("Dialog", 0, 16));
   MoneyDuom.setPreferredSize(new Dimension(100, 30));
   MoneyDuom.setEditable(true);
   MoneyDuom.setText("");
   jLabel1.setFont(new java.awt.Font("Dialog", 1, 16));
   jLabel1.setPreferredSize(new Dimension(70, 23));
   jLabel1.setHorizontalAlignment(SwingConstants.RIGHT);
   jLabel1.setText("金  额:");
   this.getContentPane().add(jPanel1, BorderLayout.CENTER);
   jPanel1.add(jPanel2, BorderLayout.CENTER);
   jPanel2.add(jPanel8, null);
   jPanel8.add(jLabel1, null);
   jPanel8.add(MoneyDuom, null);
   jPanel2.add(jPanel7, null);
   jPanel1.add(jPanel3, BorderLayout.SOUTH);
   jPanel1.add(jPanel4, BorderLayout.WEST);
   jPanel1.add(jPanel5, BorderLayout.EAST);
   jPanel1.add(jPanel6, BorderLayout.NORTH);
 }
Esempio n. 23
0
  private void buildPointPanels() {
    deleteBtns.clear();
    latTexts.clear();
    lngTexts.clear();
    points = layer.getPositions();
    if (pointPanels.size() != 0) {
      for (JPanel p : pointPanels) {
        this.remove(p);
      }
    }
    pointPanels.clear();

    if (points.size() > 1) {

      for (int i = 0; i < points.size(); i++) {
        JPanel panel = new JPanel();
        panel.setLayout(new FlowLayout(FlowLayout.LEFT));
        Position p = points.get(i);
        final int index = i;
        JLabel label = new JLabel("点" + i + ":");
        label.setPreferredSize(labelDimension);
        panel.add(label);
        JTextField lngTextField = new JTextField();
        lngTextField.setText(p.getLongitude().getDegrees() + "");
        lngTextField.setPreferredSize(smallComponentDimension);
        panel.add(lngTextField);
        lngTexts.add(lngTextField);
        JTextField latTextField = new JTextField();
        latTextField.setText(p.getLatitude().getDegrees() + "");
        latTextField.setPreferredSize(smallComponentDimension);
        panel.add(latTextField);
        latTexts.add(latTextField);
        JButton deleteBtn = new JButton();
        deleteBtn.setText("删除");
        deleteBtn.setPreferredSize(deleteComponentDimension);
        ActionListener deleteListener =
            new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent event) {
                if (deleteBtns.size() > 2) {
                  deleteBtns.remove(index);
                  points.remove(index);
                  refreshPointsPanel();
                  layer.refresh();
                  if (deleteBtns.size() <= 2) {
                    for (JButton btn : deleteBtns) {
                      btn.setEnabled(false);
                    }
                  }
                }
              }
            };
        deleteBtn.addActionListener(deleteListener);
        deleteBtns.add(deleteBtn);
        panel.add(deleteBtn);
        pointPanels.add(panel);
        this.add(panel, pointPanels.size() + 1);
      }
    }
  }
Esempio n. 24
0
  private void resizeLabels() {
    // adjust size of labels so they right-align
    int w = 0;
    Font font = nameLabel.getFont();
    FontRenderContext frc = new FontRenderContext(null, false, false);
    Rectangle2D rect = font.getStringBounds(nameLabel.getText() + " ", frc); // $NON-NLS-1$
    w = Math.max(w, (int) rect.getWidth() + 4);
    rect = font.getStringBounds(pathLabel.getText() + " ", frc); // $NON-NLS-1$
    w = Math.max(w, (int) rect.getWidth() + 4);

    Dimension labelSize = new Dimension(w, 20);
    nameLabel.setPreferredSize(labelSize);
    nameLabel.setMinimumSize(labelSize);
    pathLabel.setPreferredSize(labelSize);
    pathLabel.setMinimumSize(labelSize);
  }
Esempio n. 25
0
  private JPanel panelOpciones() {
    jlb_buscar = new JLabel("Buscar");
    jtf_buscar = new JTextField();
    jbtn_buscar = new JButton();
    jbtn_agregar = new JButton();

    jbtn_buscar.setIcon(iconos.getIcono(Iconos.ICON_BUSCAR));
    jbtn_agregar.setIcon(iconos.getIcono(Iconos.ICON_AGREGAR));

    jlb_buscar.setPreferredSize(new Dimension(50, 27));
    jtf_buscar.setPreferredSize(new Dimension(150, 27));
    jbtn_buscar.setPreferredSize(new Dimension(40, 27));
    jbtn_agregar.setPreferredSize(new Dimension(40, 27));

    JPanel pnlOpciones = new JPanel(new FlowLayout(FlowLayout.LEFT));
    pnlOpciones.setBorder(BorderFactory.createTitledBorder("Opciones"));
    pnlOpciones.setPreferredSize(new Dimension(-1, 60));

    pnlOpciones.add(jlb_buscar);
    pnlOpciones.add(jtf_buscar);
    pnlOpciones.add(jbtn_buscar);
    pnlOpciones.add(jbtn_agregar);

    return pnlOpciones;
  }
Esempio n. 26
0
  public void styleIconButton(final JLabel label) {
    label.setPreferredSize(new Dimension(40, 25));

    label.setOpaque(true);
    label.setBorder(toolPaddingBorder);
    label.setBackground(standardColor);

    label.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mousePressed(MouseEvent e) {
            if (label.isEnabled()) {
              label.setBackground(clickedColor);
              label.setBorder(
                  BorderFactory.createCompoundBorder(toolPaddingBorder, toolInnerEtchedBorder));
              label.setOpaque(true);
            }
          }

          @Override
          public void mouseReleased(MouseEvent e) {
            if (label.isEnabled()) {

              label.setBorder(toolPaddingBorder);
              label.setBackground(standardColor);
            }
          }
        });
  }
Esempio n. 27
0
  /**
   * Constructor method
   *
   * @param withTransparencySlider boolean that specifies if the user wants a slider with the color
   *     chooser panel to control the transparency of the selected color.
   * @param withNoFill boolean that specifies if the color chooser panel allows a null value for the
   *     color selected (true case). If this values is false, when the color selected is null then
   *     black color is assigned automatically.
   */
  public ColorChooserPanel(boolean withTransparencySlider, boolean withNoFill) {

    this.withTransp = withTransparencySlider;
    this.withTranspPerc = withTransparencySlider;
    this.withNoFill = withNoFill;

    try {
      if (withTransp) {
        sldTransparency = new JSlider(0, 255);
        sldTransparency.addChangeListener(sldAction);
        int width = withNoFill ? dim2.width - 40 : dim2.width;
        sldTransparency.setPreferredSize(new Dimension(width - 5, dim2.height / 2));
        sldTransparency.setToolTipText(PluginServices.getText(this, "transparencia"));

        if (withTranspPerc) {
          lblTransparency = new JLabel();
          int percValue = (int) (sldTransparency.getValue() * perc);
          lblTransparency.setText(String.valueOf(percValue) + "%");
          lblTransparency.setPreferredSize(new Dimension(40, 20));
        }

        sldTransparency.setValue(255);
      }
      jbInit();
      colorPanel.setLineColor(null);
      changeButton.setToolTipText(PluginServices.getText(this, "browse"));

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
 /**
  * Sets the preferred width of the title label. Use this function if you embed several data
  * constructor editor panels and want to align them.
  *
  * @param width the new preferred width
  */
 public void setTitleLabelWidth(int width) {
   Dimension prefSize = titleLabel.getPreferredSize();
   Insets insets = titleLabel.getInsets();
   titleLabel.setPreferredSize(
       new Dimension(
           width + insets.left + insets.right, prefSize.height + insets.top + insets.bottom));
 }
Esempio n. 29
0
  private void initComponents() {
    // Message - JLabel
    lblMessage =
        new JLabel(
            String.format(
                "An unexpected error has occurred: %s",
                e == null ? "Unexpected exception" : e.getMessage()));
    lblMessage.setIcon(icon);
    lblMessage.setPreferredSize(new Dimension(360, 40));
    lblMessage.setBorder(BorderFactory.createLineBorder(Color.red));

    // txtTrace - ExceptionTracePane
    txtTrace = new ExceptionTracePane();
    txtTrace.setBackground(new Color(92, 0, 0));
    txtTrace.setException(e);

    // srlTrace - JScrollPane
    JPanel traceWrapper = new JPanel(new BorderLayout());
    traceWrapper.add(txtTrace, BorderLayout.CENTER);
    srlTrace = new JScrollPane(traceWrapper);
    srlTrace.setPreferredSize(new Dimension(360, 200));
    srlTrace.setVisible(false);

    // btnDetails - JButton
    btnDetails = new JButton(new DetailsButtonAction());
    btnDetails.setPreferredSize(new Dimension(100, 40));

    // btnClose - JButton
    btnClose = new JButton(new CloseButtonAction());
    btnClose.setDefaultCapable(true);
    btnClose.setPreferredSize(new Dimension(100, 40));
  }
Esempio n. 30
0
  public void styleButton(final JLabel label) {

    label.setPreferredSize(new Dimension(80, 25));
    label.setFont(defaultFont);
    label.setForeground(textColor);
    label.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, borderColor));
    label.setBackground(standardColor);
    label.setOpaque(true);

    label.setHorizontalAlignment(SwingConstants.CENTER);

    label.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mousePressed(MouseEvent e) {
            if (label.isEnabled()) {
              label.setBackground(clickedColor);
            }
          }

          @Override
          public void mouseReleased(MouseEvent e) {
            if (label.isEnabled()) {

              label.setBackground(standardColor);
            }
          }
        });
  }