List of usage examples for javax.swing JPanel setBackground
@BeanProperty(preferred = true, visualUpdate = true, description = "The background color of the component.") public void setBackground(Color bg)
From source file:utybo.branchingstorytree.swing.visuals.AboutDialog.java
@SuppressWarnings("unchecked") public AboutDialog(OpenBSTGUI parent) { super(parent); setTitle(Lang.get("about.title")); setModalityType(ModalityType.APPLICATION_MODAL); JPanel banner = new JPanel(new FlowLayout(FlowLayout.CENTER)); banner.setBackground(OpenBSTGUI.OPENBST_BLUE); JLabel lblOpenbst = new JLabel(new ImageIcon(Icons.getImage("FullLogoWhite", 48))); lblOpenbst.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); banner.add(lblOpenbst, "flowx,cell 0 0,alignx center"); getContentPane().add(banner, BorderLayout.NORTH); JPanel pan = new JPanel(); pan.setLayout(new MigLayout("insets 10, gap 10px", "[grow]", "[][][grow]")); getContentPane().add(pan, BorderLayout.CENTER); JLabel lblWebsite = new JLabel("https://utybo.github.io/BST/"); Font f = lblWebsite.getFont(); @SuppressWarnings("rawtypes") Map attrs = f.getAttributes(); attrs.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON); lblWebsite.setFont(f.deriveFont(attrs)); lblWebsite.setForeground(OpenBSTGUI.OPENBST_BLUE); lblWebsite.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); lblWebsite.addMouseListener(new MouseAdapter() { @Override/*from www . j av a2 s .c o m*/ public void mouseClicked(MouseEvent e) { if (Desktop.isDesktopSupported()) { try { Desktop.getDesktop().browse(new URL("https://utybo.github.io/BST/").toURI()); } catch (IOException | URISyntaxException e1) { OpenBST.LOG.warn("Exception when trying to open website", e1); } } } }); pan.add(lblWebsite, "cell 0 0,alignx center"); JLabel lblVersion = new JLabel(Lang.get("about.version").replace("$v", OpenBST.VERSION)); pan.add(lblVersion, "flowy,cell 0 1"); JScrollPane scrollPane = new JScrollPane(); scrollPane.setBorder(new LineBorder(pan.getBackground().darker(), 1, false)); pan.add(scrollPane, "cell 0 2,grow"); JTextArea textArea = new JTextArea(); textArea.setMargin(new Insets(5, 5, 5, 5)); textArea.setLineWrap(true); textArea.setWrapStyleWord(true); textArea.setFont(new Font(textArea.getFont().getFontName(), Font.PLAIN, (int) (Icons.getScale() * 11))); try (InputStream in = getClass().getResourceAsStream("/utybo/branchingstorytree/swing/about.txt");) { textArea.setText(IOUtils.toString(in, StandardCharsets.UTF_8)); } catch (IOException ex) { OpenBST.LOG.warn("Loading about information failed", ex); } textArea.setEditable(false); textArea.setCaretPosition(0); scrollPane.setViewportView(textArea); JLabel lblTranslatedBy = new JLabel(Lang.get("author")); pan.add(lblTranslatedBy, "cell 0 1"); setSize((int) (Icons.getScale() * 450), (int) (Icons.getScale() * 400)); setLocationRelativeTo(parent); }
From source file:view.ImagePanel.java
public void refreshSignatureValidationListPanels() { for (JPanel jp : panelList) { remove(jp);//from www . j ava 2 s .c o m } if (buf == null) { return; } if (pdfDocument != null) { if (svList != null) { Point p = getImageLocation(); for (final SignatureValidation sv : svList) { try { int pgNumber = sv.getPosList().get(0).page - 1; if (this.pageNumber == pgNumber) { for (AcroFields.FieldPosition pos : sv.getPosList()) { int p1 = (int) (p.x + (pos.position.getLeft() * scale)); int p2 = (int) (p.y + Math.floor((pdfDocument.getPage(pageNumber).getCropBox().getHeight() - pos.position.getTop()) * scale)); int p3 = (int) (pos.position.getWidth() * scale); int p4 = (int) (pos.position.getHeight() * scale); final JPanel jp1 = sv.getPanel(); jp1.setLocation(p1, p2); jp1.setSize(p3, p4); if (sv.equals(selectedSignature)) { jp1.setBackground(new Color(0, 0, 0, 45)); jp1.setBorder(new LineBorder(Color.BLACK, 1)); } else { jp1.setBackground(new Color(0, 0, 0, 0)); jp1.setBorder(null); } jp1.setVisible(true); jp1.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(java.awt.event.MouseEvent evt) { if (mainWindow.getWorkspacePanel() .getStatus() != WorkspacePanel.Status.SIGNING) { jp1.setCursor(new Cursor(Cursor.HAND_CURSOR)); jp1.setBackground(new Color(0, 0, 0, 45)); jp1.setBorder(new LineBorder(Color.BLACK, 1)); repaint(); } else { jp1.setCursor(null); } } @Override public void mouseExited(java.awt.event.MouseEvent evt) { if (mainWindow.getWorkspacePanel() .getStatus() != WorkspacePanel.Status.SIGNING) { if (selectedSignature == null) { jp1.setBackground(new Color(0, 0, 0, 0)); jp1.setBorder(null); repaint(); } else if (!selectedSignature.equals(sv)) { jp1.setBackground(new Color(0, 0, 0, 0)); jp1.setBorder(null); repaint(); } } } }); panelList.add(jp1); add(jp1); repaint(); } } } catch (Exception e) { } } } } }
From source file:views.online.Panel_RejoindrePartieMulti.java
/** * Constructeur/*w ww . jav a 2 s . c o m*/ * * @param parent le fenetre parent */ public Panel_RejoindrePartieMulti(JFrame parent) { // initialisation super(new BorderLayout()); this.parent = parent; parent.setTitle(Language.getTexte(Language.ID_TITRE_REJOINDRE_UNE_PARTIE_MULTI)); setBorder(new EmptyBorder(new Insets(MARGES_PANEL, MARGES_PANEL, MARGES_PANEL, MARGES_PANEL))); setBackground(LookInterface.COULEUR_DE_FOND_PRI); // --------- // -- TOP -- // --------- JPanel pTop = new JPanel(new BorderLayout()); pTop.setBackground(LookInterface.COULEUR_DE_FOND_PRI); JLabel titre = new JLabel(Language.getTexte(Language.ID_TITRE_REJOINDRE_UNE_PARTIE_MULTI)); titre.setFont(ManageFonts.POLICE_TITRE); titre.setForeground(LookInterface.COULEUR_TEXTE_PRI); pTop.add(titre, BorderLayout.NORTH); // filtre JPanel pADroite = new JPanel(new BorderLayout()); pADroite.setBackground(LookInterface.COULEUR_DE_FOND_PRI); tfFiltre.setPreferredSize(new Dimension(100, 25)); tfFiltre.addKeyListener(this); tfFiltre.addMouseListener(this); pADroite.add(tfFiltre, BorderLayout.WEST); pTop.add(pADroite, BorderLayout.CENTER); ManageFonts.setStyle(bRafraichir); pTop.add(bRafraichir, BorderLayout.EAST); bRafraichir.addActionListener(this); add(pTop, BorderLayout.NORTH); // ------------ // -- CENTER -- // ------------ // cration de la table avec boquage des editions tbServeurs = new JTable(model) { public boolean isCellEditable(int rowIndex, int colIndex) { return false; // toujours dsactiv } }; // Simple selection tbServeurs.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // nom de colonnes model.addColumn(Language.getTexte(Language.ID_TXT_NOM)); model.addColumn(Language.getTexte(Language.ID_TXT_IP)); model.addColumn(Language.getTexte(Language.ID_TXT_PORT)); model.addColumn(Language.getTexte(Language.ID_TXT_MODE)); model.addColumn(Language.getTexte(Language.ID_TXT_TERRAIN)); model.addColumn(Language.getTexte(Language.ID_TXT_PLACES_DISPO)); // Cration du canal avec le serveur d'enregistrement try { canalServeurEnregistrement = new ChannelTCP(Configuration.getIpSE(), Configuration.getPortSE()); mettreAJourListeDesServeurs(); } catch (ConnectException e) { connexionSEImpossible(); } catch (ChannelException e) { connexionSEImpossible(); } // ajout dans le panel add(new JScrollPane(tbServeurs), BorderLayout.CENTER); // ------------ // -- BOTTOM -- // ------------ JPanel pBottom = new JPanel(new BorderLayout()); pBottom.setBackground(LookInterface.COULEUR_DE_FOND_PRI); bRetour.addActionListener(this); ManageFonts.setStyle(bRetour); bRetour.setPreferredSize(new Dimension(80, 50)); pBottom.add(bRetour, BorderLayout.WEST); JPanel bottomCenter = new JPanel(); bottomCenter.setBackground(LookInterface.COULEUR_DE_FOND_PRI); // connexion par IP lblConnexionParIP.setFont(ManageFonts.POLICE_SOUS_TITRE); lblConnexionParIP.setForeground(LookInterface.COULEUR_TEXTE_PRI); bottomCenter.add(lblConnexionParIP); tfConnexionParIP.setPreferredSize(new Dimension(100, 25)); bottomCenter.add(tfConnexionParIP); tfConnexionParIP.addMouseListener(this); // pseudo JPanel pPseudo = new JPanel(); JPanel pTmp = new JPanel(); lblPseudo.setFont(ManageFonts.POLICE_SOUS_TITRE); lblPseudo.setForeground(LookInterface.COULEUR_TEXTE_PRI); bottomCenter.add(lblPseudo); tfPseudo.setText(Configuration.getPseudoJoueur()); bottomCenter.add(tfPseudo); pPseudo.add(pTmp, BorderLayout.EAST); pBottom.add(bottomCenter, BorderLayout.CENTER); // bouton rejoindre bRejoindre.setPreferredSize(new Dimension(100, 50)); ManageFonts.setStyle(bRejoindre); pBottom.add(bRejoindre, BorderLayout.EAST); bRejoindre.addActionListener(this); pBottom.add(lblEtat, BorderLayout.SOUTH); add(pBottom, BorderLayout.SOUTH); }
From source file:vues.reseau.Panel_RejoindrePartieMulti.java
/** * Constructeur/*from www. j a v a 2 s .c o m*/ * * @param parent le fenetre parent */ public Panel_RejoindrePartieMulti(JFrame parent) { // initialisation super(new BorderLayout()); this.parent = parent; parent.setTitle(Langue.getTexte(Langue.ID_TITRE_REJOINDRE_UNE_PARTIE_MULTI)); setBorder(new EmptyBorder(new Insets(MARGES_PANEL, MARGES_PANEL, MARGES_PANEL, MARGES_PANEL))); setBackground(LookInterface.COULEUR_DE_FOND_PRI); // --------- // -- TOP -- // --------- JPanel pTop = new JPanel(new BorderLayout()); pTop.setBackground(LookInterface.COULEUR_DE_FOND_PRI); JLabel titre = new JLabel(Langue.getTexte(Langue.ID_TITRE_REJOINDRE_UNE_PARTIE_MULTI)); titre.setFont(GestionnaireDesPolices.POLICE_TITRE); titre.setForeground(LookInterface.COULEUR_TEXTE_PRI); pTop.add(titre, BorderLayout.NORTH); // filtre JPanel pADroite = new JPanel(new BorderLayout()); pADroite.setBackground(LookInterface.COULEUR_DE_FOND_PRI); tfFiltre.setPreferredSize(new Dimension(100, 25)); tfFiltre.addKeyListener(this); tfFiltre.addMouseListener(this); pADroite.add(tfFiltre, BorderLayout.WEST); pTop.add(pADroite, BorderLayout.CENTER); GestionnaireDesPolices.setStyle(bRafraichir); pTop.add(bRafraichir, BorderLayout.EAST); bRafraichir.addActionListener(this); add(pTop, BorderLayout.NORTH); // ------------ // -- CENTER -- // ------------ // cration de la table avec boquage des editions tbServeurs = new JTable(model) { public boolean isCellEditable(int rowIndex, int colIndex) { return false; // toujours dsactiv } }; // Simple selection tbServeurs.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // nom de colonnes model.addColumn(Langue.getTexte(Langue.ID_TXT_NOM)); model.addColumn(Langue.getTexte(Langue.ID_TXT_IP)); model.addColumn(Langue.getTexte(Langue.ID_TXT_PORT)); model.addColumn(Langue.getTexte(Langue.ID_TXT_MODE)); model.addColumn(Langue.getTexte(Langue.ID_TXT_TERRAIN)); model.addColumn(Langue.getTexte(Langue.ID_TXT_PLACES_DISPO)); // Cration du canal avec le serveur d'enregistrement try { canalServeurEnregistrement = new CanalTCP(Configuration.getIpSE(), Configuration.getPortSE()); mettreAJourListeDesServeurs(); } catch (ConnectException e) { connexionSEImpossible(); } catch (CanalException e) { connexionSEImpossible(); } // ajout dans le panel add(new JScrollPane(tbServeurs), BorderLayout.CENTER); // ------------ // -- BOTTOM -- // ------------ JPanel pBottom = new JPanel(new BorderLayout()); pBottom.setBackground(LookInterface.COULEUR_DE_FOND_PRI); bRetour.addActionListener(this); GestionnaireDesPolices.setStyle(bRetour); bRetour.setPreferredSize(new Dimension(80, 50)); pBottom.add(bRetour, BorderLayout.WEST); JPanel bottomCenter = new JPanel(); bottomCenter.setBackground(LookInterface.COULEUR_DE_FOND_PRI); // connexion par IP lblConnexionParIP.setFont(GestionnaireDesPolices.POLICE_SOUS_TITRE); lblConnexionParIP.setForeground(LookInterface.COULEUR_TEXTE_PRI); bottomCenter.add(lblConnexionParIP); tfConnexionParIP.setPreferredSize(new Dimension(100, 25)); bottomCenter.add(tfConnexionParIP); tfConnexionParIP.addMouseListener(this); // pseudo JPanel pPseudo = new JPanel(); JPanel pTmp = new JPanel(); lblPseudo.setFont(GestionnaireDesPolices.POLICE_SOUS_TITRE); lblPseudo.setForeground(LookInterface.COULEUR_TEXTE_PRI); bottomCenter.add(lblPseudo); tfPseudo.setText(Configuration.getPseudoJoueur()); bottomCenter.add(tfPseudo); pPseudo.add(pTmp, BorderLayout.EAST); pBottom.add(bottomCenter, BorderLayout.CENTER); // bouton rejoindre bRejoindre.setPreferredSize(new Dimension(100, 50)); GestionnaireDesPolices.setStyle(bRejoindre); pBottom.add(bRejoindre, BorderLayout.EAST); bRejoindre.addActionListener(this); pBottom.add(lblEtat, BorderLayout.SOUTH); add(pBottom, BorderLayout.SOUTH); }
From source file:wigraph.ShortestPathRelation.java
/** * */// www . j a v a 2s. c o m private JPanel setUpControls() { JPanel jp = new JPanel(); jp.setBackground(Color.WHITE); jp.setLayout(new BoxLayout(jp, BoxLayout.PAGE_AXIS)); jp.setBorder(BorderFactory.createLineBorder(Color.black, 3)); // jp_ss - word wist 1 (ss) horizontal panel JPanel jp_wl1 = new JPanel(); jp_wl1.setLayout(new BoxLayout(jp_wl1, BoxLayout.X_AXIS)); JLabel word1_label = new JLabel("List of words 1 separated by comma");//, Label.RIGHT) word_set1 = new JTextField(20); word1_label.setDisplayedMnemonic('W'); word_set1.setFocusAccelerator('W'); word_set1.setText(INITIAL_WORD_SET1); jp_wl1.add(word1_label); jp_wl1.add(word_set1); // jp_ss - word wist 1 (ss) horizontal panel JPanel jp_wl2 = new JPanel(); jp_wl2.setLayout(new BoxLayout(jp_wl2, BoxLayout.X_AXIS)); JLabel word2_label = new JLabel("List of words 2");//, Label.RIGHT) word_set2 = new JTextField(20); word2_label.setDisplayedMnemonic('o'); word_set2.setFocusAccelerator('o'); word_set2.setText(INITIAL_WORD_SET2); jp_wl2.add(word2_label); jp_wl2.add(word_set2); jp_wl2.add(Box.createRigidArea(new Dimension(5, 0))); jp_wl2.add(search_path_btn); jp.add(jp_wl1); jp.add(jp_wl2); result_len = new JTextField(20); jp.add(result_len); jp.add(new JLabel("Select a pair of vertices for which a shortest path will be displayed")); JPanel jp2 = new JPanel(); jp2.add(new JLabel("vertex from", SwingConstants.LEFT)); jp2.add(getSelectionBox(true)); jp2.setBackground(Color.white); JPanel jp3 = new JPanel(); jp3.add(new JLabel("vertex to", SwingConstants.LEFT)); jp3.add(getSelectionBox(false)); jp3.setBackground(Color.white); jp.add(jp2); jp.add(jp3); final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse(); vv.setGraphMouse(graphMouse); JComboBox modeBox = graphMouse.getModeComboBox(); jp.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); jp.add(modeBox); return jp; }