List of usage examples for javax.swing JPanel setForeground
@BeanProperty(preferred = true, visualUpdate = true, description = "The foreground color of the component.") public void setForeground(Color fg)
From source file:Main.java
public static void main(String[] args) { JPanel panel1 = new JPanel(); JPanel panel2 = new JPanel(); JButton button = new JButton(); Main f = null;/*from ww w . java 2 s .co m*/ f = new Main(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setSize(700, 400); panel1.setLayout(new BorderLayout()); panel1.setForeground(Color.white); button.setText("Convert"); panel1.add(button, BorderLayout.SOUTH); f.setContentPane(panel1); f.setVisible(true); f1 = new Main(); f1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f1.setSize(457, 100); f1.setTitle("Conversion Progress"); f1.setLocationRelativeTo(null); panel2.setLayout(new BorderLayout()); panel2.setForeground(Color.white); JProgressBar progressBar = new JProgressBar(); progressBar.setValue(35); progressBar.setStringPainted(true); panel2.add(progressBar, BorderLayout.SOUTH); f1.setContentPane(panel2); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { f1.setVisible(true); } }); }
From source file:filterviewplugin.FilterViewSettingsTab.java
public JPanel createSettingsPanel() { final EnhancedPanelBuilder panelBuilder = new EnhancedPanelBuilder(FormFactory.RELATED_GAP_COLSPEC.encode() + ',' + FormFactory.PREF_COLSPEC.encode() + ',' + FormFactory.RELATED_GAP_COLSPEC.encode() + ',' + FormFactory.PREF_COLSPEC.encode() + ", fill:default:grow"); final CellConstraints cc = new CellConstraints(); final JLabel label = new JLabel(mLocalizer.msg("daysToShow", "Days to show")); panelBuilder.addRow();//from w w w .ja va 2s . co m panelBuilder.add(label, cc.xy(2, panelBuilder.getRow())); final SpinnerNumberModel model = new SpinnerNumberModel(3, 1, 7, 1); mSpinner = new JSpinner(model); mSpinner.setValue(mSettings.getDays()); panelBuilder.add(mSpinner, cc.xy(4, panelBuilder.getRow())); panelBuilder.addParagraph(mLocalizer.msg("filters", "Filters to show")); mFilterList = new SelectableItemList(mSettings.getActiveFilterNames(), FilterViewSettings.getAvailableFilterNames()); mIcons.clear(); for (String filterName : FilterViewSettings.getAvailableFilterNames()) { mIcons.put(filterName, mSettings.getFilterIconName(mSettings.getFilter(filterName))); } mFilterList.addCenterRendererComponent(String.class, new SelectableItemRendererCenterComponentIf() { private DefaultListCellRenderer mRenderer = new DefaultListCellRenderer(); public void calculateSize(JList list, int index, JPanel contentPane) { } public JPanel createCenterPanel(JList list, Object value, int index, boolean isSelected, boolean isEnabled, JScrollPane parentScrollPane, int leftColumnWidth) { DefaultListCellRenderer label = (DefaultListCellRenderer) mRenderer .getListCellRendererComponent(list, value, index, isSelected, false); String filterName = value.toString(); String iconFileName = mIcons.get(filterName); Icon icon = null; if (!StringUtils.isEmpty(iconFileName)) { try { icon = FilterViewPlugin.getInstance().getIcon( FilterViewSettings.getIconDirectoryName() + File.separatorChar + iconFileName); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } label.setIcon(icon); } String text = filterName; if (icon == null) { text += " (" + mLocalizer.msg("noIcon", "no icon") + ')'; } label.setText(text); label.setHorizontalAlignment(SwingConstants.LEADING); label.setVerticalAlignment(SwingConstants.CENTER); label.setOpaque(false); JPanel panel = new JPanel(new BorderLayout()); if (isSelected && isEnabled) { panel.setOpaque(true); panel.setForeground(list.getSelectionForeground()); panel.setBackground(list.getSelectionBackground()); } else { panel.setOpaque(false); panel.setForeground(list.getForeground()); panel.setBackground(list.getBackground()); } panel.add(label, BorderLayout.WEST); return panel; } }); panelBuilder.addGrowingRow(); panelBuilder.add(mFilterList, cc.xyw(2, panelBuilder.getRow(), panelBuilder.getColumnCount() - 1)); panelBuilder.addRow(); mFilterButton = new JButton(mLocalizer.msg("changeIcon", "Change icon")); mFilterButton.setEnabled(false); panelBuilder.add(mFilterButton, cc.xyw(2, panelBuilder.getRow(), 1)); mRemoveButton = new JButton(mLocalizer.msg("deleteIcon", "Remove icon")); mRemoveButton.setEnabled(false); panelBuilder.add(mRemoveButton, cc.xyw(4, panelBuilder.getRow(), 1)); mFilterButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SelectableItem item = (SelectableItem) mFilterList.getSelectedValue(); String filterName = (String) item.getItem(); chooseIcon(filterName); } }); mFilterList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { mFilterButton.setEnabled(mFilterList.getSelectedValue() != null); mRemoveButton.setEnabled(mFilterButton.isEnabled()); } }); mRemoveButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SelectableItem item = (SelectableItem) mFilterList.getSelectedValue(); String filterName = (String) item.getItem(); mIcons.put(filterName, ""); mFilterList.updateUI(); } }); return panelBuilder.getPanel(); }
From source file:userinterface.graph.GraphOptionsPanel.java
/** Creates new form GraphOptionsPanel */ public GraphOptionsPanel(GUIPlugin plugin, JFrame parent, JPanel theModel) { this.plugin = plugin; this.parent = parent; this.theModel = theModel; /* TODO: Use generic container. */ ArrayList own = new ArrayList(); own.add(theModel);//from w w w. java 2 s . c om graphPropertiesTable = new SettingTable(parent); graphPropertiesTable.setOwners(own); if (theModel instanceof Graph) { ((Graph) theModel).setDisplay(graphPropertiesTable); xAxisSettings = ((Graph) theModel).getXAxisSettings(); yAxisSettings = ((Graph) theModel).getYAxisSettings(); zAxisSettings = null; displaySettings = ((Graph) theModel).getDisplaySettings(); } else if (theModel instanceof Histogram) { ((Histogram) theModel).setDisplay(graphPropertiesTable); xAxisSettings = ((Histogram) theModel).getXAxisSettings(); yAxisSettings = ((Histogram) theModel).getYAxisSettings(); zAxisSettings = null; displaySettings = ((Histogram) theModel).getDisplaySettings(); } else if (theModel instanceof Graph3D) { ((Graph3D) theModel).setDisplay(graphPropertiesTable); xAxisSettings = ((Graph3D) theModel).getxAxisSetting(); yAxisSettings = ((Graph3D) theModel).getyAxisSetting(); zAxisSettings = null; //zAxisSettings = ((Graph3D)theModel).getzAxisSetting(); displaySettings = ((Graph3D) theModel).getDisplaySettings(); } String[] axes = { "x-Axis", "y-Axis" }; axesList = new JList(axes); axesList.setSelectedIndex(0); axesList.addListSelectionListener(this); own = new ArrayList(); own.add(xAxisSettings); axisPropertiesTable = new SettingTable(parent); axisPropertiesTable.setOwners(own); if (theModel instanceof Graph) { ((AxisSettings) xAxisSettings).setDisplay(axisPropertiesTable); ((AxisSettings) yAxisSettings).setDisplay(axisPropertiesTable); } else if (theModel instanceof Histogram) { ((AxisSettingsHistogram) xAxisSettings).setDisplay(axisPropertiesTable); ((AxisSettingsHistogram) yAxisSettings).setDisplay(axisPropertiesTable); } else { ((AxisSettings3D) xAxisSettings).setDisplay(axisPropertiesTable); ((AxisSettings3D) yAxisSettings).setDisplay(axisPropertiesTable); } own = new ArrayList(); own.add(displaySettings); displayPropertiesTable = new SettingTable(parent); displayPropertiesTable.setOwners(own); if (theModel instanceof ChartPanel) ((DisplaySettings) displaySettings).setDisplay(displayPropertiesTable); else if (theModel instanceof Graph3D) ((DisplaySettings3D) displaySettings).setDisplay(displayPropertiesTable); if (theModel instanceof Graph) { seriesList = new JList(((Graph) theModel).getGraphSeriesList()); } else if (theModel instanceof Histogram) { seriesList = new JList(((Histogram) theModel).getGraphSeriesList()); } else if (theModel instanceof Graph3D) { seriesList = new JList(((Graph3D) theModel).getGraphSeriesList()); } seriesList.addListSelectionListener(this); seriesList.setCellRenderer(new ListCellRenderer() { public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { JLabel label = new JLabel((value == null) ? "undefined" : value.toString()); JPanel panel = new JPanel(); panel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0)); if (isSelected) { panel.setBackground(list.getSelectionBackground()); panel.setForeground(list.getSelectionForeground()); } else { panel.setBackground(list.getBackground()); panel.setForeground(list.getForeground()); } if (value instanceof SeriesSettings) { SeriesSettings graphSeries = (SeriesSettings) value; panel.add(graphSeries.getIcon()); } panel.add(label); return panel; } }); seriesPropertiesTable = new SettingTable(parent); /*seriesList = theModel.getSeriesList(); seriesList.addListSelectionListener(this); //seriesModel = new PropertyTableModel(); ArrayList ss = seriesList.getSelectedSeries(); //seriesModel.setOwners(ss); seriesProperties = new SettingTable(parent); seriesProperties.setOwners(ss);*/ initComponents(); //addSeries.setEnabled(ss.size() > 0); /*removeSeries.setEnabled(ss.size() > 0); moveUp.setEnabled(ss.size() > 0); moveDown.setEnabled(ss.size() > 0); viewData.setEnabled(ss.size() > 0);*/ }
From source file:net.technicpack.launcher.ui.LauncherFrame.java
private void initComponents() { BorderLayout layout = new BorderLayout(); setLayout(layout);// w w w.ja v a2 s. c o m ///////////////////////////////////////////////////////////// //HEADER ///////////////////////////////////////////////////////////// JPanel header = new JPanel(); header.setLayout(new BoxLayout(header, BoxLayout.LINE_AXIS)); header.setBackground(COLOR_BLUE); header.setForeground(COLOR_WHITE_TEXT); header.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 10)); this.add(header, BorderLayout.PAGE_START); ImageIcon headerIcon = resources.getIcon("platform_icon_title.png"); JButton headerLabel = new JButton(headerIcon); headerLabel.setBorder(BorderFactory.createEmptyBorder(5, 8, 5, 0)); headerLabel.setContentAreaFilled(false); headerLabel.setFocusPainted(false); headerLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); headerLabel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { DesktopUtils.browseUrl("http://beta.technicpack.net/"); } }); header.add(headerLabel); header.add(Box.createRigidArea(new Dimension(6, 0))); ActionListener tabListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { selectTab(e.getActionCommand()); } }; discoverTab = new HeaderTab(resources.getString("launcher.title.discover"), resources); header.add(discoverTab); discoverTab.setActionCommand(TAB_DISCOVER); discoverTab.addActionListener(tabListener); modpacksTab = new HeaderTab(resources.getString("launcher.title.modpacks"), resources); modpacksTab.setIsActive(true); modpacksTab.setHorizontalTextPosition(SwingConstants.LEADING); modpacksTab.addActionListener(tabListener); modpacksTab.setActionCommand(TAB_MODPACKS); header.add(modpacksTab); newsTab = new HeaderTab(resources.getString("launcher.title.news"), resources); newsTab.setLayout(null); newsTab.addActionListener(tabListener); newsTab.setActionCommand(TAB_NEWS); header.add(newsTab); CountCircle newsCircle = new CountCircle(); newsCircle.setBackground(COLOR_RED); newsCircle.setForeground(COLOR_WHITE_TEXT); newsCircle.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS_BOLD, 14)); newsTab.add(newsCircle); newsCircle.setBounds(10, 17, 25, 25); header.add(Box.createHorizontalGlue()); JPanel rightHeaderPanel = new JPanel(); rightHeaderPanel.setOpaque(false); rightHeaderPanel.setLayout(new BoxLayout(rightHeaderPanel, BoxLayout.PAGE_AXIS)); rightHeaderPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0)); JPanel windowGadgetPanel = new JPanel(); windowGadgetPanel.setOpaque(false); windowGadgetPanel.setLayout(new BoxLayout(windowGadgetPanel, BoxLayout.LINE_AXIS)); windowGadgetPanel.setAlignmentX(RIGHT_ALIGNMENT); ImageIcon minimizeIcon = resources.getIcon("minimize.png"); JButton minimizeButton = new JButton(minimizeIcon); minimizeButton.setBorder(BorderFactory.createEmptyBorder()); minimizeButton.setContentAreaFilled(false); minimizeButton.setCursor(new Cursor(Cursor.HAND_CURSOR)); minimizeButton.setFocusable(false); minimizeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { minimizeWindow(); } }); windowGadgetPanel.add(minimizeButton); ImageIcon closeIcon = resources.getIcon("close.png"); JButton closeButton = new JButton(closeIcon); closeButton.setBorder(BorderFactory.createEmptyBorder()); closeButton.setContentAreaFilled(false); closeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { closeWindow(); } }); closeButton.setCursor(new Cursor(Cursor.HAND_CURSOR)); closeButton.setFocusable(false); windowGadgetPanel.add(closeButton); rightHeaderPanel.add(windowGadgetPanel); rightHeaderPanel.add(Box.createVerticalGlue()); JButton launcherOptionsLabel = new JButton(resources.getString("launcher.title.options")); launcherOptionsLabel.setIcon(resources.getIcon("options_cog.png")); launcherOptionsLabel.setFont(resources.getFont(ResourceLoader.FONT_RALEWAY, 14)); launcherOptionsLabel.setForeground(COLOR_WHITE_TEXT); launcherOptionsLabel.setHorizontalAlignment(SwingConstants.RIGHT); launcherOptionsLabel.setHorizontalTextPosition(SwingConstants.LEADING); launcherOptionsLabel.setAlignmentX(RIGHT_ALIGNMENT); launcherOptionsLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); launcherOptionsLabel.setBorder(BorderFactory.createEmptyBorder()); launcherOptionsLabel.setContentAreaFilled(false); launcherOptionsLabel.setFocusPainted(false); launcherOptionsLabel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openLauncherOptions(); } }); rightHeaderPanel.add(launcherOptionsLabel); header.add(rightHeaderPanel); ///////////////////////////////////////////////////////////// // CENTRAL AREA ///////////////////////////////////////////////////////////// centralPanel = new TintablePanel(); centralPanel.setBackground(COLOR_CHARCOAL); centralPanel.setForeground(COLOR_WHITE_TEXT); centralPanel.setTintColor(COLOR_CENTRAL_BACK); this.add(centralPanel, BorderLayout.CENTER); centralPanel.setLayout(new BorderLayout()); modpackPanel = new ModpackInfoPanel(resources, iconRepo, logoRepo, backgroundRepo, avatarRepo, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openModpackOptions((ModpackModel) e.getSource()); } }, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { refreshModpackOptions((ModpackModel) e.getSource()); } }); modpackSelector.setInfoPanel(modpackPanel); playButton = modpackPanel.getPlayButton(); playButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (e.getSource() instanceof ModpackModel) { setupPlayButtonText((ModpackModel) e.getSource(), userModel.getCurrentUser()); } else if (installer.isCurrentlyRunning()) { installer.cancel(); setupPlayButtonText(modpackSelector.getSelectedPack(), userModel.getCurrentUser()); } else { launchModpack(); } } }); modpackPanel.getDeleteButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (JOptionPane.showConfirmDialog(LauncherFrame.this, resources.getString("modpackoptions.delete.confirmtext"), resources.getString("modpackoptions.delete.confirmtitle"), JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { modpackSelector.getSelectedPack().delete(); modpackSelector.forceRefresh(); } } }); infoSwap = new JPanel(); infoLayout = new CardLayout(); infoSwap.setLayout(infoLayout); infoSwap.setOpaque(false); newsInfoPanel = new NewsInfoPanel(resources, avatarRepo); infoSwap.add(discoverInfoPanel, "discover"); JPanel newsHost = new JPanel(); infoSwap.add(newsHost, "news"); JPanel modpackHost = new JPanel(); infoSwap.add(modpackHost, "modpacks"); centralPanel.add(infoSwap, BorderLayout.CENTER); newsSelector = new NewsSelector(resources, newsInfoPanel, platformApi, avatarRepo, newsCircle, settings); newsHost.setLayout(new BorderLayout()); newsHost.add(newsInfoPanel, BorderLayout.CENTER); newsHost.add(newsSelector, BorderLayout.WEST); modpackHost.setLayout(new BorderLayout()); modpackHost.add(modpackPanel, BorderLayout.CENTER); modpackHost.add(modpackSelector, BorderLayout.WEST); footer = new TintablePanel(); footer.setTintColor(COLOR_CENTRAL_BACK); footer.setBackground(COLOR_FOOTER); footer.setLayout(new BoxLayout(footer, BoxLayout.LINE_AXIS)); footer.setForeground(COLOR_WHITE_TEXT); footer.setBorder(BorderFactory.createEmptyBorder(3, 6, 3, 12)); userWidget = new UserWidget(resources, skinRepository); userWidget.setMaximumSize(userWidget.getPreferredSize()); footer.add(userWidget); JLabel dashText = new JLabel("| "); dashText.setForeground(LauncherFrame.COLOR_WHITE_TEXT); dashText.setFont(resources.getFont(ResourceLoader.FONT_RALEWAY, 15)); footer.add(dashText); JButton logout = new JButton(resources.getString("launcher.user.logout")); logout.setBorder(BorderFactory.createEmptyBorder()); logout.setContentAreaFilled(false); logout.setFocusable(false); logout.setForeground(LauncherFrame.COLOR_WHITE_TEXT); logout.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); logout.setFont(resources.getFont(ResourceLoader.FONT_RALEWAY, 15)); logout.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { logout(); } }); footer.add(logout); installProgress = new ProgressBar(); installProgress.setForeground(Color.white); installProgress.setBackground(LauncherFrame.COLOR_GREEN); installProgress.setBorder(BorderFactory.createEmptyBorder(5, 45, 4, 45)); installProgress.setIcon(resources.getIcon("download_icon.png")); installProgress.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 12)); installProgress.setVisible(false); footer.add(installProgress); installProgressPlaceholder = Box.createHorizontalGlue(); footer.add(installProgressPlaceholder); JLabel buildCtrl = new JLabel(resources.getString("launcher.build.text", resources.getLauncherBuild(), resources.getString("launcher.build." + settings.getBuildStream()))); buildCtrl.setForeground(COLOR_WHITE_TEXT); buildCtrl.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 14)); buildCtrl.setHorizontalTextPosition(SwingConstants.RIGHT); buildCtrl.setHorizontalAlignment(SwingConstants.RIGHT); footer.add(buildCtrl); this.add(footer, BorderLayout.PAGE_END); }
From source file:org.nuxeo.launcher.gui.NuxeoFrame.java
protected Component buildSummaryPanel() { JPanel summaryPanel = new JPanel(); summaryPanel.setLayout(new BoxLayout(summaryPanel, BoxLayout.PAGE_AXIS)); summaryPanel.setBackground(new Color(35, 37, 59)); summaryPanel.setForeground(Color.WHITE); summaryPanel.add(// www .j a va 2 s .c o m new JLabel("<html><font color=#ffffdd>" + NuxeoLauncherGUI.getMessage("summary.status.label"))); summaryStatus = new JLabel(controller.launcher.status()); summaryStatus.setForeground(Color.WHITE); summaryPanel.add(summaryStatus); summaryPanel .add(new JLabel("<html><font color=#ffffdd>" + NuxeoLauncherGUI.getMessage("summary.url.label"))); summaryURL = new JLabel(controller.launcher.getURL()); summaryURL.setForeground(Color.WHITE); summaryPanel.add(summaryURL); errorMessageLabel = new JLabel(); errorMessageLabel.setForeground(Color.RED); summaryPanel.add(errorMessageLabel); summaryPanel.add(new JSeparator()); ConfigurationGenerator config = controller.launcher.getConfigurationGenerator(); summaryPanel.add( new JLabel("<html><font color=#ffffdd>" + NuxeoLauncherGUI.getMessage("summary.homedir.label"))); summaryPanel.add(new JLabel("<html><font color=white>" + config.getNuxeoHome().getPath())); summaryPanel.add( new JLabel("<html><font color=#ffffdd>" + NuxeoLauncherGUI.getMessage("summary.nuxeoconf.label"))); summaryPanel.add(new JLabel("<html><font color=white>" + config.getNuxeoConf().getPath())); summaryPanel.add( new JLabel("<html><font color=#ffffdd>" + NuxeoLauncherGUI.getMessage("summary.datadir.label"))); summaryPanel.add(new JLabel("<html><font color=white>" + config.getDataDir().getPath())); return summaryPanel; }
From source file:org.openstatic.irc.client.O5Client.java
public void addPanel(String panel_caption, Component panel) { final JPanel plugin_pane = new JPanel(new BorderLayout()); plugin_pane.add(panel, BorderLayout.CENTER); plugin_pane.setForeground(Color.WHITE); plugin_pane.setBackground(Color.GRAY); JButton close_button = new JButton("Close Tab"); close_button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { tabbed.remove(plugin_pane);//from ww w .ja v a 2 s . c om } }); /* JPanel sub_layout = new JPanel(new BorderLayout()) { public void paintComponent(Graphics g) { g.drawImage(placebo_icon, 2, 2, 24, 24, null); } }; sub_layout.add(close_button, BorderLayout.EAST); plugin_pane.add(sub_layout, BorderLayout.PAGE_END); */ tabbed.addTab(panel_caption, null, plugin_pane, ""); }