Java Code Examples for javax.swing.JLabel#setText()

The following examples show how to use javax.swing.JLabel#setText() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TradeRouteListRenderer.java    From Open-Realms-of-Stars with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Component getListCellRendererComponent(
    final JList<? extends TradeRoute> list, final TradeRoute value,
    final int index, final boolean isSelected, final boolean cellHasFocus) {
  JLabel renderer = (JLabel) defaultRenderer.getListCellRendererComponent(
      list, value, index, isSelected, cellHasFocus);
  renderer.setFont(GuiStatics.getFontCubellan());
  renderer.setText(value.toString());
  if (isSelected) {
    renderer.setForeground(GuiStatics.COLOR_COOL_SPACE_BLUE);
    renderer.setBackground(GuiStatics.COLOR_DEEP_SPACE_PURPLE);
  } else {
    renderer.setForeground(GuiStatics.COLOR_COOL_SPACE_BLUE_DARK);
    renderer.setBackground(GuiStatics.COLOR_DEEP_SPACE_PURPLE_DARK);
  }
  return renderer;
}
 
Example 2
Source File: InfoRenderer.java    From RipplePower with Apache License 2.0 6 votes vote down vote up
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
		int row, int column) {
	if (value == null) {
		setText("");
		return this;
	}
	JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
	String text = (String) value;
	table.setRowHeight(80);
	label.setFont(GraphicsUtils.getFont(Font.SANS_SERIF, 0, 14));
	label.setText("<html>" + text + "</html>");
	label.setHorizontalAlignment(getHorizontalAlignment());
	if (hasFocus) {
		if (isSelected) {
			label.setForeground(LColor.red);
		} else {
			label.setForeground(LColor.black);
		}
	} else {
		label.setForeground(LColor.black);
	}
	return label;
}
 
Example 3
Source File: SourceProductSelector.java    From snap-desktop with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
    JComboBox box = (JComboBox) e.getSource();
    Object comp = box.getUI().getAccessibleChild(box, 0);
    if (!(comp instanceof JPopupMenu)) {
        return;
    }
    JComponent scrollPane = (JComponent) ((JPopupMenu) comp).getComponent(0);
    Dimension size = new Dimension();
    size.width = scrollPane.getPreferredSize().width;
    final int boxItemCount = box.getModel().getSize();
    for (int i = 0; i < boxItemCount; i++) {
        final JLabel label = new JLabel();
        Object elementAt = box.getModel().getElementAt(i);
        if (elementAt != null && elementAt instanceof Product) {
            label.setText(((Product) elementAt).getDisplayName());
        }
        size.width = Math.max(label.getPreferredSize().width, size.width);
    }
    size.height = scrollPane.getPreferredSize().height;
    scrollPane.setPreferredSize(size);
    scrollPane.setMaximumSize(size);
}
 
Example 4
Source File: TendencyTableCellRenderer.java    From dsworkbench with Apache License 2.0 6 votes vote down vote up
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
    JLabel label = (JLabel) c;
    Integer val = (Integer) value;
    String text = "";
    if (val == 0) {
        label.setIcon(yellow);
    } else if (val > 0) {
        label.setIcon(red);
        text = "(+ " + val + ")";
    } else if (val < 0) {
        label.setIcon(green);
        text = "(" + val + ")";
    }
    label.setText(StringUtils.center(text, 9));
    return label;
}
 
