private void setBorder(boolean isEnabled) { JTextField txfTmp = new JTextField(); if (isEnabled) setBorder(txfTmp.getBorder()); else { String strStyle = getAttribute(DISABLE); if (strStyle != null && strStyle.equals(m_arrStrDisAbl[1])) { setBorder(null); setBackground(Util.getBgColor()); } else { setBorder(txfTmp.getBorder()); setBackground(Global.NPCOLOR); } } }
public static JPanel createSelected(final JTextField textField, final JButton... btns) { final Dimension btnDim = new Dimension(18, 18); initComponentHeight(textField); final JPanel jp = new JPanel(new GridBagLayout()); jp.setBorder(textField.getBorder()); textField.setBorder(BorderFactory.createEmptyBorder()); jp.setPreferredSize(textField.getPreferredSize()); final GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.weightx = 1.0; gbc.weighty = 1.0; gbc.fill = GridBagConstraints.BOTH; jp.add(textField, gbc); gbc.weightx = 0.0; if (btns != null) { for (final JButton btn : btns) { gbc.gridx++; btn.setMaximumSize(btnDim); btn.setMinimumSize(btnDim); btn.setPreferredSize(btnDim); btn.setText(".."); jp.add(btn, gbc); } } return jp; }
private void buildUI() { Box.Filler divider = new Box.Filler(new Dimension(1, 1), new Dimension(1, 1), new Dimension(1, 1)); divider.setBackground(field.getForeground()); divider.setOpaque(true); GridBagConstraints gbcLabel = new GridBagConstraints( 1, 1, 1, 1, 0, 1, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0); GridBagConstraints gbcDivider = new GridBagConstraints( 2, 1, 1, 1, 0, 1, GridBagConstraints.CENTER, GridBagConstraints.VERTICAL, new Insets(0, 2, 0, 2), 0, 0); GridBagConstraints gbcField = new GridBagConstraints( 3, 1, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0); setLayout(new GridBagLayout()); add(label, gbcLabel); add(divider, gbcDivider); add(field, gbcField); setBorder(field.getBorder()); setBackground(field.getBackground()); setOpaque(true); label.setBackground(field.getBackground()); label.setOpaque(true); field.setBorder(null); }
@Override public void installUI(JComponent c) { super.installUI(c); jtf = (JTextField) c; JTextField editor = jtf; UIDefaults uidefaults = XToolkit.getUIDefaults(); String prefix = getPropertyPrefix(); Font f = editor.getFont(); if ((f == null) || (f instanceof UIResource)) { editor.setFont(uidefaults.getFont(prefix + ".font")); } Color bg = editor.getBackground(); if ((bg == null) || (bg instanceof UIResource)) { editor.setBackground(uidefaults.getColor(prefix + ".background")); } Color fg = editor.getForeground(); if ((fg == null) || (fg instanceof UIResource)) { editor.setForeground(uidefaults.getColor(prefix + ".foreground")); } Color color = editor.getCaretColor(); if ((color == null) || (color instanceof UIResource)) { editor.setCaretColor(uidefaults.getColor(prefix + ".caretForeground")); } Color s = editor.getSelectionColor(); if ((s == null) || (s instanceof UIResource)) { editor.setSelectionColor(uidefaults.getColor(prefix + ".selectionBackground")); } Color sfg = editor.getSelectedTextColor(); if ((sfg == null) || (sfg instanceof UIResource)) { editor.setSelectedTextColor(uidefaults.getColor(prefix + ".selectionForeground")); } Color dfg = editor.getDisabledTextColor(); if ((dfg == null) || (dfg instanceof UIResource)) { editor.setDisabledTextColor(uidefaults.getColor(prefix + ".inactiveForeground")); } Border b = editor.getBorder(); if ((b == null) || (b instanceof UIResource)) { editor.setBorder(uidefaults.getBorder(prefix + ".border")); } Insets margin = editor.getMargin(); if (margin == null || margin instanceof UIResource) { editor.setMargin(uidefaults.getInsets(prefix + ".margin")); } }
/** * Creates a {@link JTextField} customized for use in this UI widget. * * @return a {@link JTextField} */ protected JTextField createTextField() { JTextField tf = UIHelper.createTextField(); Insets insets = tf.getBorder().getBorderInsets(tf); tf.setBorder( BorderFactory.createEmptyBorder(insets.top, insets.left, insets.bottom, insets.bottom)); tf.setForeground(Color.BLACK); tf.setBackground(Color.WHITE); tf.setEditable(false); return tf; }
public dialogAlterarCliente(Cliente cliente) { setContentPane(contentPane); setModal(true); getRootPane().setDefaultButton(buttonOK); borderError = BorderFactory.createLineBorder(Color.red); borderDefault = txtNome.getBorder(); c = cliente; txtNome.setText(c.getNome()); txtCpf.setText(c.getCpf()); txtEndereco.setText(c.getEndereco()); txtEmail.setText(c.getEmail()); txtTelefone.setText(c.getTelefone()); cboxStatusCliente.setSelectedIndex(c.getStatus()); buttonOK.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { onOK(); } }); buttonCancel.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { onCancel(); } }); // call onCancel() when cross is clicked setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { onCancel(); } }); // call onCancel() on ESCAPE contentPane.registerKeyboardAction( new ActionListener() { public void actionPerformed(ActionEvent e) { onCancel(); } }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); }
private void updateComponentsUI() { if (this._changedUI) { JTextField t = new JTextField(); this._fieldPanel.setOpaque(true); this._fieldPanel.setBackground(t.getBackground()); this._fieldPanel.setForeground(t.getForeground()); this._fieldPanel.setBorder(t.getBorder()); prepareComponent(this._hourField); prepareComponent(this._minuteField); prepareComponent(this._secondField); prepareComponent(this._hmSeparator); prepareComponent(this._msSeparator); this._changedUI = false; } }
/** * _more_ * * @param initValue * @param min * @param max */ public JSpinner(int initValue, int min, int max) { value = initValue; this.minValue = min; this.maxValue = max; // the value field tf = new JTextField(1); tf.setEditable(false); javax.swing.border.Border border = tf.getBorder(); tf.setBorder(BorderFactory.createEmptyBorder()); setBorder(javax.swing.border.LineBorder.createBlackLineBorder()); setValue(initValue); // create up & down buttons JPanel udPanel = new JPanel(new GridLayout(2, 1)); JButton up = createButton(SpinIcon.TypeUp); udPanel.add(up); JButton down = createButton(SpinIcon.TypeDown); udPanel.add(down); add(tf); add(udPanel); // listeners up.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (value < maxValue) { value++; } setValue(value); } }); down.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (value > minValue) { value--; } setValue(value); } }); }
private JPanel createInstructionsPanel(int stentWidth) { MultiBitTitledPanel instructionsPanel = new MultiBitTitledPanel( controller.getLocaliser().getString("verifyMessagePanel.instructions.title"), ComponentOrientation.getOrientation(controller.getLocaliser().getLocale())); GridBagConstraints constraints = new GridBagConstraints(); MultiBitTitledPanel.addLeftJustifiedTextAtIndent( controller.getLocaliser().getString("verifyMessagePanel.instructions.text1"), 3, instructionsPanel); MultiBitTitledPanel.addLeftJustifiedTextAtIndent( controller.getLocaliser().getString("verifyMessagePanel.instructions.text2"), 4, instructionsPanel); constraints.fill = GridBagConstraints.BOTH; constraints.gridx = 1; constraints.gridy = 5; constraints.weightx = 0.3; constraints.weighty = 0.3; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.LINE_START; instructionsPanel.add( MultiBitTitledPanel.createStent(stentWidth, ExportPrivateKeysPanel.STENT_HEIGHT), constraints); constraints.fill = GridBagConstraints.BOTH; constraints.gridx = 2; constraints.gridy = 6; constraints.weightx = 0.05; constraints.weighty = 0.3; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.CENTER; instructionsPanel.add( MultiBitTitledPanel.createStent(MultiBitTitledPanel.SEPARATION_BETWEEN_NAME_VALUE_PAIRS), constraints); JPanel filler3 = new JPanel(); filler3.setOpaque(false); constraints.fill = GridBagConstraints.BOTH; constraints.gridx = 1; constraints.gridy = 8; constraints.weightx = 0.3; constraints.weighty = 0.3; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.LINE_START; instructionsPanel.add(filler3, constraints); addressLabel = new MultiBitLabel(controller.getLocaliser().getString("sendBitcoinPanel.addressLabel")); addressLabel.applyComponentOrientation( ComponentOrientation.getOrientation(controller.getLocaliser().getLocale())); constraints.fill = GridBagConstraints.NONE; constraints.gridx = 1; constraints.gridy = 9; constraints.weightx = 0.3; constraints.weighty = 0.4; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.LINE_END; instructionsPanel.add(addressLabel, constraints); constraints.fill = GridBagConstraints.BOTH; constraints.gridx = 2; constraints.gridy = 9; constraints.weightx = 0.05; constraints.weighty = 0.3; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.CENTER; instructionsPanel.add( MultiBitTitledPanel.createStent(MultiBitTitledPanel.SEPARATION_BETWEEN_NAME_VALUE_PAIRS), constraints); // addressTextArea = new MultiBitTextField("", 30, controller); JTextField aTextField = new JTextField(); addressTextArea = new MultiBitTextArea("", 1, 30, controller); addressTextArea.setBorder(aTextField.getBorder()); addressTextArea.setMinimumSize(new Dimension(FIELD_WIDTH, FIELD_HEIGHT)); addressTextArea.setPreferredSize(new Dimension(FIELD_WIDTH, FIELD_HEIGHT)); addressTextArea.setMaximumSize(new Dimension(FIELD_WIDTH, FIELD_HEIGHT)); addressTextArea.applyComponentOrientation( ComponentOrientation.getOrientation(controller.getLocaliser().getLocale())); constraints.fill = GridBagConstraints.BOTH; constraints.gridx = 3; constraints.gridy = 9; constraints.weightx = 0.3; constraints.weighty = 0.4; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.LINE_START; instructionsPanel.add(addressTextArea, constraints); JPanel filler4 = new JPanel(); filler4.setOpaque(false); constraints.fill = GridBagConstraints.BOTH; constraints.gridx = 1; constraints.gridy = 10; constraints.weightx = 0.3; constraints.weighty = 0.3; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.LINE_START; instructionsPanel.add(filler4, constraints); JTextField secondTextField = new JTextField(); messageTextArea = new MultiBitTextArea( "", AbstractTradePanel.PREFERRED_NUMBER_OF_LABEL_ROWS + 1, 20, controller); messageTextArea.setBorder(secondTextField.getBorder()); messageTextArea.applyComponentOrientation( ComponentOrientation.getOrientation(controller.getLocaliser().getLocale())); final JScrollPane messageScrollPane = new JScrollPane( messageTextArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); messageScrollPane.setOpaque(true); messageScrollPane.setBackground(ColorAndFontConstants.VERY_LIGHT_BACKGROUND_COLOR); messageScrollPane.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1)); messageScrollPane .getViewport() .addChangeListener( new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { if (messageScrollPane.getVerticalScrollBar().isVisible()) { messageScrollPane.setBorder( BorderFactory.createMatteBorder(1, 1, 1, 1, Color.LIGHT_GRAY)); } else { messageScrollPane.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1)); } } }); messageScrollPane.setMinimumSize( new Dimension( FIELD_WIDTH, (AbstractTradePanel.PREFERRED_NUMBER_OF_LABEL_ROWS + 1) * FIELD_HEIGHT + 6)); messageScrollPane.setPreferredSize( new Dimension( FIELD_WIDTH, (AbstractTradePanel.PREFERRED_NUMBER_OF_LABEL_ROWS + 1) * FIELD_HEIGHT + 6)); messageScrollPane.getHorizontalScrollBar().setUnitIncrement(CoreModel.SCROLL_INCREMENT); messageScrollPane.getVerticalScrollBar().setUnitIncrement(CoreModel.SCROLL_INCREMENT); if (messageScrollPane.getVerticalScrollBar().isVisible()) { messageScrollPane.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.LIGHT_GRAY)); } else { messageScrollPane.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1)); } messageLabel = new MultiBitLabel(controller.getLocaliser().getString("verifyMessagePanel.message.text")); messageLabel.applyComponentOrientation( ComponentOrientation.getOrientation(controller.getLocaliser().getLocale())); constraints.fill = GridBagConstraints.NONE; constraints.gridx = 1; constraints.gridy = 11; constraints.weightx = 0.3; constraints.weighty = 0.4; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.LINE_END; instructionsPanel.add(messageLabel, constraints); constraints.fill = GridBagConstraints.BOTH; constraints.gridx = 2; constraints.gridy = 11; constraints.weightx = 0.05; constraints.weighty = 0.3; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.CENTER; instructionsPanel.add( MultiBitTitledPanel.createStent(MultiBitTitledPanel.SEPARATION_BETWEEN_NAME_VALUE_PAIRS), constraints); constraints.fill = GridBagConstraints.HORIZONTAL; constraints.gridx = 3; constraints.gridy = 11; constraints.weightx = 0.3; constraints.weighty = 0.4; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.LINE_START; instructionsPanel.add(messageScrollPane, constraints); JPanel filler5 = new JPanel(); filler5.setOpaque(false); constraints.fill = GridBagConstraints.BOTH; constraints.gridx = 1; constraints.gridy = 12; constraints.weightx = 0.3; constraints.weighty = 0.3; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.LINE_START; instructionsPanel.add(filler5, constraints); signatureLabel = new MultiBitLabel(controller.getLocaliser().getString("verifyMessagePanel.signature.text")); signatureLabel.applyComponentOrientation( ComponentOrientation.getOrientation(controller.getLocaliser().getLocale())); constraints.fill = GridBagConstraints.NONE; constraints.gridx = 1; constraints.gridy = 13; constraints.weightx = 0.3; constraints.weighty = 0.4; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.LINE_END; instructionsPanel.add(signatureLabel, constraints); constraints.fill = GridBagConstraints.BOTH; constraints.gridx = 2; constraints.gridy = 13; constraints.weightx = 0.05; constraints.weighty = 0.3; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.CENTER; instructionsPanel.add( MultiBitTitledPanel.createStent(MultiBitTitledPanel.SEPARATION_BETWEEN_NAME_VALUE_PAIRS), constraints); JTextField anotherTextField = new JTextField(); signatureTextArea = new MultiBitTextArea("", 2, 30, controller); signatureTextArea.setBorder(anotherTextField.getBorder()); signatureTextArea.setMinimumSize(new Dimension(FIELD_WIDTH, FIELD_HEIGHT * 2)); signatureTextArea.setPreferredSize(new Dimension(FIELD_WIDTH, FIELD_HEIGHT * 2)); signatureTextArea.setMaximumSize(new Dimension(FIELD_WIDTH, FIELD_HEIGHT * 2)); signatureTextArea.setLineWrap(true); signatureTextArea.applyComponentOrientation( ComponentOrientation.getOrientation(controller.getLocaliser().getLocale())); constraints.fill = GridBagConstraints.BOTH; constraints.gridx = 3; constraints.gridy = 13; constraints.weightx = 0.3; constraints.weighty = 0.4; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.LINE_START; instructionsPanel.add(signatureTextArea, constraints); return instructionsPanel; }
@Override public void displayView(DisplayHint displayHint) { super.displayView(displayHint); if (DisplayHint.WALLET_TRANSACTIONS_HAVE_CHANGED == displayHint) { return; } JTextField aTextField = new JTextField(); labelTextArea.setBorder(aTextField.getBorder()); String bringToFront = controller.getModel().getUserPreference(BitcoinModel.BRING_TO_FRONT); if (Boolean.TRUE.toString().equals(bringToFront)) { controller.getModel().setUserPreference(BitcoinModel.BRING_TO_FRONT, "false"); mainFrame.bringToFront(); } // disable any new changes if another process has changed the wallet if (this.bitcoinController.getModel().getActivePerWalletModelData() != null && this.bitcoinController .getModel() .getActivePerWalletModelData() .isFilesHaveBeenChangedByAnotherProcess()) { // files have been changed by another process - disallow edits mainFrame.setUpdatesStoppedTooltip(addressTextField); addressTextField.setEditable(false); addressTextField.setEnabled(false); if (sendButton != null) { sendButton.setEnabled(false); mainFrame.setUpdatesStoppedTooltip(sendButton); } if (pasteAddressButton != null) { pasteAddressButton.setEnabled(false); mainFrame.setUpdatesStoppedTooltip(pasteAddressButton); } titleLabel.setText( controller .getLocaliser() .getString("sendBitcoinPanel.sendingAddressesTitle.mayBeOutOfDate")); mainFrame.setUpdatesStoppedTooltip(titleLabel); } else { addressTextField.setToolTipText(null); addressTextField.setEditable(true); addressTextField.setEnabled(true); if (sendButton != null) { if (SendBitcoinPanel.enableSendButton) { sendButton.setEnabled(true); sendButton.setToolTipText( HelpContentsPanel.createTooltipText( controller.getLocaliser().getString("sendBitcoinAction.tooltip"))); } else { sendButton.setEnabled(false); sendButton.setToolTipText( HelpContentsPanel.createTooltipText( controller.getLocaliser().getString("sendBitcoinAction.pleaseWait.tooltip"))); } } if (pasteAddressButton != null) { pasteAddressButton.setEnabled(true); pasteAddressButton.setToolTipText( HelpContentsPanel.createTooltipText( controller.getLocaliser().getString("pasteAddressAction.tooltip"))); } titleLabel.setText( controller.getLocaliser().getString("sendBitcoinPanel.sendingAddressesTitle")); titleLabel.setToolTipText(null); } checkDeleteSendingEnabled(); updateAmountPanel(); }
@Override protected JPanel createFormPanel(JPanel formPanel, GridBagConstraints constraints) { formPanel.setBackground(ColorAndFontConstants.VERY_LIGHT_BACKGROUND_COLOR); JPanel buttonPanel = new JPanel(); FlowLayout flowLayout = new FlowLayout(); flowLayout.setAlignment(FlowLayout.LEADING); buttonPanel.setLayout(flowLayout); formPanel.setLayout(new GridBagLayout()); // create stents and forcers createFormPanelStentsAndForcers(formPanel, constraints); MultiBitLabel addressLabel = new MultiBitLabel(controller.getLocaliser().getString("sendBitcoinPanel.addressLabel")); addressLabel.setToolTipText( HelpContentsPanel.createTooltipText( controller.getLocaliser().getString("sendBitcoinPanel.addressLabel.tooltip"))); addressLabel.setHorizontalAlignment(JLabel.TRAILING); constraints.fill = GridBagConstraints.HORIZONTAL; constraints.gridx = 0; constraints.gridy = 1; constraints.weightx = 4.0; constraints.weighty = 0.2; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.anchor = GridBagConstraints.LINE_END; formPanel.add(addressLabel, constraints); String receiveAddressText = controller.getLocaliser().getString("receiveBitcoinPanel.addressLabel"); MultiBitLabel notUsedReceiveAddressLabel = new MultiBitLabel(receiveAddressText); formPanel.add( MultiBitTitledPanel.createStent( (int) notUsedReceiveAddressLabel.getPreferredSize().getWidth()), constraints); int longFieldWidth = fontMetrics.stringWidth(MultiBitFrame.EXAMPLE_LONG_FIELD_TEXT); addressTextField = new MultiBitTextField("", 24, controller); addressTextField.setHorizontalAlignment(JTextField.LEADING); addressTextField.setMinimumSize( new Dimension( longFieldWidth, getFontMetrics(FontSizer.INSTANCE.getAdjustedDefaultFont()).getHeight() + TEXTFIELD_VERTICAL_DELTA)); addressTextField.setPreferredSize( new Dimension( longFieldWidth, getFontMetrics(FontSizer.INSTANCE.getAdjustedDefaultFont()).getHeight() + TEXTFIELD_VERTICAL_DELTA)); addressTextField.setMaximumSize( new Dimension( longFieldWidth, getFontMetrics(FontSizer.INSTANCE.getAdjustedDefaultFont()).getHeight() + TEXTFIELD_VERTICAL_DELTA)); addressTextField.addKeyListener(new QRCodeKeyListener()); constraints.fill = GridBagConstraints.HORIZONTAL; constraints.gridx = 2; constraints.gridy = 1; constraints.weightx = 1.0; constraints.weighty = 0.2; constraints.gridwidth = 3; constraints.anchor = GridBagConstraints.LINE_START; formPanel.add(addressTextField, constraints); ImageIcon copyIcon = ImageLoader.createImageIcon(ImageLoader.COPY_ICON_FILE); CopySendAddressAction copyAddressAction = new CopySendAddressAction(controller, this, copyIcon); MultiBitButton copyAddressButton = new MultiBitButton(copyAddressAction, controller); constraints.fill = GridBagConstraints.NONE; constraints.gridx = 6; constraints.gridy = 1; constraints.weightx = 1; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.LINE_START; formPanel.add(copyAddressButton, constraints); ImageIcon pasteIcon = ImageLoader.createImageIcon(ImageLoader.PASTE_ICON_FILE); PasteAddressAction pasteAddressAction = new PasteAddressAction(super.bitcoinController, this, pasteIcon); pasteAddressButton = new MultiBitButton(pasteAddressAction, controller); constraints.fill = GridBagConstraints.NONE; constraints.gridx = 8; constraints.gridy = 1; constraints.weightx = 10.0; constraints.weighty = 0.2; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.LINE_START; formPanel.add(pasteAddressButton, constraints); MultiBitLabel labelLabel = new MultiBitLabel(controller.getLocaliser().getString("sendBitcoinPanel.labelLabel")); labelLabel.setToolTipText( HelpContentsPanel.createTooltipText( controller.getLocaliser().getString("sendBitcoinPanel.labelLabel.tooltip"))); labelLabel.setHorizontalAlignment(JLabel.TRAILING); constraints.fill = GridBagConstraints.NONE; constraints.gridx = 0; constraints.gridy = 3; constraints.weightx = 0.1; constraints.weighty = 1.0; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.anchor = GridBagConstraints.LINE_END; formPanel.add(labelLabel, constraints); JTextField aTextField = new JTextField(); labelTextArea = new MultiBitTextArea("", AbstractTradePanel.PREFERRED_NUMBER_OF_LABEL_ROWS, 20, controller); labelTextArea.setBorder(aTextField.getBorder()); labelTextArea.addKeyListener(new QRCodeKeyListener()); final JScrollPane labelScrollPane = new JScrollPane( labelTextArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); labelScrollPane.setOpaque(true); labelScrollPane.setBackground(ColorAndFontConstants.VERY_LIGHT_BACKGROUND_COLOR); labelScrollPane.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1)); labelScrollPane .getViewport() .addChangeListener( new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { if (labelScrollPane.getVerticalScrollBar().isVisible()) { labelScrollPane.setBorder( BorderFactory.createMatteBorder(1, 1, 1, 1, Color.LIGHT_GRAY)); } else { labelScrollPane.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1)); } } }); labelScrollPane.setMinimumSize( new Dimension( longFieldWidth, getFontMetrics(FontSizer.INSTANCE.getAdjustedDefaultFont()).getHeight() * AbstractTradePanel.PREFERRED_NUMBER_OF_LABEL_ROWS + TEXTFIELD_VERTICAL_DELTA + 6)); labelScrollPane.setPreferredSize( new Dimension( longFieldWidth, getFontMetrics(FontSizer.INSTANCE.getAdjustedDefaultFont()).getHeight() * AbstractTradePanel.PREFERRED_NUMBER_OF_LABEL_ROWS + TEXTFIELD_VERTICAL_DELTA + 6)); labelScrollPane.getHorizontalScrollBar().setUnitIncrement(CoreModel.SCROLL_INCREMENT); labelScrollPane.getVerticalScrollBar().setUnitIncrement(CoreModel.SCROLL_INCREMENT); constraints.fill = GridBagConstraints.HORIZONTAL; constraints.gridx = 2; constraints.gridy = 3; constraints.weightx = 0.6; constraints.weighty = 1.0; constraints.gridwidth = 3; constraints.gridheight = 1; constraints.anchor = GridBagConstraints.LINE_START; formPanel.add(labelScrollPane, constraints); MultiBitLabel amountLabel = new MultiBitLabel(controller.getLocaliser().getString("sendBitcoinPanel.amountLabel")); amountLabel.setToolTipText( HelpContentsPanel.createTooltipText( controller.getLocaliser().getString("sendBitcoinPanel.amountLabel.tooltip"))); amountLabel.setHorizontalAlignment(JLabel.TRAILING); constraints.fill = GridBagConstraints.NONE; constraints.gridx = 0; constraints.gridy = 5; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx = 0.1; constraints.weighty = 0.20; constraints.anchor = GridBagConstraints.LINE_END; formPanel.add(amountLabel, constraints); JPanel amountPanel = createAmountPanel(); constraints.fill = GridBagConstraints.BOTH; constraints.gridx = 2; constraints.gridy = 5; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx = 0.1; constraints.weighty = 0.20; constraints.anchor = GridBagConstraints.LINE_START; formPanel.add(amountPanel, constraints); notificationLabel = new MultiBitLabel(""); notificationLabel.setForeground(Color.RED); // notificationLabel.setBorder(BorderFactory.createLineBorder(Color.GREEN)); constraints.fill = GridBagConstraints.BOTH; constraints.gridx = 2; constraints.gridy = 6; constraints.gridwidth = 8; constraints.gridheight = 3; constraints.weightx = 0.1; constraints.weighty = 0.1; constraints.anchor = GridBagConstraints.ABOVE_BASELINE_LEADING; formPanel.add(notificationLabel, constraints); Action helpAction; if (ComponentOrientation.LEFT_TO_RIGHT == ComponentOrientation.getOrientation(controller.getLocaliser().getLocale())) { helpAction = new HelpContextAction( controller, ImageLoader.HELP_CONTENTS_BIG_ICON_FILE, "multiBitFrame.helpMenuText", "multiBitFrame.helpMenuTooltip", "multiBitFrame.helpMenuText", HelpContentsPanel.HELP_SENDING_URL); } else { helpAction = new HelpContextAction( controller, ImageLoader.HELP_CONTENTS_BIG_RTL_ICON_FILE, "multiBitFrame.helpMenuText", "multiBitFrame.helpMenuTooltip", "multiBitFrame.helpMenuText", HelpContentsPanel.HELP_SENDING_URL); } HelpButton helpButton = new HelpButton(helpAction, controller); helpButton.setText(""); String tooltipText = HelpContentsPanel.createMultilineTooltipText( new String[] { controller.getLocaliser().getString("sendBitcoinPanel.helpLabel1.message"), controller.getLocaliser().getString("sendBitcoinPanel.helpLabel2.message"), controller.getLocaliser().getString("sendBitcoinPanel.helpLabel3.message"), "\n", controller.getLocaliser().getString("multiBitFrame.helpMenuTooltip") }); helpButton.setToolTipText(tooltipText); helpButton.setHorizontalAlignment(SwingConstants.LEADING); helpButton.setBorder( BorderFactory.createEmptyBorder( 0, HELP_BUTTON_INDENT, HELP_BUTTON_INDENT, HELP_BUTTON_INDENT)); constraints.fill = GridBagConstraints.HORIZONTAL; constraints.gridx = 0; constraints.gridy = 8; constraints.weightx = 1; constraints.weighty = 0.3; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.anchor = GridBagConstraints.BELOW_BASELINE_LEADING; formPanel.add(helpButton, constraints); sendBitcoinConfirmAction = new SendBitcoinConfirmAction(super.bitcoinController, mainFrame, this); sendBitcoinConfirmAction.setEnabled(enableSendButton); sendButton = new MultiBitButton(sendBitcoinConfirmAction, controller); if (enableSendButton) { sendButton.setEnabled(true); sendButton.setToolTipText( HelpContentsPanel.createTooltipText( controller.getLocaliser().getString("sendBitcoinAction.tooltip"))); } else { sendButton.setEnabled(false); sendButton.setToolTipText( HelpContentsPanel.createTooltipText( controller.getLocaliser().getString("sendBitcoinAction.pleaseWait.tooltip"))); } constraints.fill = GridBagConstraints.HORIZONTAL; constraints.gridx = 6; constraints.gridy = 5; constraints.weightx = 0.1; constraints.weighty = 0.1; constraints.gridwidth = 3; constraints.gridheight = 1; constraints.anchor = GridBagConstraints.LINE_START; formPanel.add(sendButton, constraints); Action sidePanelAction = new MoreOrLessAction(controller, this); sidePanelButton = new MultiBitButton(sidePanelAction, controller); sidePanelButton.setBorder(BorderFactory.createEmptyBorder()); sidePanelButton.setBorderPainted(false); sidePanelButton.setFocusPainted(false); sidePanelButton.setContentAreaFilled(false); displaySidePanel(); constraints.fill = GridBagConstraints.NONE; constraints.gridx = 4; constraints.gridy = 3; constraints.weightx = 0.1; constraints.weighty = 0.3; constraints.gridwidth = 7; constraints.gridheight = 3; constraints.anchor = GridBagConstraints.BASELINE_TRAILING; formPanel.add(sidePanelButton, constraints); return formPanel; }
public AddCompany() { setTitle("Add Company"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 392, 300); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); Calendar calendar = Calendar.getInstance(); java.util.Date now = calendar.getTime(); model = new UtilDateModel(now); Properties p = new Properties(); p.put("text.today", "Today"); p.put("text.month", "Month"); p.put("text.year", "Year"); datePanel = new JDatePanelImpl(model, p); label = new JLabel(""); label.setVerticalTextPosition(SwingConstants.TOP); label.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null)); JPanel panel = new JPanel(); panel.setBorder(null); panel.setLayout(new GridLayout(0, 1, 0, 0)); JSeparator separator = new JSeparator(); JPanel panel_1 = new JPanel(); panel_1.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); JLabel lblCompanyName = new JLabel("Company Name :"); textField_2 = new JTextField(); defaultBorder = textField_2.getBorder(); textField_2.setColumns(10); textField_3 = new JTextField(); textField_3.addKeyListener( new KeyAdapter() { @Override public void keyReleased(KeyEvent arg0) { checkDuplicate(); } }); textField_3.setColumns(10); JLabel lblCompanyCode_1 = new JLabel("Company Code :"); JLabel lblDateCreated_1 = new JLabel("Date Created :"); datePicker = new JDatePickerImpl(datePanel, new DateLabelFormatter()); GroupLayout gl_contentPane = new GroupLayout(contentPane); gl_contentPane.setHorizontalGroup( gl_contentPane .createParallelGroup(Alignment.LEADING) .addGroup( gl_contentPane .createSequentialGroup() .addGap(10) .addComponent(panel_1, GroupLayout.DEFAULT_SIZE, 346, Short.MAX_VALUE) .addGap(10)) .addGroup( gl_contentPane .createSequentialGroup() .addGap(10) .addComponent(separator, GroupLayout.DEFAULT_SIZE, 346, Short.MAX_VALUE) .addGap(10)) .addComponent(label, GroupLayout.DEFAULT_SIZE, 366, Short.MAX_VALUE) .addGroup( gl_contentPane .createSequentialGroup() .addContainerGap() .addComponent(panel, GroupLayout.DEFAULT_SIZE, 346, Short.MAX_VALUE) .addContainerGap())); gl_contentPane.setVerticalGroup( gl_contentPane .createParallelGroup(Alignment.LEADING) .addGroup( gl_contentPane .createSequentialGroup() .addComponent(panel_1, GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE) .addGap(11) .addComponent(separator) .addGap(11) .addComponent(panel, GroupLayout.PREFERRED_SIZE, 29, GroupLayout.PREFERRED_SIZE) .addGap(11) .addComponent( label, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE))); GroupLayout gl_panel_1 = new GroupLayout(panel_1); gl_panel_1.setHorizontalGroup( gl_panel_1 .createParallelGroup(Alignment.LEADING) .addGroup( gl_panel_1 .createSequentialGroup() .addGap(8) .addGroup( gl_panel_1 .createParallelGroup(Alignment.LEADING) .addGroup( gl_panel_1 .createSequentialGroup() .addComponent( lblCompanyName, GroupLayout.PREFERRED_SIZE, 98, GroupLayout.PREFERRED_SIZE) .addGap(34) .addComponent( textField_2, GroupLayout.DEFAULT_SIZE, 194, Short.MAX_VALUE)) .addGroup( gl_panel_1 .createSequentialGroup() .addComponent( lblCompanyCode_1, GroupLayout.PREFERRED_SIZE, 122, GroupLayout.PREFERRED_SIZE) .addGap(10) .addComponent( textField_3, GroupLayout.DEFAULT_SIZE, 194, Short.MAX_VALUE)) .addComponent( lblDateCreated_1, GroupLayout.PREFERRED_SIZE, 134, GroupLayout.PREFERRED_SIZE) .addGroup( gl_panel_1 .createSequentialGroup() .addGap(132) .addComponent( datePicker, GroupLayout.DEFAULT_SIZE, 194, Short.MAX_VALUE))) .addGap(8))); gl_panel_1.setVerticalGroup( gl_panel_1 .createParallelGroup(Alignment.LEADING) .addGroup( gl_panel_1 .createSequentialGroup() .addGap(6) .addGroup( gl_panel_1 .createParallelGroup(Alignment.LEADING) .addGroup( gl_panel_1 .createSequentialGroup() .addGap(3) .addComponent(lblCompanyName)) .addComponent( textField_2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGap(5) .addGroup( gl_panel_1 .createParallelGroup(Alignment.LEADING) .addComponent( lblCompanyCode_1, GroupLayout.PREFERRED_SIZE, 33, GroupLayout.PREFERRED_SIZE) .addGroup( gl_panel_1 .createSequentialGroup() .addGap(6) .addComponent( textField_3, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))) .addGap(1) .addGroup( gl_panel_1 .createParallelGroup(Alignment.LEADING) .addComponent( lblDateCreated_1, GroupLayout.PREFERRED_SIZE, 39, GroupLayout.PREFERRED_SIZE) .addGroup( gl_panel_1 .createSequentialGroup() .addGap(3) .addComponent( datePicker, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE))))); panel_1.setLayout(gl_panel_1); JPanel panel_3 = new JPanel(); panel.add(panel_3); panel_3.setLayout(new GridLayout(0, 2, 0, 0)); btnNewButton = new JButton("Save"); panel_3.add(btnNewButton); JButton btnNewButton_1 = new JButton("Cancel"); panel_3.add(btnNewButton_1); btnNewButton_1.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { AddCompany.this.setVisible(false); backPage.setVisibility(true); } }); btnNewButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { Company comp = new Company(); comp.setCompanyCode(textField_3.getText()); comp.setCompanyName(textField_2.getText()); // comp.setDateCreated(""); Date selectedDate = (Date) datePicker.getModel().getValue(); DateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS"); String reportDate = df.format(selectedDate); comp.setDateCreated(Utilities.getTime(reportDate)); try { new Company().setObject(comp); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); // Error occurs label.setText("Failed to add company!"); } // If successful, reset the fields label.setText("Company successfully added!"); reset(); } }); contentPane.setLayout(gl_contentPane); }
public deliverReceiveUI() { int textlength = 200; int textwidth = 40; int labellength = 100; int labelwidth = 40; setLayout(null); this.setBounds(0, 0, 850, 700); this.setBackground(Color.WHITE); Font font = new Font("楷体", Font.PLAIN, 18); Font f = new Font("仿宋", Font.PLAIN, 16); Foclistener foc = new Foclistener(); JLabel label1 = new JLabel("收件人姓名"); label1.setBounds(200, 100, labellength, labelwidth); label1.setFont(font); this.add(label1); JLabel label2 = new JLabel("签收时间"); label2.setBounds(200, 100 + labelwidth * 2, labellength, labelwidth); label2.setFont(font); this.add(label2); JLabel label3 = new JLabel("订单编号"); label3.setBounds(200, 100 + labelwidth * 4, labellength, labelwidth); label3.setFont(font); this.add(label3); textArea1 = new JTextField(); textArea1.setBounds(300, 100, textlength, textwidth); textArea1.setFont(f); textArea1.addFocusListener(foc); this.add(textArea1); border = textArea1.getBorder(); textArea2 = new JTextField(new SimpleDateFormat("yyyy-MM-dd").format(new Date())); textArea2.setBounds(300, 100 + textwidth * 2, textlength, textwidth); textArea2.setFont(f); textArea2.setEditable(false); this.add(textArea2); datechooser = new DateChooser("yyyy-MM-dd", textArea2); datechooser.setBounds(510, 100 + textwidth * 2, 40, 40); this.add(datechooser); textArea3 = new JTextField(); textArea3.setBounds(300, 100 + textwidth * 4, textlength, textwidth); textArea3.setFont(f); textArea3.addFocusListener(foc); this.add(textArea3); Listener lis = new Listener(); button_return = new JButton("确认"); button_return.setBounds(220, 520, 100, 30); button_return.setFont(font); button_return.addMouseListener(lis); this.add(button_return); button_cancel = new JButton("取消"); button_cancel.setBounds(400, 520, 100, 30); button_cancel.setFont(font); button_cancel.addMouseListener(lis); this.add(button_cancel); }
public ReportPanel() { if (rb == null) { rb = java.util.ResourceBundle.getBundle("jmri.jmrit.mailreport.ReportBundle"); } setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); JPanel p1; p1 = new JPanel(); p1.setLayout(new FlowLayout()); p1.add(new JLabel(rb.getString("LabelTop"))); add(p1); // grid of options p1 = new JPanel(); p1.setLayout(new GridLayout2(3, 2)); add(p1); JLabel l = new JLabel(rb.getString("LabelEmail")); l.setToolTipText(rb.getString("TooltipEmail")); p1.add(l); emailField.setToolTipText(rb.getString("TooltipEmail")); p1.add(emailField); l = new JLabel(rb.getString("LabelSummary")); l.setToolTipText(rb.getString("TooltipSummary")); p1.add(l); summaryField.setToolTipText(rb.getString("TooltipSummary")); p1.add(summaryField); l = new JLabel(rb.getString("LabelDescription")); p1.add(l); // This ensures that the long-description JTextArea font // is the same as the JTextField fields. // With some L&F, default font for JTextArea differs. descField.setFont(summaryField.getFont()); descField.setBorder(summaryField.getBorder()); descField.setLineWrap(true); descField.setWrapStyleWord(true); p1.add(descField); // buttons on bottom p1 = new JPanel(); p1.setLayout(new FlowLayout()); checkContext = new JCheckBox(rb.getString("CheckContext")); checkContext.setSelected(true); checkContext.addActionListener( new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent e) { checkNetwork.setEnabled(checkContext.isSelected()); } }); p1.add(checkContext); checkNetwork = new JCheckBox(rb.getString("CheckNetwork")); checkNetwork.setSelected(true); p1.add(checkNetwork); checkLog = new JCheckBox(rb.getString("CheckLog")); checkLog.setSelected(true); p1.add(checkLog); add(p1); p1 = new JPanel(); p1.setLayout(new FlowLayout()); checkPanel = new JCheckBox(rb.getString("CheckPanel")); checkPanel.setSelected(true); p1.add(checkPanel); checkProfile = new JCheckBox(rb.getString("CheckProfile")); checkProfile.setSelected(true); p1.add(checkProfile); checkCopy = new JCheckBox(rb.getString("CheckCopy")); checkCopy.setSelected(true); p1.add(checkCopy); add(p1); sendButton = new javax.swing.JButton(rb.getString("ButtonSend")); sendButton.setToolTipText(rb.getString("TooltipSend")); sendButton.addActionListener( new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent e) { sendButtonActionPerformed(e); } }); add(sendButton); }
public ServerDialog(OptionsDialog options_, Options opts_, CConn cc_) { super(true); cc = cc_; opts = opts_; options = options_; JLabel serverLabel = new JLabel("VNC server:", JLabel.RIGHT); String valueStr = null; if (opts.serverName != null) { String[] s = new String[1]; s[0] = opts.serverName; server = new JComboBox(s); } else if ((valueStr = UserPreferences.get("ServerDialog", "history")) != null) { server = new JComboBox(valueStr.split(",")); } else { server = new JComboBox(); } // Hack to set the left inset on editable JComboBox if (UIManager.getLookAndFeel().getID() == "Windows") { server.setBorder( BorderFactory.createCompoundBorder( server.getBorder(), BorderFactory.createEmptyBorder(0, 2, 0, 0))); } else if (UIManager.getLookAndFeel().getID() == "Metal") { ComboBoxEditor editor = server.getEditor(); JTextField jtf = (JTextField) editor.getEditorComponent(); jtf.setBorder(new CompoundBorder(jtf.getBorder(), new EmptyBorder(0, 2, 0, 0))); } server.setEditable(true); editor = server.getEditor(); editor .getEditorComponent() .addKeyListener( new KeyListener() { public void keyTyped(KeyEvent e) {} public void keyReleased(KeyEvent e) {} public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { server.insertItemAt(editor.getItem(), 0); server.setSelectedIndex(0); commit(); endDialog(); } } }); topPanel = new JPanel(new GridBagLayout()); Dialog.addGBComponent( new JLabel(VncViewer.logoIcon), topPanel, 0, 0, 1, 1, 0, 0, 0, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new Insets(5, 5, 5, 15)); Dialog.addGBComponent( serverLabel, topPanel, 1, 0, 1, 1, 0, 0, 0, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_END, new Insets(10, 0, 5, 5)); Dialog.addGBComponent( server, topPanel, 2, 0, 1, 1, 0, 0, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER, new Insets(10, 0, 5, 20)); optionsButton = new JButton("Options..."); aboutButton = new JButton("About..."); okButton = new JButton("Connect"); cancelButton = new JButton("Cancel"); buttonPanel = new JPanel(new GridBagLayout()); buttonPanel.setPreferredSize(new Dimension(350, 40)); Dialog.addGBComponent( aboutButton, buttonPanel, 0, 3, 1, 1, 0, 0, 0.8, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER, new Insets(0, 2, 0, 5)); Dialog.addGBComponent( optionsButton, buttonPanel, 1, 3, 1, 1, 0, 0, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER, new Insets(0, 2, 0, 5)); Dialog.addGBComponent( okButton, buttonPanel, 2, 3, 1, 1, 0, 0, 0.7, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER, new Insets(0, 2, 0, 5)); Dialog.addGBComponent( cancelButton, buttonPanel, 3, 3, 1, 1, 0, 0, 0.6, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER, new Insets(0, 2, 0, 5)); server.addActionListener(this); optionsButton.addActionListener(this); aboutButton.addActionListener(this); okButton.addActionListener(this); cancelButton.addActionListener(this); }
void init() { /* ============ * Windows * ============ */ this.setResizable(false); JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS)); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container con = this.getContentPane(); // inherit main frame con.add(panel); // add the panel to frame /* ============ * Menu * ============ */ this.setIconImage(new ImageIcon("img/title_img.png").getImage()); // Where the GUI is created: JMenuBar menuBar; JMenu menu; JMenuItem menuItem; // Create the menu bar. menuBar = new JMenuBar(); // Build the first menu. menu = new JMenu("File"); menu.setMnemonic(KeyEvent.VK_A); menuBar.add(menu); // a group of JMenuItems menuItem = new JMenuItem("About", new ImageIcon("img/about.png")); menu.add(menuItem); this.setJMenuBar(menuBar); /* ============ * Content * ============ */ JLabel logo = new JLabel(new ImageIcon("img/title_img.png")); logo.setAlignmentX(CENTER_ALIGNMENT); final JTextField nickname = new JTextField(); final Border defaultBorder = nickname.getBorder(); nickname.setText("Enter a nickname"); nickname.setPreferredSize(new Dimension(250, 30)); nickname.setMaximumSize(nickname.getPreferredSize()); nickname.setAlignmentX(CENTER_ALIGNMENT); // nickname.addFocusListener(this); nickname.addFocusListener( new FocusListener() { @Override public void focusLost(FocusEvent e) { // TODO Auto-generated method stub if (!nickname.getText().equals("Enter a nickname")) { nickname.setText(nickname.getText().replace(" ", "")); } if (nickname.getText().equals("") || nickname.getText().equals("Enter a nickname")) { nickname.setText("Enter a nickname"); goodNickname = false; } } @Override public void focusGained(FocusEvent e) { // TODO Auto-generated method stub goodNickname = true; } }); nickname.addMouseListener( new MouseListener() { @Override public void mouseReleased(MouseEvent arg0) { // TODO Auto-generated method stub } @Override public void mousePressed(MouseEvent arg0) { // TODO Auto-generated method stub if (nickname.getText().equals("Enter a nickname")) { nickname.setText(""); nickname.setBorder(defaultBorder); } } @Override public void mouseExited(MouseEvent arg0) { // TODO Auto-generated method stub } @Override public void mouseEntered(MouseEvent arg0) { // TODO Auto-generated method stub } @Override public void mouseClicked(MouseEvent arg0) { // TODO Auto-generated method stub } }); final JButton connect = new JButton("Connect"); connect.setPreferredSize(new Dimension(250, 30)); connect.setMaximumSize(connect.getPreferredSize()); connect.setAlignmentX(CENTER_ALIGNMENT); connect.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { // TODO Auto-generated method stub if (goodNickname) { openChatGUI(nickname); } else { nickname.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.red)); } } }); nickname.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { // TODO Auto-generated method stub if (goodNickname) { openChatGUI(nickname); } else { nickname.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.red)); } } }); panel.add(Box.createRigidArea(new Dimension(0, 15))); panel.add(logo); panel.add(Box.createRigidArea(new Dimension(0, 30))); panel.add(nickname); panel.add(Box.createRigidArea(new Dimension(0, 10))); panel.add(connect); setVisible(true); // display this frame }
public MapPanel() { MyConnection conn = new MyConnection(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); // manage to get size of the host computer screenWidth = screenSize.getWidth() - 35; // needed in resizing the preferred width of our embedded website screenHeight = screenSize.getHeight() - 150; // needed in resizing the preferred height of you embedded website mainPanel = new JPanel(new BorderLayout()); /**/ webBrowserPanel = new JPanel(new BorderLayout()); webBrowserPanel.setBorder( BorderFactory.createTitledBorder("Server")); // creates a beveled border webBrowserPanel.setVisible(false); /**/ webBrowser = new JWebBrowser(); // instantiates a new Java Web Browser webBrowser.navigate( conn.getDBUrl() + "/thesis/multiplemarkers.php"); // defines what site to be viewed on the java web // browser webBrowser.setBarsVisible(false); // hides urls and other native browser elements /**/ JPanel controlPanel = new JPanel(new BorderLayout()); /**/ /**/ powerButtonPanel = new JPanel(new BorderLayout()); powerButtonPanel.setPreferredSize(new Dimension(95, 30)); powerButtonPanel.setBackground(Color.WHITE); powerButtonPanel.setBorder(BorderFactory.createLoweredBevelBorder()); /**/ /**/ /**/ buttonOn = new JButton(" Turn On"); buttonOn.setVisible(true); /**/ /**/ /**/ buttonOff = new JButton("Turn Off"); buttonOff.setVisible(false); /**/ /**/ dataPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 4, 4)); dataPanel.setVisible(false); /**/ /**/ /**/ JLabel statusLabel = new JLabel("Status: "); statusLabel.setPreferredSize(new Dimension(70, 30)); statusLabel.setHorizontalAlignment(JLabel.RIGHT); statusLabel.setFont(new Font("Calibri", Font.BOLD, 15)); /**/ /**/ /**/ statusField = new JTextField(); statusField.setEditable(false); statusField.setPreferredSize(new Dimension(500, 30)); statusField.setText("OFFLINE. Please switch on to start server..."); statusField.setFont(new Font("Calibri", Font.PLAIN, 15)); statusField.setBackground(Color.WHITE); statusField.setBorder( BorderFactory.createCompoundBorder( statusField.getBorder(), BorderFactory.createEmptyBorder(5, 5, 5, 5))); /**/ /**/ /**/ JLabel taxiCountLabel = new JLabel("Units: "); taxiCountLabel.setPreferredSize(new Dimension(50, 30)); taxiCountLabel.setHorizontalAlignment(JLabel.RIGHT); taxiCountLabel.setFont(new Font("Calibri", Font.BOLD, 15)); /**/ /**/ /**/ taxiCounterField = new JTextField("0"); taxiCounterField.setEditable(false); taxiCounterField.setPreferredSize(new Dimension(50, 30)); taxiCounterField.setHorizontalAlignment(JTextField.CENTER); taxiCounterField.setFont(new Font("Calibri", Font.PLAIN, 14)); taxiCounterField.setBackground(Color.WHITE); /**/ /**/ /**/ JLabel clientCountLabel = new JLabel("Clients: "); clientCountLabel.setPreferredSize(new Dimension(60, 30)); clientCountLabel.setHorizontalAlignment(JLabel.RIGHT); clientCountLabel.setFont(new Font("Calibri", Font.BOLD, 15)); /**/ /**/ /**/ clientCountField = new JTextField("0"); clientCountField.setEditable(false); clientCountField.setPreferredSize(new Dimension(50, 30)); clientCountField.setHorizontalAlignment(JTextField.CENTER); clientCountField.setFont(new Font("Calibri", Font.PLAIN, 14)); clientCountField.setBackground(Color.WHITE); manageButton = new JButton("Manage"); manageButton.setPreferredSize(new Dimension(60, 33)); manageButton.setBorder(BorderFactory.createEmptyBorder()); /**/ /**/ zoomButtonPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 4, 4)); zoomButtonPanel.setVisible(false); zoomButtonPanel.setBackground(Color.WHITE); zoomButtonPanel.setBorder(BorderFactory.createLineBorder(Color.decode("#BBBBBB"))); /**/ /**/ /**/ zoomInButton = new JButton(new ImageIcon("assets/zoomin.png")); /**/ /**/ /**/ zoomOutButton = new JButton(new ImageIcon("assets/zoomout.png")); mainPanel.add(webBrowserPanel, BorderLayout.CENTER); /**/ webBrowserPanel.add(webBrowser, BorderLayout.CENTER); mainPanel.add(controlPanel, BorderLayout.SOUTH); /**/ controlPanel.add(powerButtonPanel, BorderLayout.WEST); ; /**/ /**/ powerButtonPanel.add(buttonOn, BorderLayout.WEST); /**/ /**/ powerButtonPanel.add(buttonOff, BorderLayout.EAST); /**/ controlPanel.add(dataPanel, BorderLayout.CENTER); /**/ /**/ dataPanel.add(statusLabel); /**/ /**/ dataPanel.add(statusField); /**/ /**/ dataPanel.add(taxiCountLabel); /**/ /**/ dataPanel.add(taxiCounterField); /**/ /**/ dataPanel.add(clientCountLabel); /**/ /**/ dataPanel.add(clientCountField); /**/ controlPanel.add(zoomButtonPanel, BorderLayout.EAST); /**/ /**/ zoomButtonPanel.add(manageButton); /**/ /**/ zoomButtonPanel.add(zoomInButton); /**/ /**/ zoomButtonPanel.add(zoomOutButton); }