List of usage examples for java.awt BorderLayout EAST
String EAST
To view the source code for java.awt BorderLayout EAST.
Click Source Link
From source file:com.intel.stl.ui.monitor.view.PSNodesDetailsPanel.java
/** * Description://from ww w .j a va 2 s .co m * * @param name */ protected void initComponent() { setLayout(new BorderLayout(0, 0)); setOpaque(false); setBorder(BorderFactory.createTitledBorder((Border) null)); JPanel titlePanel = new JPanel(new BorderLayout(5, 1)); titlePanel.setOpaque(false); numberLabel = ComponentFactory.getH1Label(STLConstants.K0039_NOT_AVAILABLE.getValue(), Font.PLAIN); numberLabel.setHorizontalAlignment(JLabel.RIGHT); titlePanel.add(numberLabel, BorderLayout.CENTER); nameLabel = ComponentFactory.getH3Label("", Font.PLAIN); nameLabel.setHorizontalAlignment(JLabel.LEFT); nameLabel.setVerticalAlignment(JLabel.BOTTOM); titlePanel.add(nameLabel, BorderLayout.EAST); add(titlePanel, BorderLayout.NORTH); JPanel mainPanel = new JPanel(); mainPanel.setOpaque(false); mainPanel.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 2)); GridBagLayout gridBag = new GridBagLayout(); mainPanel.setLayout(gridBag); GridBagConstraints gc = new GridBagConstraints(); gc.weighty = 0; gc.insets = new Insets(8, 2, 2, 2); gc.weightx = 1; gc.gridwidth = 1; gc.gridheight = 2; // gc.gridheight = 3; // Should change to 3 if we add Route typeChartPanel = new ChartPanel(null); typeChartPanel.setPreferredSize(new Dimension(80, 60)); mainPanel.add(typeChartPanel, gc); gc.fill = GridBagConstraints.BOTH; gc.insets = new Insets(12, 2, 2, 2); gc.weightx = 0; gc.gridheight = 1; swNumberLabel = createNumberLabel(); mainPanel.add(swNumberLabel, gc); gc.gridwidth = GridBagConstraints.REMAINDER; swNameLabel = createNameLabel(STLConstants.K0048_SWITCHES.getValue()); mainPanel.add(swNameLabel, gc); gc.insets = new Insets(2, 2, 6, 2); gc.gridwidth = 1; fiNumberLabel = createNumberLabel(); mainPanel.add(fiNumberLabel, gc); gc.gridwidth = GridBagConstraints.REMAINDER; fiNameLabel = createNameLabel(STLConstants.K0052_HOSTS.getValue()); mainPanel.add(fiNameLabel, gc); // gc.gridwidth = 1; // rtNumberLabel = ComponentFactory.getH4Label( // STLConstants.K0039_NOT_AVAILABLE.getValue(), Font.PLAIN); // rtNumberLabel.setHorizontalAlignment(JLabel.CENTER); // mainPanel.add(rtNumberLabel, gc); // // gc.gridwidth = GridBagConstraints.REMAINDER; // rtNameLabel = ComponentFactory.getH5Label( // STLConstants.K0050_ROUTERS.getValue(), Font.PLAIN); // rtNameLabel.setVerticalAlignment(JLabel.BOTTOM); // mainPanel.add(rtNameLabel, gc); add(mainPanel, BorderLayout.CENTER); JPanel bottomPanel = new JPanel(new GridBagLayout()); bottomPanel.setOpaque(false); bottomPanel.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, UIConstants.INTEL_BORDER_GRAY)); gc = new GridBagConstraints(); gc.insets = new Insets(0, 5, 1, 5); gc.fill = GridBagConstraints.BOTH; gc.weightx = 1; gc.gridheight = 2; otherPortsLabel = ComponentFactory.getH1Label(STLConstants.K0039_NOT_AVAILABLE.getValue(), Font.PLAIN); otherPortsLabel.setForeground(UIConstants.INTEL_GRAY); otherPortsLabel.setHorizontalAlignment(JLabel.RIGHT); bottomPanel.add(otherPortsLabel, gc); gc.gridwidth = GridBagConstraints.REMAINDER; gc.gridheight = 1; gc.weightx = 0; gc.weighty = 1; JLabel label = ComponentFactory.getH4Label(STLConstants.K1026_PORT_RESOURCE.getValue(), Font.PLAIN); label.setHorizontalAlignment(JLabel.LEFT); label.setVerticalAlignment(JLabel.BOTTOM); bottomPanel.add(label, gc); gc.weighty = 0; label = ComponentFactory.getH4Label(STLConstants.K2077_NOT_IN_FABRIC.getValue(), Font.PLAIN); label.setHorizontalAlignment(JLabel.LEFT); label.setVerticalAlignment(JLabel.BOTTOM); bottomPanel.add(label, gc); add(bottomPanel, BorderLayout.SOUTH); }
From source file:gg.pistol.sweeper.gui.component.DecoratedPanel.java
private void addSideImage() { JPanel panel = createVerticalPanel(); panel.add(new JLabel(sideImage)); panel.add(Box.createVerticalGlue()); if (ComponentOrientation.getOrientation(i18n.getLocale()).isLeftToRight()) { panel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, border)); add(panel, BorderLayout.WEST); } else {/*from w ww .j a va2 s .c om*/ panel.setBorder(BorderFactory.createEmptyBorder(0, border, 0, 0)); add(panel, BorderLayout.EAST); } }
From source file:views.online.Panel_RejoindrePartieMulti.java
/** * Constructeur/*from w w w . ja 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(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:uk.nhs.cfh.dsp.yasb.searchpanel.SearchPanel.java
/** * a method that initalises the components. */// www .j av a2 s . c om public synchronized void initComponents() { JPanel mainPanel = new JPanel(new BorderLayout()); mainPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "Search")); mainPanel.setName("searchPanelMainPanel"); searchField = new JTextField(); if (org.jdesktop.swingx.util.OS.isMacOSX()) { searchField.putClientProperty("JTextField.variant", "search"); } searchField.setName("searchField"); searchField.addActionListener(new AbstractAction() { public void actionPerformed(ActionEvent arg0) { doSearch(); } }); // create controls panel createControlPanel(); // create button panel createButtonPanel(); // create busy label createBusyLabel(); JPanel panel = new JPanel(new BorderLayout()); panel.add(searchField, BorderLayout.CENTER); panel.add(busyStatusLabel, BorderLayout.EAST); JPanel searchPanel = new JPanel(new BorderLayout()); searchPanel.add(panel, BorderLayout.NORTH); searchPanel.add(buttonsPanel, BorderLayout.CENTER); searchPanel.add(controlsPane, BorderLayout.SOUTH); listModel = new SearchResultsListModel(); resultsList = new JList(listModel); resultsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); renderer = new SearchResultListCellRenderer(); resultsList.setCellRenderer(renderer); // add mouse listener to resultsList resultsList.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { // check if double click and get selected object if (e.getClickCount() == 2) { Object selectedObject = resultsList.getSelectedValue(); if (selectedObject instanceof Document) { Document document = (Document) selectedObject; String conceptId = document.get("CONCEPTID"); SnomedConcept concept = checkAndReturnConceptForID(conceptId); // set focus concept if concept is not null if (concept != null) { // publish as selection selectionService.objectSelected(concept, SearchPanel.this); } } } } }); // add components to main panel mainPanel.add(searchPanel, BorderLayout.NORTH); mainPanel.add(new JScrollPane(resultsList), BorderLayout.CENTER); // add main panel to search panel setLayout(new BorderLayout()); add(mainPanel, BorderLayout.CENTER); }
From source file:com.att.aro.ui.view.waterfalltab.WaterfallPanel.java
public JPanel layoutDataPanel() { this.setLayout(new BorderLayout()); this.dataset = new SlidingCategoryDataset(new DefaultCategoryDataset(), 0, CATEGORY_MAX_COUNT); this.popup = new WaterfallPopup(); JPanel graphPanel = new JPanel(new BorderLayout()); graphPanel.add(getChartPanel(), BorderLayout.CENTER); graphPanel.add(getVerticalScroll(), BorderLayout.EAST); graphPanel.add(getHorizontalScroll(), BorderLayout.SOUTH); this.add(graphPanel, BorderLayout.CENTER); JPanel buttonsPanel = new JPanel(); buttonsPanel.add(getZoomInButton()); buttonsPanel.add(getZoomOutButton()); this.add(buttonsPanel, BorderLayout.SOUTH); return this; }
From source file:vues.reseau.Panel_RejoindrePartieMulti.java
/** * Constructeur/* www . j a v a2 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:Visuals.BarChart.java
public JPanel addCharts() { ChartPanel barPanel = drawBarChart(); barPanel.setDomainZoomable(true);//from ww w.j a va 2 s . c om JPanel thisBarPanel = new JPanel(); thisBarPanel.setLayout(new BorderLayout()); String[][] finalRisks = new String[riskCount][4]; for (int i = 0; i < riskCount; i++) { finalRisks[i][0] = risks[i][0]; finalRisks[i][1] = risks[i][1]; finalRisks[i][2] = risks[i][2]; finalRisks[i][3] = risks[i][3]; } JTable table = new JTable(finalRisks, columns); //table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); TableRowSorter<TableModel> sorter = new TableRowSorter<>(table.getModel()); table.setRowSorter(sorter); List<RowSorter.SortKey> sortKeys = new ArrayList<>(); int columnIndexToSort = 2; sortKeys.add(new RowSorter.SortKey(columnIndexToSort, SortOrder.ASCENDING)); sorter.setSortKeys(sortKeys); sorter.sort(); TableColumn tcol = table.getColumnModel().getColumn(2); table.removeColumn(tcol); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); table.getColumnModel().getColumn(1).setPreferredWidth(600); table.getColumnModel().getColumn(2).setPreferredWidth(600); table.setShowHorizontalLines(true); table.setRowHeight(40); table.setEnabled(false); JScrollPane tableScrollPane = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); Dimension d = table.getPreferredSize(); tableScrollPane .setPreferredSize(new Dimension((d.width - 400), (table.getRowHeight() + 1) * (riskCount + 1))); JLabel right = new JLabel( " "); thisBarPanel.add(right, BorderLayout.EAST); thisBarPanel.add(barPanel, BorderLayout.CENTER); thisBarPanel.add(tableScrollPane, BorderLayout.SOUTH); return thisBarPanel; }
From source file:userinterface.graph.GUIImageExportDialog.java
/** This method is called from within the constructor to * initialize the form.//from www .j av a 2 s . c o m * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents private void initComponents() { allPanel = new javax.swing.JPanel(); bottomPanel = new javax.swing.JPanel(); warningLabel = new javax.swing.JLabel(); buttonPanel = new javax.swing.JPanel(); okayButton = new javax.swing.JButton(); cancelButton = new javax.swing.JButton(); topPanel = new javax.swing.JPanel(); innerTopPanel = new javax.swing.JPanel(); widthInputLabel = new javax.swing.JLabel(); widthInputField = new javax.swing.JTextField(); heightInputLabel = new javax.swing.JLabel(); heightInputField = new javax.swing.JTextField(); imageTypeInputLabel = new javax.swing.JLabel(); imageTypeInputField = new javax.swing.JComboBox(); alphaInputLabel = new javax.swing.JLabel(); alphaInputField = new javax.swing.JCheckBox(); setMinimumSize(new java.awt.Dimension(550, 350)); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { closeDialog(evt); } }); allPanel.setLayout(new java.awt.BorderLayout()); allPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); bottomPanel.setLayout(new java.awt.BorderLayout()); warningLabel.setText("Please enter positive integers for width and height."); warningLabel.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 5, 0, 0)); bottomPanel.add(warningLabel, java.awt.BorderLayout.CENTER); warningLabel.getAccessibleContext() .setAccessibleName("Please enter a positive integer for both width and height."); buttonPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT)); okayButton.setText("Okay"); okayButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { okayButtonActionPerformed(evt); } }); buttonPanel.add(okayButton); cancelButton.setText("Cancel"); cancelButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { cancelButtonActionPerformed(evt); } }); buttonPanel.add(cancelButton); bottomPanel.add(buttonPanel, java.awt.BorderLayout.EAST); allPanel.add(bottomPanel, java.awt.BorderLayout.SOUTH); topPanel.setLayout(new java.awt.BorderLayout()); topPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Image properties")); topPanel.setMinimumSize(new java.awt.Dimension(400, 200)); topPanel.setPreferredSize(new java.awt.Dimension(400, 200)); innerTopPanel.setLayout(new java.awt.GridLayout(4, 2, 5, 5)); innerTopPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); widthInputLabel.setText("Width:"); innerTopPanel.add(widthInputLabel); innerTopPanel.add(widthInputField); heightInputLabel.setText("Height:"); innerTopPanel.add(heightInputLabel); innerTopPanel.add(heightInputField); imageTypeInputLabel.setText("Image format:"); innerTopPanel.add(imageTypeInputLabel); imageTypeInputField.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "JPEG", "PNG", "EPS" })); imageTypeInputField.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { imageTypeInputFieldActionPerformed(evt); } }); innerTopPanel.add(imageTypeInputField); alphaInputLabel.setText("Transparent background:"); innerTopPanel.add(alphaInputLabel); alphaInputField.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); alphaInputField.setMargin(new java.awt.Insets(0, 0, 0, 0)); innerTopPanel.add(alphaInputField); topPanel.add(innerTopPanel, java.awt.BorderLayout.NORTH); allPanel.add(topPanel, java.awt.BorderLayout.CENTER); getContentPane().add(allPanel, java.awt.BorderLayout.CENTER); }
From source file:hr.fer.zemris.vhdllab.platform.gui.dialog.save.SaveDialog.java
public SaveDialog(LocalizationSource source, SaveContext context) { super(source); Validate.notNull(context, "Save variant can't be null"); // setup label JLabel label = new JLabel(getMainMessage(source, context)); int width = DIALOG_WIDTH - 2 * BORDER; int height = LABEL_HEIGHT - 2 * BORDER; label.setPreferredSize(new Dimension(width, height)); label.setBorder(BorderFactory.createEmptyBorder(BORDER, BORDER, BORDER, BORDER)); // setup check box list list = new CheckBoxList(); width = DIALOG_WIDTH - 2 * BORDER;/*from ww w .j a v a2s . c om*/ height = 0; // because list is a center component and it doesnt need // height list.setPreferredSize(new Dimension(width, height)); list.setBorder(BorderFactory.createEmptyBorder(BORDER, BORDER, BORDER, BORDER)); // setup select all and deselect all buttons JButton selectAll = new JButton(source.getMessage(SELECT_ALL_MESSAGE)); selectAll.setPreferredSize(new Dimension(BUTTON_WIDTH, BUTTON_HEIGHT)); selectAll.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { list.setSelectionToAll(true); } }); JButton deselectAll = new JButton(source.getMessage(DESELECT_ALL_MESSAGE)); deselectAll.setPreferredSize(new Dimension(BUTTON_WIDTH, BUTTON_HEIGHT)); deselectAll.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { list.setSelectionToAll(false); } }); Box selectBox = Box.createHorizontalBox(); selectBox.add(selectAll); selectBox.add(Box.createRigidArea(new Dimension(BORDER, BUTTON_HEIGHT))); selectBox.add(deselectAll); selectBox.setBorder(BorderFactory.createEmptyBorder(0, 0, BORDER, 0)); // setup ok and cancel buttons JButton ok = new JButton(source.getMessage(OK_MESSAGE)); ok.setPreferredSize(new Dimension(BUTTON_WIDTH, BUTTON_HEIGHT)); ok.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { closeDialog(new ArrayList<File>()); } }); JButton cancel = new JButton(source.getMessage(CANCEL_MESSAGE)); cancel.setPreferredSize(new Dimension(BUTTON_WIDTH, BUTTON_HEIGHT)); cancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { closeDialog(null); } }); Box actionBox = Box.createHorizontalBox(); actionBox.add(ok); actionBox.add(Box.createRigidArea(new Dimension(BORDER, BUTTON_HEIGHT))); actionBox.add(cancel); actionBox.setBorder(BorderFactory.createEmptyBorder(BORDER, 0, BORDER, 0)); JPanel selectPanel = new JPanel(new BorderLayout()); selectPanel.add(selectBox, BorderLayout.EAST); JPanel actionPanel = new JPanel(new BorderLayout()); actionPanel.add(actionBox, BorderLayout.EAST); JCheckBox alwaysSave = new JCheckBox(source.getMessage(ALWAYS_SAVE_MESSAGE)); alwaysSave.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JCheckBox checkBox = (JCheckBox) e.getSource(); Preferences preferences = Preferences.userNodeForPackage(SaveDialog.class); preferences.putBoolean(SHOULD_AUTO_SAVE, checkBox.isSelected()); } }); alwaysSave.setSelected(false); JPanel alwaysSavePanel = new JPanel(new BorderLayout()); alwaysSavePanel.add(alwaysSave, BorderLayout.WEST); JPanel lowerPanel = new JPanel(new BorderLayout()); lowerPanel.add(selectPanel, BorderLayout.NORTH); lowerPanel.add(alwaysSavePanel, BorderLayout.CENTER); lowerPanel.add(actionPanel, BorderLayout.SOUTH); this.setLayout(new BorderLayout()); JPanel messagePanel = new JPanel(new BorderLayout()); messagePanel.add(label, BorderLayout.NORTH); messagePanel.add(list, BorderLayout.CENTER); messagePanel.add(lowerPanel, BorderLayout.SOUTH); this.getContentPane().add(messagePanel, BorderLayout.CENTER); this.getRootPane().setDefaultButton(ok); this.setPreferredSize(new Dimension(DIALOG_WIDTH, DIALOG_HEIGHT)); this.setTitle(getTitle(source, context)); }
From source file:de.tbuchloh.kiskis.gui.widgets.PasswordElement.java
private void init() { this.setLayout(new BorderLayout()); final JPanel main = new JPanel(new BorderLayout()); main.add(_pwdField, BorderLayout.CENTER); main.add(_progressBar, BorderLayout.SOUTH); this.add(main, BorderLayout.CENTER); _buttonPanel = new JPanel(new GridLayout(2, 1)); _buttonPanel.add(_pwdButton);/*from ww w . j a v a2 s . c o m*/ _buttonPanel.add(_testButton); this.add(_buttonPanel, BorderLayout.EAST); _pwdField.addKeyListener(new KeyAdapter() { @Override public void keyReleased(final KeyEvent e) { notifyListeners(); } }); _pwdField.setColumns(50); updatePwdButton(HIDDEN); updatePwdField(); }