Example 5
Source File: ColorPanel.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
void buildPanel() {
    int count = this.model.getCount();
    this.spinners[4].setVisible(count > 4);
    for (int i = 0; i < count; i++) {
        String text = this.model.getLabel(this, i);
        Object object = this.spinners[i].getLabel();
        if (object instanceof JRadioButton) {
            JRadioButton button = (JRadioButton) object;
            button.setText(text);
            button.getAccessibleContext().setAccessibleDescription(text);
        }
        else if (object instanceof JLabel) {
            JLabel label = (JLabel) object;
            label.setText(text);
        }
        this.spinners[i].setRange(this.model.getMinimum(i), this.model.getMaximum(i));
        this.spinners[i].setValue(this.values[i]);
        this.spinners[i].getSlider().getAccessibleContext().setAccessibleName(text);
        this.spinners[i].getSpinner().getAccessibleContext().setAccessibleName(text);
        DefaultEditor editor = (DefaultEditor) this.spinners[i].getSpinner().getEditor();
        editor.getTextField().getAccessibleContext().setAccessibleName(text);
        this.spinners[i].getSlider().getAccessibleContext().setAccessibleDescription(text);
        this.spinners[i].getSpinner().getAccessibleContext().setAccessibleDescription(text);
        editor.getTextField().getAccessibleContext().setAccessibleDescription(text);
    }
}
 
Example 6
Source File: PurchaseInfoTab.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void install()
{
	String currencyDisplay = character.getDataSet().getGameMode().getCurrencyDisplay();
	for (JLabel label : currencyLabels)
	{
		label.setText(currencyDisplay);
	}
}
 
Example 7
Source File: MBooleanTableCellRenderer.java    From javamelody with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public Component getTableCellRendererComponent(final JTable table, final Object value,
		final boolean isSelected, final boolean hasFocus, final int row, final int column) {

	if (isSelected) {
		super.setForeground(table.getSelectionForeground());
		super.setBackground(table.getSelectionBackground());
	} else {
		super.setForeground(table.getForeground());
		if (MTable.BICOLOR_LINE != null && row % 2 == 0) {
			super.setBackground(MTable.BICOLOR_LINE);
		} else {
			super.setBackground(table.getBackground());
		}
	}

	if (hasFocus) {
		setBorder(BORDER);
	} else {
		setBorder(null);
	}

	setEnabled(table.isCellEditable(row, column));

	if (value instanceof Boolean) {
		final boolean selected = ((Boolean) value).booleanValue();
		this.setSelected(selected);
		// this.setToolTipText(selected ? "vrai" : "false");
		return this;
	}
	final JLabel label = (JLabel) table.getDefaultRenderer(String.class)
			.getTableCellRendererComponent(table, null, isSelected, hasFocus, row, column);
	if (value == null) {
		label.setText(null);
	} else {
		label.setText("??");
	}
	return label;
}
 
Example 8
Source File: WmsAssistantPage2.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded,
                                              boolean leaf, int row, boolean hasFocus) {
    JLabel label = (JLabel) super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
    String text;
    if (value instanceof Layer) {
        String title;
        Layer layer = (Layer) value;
        title = layer.getTitle();
        if (title == null) {
            title = layer.getName();
        }
        if (title == null) {
            title = layer.toString();
        }
        StringBuilder sb = new StringBuilder(String.format("<html><b>%s</b>", title));

        Layer[] children = layer.getChildren();
        if (children.length > 1) {
            sb.append(String.format(" (%d children)", children.length));
        } else if (children.length == 1) {
            sb.append(" (1 child)");
        }

        text = sb.append("</html>").toString();
    } else if (value instanceof WMSCapabilities) {
        WMSCapabilities capabilities = (WMSCapabilities) value;
        text = String.format("<html><b>%s</b></html>", capabilities.getService().getName());
    } else {
        text = String.format("<html><b>%s</b></html>", value);
    }
    label.setText(text);
    return label;
}
 
Example 9
Source File: TableCheckBoxColumn.java    From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 5 votes vote down vote up
@Override
    public Component getTableCellRendererComponent(
            JTable tbl, Object val, boolean isS, boolean hasF, int row, int col) {
        if (val instanceof Status) {
            switch ((Status) val) {
                case SELECTED:
                    setSelected(true);
                    setEnabled(true);
                    break;
                case DESELECTED:
                    setSelected(false);
                    setEnabled(true);
                    break;
                case INDETERMINATE:
                    setSelected(true);
                    setEnabled(false);
                    break;
            }
        } else {
            setSelected(true);
            setEnabled(false);
        }
        TableCellRenderer r = tbl.getTableHeader().getDefaultRenderer();
        JLabel l = (JLabel) r.getTableCellRendererComponent(tbl, null, isS, hasF, row, col);

        l.setIcon(new CheckBoxIcon(this));
        l.setText(null);
        l.setHorizontalAlignment(SwingConstants.CENTER);
//        l.setComponentPopupMenu(popupMenu);

        return l;
    }
 
