List of usage examples for javax.swing JPanel setOpaque
@BeanProperty(expert = true, description = "The component's opacity") public void setOpaque(boolean isOpaque)
From source file:org.multibit.viewsystem.swing.view.panels.ShowPreferencesPanel.java
private JPanel createLanguagePanel(int stentWidth) { // Language radios. MultiBitTitledPanel languagePanel = new MultiBitTitledPanel( controller.getLocaliser().getString("showPreferencesPanel.languageTitle"), ComponentOrientation.getOrientation(controller.getLocaliser().getLocale())); GridBagConstraints constraints = new GridBagConstraints(); constraints.fill = GridBagConstraints.BOTH; constraints.gridx = 0;//from w ww. j a v a 2 s.com constraints.gridy = 3; constraints.weightx = 0.1; constraints.weighty = 0.05; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.anchor = GridBagConstraints.LINE_START; JPanel indent = MultiBitTitledPanel.getIndentPanel(1); languagePanel.add(indent, constraints); constraints.fill = GridBagConstraints.BOTH; constraints.gridx = 1; constraints.gridy = 3; constraints.weightx = 0.3; constraints.weighty = 0.3; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.LINE_START; JPanel stent = MultiBitTitledPanel.createStent(stentWidth); languagePanel.add(stent, constraints); constraints.fill = GridBagConstraints.BOTH; constraints.gridx = 2; constraints.gridy = 3; constraints.weightx = 0.05; constraints.weighty = 0.3; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.CENTER; languagePanel.add(MultiBitTitledPanel.createStent(MultiBitTitledPanel.SEPARATION_BETWEEN_NAME_VALUE_PAIRS), constraints); ButtonGroup languageUsageGroup = new ButtonGroup(); useDefaultLocale = new JRadioButton(controller.getLocaliser().getString("showPreferencesPanel.useDefault")); useDefaultLocale.setOpaque(false); useDefaultLocale.setFont(FontSizer.INSTANCE.getAdjustedDefaultFont()); JRadioButton useSpecific = new JRadioButton( controller.getLocaliser().getString("showPreferencesPanel.useSpecific")); useSpecific.setOpaque(false); useSpecific.setFont(FontSizer.INSTANCE.getAdjustedDefaultFont()); ItemListener itemListener = new ChangeLanguageUsageListener(); useDefaultLocale.addItemListener(itemListener); useSpecific.addItemListener(itemListener); languageUsageGroup.add(useDefaultLocale); languageUsageGroup.add(useSpecific); constraints.fill = GridBagConstraints.NONE; constraints.gridx = 1; constraints.gridy = 4; constraints.weightx = 0.2; constraints.weighty = 0.3; constraints.gridwidth = 3; constraints.anchor = GridBagConstraints.LINE_START; languagePanel.add(useDefaultLocale, constraints); constraints.fill = GridBagConstraints.NONE; constraints.gridx = 1; constraints.gridy = 5; constraints.weightx = 0.2; constraints.weighty = 0.3; constraints.gridwidth = 3; constraints.anchor = GridBagConstraints.LINE_START; languagePanel.add(useSpecific, constraints); // Language combo box. int numberOfLanguages = Integer .parseInt(controller.getLocaliser().getString("showPreferencesPanel.numberOfLanguages")); // Languages are added to the combo box in alphabetic order. languageDataSet = new TreeSet<LanguageData>(); for (int i = 0; i < numberOfLanguages; i++) { String languageCode = controller.getLocaliser() .getString("showPreferencesPanel.languageCode." + (i + 1)); String language = controller.getLocaliser().getString("showPreferencesPanel.language." + (i + 1)); LanguageData languageData = new LanguageData(); languageData.languageCode = languageCode; languageData.language = language; languageData.image = createImageIcon(languageCode); languageData.image.setDescription(language); languageDataSet.add(languageData); } Integer[] indexArray = new Integer[languageDataSet.size()]; int index = 0; for (@SuppressWarnings("unused") LanguageData languageData : languageDataSet) { indexArray[index] = index; index++; } languageComboBox = new JComboBox(indexArray); languageComboBox.setFont(FontSizer.INSTANCE.getAdjustedDefaultFont()); languageComboBox.setOpaque(false); LanguageComboBoxRenderer renderer = new LanguageComboBoxRenderer(); FontMetrics fontMetrics = getFontMetrics(FontSizer.INSTANCE.getAdjustedDefaultFont()); Dimension preferredSize = new Dimension(fontMetrics.stringWidth(A_LONG_LANGUAGE_NAME) + LANGUAGE_COMBO_WIDTH_DELTA + LANGUAGE_CODE_IMAGE_WIDTH, fontMetrics.getHeight() + COMBO_HEIGHT_DELTA); renderer.setPreferredSize(preferredSize); languageComboBox.setRenderer(renderer); // Get the languageCode value stored in the model. String userLanguageCode = controller.getModel().getUserPreference(CoreModel.USER_LANGUAGE_CODE); if (userLanguageCode == null || CoreModel.USER_LANGUAGE_IS_DEFAULT.equals(userLanguageCode)) { useDefaultLocale.setSelected(true); languageComboBox.setEnabled(false); } else { useSpecific.setSelected(true); int startingIndex = 0; Integer languageCodeIndex = 0; for (LanguageData languageData : languageDataSet) { if (languageData.languageCode.equals(userLanguageCode)) { languageCodeIndex = startingIndex; break; } startingIndex++; } if (languageCodeIndex != 0) { languageComboBox.setSelectedItem(languageCodeIndex); languageComboBox.setEnabled(true); } } // Store original value for use by submit action. originalUserLanguageCode = userLanguageCode; constraints.fill = GridBagConstraints.NONE; constraints.gridx = 3; constraints.gridy = 6; constraints.weightx = 0.8; constraints.weighty = 0.6; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.LINE_START; languagePanel.add(languageComboBox, constraints); JPanel fill1 = new JPanel(); fill1.setOpaque(false); constraints.fill = GridBagConstraints.BOTH; constraints.gridx = 4; constraints.gridy = 6; constraints.weightx = 20; constraints.weighty = 1; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.LINE_END; languagePanel.add(fill1, constraints); return languagePanel; }
From source file:org.multibit.viewsystem.swing.view.panels.ShowPreferencesPanel.java
/** * Create the messaging server panel which consists of MultiBit style header * and our Netbean visual editor designed panel * @param stentWidth//from w w w. j av a 2 s . co m * @return */ private JPanel createMessagingServerPanel(int stentWidth) { MultiBitTitledPanel panel = new MultiBitTitledPanel("Messaging Servers", ComponentOrientation.getOrientation(controller.getLocaliser().getLocale())); // Create layout like other panels GridBagConstraints constraints = new GridBagConstraints(); constraints.fill = GridBagConstraints.BOTH; constraints.gridx = 0; constraints.gridy = 3; constraints.weightx = 0.1; constraints.weighty = 0.3; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.anchor = GridBagConstraints.LINE_START; JPanel indent = MultiBitTitledPanel.getIndentPanel(1); panel.add(indent, constraints); constraints.fill = GridBagConstraints.BOTH; constraints.gridx = 1; constraints.gridy = 4; constraints.weightx = 0.3; constraints.weighty = 0.3; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.LINE_START; JPanel stent = MultiBitTitledPanel.createStent(stentWidth); panel.add(stent, constraints); constraints.fill = GridBagConstraints.BOTH; constraints.gridx = 2; constraints.gridy = 3; constraints.weightx = 0.05; constraints.weighty = 0.3; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.CENTER; panel.add(MultiBitTitledPanel.createStent(MultiBitTitledPanel.SEPARATION_BETWEEN_NAME_VALUE_PAIRS), constraints); // Now insert our custom panel messagingServerPanel = new CSMessagingServerPanel(); constraints.fill = GridBagConstraints.NONE; constraints.gridx = 1; constraints.gridy = 5; constraints.weightx = 1; constraints.weighty = 1; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.LINE_START; panel.add(messagingServerPanel, constraints); // fill up right side JPanel fill1 = new JPanel(); fill1.setOpaque(false); constraints.fill = GridBagConstraints.BOTH; constraints.gridx = 4; constraints.gridy = 10; constraints.weightx = 20; constraints.weighty = 1; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.LINE_END; panel.add(fill1, constraints); return panel; }
From source file:org.multibit.viewsystem.swing.view.panels.ShowPreferencesPanel.java
private JPanel createAppearancePanel(int stentWidth) { MultiBitTitledPanel appearancePanel = new MultiBitTitledPanel( controller.getLocaliser().getString("showPreferencesPanel.appearanceTitle"), ComponentOrientation.getOrientation(controller.getLocaliser().getLocale())); GridBagConstraints constraints = new GridBagConstraints(); constraints.fill = GridBagConstraints.BOTH; constraints.gridx = 0;//from w w w . j ava 2 s .c o m constraints.gridy = 3; constraints.weightx = 0.1; constraints.weighty = 0.3; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.anchor = GridBagConstraints.LINE_START; JPanel indent = MultiBitTitledPanel.getIndentPanel(1); appearancePanel.add(indent, constraints); constraints.fill = GridBagConstraints.BOTH; constraints.gridx = 1; constraints.gridy = 4; constraints.weightx = 0.3; constraints.weighty = 0.3; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.LINE_START; JPanel stent = MultiBitTitledPanel.createStent(stentWidth); appearancePanel.add(stent, constraints); constraints.fill = GridBagConstraints.BOTH; constraints.gridx = 2; constraints.gridy = 3; constraints.weightx = 0.05; constraints.weighty = 0.3; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.CENTER; appearancePanel.add( MultiBitTitledPanel.createStent(MultiBitTitledPanel.SEPARATION_BETWEEN_NAME_VALUE_PAIRS), constraints); MultiBitLabel fontNameLabel = new MultiBitLabel( controller.getLocaliser().getString("fontChooser.fontName")); constraints.fill = GridBagConstraints.NONE; constraints.gridx = 1; constraints.gridy = 4; constraints.weightx = 0.3; constraints.weighty = 1; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.LINE_END; appearancePanel.add(fontNameLabel, constraints); fontNameTextLabel = new MultiBitLabel(""); constraints.fill = GridBagConstraints.NONE; constraints.gridx = 3; constraints.gridy = 4; constraints.weightx = 0.3; constraints.weighty = 1; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.LINE_START; appearancePanel.add(fontNameTextLabel, constraints); MultiBitLabel fontStyleLabel = new MultiBitLabel( controller.getLocaliser().getString("fontChooser.fontStyle")); constraints.fill = GridBagConstraints.NONE; constraints.gridx = 1; constraints.gridy = 5; constraints.weightx = 0.3; constraints.weighty = 1; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.LINE_END; appearancePanel.add(fontStyleLabel, constraints); fontStyleTextLabel = new MultiBitLabel(""); constraints.fill = GridBagConstraints.NONE; constraints.gridx = 3; constraints.gridy = 5; constraints.weightx = 0.3; constraints.weighty = 1; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.LINE_START; appearancePanel.add(fontStyleTextLabel, constraints); MultiBitLabel fontSizeLabel = new MultiBitLabel( controller.getLocaliser().getString("fontChooser.fontSize")); constraints.fill = GridBagConstraints.NONE; constraints.gridx = 1; constraints.gridy = 6; constraints.weightx = 0.3; constraints.weighty = 1; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.LINE_END; appearancePanel.add(fontSizeLabel, constraints); fontSizeTextLabel = new MultiBitLabel(""); constraints.fill = GridBagConstraints.NONE; constraints.gridx = 3; constraints.gridy = 6; constraints.weightx = 0.3; constraints.weighty = 1; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.LINE_START; appearancePanel.add(fontSizeTextLabel, constraints); ChooseFontAction chooseFontAction = new ChooseFontAction(controller, this, null); MultiBitButton fontChooserButton = new MultiBitButton(chooseFontAction, controller); constraints.fill = GridBagConstraints.NONE; constraints.gridx = 3; constraints.gridy = 7; constraints.weightx = 1; constraints.weighty = 1; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.LINE_START; appearancePanel.add(fontChooserButton, constraints); constraints.fill = GridBagConstraints.VERTICAL; constraints.gridx = 4; constraints.gridy = 8; constraints.weightx = 0.2; constraints.weighty = 0.3; constraints.gridwidth = 3; constraints.anchor = GridBagConstraints.LINE_START; appearancePanel.add(MultiBitTitledPanel.createStent(1, 30), constraints); MultiBitLabel lookAndFeelLabel = new MultiBitLabel( controller.getLocaliser().getString("showPreferencesPanel.lookAndFeel")); constraints.fill = GridBagConstraints.NONE; constraints.gridx = 1; constraints.gridy = 9; constraints.weightx = 0.3; constraints.weighty = 1; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.LINE_END; appearancePanel.add(lookAndFeelLabel, constraints); originalLookAndFeel = controller.getModel().getUserPreference(CoreModel.LOOK_AND_FEEL); LookAndFeelInfo[] lookAndFeels = UIManager.getInstalledLookAndFeels(); lookAndFeelComboBox = new JComboBox(); lookAndFeelComboBox.addItem(localisedSystemLookAndFeelName); if (lookAndFeels != null) { for (LookAndFeelInfo info : lookAndFeels) { lookAndFeelComboBox.addItem(info.getName()); if (info.getName().equalsIgnoreCase(originalLookAndFeel)) { lookAndFeelComboBox.setSelectedItem(info.getName()); } } } if (originalLookAndFeel == null || originalLookAndFeel.equals("") || CoreModel.SYSTEM_LOOK_AND_FEEL.equalsIgnoreCase(originalLookAndFeel)) { lookAndFeelComboBox.setSelectedItem(localisedSystemLookAndFeelName); } lookAndFeelComboBox.setFont(FontSizer.INSTANCE.getAdjustedDefaultFont()); lookAndFeelComboBox.setOpaque(false); FontMetrics fontMetrics = getFontMetrics(FontSizer.INSTANCE.getAdjustedDefaultFont()); int textWidth = Math.max(fontMetrics.stringWidth("CDE/Motif"), fontMetrics.stringWidth("Windows classic")); Dimension preferredSize = new Dimension(textWidth + TICKER_COMBO_WIDTH_DELTA, fontMetrics.getHeight() + EXCHANGE_COMBO_HEIGHT_DELTA); lookAndFeelComboBox.setPreferredSize(preferredSize); constraints.fill = GridBagConstraints.NONE; constraints.gridx = 3; constraints.gridy = 9; constraints.weightx = 0.8; constraints.weighty = 0.6; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.LINE_START; appearancePanel.add(lookAndFeelComboBox, constraints); JPanel fill1 = new JPanel(); fill1.setOpaque(false); constraints.fill = GridBagConstraints.BOTH; constraints.gridx = 4; constraints.gridy = 10; constraints.weightx = 20; constraints.weighty = 1; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.LINE_END; appearancePanel.add(fill1, constraints); return appearancePanel; }
From source file:org.multibit.viewsystem.swing.view.panels.ShowPreferencesPanel.java
private JPanel createTickerPanel(int stentWidth) { // Load up the original values. originalShowTicker = !Boolean.FALSE.toString() .equals(controller.getModel().getUserPreference(ExchangeModel.TICKER_SHOW)); originalExchange1 = controller.getModel().getUserPreference(ExchangeModel.TICKER_FIRST_ROW_EXCHANGE); originalCurrency1 = controller.getModel().getUserPreference(ExchangeModel.TICKER_FIRST_ROW_CURRENCY); // Map MtGox to Bitstamp + USD if (ExchangeData.MT_GOX_EXCHANGE_NAME.equalsIgnoreCase(originalExchange1)) { originalExchange1 = ExchangeData.BITSTAMP_EXCHANGE_NAME; controller.getModel().setUserPreference(ExchangeModel.TICKER_FIRST_ROW_EXCHANGE, ExchangeData.BITSTAMP_EXCHANGE_NAME); originalCurrency1 = "USD"; controller.getModel().setUserPreference(ExchangeModel.TICKER_FIRST_ROW_CURRENCY, "USD"); }/*w ww. j a v a2s . c om*/ originalShowSecondRow = Boolean.TRUE.toString() .equals(controller.getModel().getUserPreference(ExchangeModel.TICKER_SHOW_SECOND_ROW)); originalExchange2 = controller.getModel().getUserPreference(ExchangeModel.TICKER_SECOND_ROW_EXCHANGE); originalCurrency2 = controller.getModel().getUserPreference(ExchangeModel.TICKER_SECOND_ROW_CURRENCY); // Map MtGox to Bitstamp if (ExchangeData.MT_GOX_EXCHANGE_NAME.equalsIgnoreCase(originalExchange2)) { originalExchange2 = ExchangeData.BITSTAMP_EXCHANGE_NAME; controller.getModel().setUserPreference(ExchangeModel.TICKER_SECOND_ROW_EXCHANGE, ExchangeData.BITSTAMP_EXCHANGE_NAME); originalCurrency2 = "USD"; controller.getModel().setUserPreference(ExchangeModel.TICKER_SECOND_ROW_CURRENCY, "USD"); } MultiBitTitledPanel tickerPanel = new MultiBitTitledPanel( controller.getLocaliser().getString("showPreferencesPanel.ticker.title2"), ComponentOrientation.getOrientation(controller.getLocaliser().getLocale())); GridBagConstraints constraints = new GridBagConstraints(); constraints.fill = GridBagConstraints.BOTH; constraints.gridx = 3; constraints.gridy = 3; constraints.weightx = 0.05; constraints.weighty = 0.3; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.CENTER; tickerPanel.add(MultiBitTitledPanel.createStent(MultiBitTitledPanel.SEPARATION_BETWEEN_NAME_VALUE_PAIRS), constraints); String showTickerText = controller.getLocaliser().getString("multiBitFrame.ticker.show.text"); if (showTickerText != null && showTickerText.length() >= 1) { // Capitalise text (this is to save adding a new I18n term. showTickerText = Character.toUpperCase(showTickerText.charAt(0)) + showTickerText.toLowerCase().substring(1); } showTicker = new JCheckBox(showTickerText); showTicker.setOpaque(false); showTicker.setFont(FontSizer.INSTANCE.getAdjustedDefaultFont()); showTicker.setSelected(originalShowTicker); exchangeInformationLabel = new MultiBitLabel( controller.getLocaliser().getString("showPreferencesPanel.ticker.exchangeInformation")); exchangeInformationLabel.setVisible(originalShowBitcoinConvertedToFiat); showBitcoinConvertedToFiat = new JCheckBox( controller.getLocaliser().getString("showPreferencesPanel.ticker.showBitcoinConvertedToFiat")); showBitcoinConvertedToFiat.setOpaque(false); showBitcoinConvertedToFiat.setFont(FontSizer.INSTANCE.getAdjustedDefaultFont()); showBitcoinConvertedToFiat.setSelected(originalShowBitcoinConvertedToFiat); showBitcoinConvertedToFiat.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { boolean selectedChange = (e.getStateChange() == ItemEvent.SELECTED); boolean unSelectedChange = (e.getStateChange() == ItemEvent.DESELECTED); if (exchangeInformationLabel != null) { if (selectedChange) { exchangeInformationLabel.setVisible(true); } if (unSelectedChange) { exchangeInformationLabel.setVisible(false); } } } }); showExchange = new JCheckBox(controller.getLocaliser().getString("tickerTableModel.exchange")); showExchange.setOpaque(false); showExchange.setFont(FontSizer.INSTANCE.getAdjustedDefaultFont()); showCurrency = new JCheckBox(controller.getLocaliser().getString("tickerTableModel.currency")); showCurrency.setOpaque(false); showCurrency.setFont(FontSizer.INSTANCE.getAdjustedDefaultFont()); showLastPrice = new JCheckBox(controller.getLocaliser().getString("tickerTableModel.lastPrice")); showLastPrice.setOpaque(false); showLastPrice.setFont(FontSizer.INSTANCE.getAdjustedDefaultFont()); showBid = new JCheckBox(controller.getLocaliser().getString("tickerTableModel.bid")); showBid.setOpaque(false); showBid.setFont(FontSizer.INSTANCE.getAdjustedDefaultFont()); showAsk = new JCheckBox(controller.getLocaliser().getString("tickerTableModel.ask")); showAsk.setOpaque(false); showAsk.setFont(FontSizer.INSTANCE.getAdjustedDefaultFont()); String tickerColumnsToShow = controller.getModel().getUserPreference(ExchangeModel.TICKER_COLUMNS_TO_SHOW); if (tickerColumnsToShow == null || tickerColumnsToShow.equals("")) { tickerColumnsToShow = TickerTableModel.DEFAULT_COLUMNS_TO_SHOW; } originalShowCurrency = tickerColumnsToShow.contains(TickerTableModel.TICKER_COLUMN_CURRENCY); showCurrency.setSelected(originalShowCurrency); originalShowRate = tickerColumnsToShow.contains(TickerTableModel.TICKER_COLUMN_LAST_PRICE); showLastPrice.setSelected(originalShowRate); originalShowBid = tickerColumnsToShow.contains(TickerTableModel.TICKER_COLUMN_BID); showBid.setSelected(originalShowBid); originalShowAsk = tickerColumnsToShow.contains(TickerTableModel.TICKER_COLUMN_ASK); showAsk.setSelected(originalShowAsk); originalShowExchange = tickerColumnsToShow.contains(TickerTableModel.TICKER_COLUMN_EXCHANGE); showExchange.setSelected(originalShowExchange); constraints.fill = GridBagConstraints.HORIZONTAL; constraints.gridx = 1; constraints.gridy = 4; constraints.weightx = 0.2; constraints.weighty = 0.3; constraints.gridwidth = 4; constraints.anchor = GridBagConstraints.LINE_START; tickerPanel.add(showTicker, constraints); constraints.fill = GridBagConstraints.HORIZONTAL; constraints.gridx = 1; constraints.gridy = 5; constraints.weightx = 0.2; constraints.weighty = 0.3; constraints.gridwidth = 4; constraints.anchor = GridBagConstraints.LINE_START; tickerPanel.add(showBitcoinConvertedToFiat, constraints); constraints.fill = GridBagConstraints.VERTICAL; constraints.gridx = 0; constraints.gridy = 6; constraints.weightx = 0.2; constraints.weighty = 0.3; constraints.gridwidth = 3; constraints.anchor = GridBagConstraints.LINE_START; tickerPanel.add(MultiBitTitledPanel.createStent(1, 12), constraints); MultiBitTitledPanel.addLeftJustifiedTextAtIndent( controller.getLocaliser().getString("showPreferencesPanel.ticker.columnsToShow"), 7, tickerPanel); constraints.fill = GridBagConstraints.NONE; constraints.gridx = 1; constraints.gridy = 8; constraints.weightx = 0.2; constraints.weighty = 0.3; constraints.gridwidth = 3; constraints.anchor = GridBagConstraints.LINE_START; tickerPanel.add(showExchange, constraints); constraints.fill = GridBagConstraints.HORIZONTAL; constraints.gridx = 1; constraints.gridy = 9; constraints.weightx = 0.2; constraints.weighty = 0.3; constraints.gridwidth = 3; constraints.anchor = GridBagConstraints.LINE_START; tickerPanel.add(showCurrency, constraints); constraints.fill = GridBagConstraints.NONE; constraints.gridx = 1; constraints.gridy = 10; constraints.weightx = 0.2; constraints.weighty = 0.3; constraints.gridwidth = 3; constraints.anchor = GridBagConstraints.LINE_START; tickerPanel.add(showLastPrice, constraints); constraints.fill = GridBagConstraints.NONE; constraints.gridx = 1; constraints.gridy = 11; constraints.weightx = 0.2; constraints.weighty = 0.3; constraints.gridwidth = 3; constraints.anchor = GridBagConstraints.LINE_START; tickerPanel.add(showBid, constraints); constraints.fill = GridBagConstraints.NONE; constraints.gridx = 1; constraints.gridy = 12; constraints.weightx = 0.2; constraints.weighty = 0.3; constraints.gridwidth = 3; constraints.anchor = GridBagConstraints.LINE_START; tickerPanel.add(showAsk, constraints); constraints.fill = GridBagConstraints.VERTICAL; constraints.gridx = 1; constraints.gridy = 13; constraints.weightx = 0.3; constraints.weighty = 0.3; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.LINE_START; tickerPanel.add(MultiBitTitledPanel.createStent(1, 13), constraints); MultiBitTitledPanel.addLeftJustifiedTextAtIndent( controller.getLocaliser().getString("showPreferencesPanel.ticker.firstRow"), 14, tickerPanel); MultiBitLabel exchangeLabel1 = new MultiBitLabel( controller.getLocaliser().getString("showPreferencesPanel.ticker.exchange")); exchangeLabel1.setHorizontalAlignment(JLabel.TRAILING); constraints.fill = GridBagConstraints.HORIZONTAL; constraints.gridx = 1; constraints.gridy = 15; constraints.weightx = 0.3; constraints.weighty = 1; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.LINE_END; tickerPanel.add(exchangeLabel1, constraints); String exchangeToUse1; if (originalExchange1 == null | "".equals(originalExchange1)) { exchangeToUse1 = ExchangeData.DEFAULT_EXCHANGE; } else { exchangeToUse1 = originalExchange1; } String exchangeToUse2; if (originalExchange2 == null | "".equals(originalExchange2)) { exchangeToUse2 = ExchangeData.DEFAULT_EXCHANGE; } else { exchangeToUse2 = originalExchange2; } exchangeComboBox1 = new JComboBox(ExchangeData.getAvailableExchanges()); exchangeComboBox1.setSelectedItem(exchangeToUse1); exchangeComboBox1.setFont(FontSizer.INSTANCE.getAdjustedDefaultFont()); exchangeComboBox1.setOpaque(false); FontMetrics fontMetrics = getFontMetrics(FontSizer.INSTANCE.getAdjustedDefaultFont()); int textWidth = Math.max(fontMetrics.stringWidth(ExchangeData.OPEN_EXCHANGE_RATES_EXCHANGE_NAME), fontMetrics.stringWidth("USD")) + COMBO_WIDTH_DELTA; Dimension preferredSize = new Dimension(textWidth + TICKER_COMBO_WIDTH_DELTA, fontMetrics.getHeight() + EXCHANGE_COMBO_HEIGHT_DELTA); exchangeComboBox1.setPreferredSize(preferredSize); constraints.fill = GridBagConstraints.BOTH; constraints.gridx = 1; constraints.gridy = 15; constraints.weightx = 0.3; constraints.weighty = 0.3; constraints.gridwidth = 2; constraints.anchor = GridBagConstraints.LINE_START; JPanel stent = MultiBitTitledPanel.createStent(stentWidth); tickerPanel.add(stent, constraints); constraints.fill = GridBagConstraints.NONE; constraints.gridx = 4; constraints.gridy = 15; constraints.weightx = 0.8; constraints.weighty = 0.6; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.LINE_START; tickerPanel.add(exchangeComboBox1, constraints); oerMessageLabel1 = new MultiBitLabel( " " + controller.getLocaliser().getString("showPreferencesPanel.getAppId.label")); oerMessageLabel1.setForeground(Color.GREEN.darker().darker()); boolean showMessageLabel1 = isBrowserSupported() && ExchangeData.OPEN_EXCHANGE_RATES_EXCHANGE_NAME.equalsIgnoreCase(exchangeToUse1) && (originalOERApiCode == null || originalOERApiCode.trim().length() == 0); oerMessageLabel1.setVisible(showMessageLabel1); constraints.fill = GridBagConstraints.NONE; constraints.gridx = 5; constraints.gridy = 15; constraints.weightx = 0.8; constraints.weighty = 0.6; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.LINE_START; tickerPanel.add(oerMessageLabel1, constraints); MultiBitLabel currencyLabel1 = new MultiBitLabel( controller.getLocaliser().getString("showPreferencesPanel.ticker.currency")); currencyLabel1.setHorizontalAlignment(JLabel.TRAILING); constraints.fill = GridBagConstraints.HORIZONTAL; constraints.gridx = 1; constraints.gridy = 16; constraints.weightx = 0.3; constraints.weighty = 1; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.LINE_END; tickerPanel.add(currencyLabel1, constraints); // Make sure the exchange1 has been created and initialised the list of // currencies. if (mainFrame != null && mainFrame.getTickerTimerTask1() != null) { TickerTimerTask tickerTimerTask = mainFrame.getTickerTimerTask1(); synchronized (tickerTimerTask) { if (tickerTimerTask.getExchange() == null) { tickerTimerTask.createExchangeObjects(exchangeToUse1); } } } currencyComboBox1 = new JComboBox(); Collection<String> currenciesToUse = ExchangeData.getAvailableCurrenciesForExchange(exchangeToUse1); if (currenciesToUse != null) { for (String currency : currenciesToUse) { String item = currency; String description = CurrencyConverter.INSTANCE.getCurrencyCodeToDescriptionMap().get(currency); if (description != null && description.trim().length() > 0) { item = item + " (" + description + ")"; } currencyComboBox1.addItem(item); if (currency.equals(originalCurrency1)) { currencyComboBox1.setSelectedItem(item); } } } currencyComboBox1.setFont(FontSizer.INSTANCE.getAdjustedDefaultFont()); currencyComboBox1.setOpaque(false); currencyComboBox1.setPreferredSize(preferredSize); exchangeComboBox1.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent event) { if (event.getStateChange() == ItemEvent.SELECTED) { Object item = event.getItem(); String exchangeShortName = item.toString(); // Make sure the exchange1 has been created and initialised // the list of currencies. if (mainFrame != null && mainFrame.getTickerTimerTask1() != null) { TickerTimerTask tickerTimerTask = mainFrame.getTickerTimerTask1(); synchronized (tickerTimerTask) { tickerTimerTask.createExchangeObjects(exchangeShortName); currencyComboBox1.removeAllItems(); Collection<String> currenciesToUse = ExchangeData .getAvailableCurrenciesForExchange(exchangeShortName); if (currenciesToUse != null) { for (String currency : currenciesToUse) { String loopItem = currency; String description = CurrencyConverter.INSTANCE .getCurrencyCodeToDescriptionMap().get(currency); if (description != null && description.trim().length() > 0) { loopItem = loopItem + " (" + description + ")"; } currencyComboBox1.addItem(loopItem); } } } } // Enable the OpenExchangeRates App ID if required. boolean showOER = ExchangeData.OPEN_EXCHANGE_RATES_EXCHANGE_NAME .equalsIgnoreCase(exchangeShortName) || ExchangeData.OPEN_EXCHANGE_RATES_EXCHANGE_NAME .equalsIgnoreCase((String) exchangeComboBox2.getSelectedItem()); oerStent.setVisible(showOER); oerApiCodeLabel.setVisible(showOER); oerApiCodeTextField.setVisible(showOER); getOerAppIdButton.setVisible(showOER); boolean showMessageLabel = isBrowserSupported() && ExchangeData.OPEN_EXCHANGE_RATES_EXCHANGE_NAME.equalsIgnoreCase(exchangeShortName) && (oerApiCodeTextField.getText() == null || oerApiCodeTextField.getText().trim().length() == 0); oerMessageLabel1.setVisible(showMessageLabel); } } }); constraints.fill = GridBagConstraints.NONE; constraints.gridx = 4; constraints.gridy = 16; constraints.weightx = 0.8; constraints.weighty = 0.6; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.LINE_START; tickerPanel.add(currencyComboBox1, constraints); constraints.fill = GridBagConstraints.BOTH; constraints.gridx = 1; constraints.gridy = 17; constraints.weightx = 0.3; constraints.weighty = 0.3; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.LINE_START; tickerPanel.add(MultiBitTitledPanel.createStent(12, 12), constraints); constraints.fill = GridBagConstraints.NONE; constraints.gridx = 4; constraints.gridy = 18; constraints.weightx = 0.8; constraints.weighty = 0.6; constraints.gridwidth = 2; constraints.anchor = GridBagConstraints.LINE_START; tickerPanel.add(MultiBitTitledPanel.createStent(fontMetrics.stringWidth(exchangeInformationLabel.getText()), fontMetrics.getHeight()), constraints); tickerPanel.add(exchangeInformationLabel, constraints); constraints.fill = GridBagConstraints.BOTH; constraints.gridx = 1; constraints.gridy = 19; constraints.weightx = 0.3; constraints.weighty = 0.3; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.LINE_START; tickerPanel.add(MultiBitTitledPanel.createStent(12, 12), constraints); MultiBitTitledPanel.addLeftJustifiedTextAtIndent( controller.getLocaliser().getString("showPreferencesPanel.ticker.secondRow"), 20, tickerPanel); showSecondRowCheckBox = new JCheckBox( controller.getLocaliser().getString("showPreferencesPanel.ticker.showSecondRow")); showSecondRowCheckBox.setOpaque(false); showSecondRowCheckBox.setFont(FontSizer.INSTANCE.getAdjustedDefaultFont()); showSecondRowCheckBox.addItemListener(new ChangeTickerShowSecondRowListener()); constraints.fill = GridBagConstraints.HORIZONTAL; constraints.gridx = 1; constraints.gridy = 21; constraints.weightx = 0.3; constraints.weighty = 1; constraints.gridwidth = 3; constraints.anchor = GridBagConstraints.LINE_START; tickerPanel.add(showSecondRowCheckBox, constraints); exchangeLabel2 = new MultiBitLabel( controller.getLocaliser().getString("showPreferencesPanel.ticker.exchange")); exchangeLabel2.setHorizontalAlignment(JLabel.TRAILING); constraints.fill = GridBagConstraints.HORIZONTAL; constraints.gridx = 1; constraints.gridy = 22; constraints.weightx = 0.3; constraints.weighty = 1; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.LINE_END; tickerPanel.add(exchangeLabel2, constraints); exchangeComboBox2 = new JComboBox(ExchangeData.getAvailableExchanges()); exchangeComboBox2.setSelectedItem(exchangeToUse2); exchangeComboBox2.setFont(FontSizer.INSTANCE.getAdjustedDefaultFont()); exchangeComboBox2.setOpaque(false); exchangeComboBox2.setPreferredSize(preferredSize); exchangeComboBox2.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent event) { if (event.getStateChange() == ItemEvent.SELECTED) { Object item = event.getItem(); String exchangeShortName = item.toString(); // Make sure the exchange2 has been created and initialised // the list of currencies. if (mainFrame != null && mainFrame.getTickerTimerTask2() != null) { TickerTimerTask tickerTimerTask = mainFrame.getTickerTimerTask2(); synchronized (tickerTimerTask) { tickerTimerTask.createExchangeObjects(exchangeShortName); currencyComboBox2.removeAllItems(); Collection<String> currenciesToUse = ExchangeData .getAvailableCurrenciesForExchange(exchangeShortName); if (currenciesToUse != null) { for (String currency : currenciesToUse) { String loopItem = currency; String description = CurrencyConverter.INSTANCE .getCurrencyCodeToDescriptionMap().get(currency); if (description != null && description.trim().length() > 0) { loopItem = loopItem + " (" + description + ")"; } currencyComboBox2.addItem(loopItem); } } } } // Enable the OpenExchangeRates App ID if required. boolean showOER = ExchangeData.OPEN_EXCHANGE_RATES_EXCHANGE_NAME .equalsIgnoreCase(exchangeShortName) || ExchangeData.OPEN_EXCHANGE_RATES_EXCHANGE_NAME .equalsIgnoreCase((String) exchangeComboBox1.getSelectedItem()); oerStent.setVisible(showOER); oerApiCodeLabel.setVisible(showOER); oerApiCodeTextField.setVisible(showOER); getOerAppIdButton.setVisible(showOER); boolean showMessageLabel = isBrowserSupported() && ExchangeData.OPEN_EXCHANGE_RATES_EXCHANGE_NAME.equalsIgnoreCase(exchangeShortName) && (oerApiCodeTextField.getText() == null || oerApiCodeTextField.getText().trim().length() == 0); oerMessageLabel2.setVisible(showMessageLabel); } } }); constraints.fill = GridBagConstraints.NONE; constraints.gridx = 4; constraints.gridy = 22; constraints.weightx = 0.8; constraints.weighty = 0.6; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.LINE_START; tickerPanel.add(exchangeComboBox2, constraints); oerMessageLabel2 = new MultiBitLabel( " " + controller.getLocaliser().getString("showPreferencesPanel.getAppId.label")); oerMessageLabel2.setForeground(Color.GREEN.darker().darker()); boolean showMessageLabel2 = isBrowserSupported() && ExchangeData.OPEN_EXCHANGE_RATES_EXCHANGE_NAME.equalsIgnoreCase(exchangeToUse2) && (originalOERApiCode == null || originalOERApiCode.trim().length() == 0); oerMessageLabel2.setVisible(showMessageLabel2); constraints.fill = GridBagConstraints.NONE; constraints.gridx = 5; constraints.gridy = 22; constraints.weightx = 0.8; constraints.weighty = 0.6; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.LINE_START; tickerPanel.add(oerMessageLabel2, constraints); currencyLabel2 = new MultiBitLabel( controller.getLocaliser().getString("showPreferencesPanel.ticker.currency")); currencyLabel2.setHorizontalAlignment(JLabel.TRAILING); constraints.fill = GridBagConstraints.HORIZONTAL; constraints.gridx = 1; constraints.gridy = 23; constraints.weightx = 0.3; constraints.weighty = 1; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.LINE_END; tickerPanel.add(currencyLabel2, constraints); // Make sure the exchange2 has been created and initialised the list of // currencies. if (mainFrame != null && mainFrame.getTickerTimerTask2() != null) { TickerTimerTask tickerTimerTask = mainFrame.getTickerTimerTask2(); synchronized (tickerTimerTask) { if (tickerTimerTask.getExchange() == null) { tickerTimerTask.createExchangeObjects(exchangeToUse2); } } } currencyComboBox2 = new JComboBox(); currenciesToUse = ExchangeData.getAvailableCurrenciesForExchange(exchangeToUse2); if (currenciesToUse != null) { for (String currency : currenciesToUse) { String loopItem = currency; String description = CurrencyConverter.INSTANCE.getCurrencyCodeToDescriptionMap().get(currency); if (description != null && description.trim().length() > 0) { loopItem = loopItem + " (" + description + ")"; } currencyComboBox2.addItem(loopItem); if (currency.equals(originalCurrency2)) { currencyComboBox2.setSelectedItem(loopItem); } } } currencyComboBox2.setFont(FontSizer.INSTANCE.getAdjustedDefaultFont()); currencyComboBox2.setOpaque(false); currencyComboBox2.setPreferredSize(preferredSize); constraints.fill = GridBagConstraints.NONE; constraints.gridx = 4; constraints.gridy = 23; constraints.weightx = 0.8; constraints.weighty = 0.6; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.LINE_START; tickerPanel.add(currencyComboBox2, constraints); showSecondRowCheckBox.setSelected(originalShowSecondRow); enableTickerSecondRow(originalShowSecondRow); constraints.fill = GridBagConstraints.BOTH; constraints.gridx = 1; constraints.gridy = 24; constraints.weightx = 0.3; constraints.weighty = 0.3; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.LINE_START; tickerPanel.add(MultiBitTitledPanel.createStent(12, 12), constraints); JPanel fill1 = new JPanel(); fill1.setOpaque(false); constraints.fill = GridBagConstraints.BOTH; constraints.gridx = 5; constraints.gridy = 25; constraints.weightx = 20; constraints.weighty = 1; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.LINE_END; tickerPanel.add(fill1, constraints); boolean showOerSignup = ExchangeData.OPEN_EXCHANGE_RATES_EXCHANGE_NAME.equalsIgnoreCase(exchangeToUse1) || ExchangeData.OPEN_EXCHANGE_RATES_EXCHANGE_NAME.equalsIgnoreCase(exchangeToUse2); oerStent = MultiBitTitledPanel.createStent(12, 12); constraints.fill = GridBagConstraints.BOTH; constraints.gridx = 1; constraints.gridy = 26; constraints.weightx = 0.3; constraints.weighty = 0.3; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.LINE_START; oerStent.setVisible(showOerSignup); tickerPanel.add(oerStent, constraints); oerApiCodeLabel = new MultiBitLabel( controller.getLocaliser().getString("showPreferencesPanel.oerLabel.text")); oerApiCodeLabel.setToolTipText(HelpContentsPanel .createTooltipText(controller.getLocaliser().getString("showPreferencesPanel.oerLabel.tooltip"))); oerApiCodeLabel.setVisible(showOerSignup); oerApiCodeTextField = new MultiBitTextField("", 25, controller); oerApiCodeTextField.setHorizontalAlignment(JLabel.LEADING); oerApiCodeTextField.setMinimumSize(new Dimension(API_CODE_FIELD_WIDTH, API_CODE_FIELD_HEIGHT)); oerApiCodeTextField.setPreferredSize(new Dimension(API_CODE_FIELD_WIDTH, API_CODE_FIELD_HEIGHT)); oerApiCodeTextField.setMaximumSize(new Dimension(API_CODE_FIELD_WIDTH, API_CODE_FIELD_HEIGHT)); oerApiCodeTextField.setVisible(showOerSignup); oerApiCodeTextField.setText(originalOERApiCode); oerApiCodeTextField.addFocusListener(new FocusListener() { @Override public void focusGained(FocusEvent arg0) { } @Override public void focusLost(FocusEvent arg0) { String apiCode = oerApiCodeTextField.getText(); if (apiCode != null && !(WhitespaceTrimmer.trim(apiCode).length() == 0) && !apiCode.equals( controller.getModel().getUserPreference(ExchangeModel.OPEN_EXCHANGE_RATES_API_CODE))) { // New API code. // Check its length if (!(apiCode.trim().length() == LENGTH_OF_OPEN_EXCHANGE_RATE_APP_ID) && !apiCode.equals(haveShownErrorMessageForApiCode)) { haveShownErrorMessageForApiCode = apiCode; // Give user a message that App ID is not in the correct format. JOptionPane.showMessageDialog(null, new String[] { controller .getLocaliser().getString("showPreferencesPanel.oerValidationError.text1"), " ", controller.getLocaliser() .getString("showPreferencesPanel.oerValidationError.text2"), controller.getLocaliser() .getString("showPreferencesPanel.oerValidationError.text3") }, controller.getLocaliser().getString( "showPreferencesPanel.oerValidationError.title"), JOptionPane.ERROR_MESSAGE, ImageLoader.createImageIcon(ImageLoader.EXCLAMATION_MARK_ICON_FILE)); return; } } updateApiCode(); } }); oerApiCodeTextField.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { String apiCode = oerApiCodeTextField.getText(); if (apiCode != null && !(WhitespaceTrimmer.trim(apiCode).length() == 0) && !apiCode.equals( controller.getModel().getUserPreference(ExchangeModel.OPEN_EXCHANGE_RATES_API_CODE))) { // New API code. // Check its length if (!(apiCode.trim().length() == LENGTH_OF_OPEN_EXCHANGE_RATE_APP_ID) && !apiCode.equals(haveShownErrorMessageForApiCode)) { haveShownErrorMessageForApiCode = apiCode; // Give user a message that App ID is not in the correct format. JOptionPane.showMessageDialog(null, new String[] { controller.getLocaliser() .getString("showPreferencesPanel.oerValidationError.text1"), controller.getLocaliser() .getString("showPreferencesPanel.oerValidationError.text2"), controller.getLocaliser() .getString("showPreferencesPanel.oerValidationError.text3") }, controller.getLocaliser().getString( "showPreferencesPanel.oerValidationError.title"), JOptionPane.ERROR_MESSAGE, ImageLoader.createImageIcon(ImageLoader.EXCLAMATION_MARK_ICON_FILE)); return; } } updateApiCode(); } }); constraints.fill = GridBagConstraints.NONE; constraints.gridx = 1; constraints.gridy = 27; constraints.weightx = 0.3; constraints.weighty = 0.3; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.LINE_END; tickerPanel.add(oerApiCodeLabel, constraints); constraints.fill = GridBagConstraints.NONE; constraints.gridx = 4; constraints.gridy = 27; constraints.weightx = 0.3; constraints.weighty = 0.3; constraints.gridwidth = 2; constraints.anchor = GridBagConstraints.LINE_START; tickerPanel.add(oerApiCodeTextField, constraints); if (isBrowserSupported()) { getOerAppIdButton = new MultiBitButton( controller.getLocaliser().getString("showPreferencesPanel.getAppId.text")); getOerAppIdButton .setToolTipText(controller.getLocaliser().getString("showPreferencesPanel.getAppId.tooltip")); getOerAppIdButton.setVisible(showOerSignup); getOerAppIdButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { try { openURI(new URI(OPEN_EXCHANGE_RATES_SIGN_UP_URI)); } catch (URISyntaxException e) { log.debug(e.getMessage()); } } }); constraints.fill = GridBagConstraints.NONE; constraints.gridx = 4; constraints.gridy = 28; constraints.weightx = 1; constraints.weighty = 1; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.LINE_START; tickerPanel.add(getOerAppIdButton, constraints); } return tickerPanel; }
From source file:org.multibit.viewsystem.swing.view.panels.ShowPreferencesPanel.java
private JPanel createButtonPanel() { JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new GridBagLayout()); GridBagConstraints constraints = new GridBagConstraints(); buttonPanel.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, SystemColor.windowBorder)); buttonPanel.setOpaque(true); buttonPanel.setBackground(ColorAndFontConstants.MID_BACKGROUND_COLOR); buttonPanel.setComponentOrientation( ComponentOrientation.getOrientation(controller.getLocaliser().getLocale())); Action helpAction;// w w w . ja va 2 s. c om 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_PREFERENCES_URL); } else { helpAction = new HelpContextAction(controller, ImageLoader.HELP_CONTENTS_BIG_RTL_ICON_FILE, "multiBitFrame.helpMenuText", "multiBitFrame.helpMenuTooltip", "multiBitFrame.helpMenuText", HelpContentsPanel.HELP_PREFERENCES_URL); } HelpButton helpButton = new HelpButton(helpAction, controller); helpButton.setText(""); helpButton.setToolTipText(controller.getLocaliser().getString("multiBitFrame.helpMenuTooltip")); helpButton.setHorizontalAlignment(SwingConstants.LEADING); constraints.fill = GridBagConstraints.HORIZONTAL; constraints.gridx = 0; constraints.gridy = 0; constraints.weightx = 0.3; constraints.weighty = 0.1; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.anchor = GridBagConstraints.LINE_START; buttonPanel.add(helpButton, constraints); ShowPreferencesSubmitAction submitAction = new ShowPreferencesSubmitAction(this.bitcoinController, this.exchangeController, this, ImageLoader.createImageIcon(ImageLoader.PREFERENCES_ICON_FILE), mainFrame); MultiBitButton submitButton = new MultiBitButton(submitAction, controller); buttonPanel.add(submitButton); UndoPreferencesChangesSubmitAction undoChangesAction = new UndoPreferencesChangesSubmitAction(controller, ImageLoader.createImageIcon(ImageLoader.UNDO_ICON_FILE)); undoChangesButton = new MultiBitButton(undoChangesAction, controller); buttonPanel.add(undoChangesButton); constraints.fill = GridBagConstraints.NONE; constraints.gridx = 1; constraints.gridy = 0; constraints.weightx = 0.1; constraints.weighty = 1.0; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.anchor = GridBagConstraints.LINE_START; buttonPanel.add(submitButton, constraints); constraints.fill = GridBagConstraints.NONE; constraints.gridx = 2; constraints.gridy = 0; constraints.weightx = 0.1; constraints.weighty = 1.0; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.anchor = GridBagConstraints.LINE_START; buttonPanel.add(undoChangesButton, constraints); JPanel fill1 = new JPanel(); fill1.setOpaque(false); constraints.fill = GridBagConstraints.HORIZONTAL; constraints.gridx = 2; constraints.gridy = 0; constraints.weightx = 200; constraints.weighty = 1; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.anchor = GridBagConstraints.LINE_END; buttonPanel.add(fill1, constraints); return buttonPanel; }
From source file:org.nuclos.client.layout.wysiwyg.component.properties.PropertiesPanel.java
/** * The Label for the {@link PropertyValue} (left side of the Table) * @param value/*from ww w .j ava 2 s .c o m*/ * @return */ public static Component getCellComponent(String value) { JPanel result = new JPanel(); result.setOpaque(true); result.setBackground(Color.WHITE); TableLayout layout = new TableLayout( new double[][] { { InterfaceGuidelines.CELL_MARGIN_LEFT, TableLayout.FILL }, { InterfaceGuidelines.CELL_MARGIN_TOP, TableLayout.PREFERRED } }); result.setLayout(layout); result.add(new JLabel(value), new TableLayoutConstraints(1, 1)); return result; }
From source file:org.openconcerto.erp.core.finance.accounting.ui.EtatJournauxPanel.java
public void loadAsynchronous() { // On recupere les differents journaux SQLTable journalTable = base.getTable("JOURNAL"); List<SQLRow> liste = SQLBackgroundTableCache.getInstance().getCacheForTable(journalTable).getRows(); for (int k = 0; k < liste.size(); k++) { SQLRow row = liste.get(k);/*from w w w. j a va 2 s. c o m*/ fireIsLoading(true); final Journal jrnlTmp = new Journal(row.getID(), row.getString("NOM"), row.getString("CODE")); new SwingWorker<JPanel, Object>() { @Override protected JPanel doInBackground() throws Exception { final JPanel initJournalPanel = initJournalPanel(jrnlTmp); return initJournalPanel; } @Override protected void done() { JPanel initJournalPanel; try { initJournalPanel = get(); initJournalPanel.setOpaque(false); JScrollPane scroll = new JScrollPane(initJournalPanel); scroll.setBorder(null); scroll.setOpaque(false); scroll.getViewport().setOpaque(false); EtatJournauxPanel.this.tabbedJournaux.addTab(jrnlTmp.getNom(), scroll); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ExecutionException e) { // TODO Auto-generated catch block e.printStackTrace(); } fireIsLoading(false); super.done(); } }.execute(); } }
From source file:org.openconcerto.erp.core.finance.accounting.ui.EtatJournauxPanel.java
private JPanel initJournalPanel(final Journal jrnl) { final JPanel panelTmp = new JPanel(); long totalDebitJournal = 0; long totalCreditJournal = 0; panelTmp.setLayout(new GridBagLayout()); final GridBagConstraints c = new GridBagConstraints(); c.insets = new Insets(2, 2, 1, 2); c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.NORTHWEST; c.gridx = 0;// w ww . j a v a 2 s . c o m c.gridy = 0; c.gridwidth = 1; c.gridheight = 1; c.weightx = 1; c.weighty = 0; String req = "SELECT DISTINCT EXTRACT(YEAR FROM \"" + baseName + "\".\"ECRITURE\".\"DATE\"), " + "EXTRACT(MONTH FROM \"" + baseName + "\".\"ECRITURE\".\"DATE\")," + " SUM(\"" + baseName + "\".\"ECRITURE\".\"DEBIT\"), " + "SUM(\"" + baseName + "\".\"ECRITURE\".\"CREDIT\")" + " FROM \"" + baseName + "\".\"ECRITURE\" " + "WHERE (\"" + baseName + "\".\"ECRITURE\".\"ID\" != 1) " + "AND ((\"" + baseName + "\".\"ECRITURE\".\"ARCHIVE\" = 0) " + "AND (\"" + baseName + "\".\"ECRITURE\".\"ID_JOURNAL\" = " + jrnl.getId() + ")) " + "GROUP BY EXTRACT(YEAR FROM \"" + baseName + "\".\"ECRITURE\".\"DATE\"), " + "EXTRACT(MONTH FROM \"" + baseName + "\".\"ECRITURE\".\"DATE\") " + "ORDER BY EXTRACT(YEAR FROM \"" + baseName + "\".\"ECRITURE\".\"DATE\"), " + "EXTRACT(MONTH FROM \"" + baseName + "\".\"ECRITURE\".\"DATE\")"; System.out.println(req); Object ob = base.getDataSource().execute(req, new ArrayListHandler()); List myList = (List) ob; // System.err.println("TEST DATE " + t); if (myList.size() != 0) { for (int i = 0; i < myList.size(); i++) { Object[] objTmp = (Object[]) myList.get(i); Calendar cal = Calendar.getInstance(); cal.set(Calendar.DATE, 1); int month = (new Double(objTmp[1].toString()).intValue() - 1); System.err.println(jrnl.getNom() + " SET MONTH " + month); cal.set(Calendar.MONTH, month); System.err.println(month + " = " + cal.getTime()); cal.set(Calendar.YEAR, new Double(objTmp[0].toString()).intValue()); long debitMois = ((Number) objTmp[2]).longValue(); long creditMois = ((Number) objTmp[3]).longValue(); c.gridwidth = GridBagConstraints.REMAINDER; final JPanel creerJournalMoisPanel = creerJournalMoisPanel(cal.getTime(), debitMois, creditMois, jrnl); creerJournalMoisPanel.setOpaque(false); panelTmp.add(creerJournalMoisPanel, c); c.gridy++; totalDebitJournal += debitMois; totalCreditJournal += creditMois; } } c.gridx = 0; c.weighty = 1; c.gridwidth = 1; final JLabel label = new JLabel("Journal " + jrnl.getNom()); label.setOpaque(false); panelTmp.add(label, c); c.gridx = GridBagConstraints.RELATIVE; panelTmp.add(new JLabel(" Total dbit : " + GestionDevise.currencyToString(totalDebitJournal)), c); panelTmp.add(new JLabel(" Total crdit : " + GestionDevise.currencyToString(totalCreditJournal)), c); return panelTmp; }
From source file:org.openconcerto.erp.core.finance.accounting.ui.GrandLivrePanel.java
public void loadAsynchronous() { // On recupere les differentes classes List<ClasseCompte> liste = ClasseCompte.getClasseCompte(); if (liste.size() != 0) { for (int k = 0; k < liste.size(); k++) { final ClasseCompte ccTmp = liste.get(k); fireLoading(true);/*from ww w . ja va 2 s .c om*/ new SwingWorker<JPanel, Object>() { @Override protected JPanel doInBackground() throws Exception { // TODO Auto-generated method stub return initClassePanel(ccTmp); } @Override protected void done() { JPanel initClassePanel; try { initClassePanel = get(); initClassePanel.setOpaque(false); final JScrollPane scrollPane = new JScrollPane(initClassePanel); scrollPane.setOpaque(false); scrollPane.setBorder(null); scrollPane.getViewport().setOpaque(false); // On crer les comptes de chaque classe GrandLivrePanel.this.tabbedClasse.addTab(ccTmp.getNom(), scrollPane); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ExecutionException e) { // TODO Auto-generated catch block e.printStackTrace(); } fireLoading(false); super.done(); } }.execute(); } } }
From source file:org.openconcerto.erp.core.finance.accounting.ui.GrandLivrePanel.java
/** * Cre le panel d'un onglet associ une classe * //from ww w . j av a 2 s.com * @param cc ClasseCompte la classe des comptes * @return JPanel le JPanel associ */ private JPanel initClassePanel(ClasseCompte cc) { final JPanel panelTmp = new JPanel(); long totalDebitClasse = 0; long totalCreditClasse = 0; panelTmp.setLayout(new GridBagLayout()); panelTmp.setOpaque(false); final GridBagConstraints c = new GridBagConstraints(); c.insets = new Insets(2, 2, 1, 2); c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.NORTHWEST; c.gridx = 0; c.gridy = 0; c.gridwidth = 1; c.gridheight = 1; c.weightx = 1; c.weighty = 0; // Rcupration des comptes de la classe avec le total SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete(); SQLTable compteTable = base.getTable("COMPTE_PCE"); SQLTable ecritureTable = base.getTable("ECRITURE"); SQLSelect sel = new SQLSelect(base); sel.addSelect(compteTable.getKey()); sel.addSelect(compteTable.getField("NUMERO")); sel.addSelect(compteTable.getField("NOM")); sel.addSelect(ecritureTable.getField("DEBIT"), "SUM"); sel.addSelect(ecritureTable.getField("CREDIT"), "SUM"); String function = "REGEXP"; String match = cc.getTypeNumeroCompte(); if (Configuration.getInstance().getBase().getServer().getSQLSystem() == SQLSystem.POSTGRESQL) { // function = "SIMILAR TO"; function = "~"; // match = cc.getTypeNumeroCompte().replace(".*", "%"); } Where w = new Where(compteTable.getField("NUMERO"), function, match); Where w2 = new Where(ecritureTable.getField("ID_COMPTE_PCE"), "=", compteTable.getKey()); if (!UserManager.getInstance().getCurrentUser().getRights() .haveRight(ComptaUserRight.ACCES_NOT_RESCTRICTED_TO_411)) { // TODO Show Restricted acces in UI w = w.and(new Where(ecritureTable.getField("COMPTE_NUMERO"), "LIKE", "411%")); } sel.setWhere(w.and(w2)); String req = sel.asString() + " GROUP BY \"COMPTE_PCE\".\"ID\",\"COMPTE_PCE\".\"NUMERO\",\"COMPTE_PCE\".\"NOM\" ORDER BY \"COMPTE_PCE\".\"NUMERO\""; System.out.println(req); Object ob = base.getDataSource().execute(req, new ArrayListHandler()); List myList = (List) ob; JLabel labelTotalClasse = new JLabel(); labelTotalClasse.setOpaque(false); if (myList.size() != 0) { /*************************************************************************************** * Cration des Panels de chaque compte **************************************************************************************/ // c.weighty = 1; for (int i = 0; i < myList.size(); i++) { Object[] objTmp = (Object[]) myList.get(i); final Compte compteTmp = new Compte(((Number) objTmp[0]).intValue(), objTmp[1].toString(), objTmp[2].toString(), "", ((Number) objTmp[3]).longValue(), ((Number) objTmp[4]).longValue()); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; c.weighty = 0; c.gridx = 0; c.gridy++; panelTmp.add(creerComptePanel(compteTmp), c); // calcul du total de la classe totalDebitClasse += compteTmp.getTotalDebit(); totalCreditClasse += compteTmp.getTotalCredit(); } // Total de la classe labelTotalClasse.setText( "Total Classe " + cc.getNom() + " Dbit : " + GestionDevise.currencyToString(totalDebitClasse) + " Crdit : " + GestionDevise.currencyToString(totalCreditClasse)); } else { labelTotalClasse.setHorizontalAlignment(SwingConstants.CENTER); labelTotalClasse.setText("Aucune criture pour la classe " + cc.getNom()); } c.gridy++; c.weighty = 1; panelTmp.add(labelTotalClasse, c); return panelTmp; }