List of usage examples for javax.swing BoxLayout PAGE_AXIS
int PAGE_AXIS
To view the source code for javax.swing BoxLayout PAGE_AXIS.
Click Source Link
From source file:op.care.med.inventory.DlgNewStocks.java
/** * This method is called from within the constructor to * initialize the form./*from www.j a va 2s.c om*/ * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the PrinterForm Editor. */ // <editor-fold defaultstate="collapsed" desc=" Erzeugter Quelltext ">//GEN-BEGIN:initComponents private void initComponents() { mainPane = new JPanel(); lblPZN = new JLabel(); panel2 = new JPanel(); txtMedSuche = new JXSearchField(); hSpacer1 = new JPanel(null); btnMed = new JButton(); lblProd = new JLabel(); cmbMProdukt = new JComboBox<>(); lblInventory = new JLabel(); lblResident = new JLabel(); txtBWSuche = new JTextField(); lblAmount = new JLabel(); lblPack = new JLabel(); cmbPackung = new JComboBox<>(); lblExpires = new JLabel(); txtExpires = new JTextField(); panel3 = new JPanel(); lblWeightControl = new JLabel(); txtWeightControl = new JTextField(); lblRemark = new JLabel(); txtBemerkung = new JTextField(); btnPrint = new JToggleButton(); panel1 = new JPanel(); btnClose = new JButton(); btnApply = new JButton(); //======== this ======== setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); setTitle("Medikamente einbuchen"); setMinimumSize(new Dimension(640, 300)); Container contentPane = getContentPane(); contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.PAGE_AXIS)); //======== mainPane ======== { mainPane.setLayout(new FormLayout( "14dlu, $lcgap, default, $lcgap, 39dlu:grow, $lcgap, default:grow, $lcgap, 14dlu", "14dlu, 2*($lgap, fill:17dlu), $lgap, fill:default, $lgap, 17dlu, 4*($lgap, fill:17dlu), 10dlu, fill:default, $lgap, 14dlu")); //---- lblPZN ---- lblPZN.setText("PZN oder Suchbegriff"); lblPZN.setFont(new Font("Arial", Font.PLAIN, 14)); mainPane.add(lblPZN, CC.xy(3, 3)); //======== panel2 ======== { panel2.setLayout(new BoxLayout(panel2, BoxLayout.LINE_AXIS)); //---- txtMedSuche ---- txtMedSuche.setFont(new Font("Arial", Font.PLAIN, 14)); txtMedSuche.addActionListener(e -> txtMedSucheActionPerformed(e)); panel2.add(txtMedSuche); panel2.add(hSpacer1); //---- btnMed ---- btnMed.setBackground(Color.white); btnMed.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/add.png"))); btnMed.setToolTipText("Medikamente bearbeiten"); btnMed.setBorder(null); btnMed.setSelectedIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/add-pressed.png"))); btnMed.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnMed.addActionListener(e -> btnMedActionPerformed(e)); panel2.add(btnMed); } mainPane.add(panel2, CC.xywh(5, 3, 4, 1)); //---- lblProd ---- lblProd.setText("Produkt"); lblProd.setFont(new Font("Arial", Font.PLAIN, 14)); mainPane.add(lblProd, CC.xy(3, 5)); //---- cmbMProdukt ---- cmbMProdukt.setModel(new DefaultComboBoxModel<>(new String[] { })); cmbMProdukt.setFont(new Font("Arial", Font.PLAIN, 14)); cmbMProdukt.addItemListener(e -> cmbMProduktItemStateChanged(e)); mainPane.add(cmbMProdukt, CC.xywh(5, 5, 4, 1)); //---- lblInventory ---- lblInventory.setText("vorhandene Vorr\u00e4te"); lblInventory.setFont(new Font("Arial", Font.PLAIN, 14)); mainPane.add(lblInventory, CC.xy(3, 13)); //---- lblResident ---- lblResident.setText("Zuordnung zu Bewohner"); lblResident.setFont(new Font("Arial", Font.PLAIN, 14)); mainPane.add(lblResident, CC.xy(3, 17)); //---- txtBWSuche ---- txtBWSuche.setFont(new Font("Arial", Font.PLAIN, 14)); txtBWSuche.addCaretListener(e -> txtBWSucheCaretUpdate(e)); mainPane.add(txtBWSuche, CC.xy(5, 17)); //---- lblAmount ---- lblAmount.setText("Buchungsmenge"); lblAmount.setFont(new Font("Arial", Font.PLAIN, 14)); mainPane.add(lblAmount, CC.xy(3, 11)); //---- lblPack ---- lblPack.setText("Packung"); lblPack.setFont(new Font("Arial", Font.PLAIN, 14)); mainPane.add(lblPack, CC.xy(3, 7)); //---- cmbPackung ---- cmbPackung.setModel(new DefaultComboBoxModel<>(new String[] { })); cmbPackung.setFont(new Font("Arial", Font.PLAIN, 14)); cmbPackung.addItemListener(e -> cmbPackungItemStateChanged(e)); mainPane.add(cmbPackung, CC.xywh(5, 7, 4, 1)); //---- lblExpires ---- lblExpires.setText("expires"); lblExpires.setFont(new Font("Arial", Font.PLAIN, 14)); mainPane.add(lblExpires, CC.xy(3, 9)); //---- txtExpires ---- txtExpires.setFont(new Font("Arial", Font.PLAIN, 14)); txtExpires.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { txtExpiresFocusGained(e); } @Override public void focusLost(FocusEvent e) { txtExpiresFocusLost(e); } }); txtExpires.addActionListener(e -> txtExpiresActionPerformed(e)); mainPane.add(txtExpires, CC.xywh(5, 9, 3, 1, CC.DEFAULT, CC.FILL)); //======== panel3 ======== { panel3.setLayout(new FormLayout("pref, $lcgap, default:grow", "fill:17dlu")); //---- lblWeightControl ---- lblWeightControl.setText("weightcontrol"); lblWeightControl.setFont(new Font("Arial", Font.PLAIN, 14)); lblWeightControl.setBackground(Color.pink); panel3.add(lblWeightControl, CC.xy(1, 1)); //---- txtWeightControl ---- txtWeightControl.setFont(new Font("Arial", Font.PLAIN, 14)); txtWeightControl.setBackground(Color.pink); txtWeightControl.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { txtWeightControlFocusGained(e); } }); txtWeightControl.addCaretListener(e -> txtWeightControlCaretUpdate(e)); panel3.add(txtWeightControl, CC.xy(3, 1, CC.DEFAULT, CC.FILL)); } mainPane.add(panel3, CC.xy(7, 11)); //---- lblRemark ---- lblRemark.setText("Bemerkung"); lblRemark.setFont(new Font("Arial", Font.PLAIN, 14)); mainPane.add(lblRemark, CC.xy(3, 15)); //---- txtBemerkung ---- txtBemerkung.setFont(new Font("Arial", Font.PLAIN, 14)); txtBemerkung.addCaretListener(e -> txtBemerkungCaretUpdate(e)); mainPane.add(txtBemerkung, CC.xywh(5, 15, 4, 1)); //---- btnPrint ---- btnPrint.setSelectedIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/printer-on.png"))); btnPrint.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/printer-off.png"))); btnPrint.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnPrint.setEnabled(false); btnPrint.addItemListener(e -> btnPrintItemStateChanged(e)); mainPane.add(btnPrint, CC.xy(3, 19, CC.RIGHT, CC.DEFAULT)); //======== panel1 ======== { panel1.setLayout(new BoxLayout(panel1, BoxLayout.X_AXIS)); //---- btnClose ---- btnClose.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/cancel.png"))); btnClose.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnClose.addActionListener(e -> btnCloseActionPerformed(e)); panel1.add(btnClose); //---- btnApply ---- btnApply.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/apply.png"))); btnApply.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnApply.addActionListener(e -> btnApplyActionPerformed(e)); panel1.add(btnApply); } mainPane.add(panel1, CC.xywh(7, 19, 2, 1, CC.RIGHT, CC.DEFAULT)); } contentPane.add(mainPane); pack(); setLocationRelativeTo(getOwner()); }
From source file:eu.apenet.dpt.standalone.gui.APETabbedPane.java
private JComponent makeResultsPanel() { JPanel resultsView = new JPanel(); resultsView.setLayout(new BoxLayout(resultsView, BoxLayout.PAGE_AXIS)); dataPreparationToolGUI.getResultArea().setForeground(new Color(255, 100, 100)); resultsView.add(dataPreparationToolGUI.getResultArea()); return resultsView; }
From source file:coreferenceresolver.gui.MarkupGUI.java
private JScrollPane newReviewPanel(Review review, int reviewId) throws BadLocationException { //Model//from w ww .j a v a2 s. com ReviewElement reviewElement = new ReviewElement(); ScrollablePanel reviewPanel = new ScrollablePanel(); reviewPanel.setLayout(new BoxLayout(reviewPanel, BoxLayout.PAGE_AXIS)); JTextField title = new JTextField("NEW REVIEW " + reviewId); title.setBackground(Color.pink); reviewPanel.add(title); JTextArea reviewContentTxtArea = new JTextArea(); reviewContentTxtArea.setLineWrap(true); reviewContentTxtArea.setWrapStyleWord(true); reviewContentTxtArea.setEditable(false); reviewContentTxtArea.setText(review.getRawContent()); int chainId = 0; for (CorefChain cc : review.getCorefChains()) { for (int npId : cc.getChain()) { NounPhrase np = review.getNounPhrases().get(npId); Object highlighTag = reviewContentTxtArea.getHighlighter().addHighlight(np.getOffsetBegin(), np.getOffsetEnd() + 1, highlightPainters.get(chainId)); this.markupReviews.get(reviewId).getNounPhrases().get(npId).highlighterTag = highlighTag; } ++chainId; } reviewPanel.add(reviewContentTxtArea); ScrollablePanel markupsPanel = new ScrollablePanel(); markupsPanel.setLayout(new BoxLayout(markupsPanel, BoxLayout.PAGE_AXIS)); for (int i = 0; i < review.getNounPhrases().size(); ++i) { JScrollPane newMarkupPanel = newMarkupPanel(review.getNounPhrases().get(i), reviewElement); markupsPanel.add(newMarkupPanel); } JScrollPane scrollMarkupsPanel = new JScrollPane(markupsPanel); //Add Dimension for scrolling Dimension curScreenDimen = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); scrollMarkupsPanel.setPreferredSize(new Dimension((int) curScreenDimen.getWidth() - 50, 400)); reviewPanel.add(scrollMarkupsPanel); //MODEL reviewElement.reviewTextArea = reviewContentTxtArea; reviewElements.add(reviewElement); reviewPanel.add(new JSeparator(SwingConstants.HORIZONTAL)); reviewPanel.add(Box.createVerticalStrut(20)); JScrollPane scrollReviewPanel = new JScrollPane(reviewPanel); return scrollReviewPanel; }
From source file:net.pms.newgui.LanguageSelection.java
private JComponent buildComponent() { // UIManager manages to get the background color wrong for text // components on OS X, so we apply the color manually Color backgroundColor = UIManager.getColor("Panel.background"); rootPanel.setLayout(new BoxLayout(rootPanel, BoxLayout.PAGE_AXIS)); // It needs to be something in the title text, or the size calculation for the border will be wrong. selectionPanelBorder.setTitle(" "); selectionPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5), BorderFactory.createCompoundBorder(selectionPanelBorder, BorderFactory.createEmptyBorder(10, 5, 10, 5)))); selectionPanel.setLayout(new BoxLayout(selectionPanel, BoxLayout.PAGE_AXIS)); descriptionText.setEditable(false);/*from ww w.j ava 2s . c o m*/ descriptionText.setBackground(backgroundColor); descriptionText.setFocusable(false); descriptionText.setLineWrap(true); descriptionText.setWrapStyleWord(true); descriptionText.setBorder(BorderFactory.createEmptyBorder(5, 15, 10, 15)); selectionPanel.add(descriptionText); jLanguage = new JComboBox<>(keyedModel); jLanguage.setEditable(false); jLanguage.setPreferredSize(new Dimension(50, jLanguage.getPreferredSize().height)); jLanguage.addActionListener(new LanguageComboBoxActionListener()); languagePanel.setLayout(new BoxLayout(languagePanel, BoxLayout.PAGE_AXIS)); languagePanel.setBorder(BorderFactory.createEmptyBorder(5, 15, 5, 15)); languagePanel.add(jLanguage); selectionPanel.add(languagePanel); warningText.setEditable(false); warningText.setFocusable(false); warningText.setBackground(backgroundColor); warningText.setFont(warningText.getFont().deriveFont(Font.BOLD)); warningText.setLineWrap(true); warningText.setWrapStyleWord(true); warningText.setBorder(BorderFactory.createEmptyBorder(5, 15, 0, 15)); selectionPanel.add(warningText); // It needs to be something in the title text, or the size calculation for the border will be wrong. infoTextBorder.setTitle(" "); infoText.setBorder( BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5), BorderFactory .createCompoundBorder(infoTextBorder, BorderFactory.createEmptyBorder(15, 20, 20, 20)))); infoText.setEditable(false); infoText.setFocusable(false); infoText.setBackground(backgroundColor); infoText.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE); // This exercise is to avoid using the default shared StyleSheet with padding CustomHTMLEditorKit editorKit = new CustomHTMLEditorKit(); StyleSheet styleSheet = new StyleSheet(); styleSheet.addRule("a { color: #0000EE; text-decoration:underline; }"); editorKit.setStyleSheet(styleSheet); infoText.setEditorKit(editorKit); infoText.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { boolean error = false; if (Desktop.isDesktopSupported()) { try { Desktop.getDesktop().browse(new URI(e.getDescription())); } catch (IOException | URISyntaxException ex) { LOGGER.error("Language selection failed to open translation page hyperlink: ", ex.getMessage()); LOGGER.trace("", ex); error = true; } } else { LOGGER.warn("Desktop is not supported, the clicked translation page link can't be opened"); error = true; } if (error) { JOptionPane.showOptionDialog(dialog, String.format(buildString("LanguageSelection.6", true), PMS.CROWDIN_LINK), buildString("Dialog.Error"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE, null, null, null); } } } }); rootPanel.add(selectionPanel); rootPanel.add(infoText); applyButton.addActionListener(new ApplyButtonActionListener()); applyButton.setActionCommand("apply"); selectButton.addActionListener(new SelectButtonActionListener()); selectButton.setActionCommand("select"); return rootPanel; }
From source file:wigraph.ShortestPathRelation.java
/** * *//*from w ww . j a v a2 s .com*/ 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; }
From source file:org.monome.pages.MIDIKeyboardJulienBPage.java
public JPanel getPanel() { if (this.panel != null) { return this.panel; }/*from w w w. j a v a 2 s.c o m*/ JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS)); JPanel subPanel = new JPanel(); pageNameLBL = new JLabel((this.index + 1) + ": MIDI Keyboard"); subPanel.add(pageNameLBL); panel.add(subPanel); subPanel = new JPanel(); JButton button = new JButton("Add MIDI Output"); button.addActionListener(this); subPanel.add(button); panel.add(subPanel); this.panel = panel; return panel; }
From source file:edu.ucla.stat.SOCR.applications.demo.PortfolioApplication2.java
public void addRadioButton(int x, int y, String text, String toolTipText, String[] bValues, int defaultIndex, JPanel panel, ActionListener l) { JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.PAGE_AXIS)); GridBagConstraints c = new GridBagConstraints(); c.gridx = x;/* www. jav a2 s. c o m*/ c.gridy = y; ButtonGroup group = new ButtonGroup(); p.setToolTipText(toolTipText); p.add(new JLabel(text)); rButtons = new JRadioButton[bValues.length]; for (int i = 0; i < bValues.length; i++) { rButtons[i] = new JRadioButton(bValues[i]); rButtons[i].setName(bValues[i]); rButtons[i].addActionListener(l); rButtons[i].setActionCommand(bValues[i]); p.add(rButtons[i]); group.add(rButtons[i]); if (defaultIndex == i) rButtons[i].setSelected(true); } panel.add(p, c); }
From source file:musiccrawler.App.java
private JPanel loadingPanel() { JPanel panel = new JPanel(); BoxLayout layoutMgr = new BoxLayout(panel, BoxLayout.PAGE_AXIS); panel.setLayout(layoutMgr);//w w w. j av a2 s. co m ClassLoader cldr = this.getClass().getClassLoader(); java.net.URL imageURL = cldr.getResource("image/ajax-loader.gif"); ImageIcon imageIcon = new ImageIcon(imageURL); JLabel iconLabel = new JLabel(); iconLabel.setIcon(imageIcon); imageIcon.setImageObserver(iconLabel); JLabel label = new JLabel("Loading..."); panel.add(iconLabel); panel.add(label); return panel; }
From source file:com.rapidminer.gui.viewer.metadata.AttributeStatisticsPanel.java
/** * Initializes the GUI.//from ww w .ja v a2s .co m * */ @SuppressWarnings({ "unchecked", "rawtypes" }) private void initGUI() { setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); // add attribute name panelAttName = new JPanel(); panelAttName.setLayout(new BoxLayout(panelAttName, BoxLayout.PAGE_AXIS)); panelAttName.setOpaque(false); // this border is to visualize that the name column can be enlarged/shrinked panelAttName.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 1, Color.LIGHT_GRAY)); labelAttHeader = new JLabel(LABEL_DOTS); labelAttHeader.setFont(labelAttHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER)); labelAttHeader.setForeground(Color.GRAY); panelAttName.add(labelAttHeader); labelAttName = new JLabel(LABEL_DOTS); labelAttName.setFont(labelAttName.getFont().deriveFont(Font.BOLD, FONT_SIZE_LABEL_VALUE)); labelAttName.setMinimumSize(DIMENSION_LABEL_ATTRIBUTE); labelAttName.setPreferredSize(DIMENSION_LABEL_ATTRIBUTE); panelAttName.add(labelAttName); gbc.gridx = 0; gbc.gridy = 0; gbc.insets = new Insets(3, 20, 3, 10); gbc.anchor = GridBagConstraints.CENTER; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.weightx = 0.0; gbc.weighty = 1.0; gbc.gridheight = 2; add(panelAttName, gbc); // create value type name and bring it to a nice to read format (aka uppercase first letter // and replace '_' with ' ' gbc.gridx += 1; gbc.insets = new Insets(5, 15, 5, 10); labelAttType = new JLabel(LABEL_DOTS); labelAttType.setMinimumSize(DIMENSION_LABEL_TYPE); labelAttType.setPreferredSize(DIMENSION_LABEL_TYPE); add(labelAttType, gbc); // missings panel JPanel panelStatsMissing = new JPanel(); panelStatsMissing.setLayout(new BoxLayout(panelStatsMissing, BoxLayout.PAGE_AXIS)); panelStatsMissing.setOpaque(false); labelStatsMissing = new JLabel(LABEL_DOTS); labelStatsMissing.setMinimumSize(DIMENSION_LABEL_MISSINGS); labelStatsMissing.setPreferredSize(DIMENSION_LABEL_MISSINGS); panelStatsMissing.add(labelStatsMissing); gbc.gridx += 1; gbc.fill = GridBagConstraints.NONE; gbc.weightx = 0.0; add(panelStatsMissing, gbc); // chart panel(s) (only visible when enlarged) JPanel chartPanel = new JPanel(new BorderLayout()); chartPanel.setBackground(COLOR_TRANSPARENT); chartPanel.setOpaque(false); listOfChartPanels.add(chartPanel); updateVisibilityOfChartPanels(); gbc.fill = GridBagConstraints.NONE; gbc.weighty = 0.0; gbc.insets = new Insets(0, 10, 0, 10); for (JPanel panel : listOfChartPanels) { gbc.gridx += 1; add(panel, gbc); } // (hidden) construction panel String constructionLabel = I18N.getMessage(I18N.getGUIBundle(), "gui.label.attribute_statistics.statistics.construction.label"); panelStatsConstruction = new JPanel(); panelStatsConstruction.setLayout(new BoxLayout(panelStatsConstruction, BoxLayout.PAGE_AXIS)); panelStatsConstruction.setOpaque(false); panelStatsConstruction.setVisible(false); JLabel labelConstructionHeader = new JLabel(constructionLabel); labelConstructionHeader.setFont(labelConstructionHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER)); labelConstructionHeader.setForeground(Color.GRAY); panelStatsConstruction.add(labelConstructionHeader); labelStatsConstruction = new JLabel(LABEL_DOTS); labelStatsConstruction.setFont(labelStatsConstruction.getFont().deriveFont(FONT_SIZE_LABEL_VALUE)); labelStatsConstruction.setMinimumSize(DIMENSION_LABEL_CONSTRUCTION); labelStatsConstruction.setPreferredSize(DIMENSION_LABEL_CONSTRUCTION); panelStatsConstruction.add(labelStatsConstruction); gbc.gridx += 1; gbc.fill = GridBagConstraints.NONE; gbc.weightx = 0.0; add(panelStatsConstruction, gbc); // statistics panel, contains different statistics panels for numerical/nominal/date_time on // a card layout // needed to switch between for model swapping cardStatsPanel = new JPanel(); cardStatsPanel.setOpaque(false); cardLayout = new CardLayout(); cardStatsPanel.setLayout(cardLayout); // numerical version JPanel statsNumPanel = new JPanel(); GridBagLayout layout = new GridBagLayout(); GridBagConstraints gbcStatPanel = new GridBagConstraints(); statsNumPanel.setLayout(layout); statsNumPanel.setOpaque(false); String avgLabel = I18N.getMessage(I18N.getGUIBundle(), "gui.label.attribute_statistics.statistics.avg.label"); String devianceLabel = I18N.getMessage(I18N.getGUIBundle(), "gui.label.attribute_statistics.statistics.variance.label"); String minLabel = I18N.getMessage(I18N.getGUIBundle(), "gui.label.attribute_statistics.statistics.min.label"); String maxLabel = I18N.getMessage(I18N.getGUIBundle(), "gui.label.attribute_statistics.statistics.max.label"); // min value panel JPanel panelStatsMin = new JPanel(); panelStatsMin.setLayout(new BoxLayout(panelStatsMin, BoxLayout.PAGE_AXIS)); panelStatsMin.setOpaque(false); JLabel labelMinHeader = new JLabel(minLabel); labelMinHeader.setFont(labelMinHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER)); labelMinHeader.setForeground(Color.GRAY); panelStatsMin.add(labelMinHeader); labelStatsMin = new JLabel(LABEL_DOTS); labelStatsMin.setFont(labelStatsMin.getFont().deriveFont(FONT_SIZE_LABEL_VALUE)); panelStatsMin.add(labelStatsMin); // max value panel JPanel panelStatsMax = new JPanel(); panelStatsMax.setLayout(new BoxLayout(panelStatsMax, BoxLayout.PAGE_AXIS)); panelStatsMax.setOpaque(false); JLabel labelMaxHeader = new JLabel(maxLabel); labelMaxHeader.setFont(labelMaxHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER)); labelMaxHeader.setForeground(Color.GRAY); panelStatsMax.add(labelMaxHeader); labelStatsMax = new JLabel(LABEL_DOTS); labelStatsMax.setFont(labelStatsMax.getFont().deriveFont(FONT_SIZE_LABEL_VALUE)); panelStatsMax.add(labelStatsMax); // average value panel JPanel panelStatsAvg = new JPanel(); panelStatsAvg.setLayout(new BoxLayout(panelStatsAvg, BoxLayout.PAGE_AXIS)); panelStatsAvg.setOpaque(false); JLabel labelAvgHeader = new JLabel(avgLabel); labelAvgHeader.setFont(labelAvgHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER)); labelAvgHeader.setForeground(Color.GRAY); panelStatsAvg.add(labelAvgHeader); labelStatsAvg = new JLabel(LABEL_DOTS); labelStatsAvg.setFont(labelStatsAvg.getFont().deriveFont(FONT_SIZE_LABEL_VALUE)); panelStatsAvg.add(labelStatsAvg); // deviance value panel JPanel panelStatsDeviance = new JPanel(); panelStatsDeviance.setLayout(new BoxLayout(panelStatsDeviance, BoxLayout.PAGE_AXIS)); panelStatsDeviance.setOpaque(false); JLabel labelDevianceHeader = new JLabel(devianceLabel); labelDevianceHeader.setFont(labelDevianceHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER)); labelDevianceHeader.setForeground(Color.GRAY); panelStatsDeviance.add(labelDevianceHeader); labelStatsDeviation = new JLabel(LABEL_DOTS); labelStatsDeviation.setFont(labelStatsDeviation.getFont().deriveFont(FONT_SIZE_LABEL_VALUE)); panelStatsDeviance.add(labelStatsDeviation); // add sub panels to stats panel gbcStatPanel.gridx = 0; gbcStatPanel.weightx = 0.0; gbcStatPanel.fill = GridBagConstraints.NONE; gbcStatPanel.insets = new Insets(0, 0, 0, 4); panelStatsMin.setPreferredSize(DIMENSION_PANEL_NUMERIC_PREF_SIZE); statsNumPanel.add(panelStatsMin, gbcStatPanel); gbcStatPanel.gridx += 1; panelStatsMax.setPreferredSize(DIMENSION_PANEL_NUMERIC_PREF_SIZE); statsNumPanel.add(panelStatsMax, gbcStatPanel); gbcStatPanel.gridx += 1; panelStatsAvg.setPreferredSize(DIMENSION_PANEL_NUMERIC_PREF_SIZE); statsNumPanel.add(panelStatsAvg, gbcStatPanel); gbcStatPanel.gridx += 1; panelStatsDeviance.setPreferredSize(DIMENSION_PANEL_NUMERIC_PREF_SIZE); statsNumPanel.add(panelStatsDeviance, gbcStatPanel); gbcStatPanel.gridx += 1; gbcStatPanel.weightx = 1.0; gbcStatPanel.fill = GridBagConstraints.HORIZONTAL; statsNumPanel.add(new JLabel(), gbcStatPanel); cardStatsPanel.add(statsNumPanel, CARD_NUMERICAL); // nominal version JPanel statsNomPanel = new JPanel(); statsNomPanel.setLayout(layout); statsNomPanel.setOpaque(false); String leastLabel = I18N.getMessage(I18N.getGUIBundle(), "gui.label.attribute_statistics.statistics.least.label"); String mostLabel = I18N.getMessage(I18N.getGUIBundle(), "gui.label.attribute_statistics.statistics.most.label"); String valuesLabel = I18N.getMessage(I18N.getGUIBundle(), "gui.label.attribute_statistics.statistics.values.label"); // least panel JPanel panelStatsLeast = new JPanel(); panelStatsLeast.setLayout(new BoxLayout(panelStatsLeast, BoxLayout.PAGE_AXIS)); panelStatsLeast.setOpaque(false); JLabel labelLeastHeader = new JLabel(leastLabel); labelLeastHeader.setFont(labelLeastHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER)); labelLeastHeader.setForeground(Color.GRAY); labelLeastHeader.setAlignmentX(Component.LEFT_ALIGNMENT); panelStatsLeast.add(labelLeastHeader); labelStatsLeast = new JLabel(LABEL_DOTS); labelStatsLeast.setFont(labelStatsLeast.getFont().deriveFont(FONT_SIZE_LABEL_VALUE)); panelStatsLeast.add(labelStatsLeast); // most panel JPanel panelStatsMost = new JPanel(); panelStatsMost.setLayout(new BoxLayout(panelStatsMost, BoxLayout.PAGE_AXIS)); panelStatsMost.setOpaque(false); JLabel labelMostHeader = new JLabel(mostLabel); labelMostHeader.setFont(labelMostHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER)); labelMostHeader.setForeground(Color.GRAY); labelMostHeader.setAlignmentX(Component.LEFT_ALIGNMENT); panelStatsMost.add(labelMostHeader); labelStatsMost = new JLabel(LABEL_DOTS); labelStatsMost.setFont(labelStatsMost.getFont().deriveFont(FONT_SIZE_LABEL_VALUE)); panelStatsMost.add(labelStatsMost); // values panel JPanel panelStatsValues = new JPanel(); panelStatsValues.setLayout(new BoxLayout(panelStatsValues, BoxLayout.PAGE_AXIS)); panelStatsValues.setOpaque(false); JLabel labelValuesHeader = new JLabel(valuesLabel); labelValuesHeader.setFont(labelValuesHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER)); labelValuesHeader.setForeground(Color.GRAY); labelValuesHeader.setAlignmentX(Component.LEFT_ALIGNMENT); panelStatsValues.add(labelValuesHeader); labelStatsValues = new JLabel(LABEL_DOTS); labelStatsValues.setFont(labelStatsValues.getFont().deriveFont(FONT_SIZE_LABEL_VALUE)); panelStatsValues.add(labelStatsValues); detailsButton = new JButton(new ShowNomValueAction(this)); detailsButton.setVisible(false); detailsButton.setOpaque(false); detailsButton.setContentAreaFilled(false); detailsButton.setBorderPainted(false); detailsButton.addMouseListener(enlargeAndHoverAndPopupMouseAdapter); detailsButton.setHorizontalAlignment(SwingConstants.LEFT); detailsButton.setHorizontalTextPosition(SwingConstants.LEFT); detailsButton.setIcon(null); Font font = detailsButton.getFont(); Map attributes = font.getAttributes(); attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON); detailsButton.setFont(font.deriveFont(attributes)); panelStatsValues.add(detailsButton); // add sub panel to stats panel gbcStatPanel.gridx = 0; gbcStatPanel.weightx = 0.0; gbcStatPanel.fill = GridBagConstraints.NONE; gbcStatPanel.insets = new Insets(0, 0, 0, 6); panelStatsLeast.setPreferredSize(DIMENSION_PANEL_NOMINAL_PREF_SIZE); statsNomPanel.add(panelStatsLeast, gbcStatPanel); gbcStatPanel.gridx += 1; panelStatsMost.setPreferredSize(DIMENSION_PANEL_NOMINAL_PREF_SIZE); statsNomPanel.add(panelStatsMost, gbcStatPanel); gbcStatPanel.gridx += 1; statsNomPanel.add(panelStatsValues, gbcStatPanel); gbcStatPanel.gridx += 1; gbcStatPanel.weightx = 1.0; gbcStatPanel.fill = GridBagConstraints.HORIZONTAL; statsNomPanel.add(new JLabel(), gbcStatPanel); cardStatsPanel.add(statsNomPanel, CARD_NOMINAL); // date_time version JPanel statsDateTimePanel = new JPanel(); statsDateTimePanel.setLayout(layout); statsDateTimePanel.setOpaque(false); String durationLabel = I18N.getMessage(I18N.getGUIBundle(), "gui.label.attribute_statistics.statistics.duration.label"); String fromLabel = I18N.getMessage(I18N.getGUIBundle(), "gui.label.attribute_statistics.statistics.from.label"); String untilLabel = I18N.getMessage(I18N.getGUIBundle(), "gui.label.attribute_statistics.statistics.until.label"); // min value panel JPanel panelStatsFrom = new JPanel(); panelStatsFrom.setLayout(new BoxLayout(panelStatsFrom, BoxLayout.PAGE_AXIS)); panelStatsFrom.setOpaque(false); JLabel labelFromHeader = new JLabel(fromLabel); labelFromHeader.setFont(labelFromHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER)); labelFromHeader.setForeground(Color.GRAY); panelStatsFrom.add(labelFromHeader); labelStatsFrom = new JLabel(LABEL_DOTS); labelStatsFrom.setFont(labelStatsFrom.getFont().deriveFont(FONT_SIZE_LABEL_VALUE)); panelStatsFrom.add(labelStatsFrom); // until value panel JPanel panelStatsUntil = new JPanel(); panelStatsUntil.setLayout(new BoxLayout(panelStatsUntil, BoxLayout.PAGE_AXIS)); panelStatsUntil.setOpaque(false); JLabel labelUntilHeader = new JLabel(untilLabel); labelUntilHeader.setFont(labelUntilHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER)); labelUntilHeader.setForeground(Color.GRAY); panelStatsUntil.add(labelUntilHeader); labelStatsUntil = new JLabel(LABEL_DOTS); labelStatsUntil.setFont(labelStatsUntil.getFont().deriveFont(FONT_SIZE_LABEL_VALUE)); panelStatsUntil.add(labelStatsUntil); // duration value panel JPanel panelStatsDuration = new JPanel(); panelStatsDuration.setLayout(new BoxLayout(panelStatsDuration, BoxLayout.PAGE_AXIS)); panelStatsDuration.setOpaque(false); JLabel labelDurationHeader = new JLabel(durationLabel); labelDurationHeader.setFont(labelDurationHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER)); labelDurationHeader.setForeground(Color.GRAY); panelStatsDuration.add(labelDurationHeader); labelStatsDuration = new JLabel(LABEL_DOTS); labelStatsDuration.setFont(labelStatsDuration.getFont().deriveFont(FONT_SIZE_LABEL_VALUE)); panelStatsDuration.add(labelStatsDuration); // add sub panels to stats panel gbcStatPanel.gridx = 0; gbcStatPanel.weightx = 0.0; gbcStatPanel.fill = GridBagConstraints.NONE; gbcStatPanel.insets = new Insets(0, 0, 0, 6); panelStatsFrom.setPreferredSize(DIMENSION_PANEL_DATE_PREF_SIZE); statsDateTimePanel.add(panelStatsFrom, gbcStatPanel); gbcStatPanel.gridx += 1; panelStatsUntil.setPreferredSize(DIMENSION_PANEL_DATE_PREF_SIZE); statsDateTimePanel.add(panelStatsUntil, gbcStatPanel); gbcStatPanel.gridx += 1; panelStatsDuration.setPreferredSize(DIMENSION_PANEL_DATE_PREF_SIZE); statsDateTimePanel.add(panelStatsDuration, gbcStatPanel); gbcStatPanel.gridx += 1; gbcStatPanel.weightx = 1.0; gbcStatPanel.fill = GridBagConstraints.HORIZONTAL; statsDateTimePanel.add(new JLabel(), gbcStatPanel); cardStatsPanel.add(statsDateTimePanel, CARD_DATE_TIME); // add stats panel to main gui gbc.gridx += 1; gbc.insets = new Insets(5, 10, 5, 10); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.weightx = 1.0; gbc.weighty = 0.0; gbc.anchor = GridBagConstraints.WEST; add(cardStatsPanel, gbc); // needed so we can draw our own background setOpaque(false); // handle mouse events for hover effect and enlarging/shrinking addMouseListener(enlargeAndHoverAndPopupMouseAdapter); // change cursor to indicate this component can be clicked setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); }
From source file:be.ac.ua.comp.scarletnebula.gui.InteractiveFirewallPanel.java
public InteractiveFirewallPanel(final CloudProvider provider) { super(new BorderLayout()); this.provider = provider; ruleList = new RuleList(provider); final JPanel mainPanel = new JPanel(new GridBagLayout()); final GridBagConstraints c = new GridBagConstraints(); c.weightx = 0.25;//from ww w.j a v a 2 s.com c.weighty = 1.0; c.fill = GridBagConstraints.BOTH; c.gridx = 0; c.gridy = 0; c.insets = new Insets(10, 10, 10, 5); final JPanel firewallPanel = new JPanel(new BorderLayout()); firewallPanel.add(firewallList, BorderLayout.CENTER); final JPanel firewallButtonPanel = new JPanel(); firewallButtonPanel.setLayout(new BoxLayout(firewallButtonPanel, BoxLayout.PAGE_AXIS)); firewallButtonPanel.setOpaque(true); firewallButtonPanel.setBackground(Color.white); addFirewallButton.setMaximumSize(new Dimension(500, 500)); addFirewallButton.addActionListener(new AddFirewallActionListener(provider)); firewallButtonPanel.add(addFirewallButton); deleteFirewallButton.setMaximumSize(new Dimension(500, 500)); deleteFirewallButton.addActionListener(new DeleteFirewallActionListener(provider)); firewallButtonPanel.add(deleteFirewallButton); firewallPanel.add(firewallButtonPanel, BorderLayout.PAGE_END); final JScrollPane firewallListScroller = new JScrollPane(firewallPanel); firewallPanel.setPreferredSize(new Dimension(10, 10)); mainPanel.add(firewallListScroller, c); c.weightx = 0.75; c.gridx = 1; c.insets = new Insets(10, 5, 10, 10); ruleList.setFillsViewportHeight(true); ruleList.setEnabled(false); firewallList.getSelectionModel().addListSelectionListener( new FirewallListSelectionListener(ruleList, addRulebutton, deleteRuleButton, deleteFirewallButton)); final JScrollPane ruleListScroller = new JScrollPane(ruleList); final JPanel ruleListPanel = new JPanel(new BorderLayout()); ruleListPanel.add(ruleListScroller, BorderLayout.CENTER); final JPanel ruleListButtonPanel = new JPanel(); addRulebutton.addActionListener(new AddRuleActionListener(provider)); deleteRuleButton.addActionListener(new DeleteRuleActionListener()); ruleListButtonPanel.add(addRulebutton); ruleListButtonPanel.add(deleteRuleButton); addRulebutton.setEnabled(false); deleteRuleButton.setEnabled(false); deleteFirewallButton.setEnabled(false); ruleListPanel.add(ruleListButtonPanel, BorderLayout.SOUTH); ruleListPanel.setPreferredSize(new Dimension(10, 10)); mainPanel.add(ruleListPanel, c); add(mainPanel, BorderLayout.CENTER); final JPanel allThrobbersPanel = getThrobbersPanel(); add(allThrobbersPanel, BorderLayout.NORTH); loadInitialFirewalls(); }