Example 10
Source File: EnumComboBoxCellRenderer.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public Component getListCellRendererComponent(JList<? extends E> list, E value, int index, boolean isSelected,
		boolean cellHasFocus) {
	JLabel listCellRendererComponent = (JLabel) defaultRenderer.getListCellRendererComponent(list, value, index,
			isSelected, cellHasFocus);

	String text = textCache.get(value);
	ImageIcon icon = iconCache.get(value);
	if (text == null) {

		// get enum text
		text = I18N.getMessageOrNull(I18N.getGUIBundle(), "gui.label." + i18nKeyPrefix + "." + value + ".label");
		if (text != null) {
			textCache.put(value, text);
		} else {
			text = i18nKeyPrefix + "." + value;
		}

		// create label icon
		String iconId = I18N.getMessageOrNull(I18N.getGUIBundle(), "gui.label." + i18nKeyPrefix + "." + value + ".icon");
		if (iconId != null) {
			icon = SwingTools.createIcon("16/" + iconId);
			iconCache.put(value, icon);
		}
	}

	// set text and icon
	listCellRendererComponent.setText(text);
	listCellRendererComponent.setIcon(icon);

	return listCellRendererComponent;
}
 
Example 11
Source File: FeaturesView.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
public FeaturesView(Component defaultView, String buttonString) {
    if (UIUtils.isOracleLookAndFeel()) {
        setOpaque(true);
        setBackground(UIUtils.getProfilerResultsBackground());
    } else {
        setOpaque(false);
    }
    setBorder(BorderFactory.createEmptyBorder());
    setLayout(new BorderLayout(0, 0));
    
    if (defaultView != null) {
        JScrollPane sp = new JScrollPane(defaultView, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER) {
            public Dimension getMinimumSize() { return getPreferredSize(); }
        };
        sp.getVerticalScrollBar().setUnitIncrement(20);
        sp.setBorder(null);
        sp.setViewportBorder(null);

        this.defaultView = sp;
        add(this.defaultView, BorderLayout.CENTER);
    } else {
        this.defaultView = null;
    }
    
    if (buttonString != null) {
        hintLabel = new JLabel();
        hintLabel.setIcon(Icons.getIcon(GeneralIcons.INFO));
        hintLabel.setIconTextGap(hintLabel.getIconTextGap() + 1);
        hintLabel.setOpaque(false);
        
        Font font = new JToolTip().getFont();
        
        Color f = hintLabel.getForeground();
        int r = f.getRed() + 70;
        if (r > 255) r = f.getRed() - 70; else r = Math.min(r, 70);
        int g = f.getGreen() + 70;
        if (g > 255) g = f.getRed() - 70; else g = Math.min(g, 70);
        int b = f.getBlue() + 70;
        if (b > 255) b = f.getRed() - 70; else b = Math.min(b, 70);
        hintLabel.setText("<html><body text=\"rgb(" + r + ", " + g + ", " + b + ")\" style=\"font-size: " + //NOI18N
                          (font.getSize()) + "pt; font-family: " + font.getName() + ";\">" + //NOI18N
                          Bundle.FeaturesView_noData("<b>" + buttonString + "</b>") + "</body></html>"); //NOI18N
        
        hintLabel.setSize(hintLabel.getPreferredSize());
        
        Color c = UIUtils.getProfilerResultsBackground();
        hintColor = Utils.checkedColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), 245));
    } else {
        hintColor = null;
    }
}
 
