List of usage examples for javax.swing JPanel getBackground
@Transient
public Color getBackground()
From source file:ComplexExample.java
public void dragGestureRecognized(DragGestureEvent event) { Cursor cursor = null;// ww w . ja va 2s.co m JPanel panel = (JPanel) event.getComponent(); Color color = panel.getBackground(); if (event.getDragAction() == DnDConstants.ACTION_COPY) { cursor = DragSource.DefaultCopyDrop; } event.startDrag(cursor, new TransferableColor(color)); }
From source file:dk.dma.epd.common.prototype.notification.StrategicRouteNotificationDetailPanelCommon.java
/** * Create the panel.//w w w . ja va 2s .co m * * @param title the title of the message panel * @param routeMessage the request message * @param routeChanges the route changes * @param the index of the message with 0 being the latest */ public StrategicNotificationMessageView(String title, StrategicRouteMessage routeMessage, String routeChanges, int index) { super(new GridBagLayout()); boolean isLatest = index == 0; if (!isLatest) { setBackground(Color.darkGray); } Insets insets0 = new Insets(0, 0, 0, 0); Insets insets1 = new Insets(5, 5, 5, 5); // ************************* // Create the title panel // ************************* JPanel titlePanel = new JPanel(new GridBagLayout()); add(titlePanel, new GridBagConstraints(0, 0, 2, 1, 1.0, 0.0, WEST, HORIZONTAL, insets0, 0, 0)); // Title if (isLatest) { titlePanel.setBackground(titlePanel.getBackground().darker()); } titlePanel.add(bold(new JLabel(title)), new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, WEST, HORIZONTAL, insets1, 0, 0)); titlePanel.add(new JLabel(Formatter.formatLongDateTime(routeMessage.getSentDate())), new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, EAST, NONE, insets1, 0, 0)); // Type CloudMessageStatus cloudStatus = isLatest ? routeMessage.getCloudMessageStatus() : null; add(new JLabel("Status:"), new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, WEST, NONE, insets1, 0, 0)); add(new JLabel(StrategicRouteNotificationDetailPanelCommon.getStatusType(routeMessage.getStatus(), cloudStatus, false)), new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, WEST, NONE, insets1, 0, 0)); // Message label if (!StringUtils.isBlank(routeMessage.getMessage())) { JLabel msgLabel = new JLabel("<html>" + Formatter.formatHtml(routeMessage.getMessage()) + "</html>"); msgLabel.setBorder(new TitledBorder("Message")); add(msgLabel, new GridBagConstraints(0, 2, 2, 1, 1.0, 0.0, WEST, HORIZONTAL, insets1, 0, 0)); } // Route changes if (!StringUtils.isBlank(routeChanges)) { JLabel routeLabel = new JLabel("<html>" + Formatter.formatHtml(routeChanges) + "</html>"); routeLabel.setBorder(new TitledBorder("Route changes")); add(routeLabel, new GridBagConstraints(0, 3, 2, 1, 1.0, 0.0, WEST, HORIZONTAL, insets1, 0, 0)); } }
From source file:SysConfig.java
public SysConfig() { super("JTabbedPane & BoxLayout Demonstration"); setSize(500, 300);/* w w w.j av a 2 s.c o m*/ setDefaultCloseOperation(EXIT_ON_CLOSE); JPanel configPane = new JPanel(); configPane.setLayout(new BoxLayout(configPane, BoxLayout.Y_AXIS)); JTextArea question = new JTextArea("Which of the following options\n" + "do you have installed?"); // Ok, now configure the textarea to show up properly inside the box. // This is part of the "high art" of Swing... question.setEditable(false); question.setMaximumSize(new Dimension(300, 50)); question.setAlignmentX(0.0f); question.setBackground(configPane.getBackground()); JCheckBox audioCB = new JCheckBox("Sound Card", true); JCheckBox nicCB = new JCheckBox("Ethernet Card", true); JCheckBox tvCB = new JCheckBox("Video Out", false); configPane.add(Box.createVerticalGlue()); configPane.add(question); configPane.add(audioCB); configPane.add(nicCB); configPane.add(tvCB); configPane.add(Box.createVerticalGlue()); JLabel audioPane = new JLabel("Audio stuff"); JLabel nicPane = new JLabel("Networking stuff"); JLabel tvPane = new JLabel("Video stuff"); JLabel helpPane = new JLabel("Help information"); audioCB.addItemListener(new TabManager(audioPane)); nicCB.addItemListener(new TabManager(nicPane)); tvCB.addItemListener(new TabManager(tvPane)); config.addTab("System", null, configPane, "Choose Installed Options"); config.addTab("Audio", null, audioPane, "Audio system configuration"); config.addTab("Networking", null, nicPane, "Networking configuration"); config.addTab("Video", null, tvPane, "Video system configuration"); config.addTab("Help", null, helpPane, "How Do I..."); getContentPane().add(config, BorderLayout.CENTER); }
From source file:com.att.aro.ui.view.menu.file.BPVideoWarnFailPanel.java
public BPVideoWarnFailPanel() { JPanel mainPanel = new JPanel(); this.add(mainPanel); mainPanel.setLayout(new GridBagLayout()); GridBagConstraints constraint = new GridBagConstraints(); mainPanel.add(getGridPanel(), constraint); mainPanel.add(getDefaultButton("Default", (ActionEvent arg) -> setDefault()), constraint); compileResultsField.setEditable(false); if (sError.isEmpty()) { compileResultsField.setBackground(mainPanel.getBackground()); compileResultsField.setForeground(Color.red); compileResultsField.setFont(compileResultsField.getFont().deriveFont(Font.BOLD)); compileResultsField.setText(""); compileResultsField.setVisible(false); } else {//from w w w .j ava 2 s . co m compileResultsField.setVisible(true); compileResultsField.setForeground(Color.red); compileResultsField.setText(String.format("ERRORS: %s", sError)); } constraint.anchor = GridBagConstraints.FIRST_LINE_START; constraint.gridy = 300; constraint.gridwidth = 2; mainPanel.add(compileResultsField, constraint); }
From source file:com.isencia.passerelle.hmi.generic.GenericHMI.java
private JPanel createCompositePanel(final JPanel b, final JComponent c, final String name) { final JPanel compositeBox = new JPanel(new VerticalLayout(5)); int r = b.getBackground().getRed() - 20; if (r < 1) { r = 0;//from www .j a v a 2 s . c o m } if (r > 254) { r = 255; } int g = b.getBackground().getGreen() - 20; if (g < 1) { g = 0; } if (g > 254) { g = 255; } int bl = b.getBackground().getBlue() - 20; if (bl < 1) { bl = 0; } if (bl > 254) { bl = 255; } compositeBox.setBackground(new Color(r, g, bl)); final JPanel title = new JPanel(new BorderLayout()); title.setBackground(new Color(r, g, bl)); /* * ImageIcon icon = new ImageIcon( Toolkit .getDefaultToolkit() * .getImage( (getClass() * .getResource("/com/isencia/passerelle/hmi/resources/composite.gif" * )))); JLabel lab = new JLabel(icon); * * title.add(lab, BorderLayout.LINE_START); */ final JLabel lab2 = new JLabel(name); final Font f = lab2.getFont(); lab2.setFont(new Font(f.getName(), f.getStyle(), f.getSize() + 6)); lab2.setForeground(new Color(49, 106, 196)); title.add(lab2); compositeBox.add(title); final Border loweredbevel = BorderFactory.createLoweredBevelBorder(); final TitledBorder border = BorderFactory.createTitledBorder(loweredbevel); compositeBox.setBorder(border); compositeBox.setName(name); c.setBackground(new Color(r, g, bl)); compositeBox.add(c); return compositeBox; }
From source file:net.aepik.alasca.gui.util.LoadFileFrame.java
/** * Initialize frame content.//from ww w . ja va 2 s . co m */ private void initFrame() { // - Panel bouton du bas - JPanel boutonsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); boutonsPanel.add(boutonOk); boutonsPanel.add(boutonAnnuler); // - Panel nom du fichier - JTextArea textAreaFilename = new JTextArea( "Indiquez le nom du fichier contenant les dfinitions du schma LDAP que vous souhaitez charger."); textAreaFilename.setEditable(false); textAreaFilename.setLineWrap(true); textAreaFilename.setWrapStyleWord(true); textAreaFilename.setFont((new JLabel()).getFont()); textAreaFilename.setBorder(BorderFactory.createEmptyBorder(7, 6, 12, 6)); textAreaFilename.setBackground(new Color(240, 235, 226)); boutonOpenFile.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createMatteBorder(0, 5, 0, 0, boutonsPanel.getBackground()), boutonOpenFile.getBorder())); JPanel filenamePanel = new JPanel(new BorderLayout()); filenamePanel.add(textAreaFilename, BorderLayout.NORTH); filenamePanel.add(filename, BorderLayout.CENTER); filenamePanel.add(boutonOpenFile, BorderLayout.EAST); filenamePanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(5, 4, 1, 4), BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(" Schma LDAP "), BorderFactory.createEmptyBorder(0, 5, 5, 5)))); // - Panel du selecteur de syntaxes - JTextArea textAreaSyntaxes = new JTextArea( "Il vous faut appliquer un filtre sur le schma que vous voulez charger. Voici la liste des filtres disponibles :"); textAreaSyntaxes.setEditable(false); textAreaSyntaxes.setLineWrap(true); textAreaSyntaxes.setWrapStyleWord(true); textAreaSyntaxes.setFont((new JLabel()).getFont()); textAreaSyntaxes.setBorder(BorderFactory.createEmptyBorder(7, 6, 12, 6)); textAreaSyntaxes.setBackground(new Color(240, 235, 226)); JPanel syntaxesPanel = new JPanel(new BorderLayout()); syntaxesPanel.add(textAreaSyntaxes, BorderLayout.NORTH); syntaxesPanel.add(syntaxes); syntaxesPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(5, 4, 1, 4), BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(" Syntaxe LDAP "), BorderFactory.createEmptyBorder(0, 5, 5, 5)))); // On injecte le nom des classes de syntaxes possibles // dynamiquement. String[] syntaxesName = Schema.getSyntaxeNames(); for (int i = 0; syntaxesName != null && i < syntaxesName.length; i++) { syntaxes.addItem(syntaxesName[i]); } // - Organisation gnrale - JPanel mainPanel = new JPanel(new BorderLayout()); mainPanel.add(filenamePanel, BorderLayout.NORTH); mainPanel.add(syntaxesPanel, BorderLayout.CENTER); JPanel mainPanelContainer = new JPanel(new BorderLayout()); mainPanelContainer.add(mainPanel, BorderLayout.NORTH); mainPanelContainer.add(boutonsPanel, BorderLayout.SOUTH); mainPanelContainer.setBorder(BorderFactory.createEmptyBorder(2, 1, 1, 1)); getContentPane().add(new DescriptiveInternalFrame(mainFrame.getIconImage(), "Slectionner un fichier et sa syntaxe.", mainPanelContainer)); // - Listeners - addWindowListener(this); boutonOpenFile.addActionListener(this); boutonOk.addActionListener(this); boutonAnnuler.addActionListener(this); }
From source file:lcmc.common.ui.EditableInfo.java
/** * Adds field with left and right component to the panel. Use panel * with spring layout for this.// w w w .j a va 2 s .c om */ public final void addField(final JPanel panel, final java.awt.Component left, final java.awt.Component right, final int leftWidth, final int rightWidth, int height) { /* right component with fixed width. */ if (height == 0) { height = application.getDefaultSize("Browser.FieldHeight"); } Tools.setSize(left, leftWidth, height); panel.add(left); Tools.setSize(right, rightWidth, height); panel.add(right); right.setBackground(panel.getBackground()); }
From source file:lcmc.gui.resources.EditableInfo.java
/** * Adds field with left and right component to the panel. Use panel * with spring layout for this.//from w w w . ja va2 s .c om */ public final void addField(final JPanel panel, final JComponent left, final JComponent right, final int leftWidth, final int rightWidth, int height) { /* right component with fixed width. */ if (height == 0) { height = Tools.getDefaultSize("Browser.FieldHeight"); } Tools.setSize(left, leftWidth, height); panel.add(left); Tools.setSize(right, rightWidth, height); panel.add(right); right.setBackground(panel.getBackground()); }
From source file:com.xilinx.kintex7.MainScreen.java
private JPanel dialChart(int w) { JPanel panel = new JPanel(); JPanel panel1 = new JPanel(new BorderLayout()); panel.setLayout(new BorderLayout()); pchart = new PowerChart("Power (in Watt)", panel.getBackground()); dialPanel = pchart.getChart(""); dialPanel.setPreferredSize(new Dimension(300, 100)); tplot = new ThermoPlot(); tplotPanel = tplot.getChart();//w w w . j av a 2s . c o m tplotPanel.setPreferredSize(new Dimension(200, 100)); panel1.add(dialPanel, BorderLayout.CENTER); panel1.add(tplotPanel, BorderLayout.LINE_END); panel.add(panel1, BorderLayout.CENTER); return panel; }
From source file:com.xilinx.kintex7.MainScreen.java
private JPanel plotPanel() { JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); JPanel panel1 = new JPanel(); JPanel panel2 = new JPanel(); String[] labels0 = { "S2C0 ", "S2C1 ", "PCIe Reads " }; String[] labels1 = { "C2S0 ", "C2S1 ", "PCIe Writes " }; dma0chart = new DMABarChart("Transmit (S2C) Performance", panel1.getBackground(), labels0); dma1chart = new DMABarChart("Receive (C2S) Performance", panel1.getBackground(), labels1); panel1.setLayout(new BoxLayout(panel1, BoxLayout.Y_AXIS)); panel1.setSize(new Dimension(panel1.getWidth() - 100, panel1.getHeight() - 100)); panel1.add(dma0chart.getChart("")); panel2.setLayout(new BoxLayout(panel2, BoxLayout.Y_AXIS)); panel2.setSize(new Dimension(panel2.getWidth() - 100, panel2.getHeight() - 100)); panel2.add(dma1chart.getChart("")); panel.add(panel1);// w ww . j a v a 2 s . co m panel.add(panel2); return panel; }