Java Code Examples for javax.swing.JPanel#setAlignmentY()
The following examples show how to use
javax.swing.JPanel#setAlignmentY() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JStatusBar.java From mars-sim with GNU General Public License v3.0 | 6 votes |
public void addRightCorner() { JPanel panel = new JPanel(new FlowLayout( FlowLayout.TRAILING, 0, 0)); // panel.setOpaque(false); // panel.setBackground(almond); JLabel label = new JLabel(new AngledLinesWindowsCornerIcon()); // label.setAlignmentX(1F); // label.setAlignmentY(1F); panel.setAlignmentX(1F); panel.setAlignmentY(1F); label.setHorizontalAlignment(JLabel.RIGHT); label.setVerticalAlignment(JLabel.BOTTOM); panel.add(label); rightPanel.add(panel); // rightPanel.add(label); }
Example 2
Source File: GUIOptionComponentBase.java From PacketProxy with Apache License 2.0 | 5 votes |
private JPanel createTableButton(ActionListener addAction, ActionListener editAction, ActionListener removeAction) { JPanel panel = new JPanel(); JButton button_add = new JButton("Add"); JButton button_edit = new JButton("Edit"); JButton button_remove = new JButton("Remove"); int height = button_add.getMinimumSize().height; button_add.setMaximumSize(new Dimension(100,height)); button_edit.setMaximumSize(new Dimension(100,height)); button_remove.setMaximumSize(new Dimension(100,height)); if(null!=addAction) { panel.add(button_add); button_add.addActionListener(addAction); } if(null!=editAction) { panel.add(button_edit); button_edit.addActionListener(editAction); } if(null!=removeAction) { panel.add(button_remove); button_remove.addActionListener(removeAction); } panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); panel.setBackground(Color.WHITE); panel.setMaximumSize(new Dimension(100, panel.getMinimumSize().height)); panel.setAlignmentY(Component.TOP_ALIGNMENT); return panel; }
Example 3
Source File: SpectralMatchPanel.java From mzmine3 with GNU General Public License v2.0 | 5 votes |
private JPanel extractMetaData(String title, SpectralDBEntry entry, DBEntryField[] other) { JPanel panelOther = new JPanel(); panelOther.setLayout(new BoxLayout(panelOther, BoxLayout.Y_AXIS)); panelOther.setBackground(Color.WHITE); panelOther.setAlignmentY(Component.TOP_ALIGNMENT); panelOther.setAlignmentX(Component.TOP_ALIGNMENT); for (DBEntryField db : other) { Object o = entry.getField(db).orElse("N/A"); if (!o.equals("N/A")) { CustomTextPane textPane = new CustomTextPane(true); textPane.setText(db.toString() + ": " + o.toString()); panelOther.add(textPane); } } JLabel otherInfo = new JLabel(title); otherInfo.setFont(headerFont); JPanel pn = new JPanel(new BorderLayout()); pn.setBackground(Color.WHITE); pn.add(otherInfo, BorderLayout.NORTH); pn.add(panelOther, BorderLayout.CENTER); JPanel pn1 = new JPanel(new BorderLayout()); pn1.add(pn, BorderLayout.NORTH); pn1.setBackground(Color.WHITE); return pn1; }
Example 4
Source File: VizGUI.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
/** Add a vertical divider to the toolbar. */ private void addDivider() { JPanel divider = OurUtil.makeH(new Dimension(1, 40), Color.LIGHT_GRAY); divider.setAlignmentY(0.5f); if (!Util.onMac()) toolbar.add(OurUtil.makeH(5, background)); else toolbar.add(OurUtil.makeH(5)); toolbar.add(divider); if (!Util.onMac()) toolbar.add(OurUtil.makeH(5, background)); else toolbar.add(OurUtil.makeH(5)); }
Example 5
Source File: DemoModule.java From beautyeye with Apache License 2.0 | 5 votes |
/** * Creates the horizontal panel. * * @param threeD the three d * @return the j panel */ public JPanel createHorizontalPanel(boolean threeD) { JPanel p = N9ComponentFactory.createPanel_style1(null).setDrawBg(threeD);//modified by jb2011 p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); p.setAlignmentY(TOP_ALIGNMENT); p.setAlignmentX(LEFT_ALIGNMENT); if(threeD) { p.setBorder(loweredBorder); } //因背景是白色N9图,这里设置它不填充默认背景好看一点,要不然灰色背景出来就不好看了 p.setOpaque(false);//add by jb2011 2012-08-24 return p; }
Example 6
Source File: DemoModule.java From beautyeye with Apache License 2.0 | 5 votes |
/** * Creates the vertical panel. * * @param threeD the three d * @return the j panel */ public JPanel createVerticalPanel(boolean threeD) { JPanel p = N9ComponentFactory.createPanel_style1(null).setDrawBg(threeD);//modified by jb2011 p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); p.setAlignmentY(TOP_ALIGNMENT); p.setAlignmentX(LEFT_ALIGNMENT); if(threeD) { p.setBorder(loweredBorder); } return p; }
Example 7
Source File: SpectralMatchPanel.java From mzmine2 with GNU General Public License v2.0 | 5 votes |
private JPanel extractMetaData(String title, SpectralDBEntry entry, DBEntryField[] other) { JPanel panelOther = new JPanel(); panelOther.setLayout(new BoxLayout(panelOther, BoxLayout.Y_AXIS)); panelOther.setBackground(Color.WHITE); panelOther.setAlignmentY(Component.TOP_ALIGNMENT); panelOther.setAlignmentX(Component.TOP_ALIGNMENT); for (DBEntryField db : other) { Object o = entry.getField(db).orElse("N/A"); if (!o.equals("N/A")) { CustomTextPane textPane = new CustomTextPane(true); textPane.setText(db.toString() + ": " + o.toString()); panelOther.add(textPane); } } JLabel otherInfo = new JLabel(title); otherInfo.setFont(headerFont); JPanel pn = new JPanel(new BorderLayout()); pn.setBackground(Color.WHITE); pn.add(otherInfo, BorderLayout.NORTH); pn.add(panelOther, BorderLayout.CENTER); JPanel pn1 = new JPanel(new BorderLayout()); pn1.add(pn, BorderLayout.NORTH); pn1.setBackground(Color.WHITE); return pn1; }
Example 8
Source File: VCSCommitParameters.java From netbeans with Apache License 2.0 | 4 votes |
public ParametersPanel() { messageLabel.setLabelFor(messageTextArea); Mnemonics.setLocalizedText(messageLabel, getMessage("CTL_CommitForm_Message")); // NOI18N JLabel templateLink = getMessagesTemplateLink(messageTextArea, "org.netbeans.modules.versioning.util.common.TemplatePanel"); //NOI18N JLabel recentLink = getRecentMessagesLink(messageTextArea); messageTextArea.setColumns(60); //this determines the preferred width of the whole dialog messageTextArea.setLineWrap(true); messageTextArea.setRows(4); messageTextArea.setTabSize(4); messageTextArea.setWrapStyleWord(true); messageTextArea.setMinimumSize(new Dimension(100, 18)); scrollpane.setViewportView(messageTextArea); messageTextArea.getAccessibleContext().setAccessibleName(getMessage("ACSN_CommitForm_Message")); // NOI18N messageTextArea.getAccessibleContext().setAccessibleDescription(getMessage("ACSD_CommitForm_Message")); // NOI18N if(commitMessage != null) { messageTextArea.setText(commitMessage); } JPanel topPanel = new VerticallyNonResizingPanel(); topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.X_AXIS)); topPanel.add(messageLabel); topPanel.add(Box.createHorizontalGlue()); topPanel.add(recentLink); topPanel.add(makeHorizontalStrut(recentLink, templateLink, RELATED, this)); topPanel.add(templateLink); messageLabel.setAlignmentX(LEFT_ALIGNMENT); messageLabel.setAlignmentY(BOTTOM_ALIGNMENT); recentLink.setAlignmentY(BOTTOM_ALIGNMENT); templateLink.setAlignmentY(BOTTOM_ALIGNMENT); setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); topPanel.setAlignmentY(BOTTOM_ALIGNMENT); add(topPanel); add(makeVerticalStrut(messageLabel, scrollpane, RELATED, this)); add(scrollpane); Spellchecker.register (messageTextArea); }
Example 9
Source File: ModelTreeRTStats.java From mts with GNU General Public License v3.0 | 4 votes |
synchronized public void displayCounters(StatKey prefixKey, javax.swing.JPanel panel) throws Exception { // We clear the panel panel.removeAll(); // We generate the railWay in relartion with th StatKey displayed generateRailWay(prefixKey); // We get all template possible for the StatKey prefixKey List<CounterReportTemplate> templateList = StatCounterConfigManager.getInstance().getTemplateList(prefixKey); // We create a String tab with all descendent of the prefixKey String[] descendentSelect = CounterReportTemplate.concat(prefixKey.getAllAttributes(), "^[^_].*"); // We create a list with all StatKey matching with descendent of prefixKey List<StatKey> descendentsList = pool.findMatchingKeyStrict(new StatKey(descendentSelect)); Collections.sort(descendentsList); // We create a new panel for insert a table for short stats JPanel jPanelShort = new JPanel(); // Color of this panel jPanelShort.setBackground(ModelTreeRTStats.instance().getColorByString("neutral")); // We choose a SpringLayout to have disposition like in a tab //jPanelShort.setLayout(new GridLayout(descendentsList.size()+2,0,10,5)); jPanelShort.setLayout(new SpringLayout()); // Layout alignment to the left jPanelShort.setAlignmentX(java.awt.Component.LEFT_ALIGNMENT); jPanelShort.setAlignmentY(java.awt.Component.TOP_ALIGNMENT); // We fill jPanelShort with all titles if (!templateList.isEmpty()) { fillWithSummaryTitles(jPanelShort, prefixKey, templateList); } // For each descendents for (StatKey descendent : descendentsList) { // We create a new line with all data fillWithData(jPanelShort, descendent, templateList, true); } // If there is any information in this section if (!templateList.isEmpty()) { // We add the line with total fillWithTotal(jPanelShort, prefixKey, templateList); } // We create a grid with elements in jPanelShort makeCompactGrid(jPanelShort, descendentsList.size() + 2, templateList.size() + 1, 3, 3, 5, 5); // We add this short panel to the main panel panel.add(jPanelShort); // We refresh the panel panel.updateUI(); }
Example 10
Source File: OurTabbedSyntaxWidget.java From org.alloytools.alloy with Apache License 2.0 | 4 votes |
/** * Create a new tab with the given filename (if filename==null, we'll create a * blank tab instead) * <p> * If a text buffer with that filename already exists, we will just switch to * it; else we'll read that file into a new tab. * * @return false iff an error occurred */ public boolean newtab(String filename) { if (filename != null) { filename = Util.canon(filename); for (int i = 0; i < tabs.size(); i++) if (tabs.get(i).getFilename().equals(filename)) { if (i != me) select(i); return true; } } final JLabel lb = OurUtil.label("", OurUtil.getVizFont().deriveFont(Font.BOLD), Color.BLACK, Color.WHITE); lb.setBorder(new OurBorder(BORDER, BORDER, Color.WHITE, BORDER)); lb.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { for (int i = 0; i < tabs.size(); i++) if (tabs.get(i).obj1 == lb) select(i); } }); JPanel h1 = OurUtil.makeH(4); h1.setBorder(new OurBorder(null, null, BORDER, null)); JPanel h2 = OurUtil.makeH(3); h2.setBorder(new OurBorder(null, null, BORDER, null)); JPanel pan = Util.onMac() ? OurUtil.makeVL(null, 2, OurUtil.makeHB(h1, lb, h2)) : OurUtil.makeVL(null, 2, OurUtil.makeHB(h1, lb, h2, GRAY), GRAY); pan.setAlignmentX(0.0f); pan.setAlignmentY(1.0f); OurSyntaxWidget text = new OurSyntaxWidget(this, syntaxHighlighting, "", fontName, fontSize, tabSize, lb, pan); tabBar.add(pan, tabs.size()); tabs.add(text); text.listeners.add(listener); // add listener AFTER we've updated // this.tabs and this.tabBar if (filename == null) { text.discard(false, getFilenames()); // forces the tab to re-derive // a suitable fresh name } else { if (!text.load(filename)) return false; for (int i = tabs.size() - 1; i >= 0; i--) if (!tabs.get(i).isFile() && tabs.get(i).getText().length() == 0) { tabs.get(i).discard(false, getFilenames()); close(i); break; // Remove the rightmost untitled empty tab } } select(tabs.size() - 1); // Must call this to switch to the new tab; and // it will fire STATUS_CHANGE message which // is important return true; }
Example 11
Source File: QuickFindPanel.java From jpexs-decompiler with GNU General Public License v3.0 | 4 votes |
public QuickFindPanel() { setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED)); JPanel pan1 = new JPanel(new WrapLayout()); JPanel pan2 = new JPanel(new WrapLayout()); pan1.setAlignmentX(0); pan2.setAlignmentX(0); pan1.setAlignmentY(0); pan2.setAlignmentY(0); JLabel jLabel1 = new javax.swing.JLabel(); findTextField = new javax.swing.JTextField(); prevButton = new javax.swing.JButton(); nextButton = new javax.swing.JButton(); ignoreCaseCheckbox = new javax.swing.JCheckBox(); regExpCheckbox = new javax.swing.JCheckBox(); wrapCheckbox = new javax.swing.JCheckBox(); statusLabel = new javax.swing.JLabel(); setName("QuickFindDialog"); jLabel1.setLabelFor(findTextField); ResourceBundle bundle = ResourceBundle.getBundle("jsyntaxpane/Bundle"); jLabel1.setText(bundle.getString("QuickFindDialog.jLabel1.text")); pan1.add(jLabel1); findTextField.setColumns(30); findTextField.setBorder(javax.swing.BorderFactory.createLineBorder(Color.black)); findTextField.setMaximumSize(new java.awt.Dimension(200, 24)); findTextField.setMinimumSize(new java.awt.Dimension(60, 24)); pan1.add(findTextField); prevButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/META-INF/images/small-icons/go-up.png"))); prevButton.setFocusable(false); prevButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); prevButton.setOpaque(false); prevButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); prevButton.addActionListener(this::previousButtonActionPerformed); pan1.add(prevButton); nextButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/META-INF/images/small-icons/go-down.png"))); nextButton.setFocusable(false); nextButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); nextButton.setMargin(new java.awt.Insets(2, 2, 2, 2)); nextButton.setOpaque(false); nextButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); nextButton.addActionListener(this::nextButtonActionPerformed); pan1.add(nextButton); ignoreCaseCheckbox.setMnemonic('C'); ignoreCaseCheckbox.setText(bundle.getString("QuickFindDialog.jChkIgnoreCase.text")); ignoreCaseCheckbox.setFocusable(false); ignoreCaseCheckbox.setOpaque(false); ignoreCaseCheckbox.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); pan2.add(ignoreCaseCheckbox); //ignoreCaseCheckbox.addActionListener(this); regExpCheckbox.setMnemonic('R'); regExpCheckbox.setText(bundle.getString("QuickFindDialog.jChkRegExp.text")); regExpCheckbox.setFocusable(false); regExpCheckbox.setOpaque(false); regExpCheckbox.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); pan2.add(regExpCheckbox); //regExpCheckbox.addActionListener(this); wrapCheckbox.setMnemonic('W'); wrapCheckbox.setText(bundle.getString("QuickFindDialog.jChkWrap.text")); wrapCheckbox.setFocusable(false); wrapCheckbox.setOpaque(false); wrapCheckbox.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); pan2.add(wrapCheckbox); //wrapCheckbox.addActionListener(this); statusLabel.setFont(statusLabel.getFont().deriveFont(statusLabel.getFont().getStyle() | java.awt.Font.BOLD, statusLabel.getFont().getSize() - 2)); statusLabel.setForeground(Color.red); pan2.add(statusLabel); add(pan1); add(pan2); setPreferredSize(getMinimumSize()); setVisible(false); }
Example 12
Source File: SplashScreen.java From importer-exporter with Apache License 2.0 | 4 votes |
private void init(int numberOfSteps, int messageX, int messageY, Color messageColor) { JPanel content = new JPanel() { public boolean isOptimizedDrawingEnabled() { return false; } }; content.setLayout(new OverlayLayout(content)); content.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 1)); JPanel dynamicContent = new JPanel(); dynamicContent.setOpaque(false); dynamicContent.setLayout(new GridBagLayout()); message = new JLabel(); message.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 12)); message.setForeground(messageColor); progressBar = new JProgressBar(); progressBar.setPreferredSize(new Dimension(icon.getIconWidth(), 18)); progressBar.setIndeterminate(false); progressBar.setMaximum(numberOfSteps); progressBar.setVisible(false); GridBagConstraints c = GuiUtil.setConstraints(0, 0, 1, 1, GridBagConstraints.HORIZONTAL, 5 + messageY, 5 + messageX, 0, 5); c.anchor = GridBagConstraints.NORTH; dynamicContent.add(message, c); c = GuiUtil.setConstraints(0, 1, 1, 1, GridBagConstraints.HORIZONTAL, 5, 5, 5, 5); c.anchor = GridBagConstraints.SOUTH; dynamicContent.add(progressBar, c); dynamicContent.setAlignmentX(0f); dynamicContent.setAlignmentY(0f); content.add(dynamicContent); JLabel image = new JLabel(icon); image.setAlignmentX(0f); image.setAlignmentY(0f); content.add(image); add(content, BorderLayout.CENTER); // center on screen Toolkit t = Toolkit.getDefaultToolkit(); Insets frame_insets = t.getScreenInsets(GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration()); int frame_insets_x = frame_insets.left + frame_insets.right; int frame_insets_y = frame_insets.bottom + frame_insets.top; Dimension dim = t.getScreenSize(); int x = (dim.width - icon.getIconWidth() - frame_insets_x) / 2; int y = (dim.height - icon.getIconHeight() - frame_insets_y) / 2; setMinimumSize(new Dimension(icon.getIconWidth(), icon.getIconHeight())); setLocation(x, y); setAlwaysOnTop(true); }