Example 12
Source File: DateInterpretationsDesktopPane.java    From ET_Redux with Apache License 2.0 4 votes vote down vote up
private void ShowDateInterpretationPanel(
        AliquotInterface aliquot,
        ValueModel sampleDateModel,
        int width,
        int offset) {

    JPanel ageInterpPanel = new JPanel();
    if (((SampleDateModel)sampleDateModel).isPreferred()){
        ageInterpPanel.setBackground(new java.awt.Color(255, 204, 204));
    }else {
        ageInterpPanel.setBackground(new java.awt.Color(255, 255, 204));
    }

    org.jdesktop.layout.GroupLayout jPanel1Layout =
            new org.jdesktop.layout.GroupLayout(ageInterpPanel);
    ageInterpPanel.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(
            org.jdesktop.layout.GroupLayout.LEADING).add(0, width, Short.MAX_VALUE));
    jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(
            org.jdesktop.layout.GroupLayout.LEADING).add(0, 100, Short.MAX_VALUE));

    ageInterpPanel.setBounds(0, offset * 120 + 25, width, 100);

    JLabel aliquotName_label = new JLabel();
    aliquotName_label.setHorizontalAlignment(SwingConstants.CENTER);
    aliquotName_label.setBorder(
            javax.swing.BorderFactory.createLineBorder(Color.black));
    aliquotName_label.setText(
            "Aliquot: " + aliquot.getAliquotName().trim());
    aliquotName_label.setSize(width, 10);


    try {
        JLabel ageInterpName_label = new JLabel(sampleDateModel.getName());
        org.jdesktop.layout.GroupLayout ageInterpPanelLayout =
                new org.jdesktop.layout.GroupLayout(ageInterpPanel);
        ageInterpPanel.setLayout(ageInterpPanelLayout);
        ageInterpPanelLayout.setHorizontalGroup(
                ageInterpPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(ageInterpPanelLayout.createSequentialGroup().add(ageInterpName_label).addContainerGap(161, Short.MAX_VALUE)).add(aliquotName_label, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 206, Short.MAX_VALUE));
        ageInterpPanelLayout.setVerticalGroup(
                ageInterpPanelLayout.createParallelGroup(//
                org.jdesktop.layout.GroupLayout.LEADING).//
                add(ageInterpPanelLayout.createSequentialGroup().//
                add(aliquotName_label).//
                //addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).//
                add(ageInterpName_label).//
                addContainerGap(60, Short.MAX_VALUE)));
    } catch (Exception e) {
    }


    add(ageInterpPanel);//, javax.swing.JLayeredPane.DEFAULT_LAYER);
}
 
Example 13
Source File: WebMapsView.java    From hortonmachine with GNU General Public License v3.0 4 votes vote down vote up
public JPanel createPanel3()
{
   JPanel jpanel1 = new JPanel();
   TitledBorder titledborder1 = new TitledBorder(null,"Bounds",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,null,new Color(33,33,33));
   jpanel1.setBorder(titledborder1);
   FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(0.5),FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0)","CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE");
   CellConstraints cc = new CellConstraints();
   jpanel1.setLayout(formlayout1);

   JLabel jlabel1 = new JLabel();
   jlabel1.setText("North");
   jpanel1.add(jlabel1,cc.xy(1,1));

   JLabel jlabel2 = new JLabel();
   jlabel2.setText("South");
   jpanel1.add(jlabel2,cc.xy(1,3));

   JLabel jlabel3 = new JLabel();
   jlabel3.setText("West");
   jpanel1.add(jlabel3,cc.xy(1,5));

   JLabel jlabel4 = new JLabel();
   jlabel4.setText("East");
   jpanel1.add(jlabel4,cc.xy(1,7));

   _northCrsLabel.setName("northCrsLabel");
   _northCrsLabel.setText("- nv -");
   jpanel1.add(_northCrsLabel,cc.xy(3,1));

   _southCrsLabel.setName("southCrsLabel");
   _southCrsLabel.setText("- nv -");
   jpanel1.add(_southCrsLabel,cc.xy(3,3));

   _westCrsLabel.setName("westCrsLabel");
   _westCrsLabel.setText("- nv -");
   jpanel1.add(_westCrsLabel,cc.xy(3,5));

   _eastCrsLabel.setName("eastCrsLabel");
   _eastCrsLabel.setText("- nv -");
   jpanel1.add(_eastCrsLabel,cc.xy(3,7));

   addFillComponents(jpanel1,new int[]{ 2 },new int[]{ 2,4,6 });
   return jpanel1;
}
 
