/** Initialise dialog. */ public void initUI() { try { FontMetrics fontMetrics = getFontMetrics(FontSizer.INSTANCE.getAdjustedDefaultFont()); int minimumHeight = fontMetrics.getHeight() * 8 + HEIGHT_DELTA; int minimumWidth = Math.max( fontMetrics.stringWidth( controller .getLocaliser() .getString("createNewReceivingAddressDialog.message")), fontMetrics.stringWidth( controller .getLocaliser() .getString( "createNewReceivingAddressSubmitAction.createdSuccessfullyShort", new Object[] {new Integer(100)}))) + WIDTH_DELTA; setMinimumSize(new Dimension(minimumWidth, minimumHeight)); positionDialogRelativeToParent(this, 0.5D, 0.47D); } catch (NullPointerException npe) { // FontSizer fail - probably headless in test - carry on. } createNewReceivingAddressPanel = new CreateNewReceivingAddressPanel(this.bitcoinController, receiveBitcoinPanel, this); setLayout(new BorderLayout()); add(createNewReceivingAddressPanel, BorderLayout.CENTER); }
@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; }
private void createTicker() { setBackground(ColorAndFontConstants.BACKGROUND_COLOR); setLayout(new GridBagLayout()); setOpaque(false); setFocusable(false); setToolTipText( HelpContentsPanel.createMultilineTooltipText( new String[] { controller.getLocaliser().getString("tickerTablePanel.tooltip"), "\n ", controller.getLocaliser().getString("tickerTablePanel.tooltip.clickToConfigure") })); // on mouse click - view the exchanges tab MouseListener viewPreferencesMouseListener = new MouseAdapter() { @Override public void mouseReleased(MouseEvent arg0) { controller.displayView(View.PREFERENCES_VIEW); } }; String tickerTooltipText = HelpContentsPanel.createMultilineTooltipText( new String[] { controller.getLocaliser().getString("tickerTablePanel.tooltip"), "\n ", controller.getLocaliser().getString("tickerTablePanel.tooltip.clickToConfigure") }); addMouseListener(viewPreferencesMouseListener); GridBagConstraints constraints = new GridBagConstraints(); tickerTableModel = new TickerTableModel(this.exchangeController); table = new JTable(tickerTableModel); table.setOpaque(true); table.setShowGrid(true); table.setGridColor(Color.lightGray); table.setBackground(ColorAndFontConstants.BACKGROUND_COLOR); table.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, SystemColor.windowBorder)); table.setComponentOrientation( ComponentOrientation.getOrientation(controller.getLocaliser().getLocale())); table.setRowHeight(getFontMetrics(FontSizer.INSTANCE.getAdjustedDefaultFont()).getHeight()); table.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); table.setRowSelectionAllowed(false); table.setColumnSelectionAllowed(false); table.getTableHeader().setReorderingAllowed(false); table.setToolTipText(tickerTooltipText); table.addMouseListener(viewPreferencesMouseListener); table.getTableHeader().addMouseListener(viewPreferencesMouseListener); table.getTableHeader().setToolTipText(tickerTooltipText); table.getTableHeader().setFont(FontSizer.INSTANCE.getAdjustedDefaultFontWithDelta(-1)); int tableHeaderHeight = fontMetrics.getHeight() + table.getTableHeader().getInsets().top + table.getTableHeader().getInsets().bottom; // Windows 8 has slightly taller headers so add a tweak for that. if (System.getProperty("os.name", "unknown").startsWith("Win")) { tableHeaderHeight = tableHeaderHeight + WINDOWS_TABLE_HEADER_HEIGHT_TWEAK; } int tickerWidth = setupColumnWidths(); setupTableHeaders(); idealHeight = (fontMetrics.getHeight() + table.getRowMargin()) * tickerTableModel.getRowCount() + tableHeaderHeight + tickerTableModel.getRowCount() + 10; setPreferredSize(new Dimension(tickerWidth, idealHeight)); scrollPane = new JScrollPane( table, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setComponentOrientation( ComponentOrientation.getOrientation(controller.getLocaliser().getLocale())); scrollPane.setBorder(BorderFactory.createEmptyBorder()); scrollPane.setViewportBorder(BorderFactory.createEmptyBorder()); scrollPane.addMouseListener(viewPreferencesMouseListener); setupScrollPane(tickerWidth); constraints.fill = GridBagConstraints.HORIZONTAL; constraints.gridx = 0; constraints.gridy = 0; constraints.gridwidth = 1; constraints.weightx = 1; constraints.weighty = 1; constraints.anchor = GridBagConstraints.CENTER; add(scrollPane, constraints); }