Example 14
Source File: ProfilerCPUPanel.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
private static void setText(JLabel l, String text, boolean mnemonics) {
    if (mnemonics) Mnemonics.setLocalizedText(l, text);
    else l.setText(text.replace("&", "")); // NOI18N
}
 
Example 15
Source File: OpendapAccessPanel.java    From snap-desktop with GNU General Public License v3.0 4 votes vote down vote up
private void initComponents() {
    urlField = new JComboBox<>();
    urlField.setEditable(true);
    urlField.getEditor().getEditorComponent().addKeyListener(new KeyAdapter() {
        @Override
        public void keyTyped(KeyEvent e) {
            if (e.getKeyChar() == KeyEvent.VK_ENTER) {
                refreshButton.doClick();
            }
        }
    });
    updateUrlField();
    refreshButton = ToolButtonFactory.createButton(
            TangoIcons.actions_view_refresh(TangoIcons.Res.R22),
            false);
    refreshButton.addActionListener(e -> {
        final boolean usingUrl = refresh();
        if (usingUrl) {
            final String urls = preferences.get(PROPERTY_KEY_SERVER_URLS, "");
            final String currentUrl = urlField.getSelectedItem().toString();
            if (!urls.contains(currentUrl)) {
                preferences.put(PROPERTY_KEY_SERVER_URLS, urls + "\n" + currentUrl);
                updateUrlField();
            }
        }
    });
    metaInfoArea = new JTabbedPane(JTabbedPane.TOP, JTabbedPane.SCROLL_TAB_LAYOUT);
    JTextArea ddsArea = new JTextArea(10, 40);
    JTextArea dasArea = new JTextArea(10, 40);

    ddsArea.setEditable(false);
    dasArea.setEditable(false);

    textAreas = new HashMap<>();
    textAreas.put(DAS_AREA_INDEX, dasArea);
    textAreas.put(DDS_AREA_INDEX, ddsArea);

    metaInfoArea.addTab("DDS", new JScrollPane(ddsArea));
    metaInfoArea.addTab("DAS", new JScrollPane(dasArea));
    metaInfoArea.setToolTipTextAt(DDS_AREA_INDEX, "Dataset Descriptor Structure: description of dataset variables");
    metaInfoArea.setToolTipTextAt(DAS_AREA_INDEX, "Dataset Attribute Structure: description of dataset attributes");

    metaInfoArea.addChangeListener(e -> {
        if (catalogTree.getSelectedLeaf() != null) {
            setMetadataText(metaInfoArea.getSelectedIndex(), catalogTree.getSelectedLeaf());
        }
    });

    catalogTree = new CatalogTree(new DefaultLeafSelectionListener(), appContext, this);
    useDatasetNameFilter = new JCheckBox("Use dataset name filter");
    useTimeRangeFilter = new JCheckBox("Use time range filter");
    useRegionFilter = new JCheckBox("Use region filter");
    useVariableFilter = new JCheckBox("Use variable name filter");

    DefaultFilterChangeListener filterChangeListener = new DefaultFilterChangeListener();
    datasetNameFilter = new DatasetNameFilter(useDatasetNameFilter);
    datasetNameFilter.addFilterChangeListener(filterChangeListener);
    timeRangeFilter = new TimeRangeFilter(useTimeRangeFilter);
    timeRangeFilter.addFilterChangeListener(filterChangeListener);
    regionFilter = new RegionFilter(useRegionFilter);
    regionFilter.addFilterChangeListener(filterChangeListener);
    variableFilter = new VariableFilter(useVariableFilter, catalogTree);
    variableFilter.addFilterChangeListener(filterChangeListener);

    catalogTree.addCatalogTreeListener(new CatalogTree.CatalogTreeListener() {
        @Override
        public void leafAdded(OpendapLeaf leaf, boolean hasNestedDatasets) {
            if (hasNestedDatasets) {
                return;
            }
            if (leaf.getDataset().getGeospatialCoverage() != null) {
                useRegionFilter.setEnabled(true);
            }
            filterLeaf(leaf);
        }

        @Override
        public void catalogElementsInsertionFinished() {
        }
    });

    openInVisat = new JCheckBox("Open in SNAP");
    statusBarMessage = new JLabel("Ready.");
    statusBarMessage.setText("Ready.");
    preMessageLabel = new JLabel();
    postMessageLabel = new JLabel();
    progressBar = new JProgressBar(0, 100);

    statusBar = new JPanel();
    statusBar.setLayout(new BoxLayout(statusBar, BoxLayout.X_AXIS));
    statusBar.add(statusBarMessage);
    statusBar.add(Box.createHorizontalStrut(4));
    statusBar.add(preMessageLabel);
    statusBar.add(Box.createHorizontalGlue());
    statusBar.add(progressBar);
    statusBar.add(Box.createHorizontalGlue());
    statusBar.add(postMessageLabel);

    useRegionFilter.setEnabled(false);
}
 
Example 16
Source File: UserAddIFrame.java    From LibraryManagementSystem with MIT License 4 votes vote down vote up
public UserAddIFrame() {
	super();
	setIconifiable(true);							// ���ô������С������������
	setClosable(true);								// ���ô���ɹرգ���������
	setTitle("��ӹ���Ա");						// ���ô�����⣭��������
	setBounds(100, 50, 500, 225);

	//������ͷͼƬ
	final JLabel logoLabel = new JLabel();
	ImageIcon userAddIcon=CreateIcon.add("tback.jpg");
	logoLabel.setIcon(userAddIcon);
	logoLabel.setOpaque(true);
	logoLabel.setBackground(Color.white);
	logoLabel.setPreferredSize(new Dimension(400, 60));
	getContentPane().add(logoLabel, BorderLayout.NORTH);

	//����һ�������������
	final JPanel panel = new JPanel();
	panel.setLayout(new FlowLayout());
	getContentPane().add(panel);

	//�������������Ƕ�����1,���ڷ��÷ǰ�ť���
	final JPanel panel_1 = new JPanel();
	final GridLayout gridLayout = new GridLayout(2, 2);
	gridLayout.setVgap(20);
	panel_1.setLayout(gridLayout);
	panel.add(panel_1);

	final JLabel label_2 = new JLabel();
	label_2.setText("�û�����");
	panel_1.add(label_2);
	name = new JTextField(10);
	name.setDocument(new MyDocument(20));
	panel_1.add(name);
	
	final JLabel label_3 = new JLabel();
	label_3.setText("���룺");
	panel_1.add(label_3);
	password = new JTextField(10);
	password.setDocument(new MyDocument(15));
	panel_1.add(password);
	
	//����������Ƕ��һ�����ڷ��Ű�ť�����
	final JPanel panel_2 = new JPanel();
	panel_2.setPreferredSize(new Dimension(450, 100));
	panel.add(panel_2);
	
	final JRadioButton radioButton1 = new JRadioButton();

	//�����������
	final JButton submit = new JButton();
	panel_2.add(submit);
	submit.setText("�ύ");
	submit.addActionListener((ActionListener) new ButtonAddListener(radioButton1));
	
	//�����������
	final JButton back = new JButton();
	panel_2.add(back);
	back.setText("����");
	back.addActionListener(new CloseActionListener());

	setVisible(true);
}
 
Example 17
Source File: LoginFrame.java    From xyTalk-pc with GNU Affero General Public License v3.0 4 votes vote down vote up
private void initComponents() {
	Dimension windowSize = new Dimension(windowWidth, windowHeight);
	setMinimumSize(windowSize);
	setMaximumSize(windowSize);

	controlPanel = new JPanel();
	controlPanel.setLayout(new FlowLayout(FlowLayout.RIGHT, 10, 5));
	// controlPanel.setBounds(0,5, windowWidth, 30);

	closeLabel = new JLabel();
	closeLabel.setIcon(IconUtil.getIcon(this, "/image/close.png"));
	closeLabel.setHorizontalAlignment(JLabel.CENTER);
	// closeLabel.setPreferredSize(new Dimension(30,30));
	closeLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));

	titleLabel = new JLabel();
	titleLabel.setText("登录 XyTalk");
	titleLabel.setFont(FontUtil.getDefaultFont(16));

	downloadLabel = new JLabel();
	downloadLabel.setText("下载客户端软件");
	downloadLabel.setFont(FontUtil.getDefaultFont(14));
	
	remberPsw = new JCheckBox("记住密码", true);
	remberPsw.setFont(FontUtil.getDefaultFont(14));
	
	offlineLogin = new JCheckBox("断网离线登陆", false);
	offlineLogin.setFont(FontUtil.getDefaultFont(14));

	editPanel = new JPanel();
	editPanel.setLayout(new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 5, true, false));

	Dimension textFieldDimension = new Dimension(200, 35);
	usernameField = new RCTextField();
	usernameField.setPlaceholder("用户名");
	usernameField.setPreferredSize(textFieldDimension);
	usernameField.setFont(FontUtil.getDefaultFont(14));
	usernameField.setForeground(Colors.FONT_BLACK);
	usernameField.setMargin(new Insets(0, 15, 0, 0));
	usernameField.setText("wangxin");

	passwordField = new RCPasswordField();
	passwordField.setPreferredSize(textFieldDimension);
	passwordField.setPlaceholder("密码");
	// passwordField.setBorder(new RCBorder(RCBorder.BOTTOM,
	// Colors.LIGHT_GRAY));
	passwordField.setFont(FontUtil.getDefaultFont(14));
	passwordField.setForeground(Colors.FONT_BLACK);
	passwordField.setMargin(new Insets(0, 15, 0, 0));
	passwordField.setText("1");

	loginButton = new RCButton("登 录", Colors.MAIN_COLOR, Colors.MAIN_COLOR_DARKER, Colors.MAIN_COLOR_DARKER);
	loginButton.setFont(FontUtil.getDefaultFont(14));
	loginButton.setPreferredSize(new Dimension(300, 40));

	statusLabel = new JLabel();
	statusLabel.setForeground(Colors.RED);
	statusLabel.setText("密码不正确");
	statusLabel.setVisible(false);
	
	usernameField.setText(readName());
	passwordField.setText(readPassword());
}
 
Example 18
Source File: BookAdd2IFrame.java    From LibraryManagementSystem with MIT License 4 votes vote down vote up
public BookAdd2IFrame() {
	super();
	setIconifiable(true);							// ���ô������С������������
	setClosable(true);								// ���ô���ɹرգ���������
	setTitle("����ͼ�����");						// ���ô�����⣭��������
	setBounds(100, 50, 500, 225);

	//������ͷͼƬ
	final JLabel logoLabel = new JLabel();
	ImageIcon readerAddIcon=CreateIcon.add("tback.jpg");
	logoLabel.setIcon(readerAddIcon);
	logoLabel.setOpaque(true);
	logoLabel.setBackground(Color.white);
	logoLabel.setPreferredSize(new Dimension(400, 60));
	getContentPane().add(logoLabel, BorderLayout.NORTH);

	//����һ�������������
	final JPanel panel = new JPanel();
	panel.setLayout(new FlowLayout());
	getContentPane().add(panel);

	//�������������Ƕ�����1,���ڷ��÷ǰ�ť���
	final JPanel panel_1 = new JPanel();
	final GridLayout gridLayout = new GridLayout(2, 2);
	gridLayout.setVgap(20);
	panel_1.setLayout(gridLayout);
	panel.add(panel_1);

	final JLabel label_2 = new JLabel();
	label_2.setText("ͼ���ţ�");
	panel_1.add(label_2);
	id = new JTextField(10);
	panel_1.add(id);
	
	final JLabel label_3 = new JLabel();
	label_3.setText("���������");
	panel_1.add(label_3);
	num = new JTextField(10);
	panel_1.add(num);
	
	//����������Ƕ��һ�����ڷ��Ű�ť�����
	final JPanel panel_2 = new JPanel();
	panel_2.setPreferredSize(new Dimension(450, 100));
	panel.add(panel_2);
	
	final JRadioButton radioButton1 = new JRadioButton();

	//�����������
	final JButton submit = new JButton();
	panel_2.add(submit);
	submit.setText("�ύ");
	submit.addActionListener((ActionListener) new ButtonAddListener(radioButton1));
	
	//�����������
	final JButton back = new JButton();
	panel_2.add(back);
	back.setText("����");
	back.addActionListener(new CloseActionListener());

	setVisible(true);
}
 
Example 19
Source File: HistoryItem.java    From Spark with Apache License 2.0 4 votes vote down vote up
public HistoryItem(String fullName, Date date, String email, String question, String duration) {
    setBackground(Color.white);
    setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.LIGHT_GRAY));
    setLayout(new GridBagLayout());

    final JLabel nameLabel = new JLabel();
    nameLabel.setText(FpRes.getString("name") + ":");
    nameLabel.setFont(new Font("Dialog", Font.BOLD, 11));
    add(nameLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 5, 2, 5), 0, 0));
    add(fullNameLabel, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 5, 2, 5), 0, 0));

    add(dateLabel, new GridBagConstraints(2, 0, 1, 1, 1.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 5, 2, 5), 0, 0));

    final JLabel emailTitleLabel = new JLabel();
    emailTitleLabel.setText(FpRes.getString("email") + ":");
    emailTitleLabel.setFont(new Font("Dialog", Font.BOLD, 11));

    add(emailTitleLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 2, 5), 0, 0));
    add(emailLabel, new GridBagConstraints(1, 1, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 2, 5), 0, 0));

    final JLabel questionTitle = new JLabel();
    questionTitle.setText(FpRes.getString("question") + ":");
    questionTitle.setFont(new Font("Dialog", Font.BOLD, 11));

    add(questionTitle, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 2, 5), 0, 0));
    add(questionLabel, new GridBagConstraints(1, 2, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 2, 5), 0, 0));

    final JLabel conLabel = new JLabel();
    conLabel.setText(FpRes.getString("duration") + ":");
    conLabel.setFont(new Font("Dialog", Font.BOLD, 11));

    add(conLabel, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 2, 5), 0, 0));
    add(conversationLabel, new GridBagConstraints(1, 3, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 2, 5), 0, 0));

    final SimpleDateFormat simpleFormat = new SimpleDateFormat("MM/dd/yyyy h:mm a");
    String theDate = simpleFormat.format(date);

    fullNameLabel.setText(fullName);
    dateLabel.setText(theDate);
    emailLabel.setText(email);
    questionLabel.setText(question);
    conversationLabel.setText(duration);
}
 
Example 20
Source File: SamplerMemoryPanel.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
private static void setText(JLabel l, String text, boolean mnemonics) {
    if (mnemonics) Mnemonics.setLocalizedText(l, text);
    else l.setText(text.replace("&", "")); // NOI18N
}