Java Code Examples for javax.swing.SwingConstants#HORIZONTAL
The following examples show how to use
javax.swing.SwingConstants#HORIZONTAL .
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: Utilities.java From beautyeye with Apache License 2.0 | 6 votes |
public static BufferedImage createGradientMask(int width, int height, int orientation) { // algorithm derived from Romain Guy's blog BufferedImage gradient = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); Graphics2D g = gradient.createGraphics(); GradientPaint paint = new GradientPaint(0.0f, 0.0f, new Color(1.0f, 1.0f, 1.0f, 1.0f), orientation == SwingConstants.HORIZONTAL? width : 0.0f, orientation == SwingConstants.VERTICAL? height : 0.0f, new Color(1.0f, 1.0f, 1.0f, 0.0f)); g.setPaint(paint); g.fill(new Rectangle2D.Double(0, 0, width, height)); g.dispose(); gradient.flush(); return gradient; }
Example 2
Source File: MarkerBarUI.java From microba with BSD 3-Clause "New" or "Revised" License | 6 votes |
protected void calculateViewRectAndBaseline(MarkerBar bar) { Insets insets = bar.getInsets(); viewRect.x = insets.left; viewRect.y = insets.top; viewRect.width = bar.getWidth() - (insets.right + viewRect.x); viewRect.height = bar.getHeight() - (insets.bottom + viewRect.y); if (bar.getOrientation() == SwingConstants.HORIZONTAL) { baselineLeft = viewRect.x + MARKER_BODY_WIDTH / 2; baselineLength = viewRect.width - MARKER_BODY_WIDTH - 1; if (bar.isFliped()) { baselineTop = viewRect.y; } else { baselineTop = viewRect.y + viewRect.height - 1; } } else { baselineLeft = viewRect.y + MARKER_BODY_WIDTH / 2; baselineLength = viewRect.height - MARKER_BODY_WIDTH - 1; if (bar.isFliped()) { baselineTop = viewRect.x + viewRect.width - 1; } else { baselineTop = viewRect.x; } } }
Example 3
Source File: Utilities.java From littleluck with Apache License 2.0 | 6 votes |
public static BufferedImage createGradientMask(int width, int height, int orientation) { // algorithm derived from Romain Guy's blog BufferedImage gradient = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); Graphics2D g = gradient.createGraphics(); GradientPaint paint = new GradientPaint(0.0f, 0.0f, new Color(1.0f, 1.0f, 1.0f, 1.0f), orientation == SwingConstants.HORIZONTAL? width : 0.0f, orientation == SwingConstants.VERTICAL? height : 0.0f, new Color(1.0f, 1.0f, 1.0f, 0.0f)); g.setPaint(paint); g.fill(new Rectangle2D.Double(0, 0, width, height)); g.dispose(); gradient.flush(); return gradient; }
Example 4
Source File: ScrollablePanel.java From magarena with GNU General Public License v3.0 | 5 votes |
@Override public int getScrollableUnitIncrement( Rectangle visible, int orientation, int direction) { switch (orientation) { case SwingConstants.HORIZONTAL: return getScrollableIncrement(horizontalUnit, visible.width); case SwingConstants.VERTICAL: return getScrollableIncrement(verticalUnit, visible.height); default: throw new IllegalArgumentException("Invalid orientation: " + orientation); } }
Example 5
Source File: FlatToolBarBorder.java From FlatLaf with Apache License 2.0 | 5 votes |
protected void paintGrip( Component c, Graphics g, int x, int y, int width, int height ) { int dotSize = scale( DOT_SIZE ); int gapSize = dotSize; int gripSize = (dotSize * DOT_COUNT) + ((gapSize * (DOT_COUNT - 1))); // include toolbar margin in grip position calculation Insets insets = getBorderInsets( c ); // calculate grip position boolean horizontal = ((JToolBar)c).getOrientation() == SwingConstants.HORIZONTAL; if( horizontal ) { if( c.getComponentOrientation().isLeftToRight() ) x += insets.left - (dotSize * 2); else x += width - insets.right + dotSize; y += Math.round( (height - gripSize) / 2f ); } else { // vertical x += Math.round( (width - gripSize) / 2f ); y += insets.top - (dotSize * 2); } // paint dots for( int i = 0; i < DOT_COUNT; i++ ) { g.fillOval( x, y, dotSize, dotSize ); if( horizontal ) y += dotSize + gapSize; else x += dotSize + gapSize; } }
Example 6
Source File: BasicFindPanel.java From constellation with Apache License 2.0 | 5 votes |
private void resetComboBox() { JSeparator sep = new JSeparator(SwingConstants.HORIZONTAL); Dimension sepDim = new Dimension(Integer.MAX_VALUE, 5); sep.setMaximumSize(sepDim); selectAll.setSelected(false); dropDownPanel.add(selectAll); dropDownPanel.add(sep); updateValidation(); }
Example 7
Source File: LanguageSelector.java From wpcleaner with Apache License 2.0 | 5 votes |
/** * Constructor. * * @param parentComponent Parent component. */ public LanguageSelector(Component parentComponent) { this.parentComponent = parentComponent; this.changeListeners = new ArrayList<>(); // Create combo box Configuration configuration = Configuration.getConfiguration(); EnumLanguage defaultLanguage = configuration.getLanguage(); combo = new JComboBox<>(EnumLanguage.getList().toArray(new EnumLanguage[0])); combo.setEditable(false); combo.setSelectedItem(defaultLanguage); combo.addItemListener(EventHandler.create( ItemListener.class, this, "notifyLanguageChange")); // Create label label = Utilities.createJLabel(GT._T("Language")); label.setLabelFor(combo); label.setHorizontalAlignment(SwingConstants.TRAILING); // Create button toolbar = new JToolBar(SwingConstants.HORIZONTAL); toolbar.setFloatable(false); toolbar.setBorderPainted(false); JButton buttonLanguageInfo = Utilities.createJButton( "tango-help-browser.png", EnumImageSize.SMALL, GT._T("Other Language"), false, null); buttonLanguageInfo.addActionListener(EventHandler.create( ActionListener.class, this, "actionOtherLanguage")); toolbar.add(buttonLanguageInfo); }
Example 8
Source File: ScrollablePanel.java From magarena with GNU General Public License v3.0 | 5 votes |
@Override public int getScrollableBlockIncrement( Rectangle visible, int orientation, int direction) { switch (orientation) { case SwingConstants.HORIZONTAL: return getScrollableIncrement(horizontalBlock, visible.width); case SwingConstants.VERTICAL: return getScrollableIncrement(verticalBlock, visible.height); default: throw new IllegalArgumentException("Invalid orientation: " + orientation); } }
Example 9
Source File: ConstantParser.java From osp with GNU General Public License v3.0 | 5 votes |
static public Value orientationConstant(String _value) { _value = _value.trim().toLowerCase(); if(_value.equals("vertical")) { //$NON-NLS-1$ return new IntegerValue(SwingConstants.VERTICAL); } return new IntegerValue(SwingConstants.HORIZONTAL); }
Example 10
Source File: CheckWikiWindow.java From wpcleaner with Apache License 2.0 | 4 votes |
/** * @return Page list components */ private Component createPageListComponents() { JPanel panel = new JPanel(new GridBagLayout()); panel.setBorder(BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), GT._T("Pages"))); modelPages = new DefaultListModel<CheckErrorPage>(); listPages = new JList<CheckErrorPage>(modelPages); // Initialize constraints GridBagConstraints constraints = new GridBagConstraints(); constraints.fill = GridBagConstraints.HORIZONTAL; constraints.gridheight = 1; constraints.gridwidth = 1; constraints.gridx = 0; constraints.gridy = 0; constraints.insets = new Insets(0, 0, 0, 0); constraints.ipadx = 0; constraints.ipady = 0; constraints.weightx = 1; constraints.weighty = 0; // Load pages JToolBar toolbarButtons = new JToolBar(SwingConstants.HORIZONTAL); toolbarButtons.setFloatable(false); JButton buttonLoad = Utilities.createJButton(GT._T("&Load pages"), null); buttonLoad.addActionListener(EventHandler.create( ActionListener.class, this, "actionLoadPages")); toolbarButtons.add(buttonLoad); ActionFullAnalysis.addButton( getParentComponent(), toolbarButtons, getWikipedia(), listPages, null, true, true); JButton buttonAutomaticFixing = Utilities.createJButton( "gnome-view-sort-descending.png", EnumImageSize.NORMAL, GT._T("Automatic fixing"), false, null); buttonAutomaticFixing.addActionListener(EventHandler.create( ActionListener.class, this, "actionRunAutomaticFixing")); toolbarButtons.add(buttonAutomaticFixing); constraints.fill = GridBagConstraints.HORIZONTAL; constraints.gridx = 0; constraints.weightx = 0; constraints.weighty = 0; panel.add(toolbarButtons, constraints); constraints.gridy++; // Page List listPages.setCellRenderer(new CheckErrorPageListCellRenderer(true)); listPages.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); listPages.addMouseListener(new MouseAdapter() { /* (non-Javadoc) * @see java.awt.event.MouseAdapter#mouseClicked(java.awt.event.MouseEvent) */ @Override public void mouseClicked(MouseEvent e) { if (e.getButton() != MouseEvent.BUTTON1) { return; } if (e.getClickCount() != 2) { return; } actionLoadPages(); } }); JScrollPane scrollPages = new JScrollPane(listPages); scrollPages.setMinimumSize(new Dimension(200, 200)); scrollPages.setPreferredSize(new Dimension(200, 300)); scrollPages.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); constraints.fill = GridBagConstraints.BOTH; constraints.gridx = 0; constraints.weightx = 0; constraints.weighty = 1; panel.add(scrollPages, constraints); constraints.gridy++; return panel; }
Example 11
Source File: MetadataPlotPanel.java From snap-desktop with GNU General Public License v3.0 | 4 votes |
private JPanel createSettingsPanel(BindingContext bindingContext) { final JLabel datasetLabel = new JLabel("Dataset: "); final JComboBox<MetadataElement> datasetBox = new JComboBox<>(); datasetBox.setRenderer(new ProductNodeListCellRenderer()); JLabel recordLabel = new JLabel("Record: "); recordValueField = new JTextField(7); recordSlider = new JSlider(SwingConstants.HORIZONTAL, 1, 1, 1); recordSlider.setPaintTrack(true); recordSlider.setPaintTicks(true); recordSlider.setPaintLabels(true); configureSilderLabels(recordSlider); JLabel numRecordsLabel = new JLabel("Records / Plot: "); numRecSpinnerModel = new SpinnerNumberModel(1, 1, 1, 1); JSpinner numRecordsSpinner = new JSpinner(numRecSpinnerModel); numRecordsSpinner.setEditor(new JSpinner.NumberEditor(numRecordsSpinner, "#")); final JLabel xFieldLabel = new JLabel("X Field: "); final JComboBox<MetadataAttribute> xFieldBox = new JComboBox<>(); xFieldBox.setRenderer(new ProductNodeListCellRenderer()); final JLabel y1FieldLabel = new JLabel("Y Field: "); final JComboBox<MetadataAttribute> y1FieldBox = new JComboBox<>(); y1FieldBox.setRenderer(new ProductNodeListCellRenderer()); final JLabel y2FieldLabel = new JLabel("Y2 Field: "); final JComboBox<MetadataAttribute> y2FieldBox = new JComboBox<>(); y2FieldBox.setRenderer(new ProductNodeListCellRenderer()); bindingContext.bind(PROP_NAME_METADATA_ELEMENT, datasetBox); bindingContext.bind(PROP_NAME_RECORD_START_INDEX, recordValueField); bindingContext.bind(PROP_NAME_RECORD_START_INDEX, new SliderAdapter(recordSlider)); bindingContext.bind(PROP_NAME_RECORDS_PER_PLOT, numRecordsSpinner); bindingContext.bind(PROP_NAME_FIELD_X, xFieldBox); bindingContext.bind(PROP_NAME_FIELD_Y1, y1FieldBox); bindingContext.bind(PROP_NAME_FIELD_Y2, y2FieldBox); TableLayout layout = new TableLayout(3); JPanel plotSettingsPanel = new JPanel(layout); layout.setTableWeightX(0.0); layout.setTableAnchor(TableLayout.Anchor.NORTHWEST); layout.setTableFill(TableLayout.Fill.HORIZONTAL); layout.setTablePadding(4, 4); layout.setCellWeightX(0, 1, 1.0); layout.setCellColspan(0, 1, 2); plotSettingsPanel.add(datasetLabel); plotSettingsPanel.add(datasetBox); layout.setCellWeightX(1, 1, 0.2); layout.setCellWeightX(1, 2, 0.8); plotSettingsPanel.add(recordLabel); plotSettingsPanel.add(recordValueField); plotSettingsPanel.add(recordSlider); layout.setCellWeightX(2, 1, 1.0); layout.setCellColspan(2, 1, 2); plotSettingsPanel.add(numRecordsLabel); plotSettingsPanel.add(numRecordsSpinner); layout.setCellWeightX(3, 1, 1.0); layout.setCellColspan(3, 1, 2); plotSettingsPanel.add(xFieldLabel); plotSettingsPanel.add(xFieldBox); layout.setCellWeightX(4, 1, 1.0); layout.setCellColspan(4, 1, 2); plotSettingsPanel.add(y1FieldLabel); plotSettingsPanel.add(y1FieldBox); layout.setCellWeightX(5, 1, 1.0); layout.setCellColspan(5, 1, 2); plotSettingsPanel.add(y2FieldLabel); plotSettingsPanel.add(y2FieldBox); updateSettings(); updateUiState(); return plotSettingsPanel; }
Example 12
Source File: ExportImage.java From Logisim with GNU General Public License v3.0 | 4 votes |
OptionsPanel(JList<?> list) { // set up components formatPng = new JRadioButton("PNG"); formatGif = new JRadioButton("GIF"); formatJpg = new JRadioButton("JPEG"); ButtonGroup bgroup = new ButtonGroup(); bgroup.add(formatPng); bgroup.add(formatGif); bgroup.add(formatJpg); formatPng.setSelected(true); slider = new JSlider(SwingConstants.HORIZONTAL, -3 * SLIDER_DIVISIONS, 3 * SLIDER_DIVISIONS, 0); slider.setMajorTickSpacing(10); slider.addChangeListener(this); curScale = new JLabel("222%"); curScale.setHorizontalAlignment(SwingConstants.RIGHT); curScale.setVerticalAlignment(SwingConstants.CENTER); curScaleDim = new Dimension(curScale.getPreferredSize()); curScaleDim.height = Math.max(curScaleDim.height, slider.getPreferredSize().height); stateChanged(null); printerView = new JCheckBox(); printerView.setSelected(true); // set up panel gridbag = new GridBagLayout(); gbc = new GridBagConstraints(); setLayout(gridbag); // now add components into panel gbc.gridy = 0; gbc.gridx = GridBagConstraints.RELATIVE; gbc.anchor = GridBagConstraints.NORTHWEST; gbc.insets = new Insets(5, 0, 5, 0); gbc.fill = GridBagConstraints.NONE; addGb(new JLabel(Strings.get("labelCircuits") + " ")); gbc.fill = GridBagConstraints.HORIZONTAL; addGb(new JScrollPane(list)); gbc.fill = GridBagConstraints.NONE; gbc.gridy++; addGb(new JLabel(Strings.get("labelImageFormat") + " ")); Box formatsPanel = new Box(BoxLayout.Y_AXIS); formatsPanel.add(formatPng); formatsPanel.add(formatGif); formatsPanel.add(formatJpg); addGb(formatsPanel); gbc.gridy++; addGb(new JLabel(Strings.get("labelScale") + " ")); addGb(slider); addGb(curScale); gbc.gridy++; addGb(new JLabel(Strings.get("labelPrinterView") + " ")); addGb(printerView); }
Example 13
Source File: JGrid.java From nextreports-designer with Apache License 2.0 | 4 votes |
public JGrid(GridModel gridModel, SpanModel spanModel) { this(gridModel, spanModel, new DefaultHeaderModel(gridModel.getRowCount(), DEFAULT_ROW_HEIGHT, SwingConstants.VERTICAL), new DefaultHeaderModel(gridModel.getColumnCount(), DEFAULT_COLUMN_WIDTH, SwingConstants.HORIZONTAL), new DefaultSelectionModel()); }
Example 14
Source File: SliderUI.java From rapidminer-studio with GNU Affero General Public License v3.0 | 4 votes |
@Override public void paintTrack(Graphics g) { Graphics2D g2 = (Graphics2D) g; // make sure slider has same background as container if (slider.getParent() != null) { g2.setColor(slider.getParent().getBackground()); g2.fillRect(0, 0, slider.getWidth(), slider.getHeight()); } if (this.slider.getOrientation() == SwingConstants.HORIZONTAL) { int trackTop = (int) this.trackRect.getY() + 2; int w = this.slider.getWidth(); int length = w - 6; // draw background bar if (this.slider.isEnabled()) { g2.setColor(Colors.SLIDER_TRACK_BACKGROUND); } else { g2.setColor(Colors.SLIDER_TRACK_BACKGROUND_DISABLED); } g2.fillRoundRect(3, trackTop + 1, length, 5, RapidLookAndFeel.CORNER_DEFAULT_RADIUS / 2, RapidLookAndFeel.CORNER_DEFAULT_RADIUS / 2); // draw fill bar g2.setColor(Colors.SLIDER_TRACK_FOREGROUND); g2.fill(new Rectangle2D.Double(4, trackTop + 2, this.thumbRect.x + 2, 3)); // draw border g2.setColor(Colors.SLIDER_TRACK_BORDER); g2.drawRoundRect(2, trackTop, length, 6, RapidLookAndFeel.CORNER_DEFAULT_RADIUS / 2, RapidLookAndFeel.CORNER_DEFAULT_RADIUS / 2); } else { int trackLeft = (int) this.trackRect.getX() + 2; int h = this.slider.getHeight(); int height = h - 6; // draw background bar if (this.slider.isEnabled()) { g2.setColor(Colors.SLIDER_TRACK_BACKGROUND); } else { g2.setColor(Colors.SLIDER_TRACK_BACKGROUND_DISABLED); } g2.fillRoundRect(trackLeft + 1, 3, 5, height, RapidLookAndFeel.CORNER_DEFAULT_RADIUS / 2, RapidLookAndFeel.CORNER_DEFAULT_RADIUS / 2); // draw fill bar g2.setColor(Colors.SLIDER_TRACK_FOREGROUND); g2.fill(new Rectangle2D.Double(trackLeft + 2, this.thumbRect.y - 2, 3, h - this.thumbRect.y - 4)); // draw border g2.setColor(Colors.SLIDER_TRACK_BORDER); g2.drawRoundRect(trackLeft, 2, 6, height, RapidLookAndFeel.CORNER_DEFAULT_RADIUS / 2, RapidLookAndFeel.CORNER_DEFAULT_RADIUS / 2); } }
Example 15
Source File: BoxTabbedPaneUI.java From pumpernickel with MIT License | 4 votes |
protected void refreshTabStates() { List<Component> newTabs = new ArrayList<>(); for (int a = 0; a < tabs.getTabCount(); a++) { JComponent tab = (JComponent) tabs.getTabComponentAt(a); if (tab == null) tab = getDefaultTab(a); TabContainer tabContainer = (TabContainer) tab .getClientProperty(PROPERTY_TAB_CONTAINER); if (tabContainer == null) { tabContainer = new TabContainer(tabs, a, tab); tab.putClientProperty(PROPERTY_TAB_CONTAINER, tabContainer); } newTabs.add(tabContainer); tab.putClientProperty(PROPERTY_TAB_INDEX, a); getStyle(tabs).formatControlRowButton(tabs, tabContainer, a); } Boolean hideSingleTab = (Boolean) tabs .getClientProperty(PROPERTY_HIDE_SINGLE_TAB); if (hideSingleTab == null) hideSingleTab = Boolean.FALSE; controlRow.setVisible(!(tabs.getTabCount() <= 1 && hideSingleTab)); if (!(tabsContainer.getLayout() instanceof SplayedLayout)) { SplayedLayout l = new SplayedLayout(true) { @Override protected Collection<JComponent> getEmphasizedComponents( JComponent container) { Collection<JComponent> returnValue = super .getEmphasizedComponents(container); for (Component c : container.getComponents()) { if (c instanceof AbstractButton) { AbstractButton ab = (AbstractButton) c; if (ab.isSelected()) returnValue.add(ab); } } return returnValue; } }; tabsContainer.setLayout(l); } int orientation = tabs.getTabPlacement() == SwingConstants.LEFT || tabs.getTabPlacement() == SwingConstants.RIGHT ? SwingConstants.VERTICAL : SwingConstants.HORIZONTAL; ((SplayedLayout) tabsContainer.getLayout()).setOrientation(null, orientation); setComponents(tabsContainer, newTabs); tabsContainer.revalidate(); }
Example 16
Source File: ALTaskManagerPanel.java From moa with GNU General Public License v3.0 | 4 votes |
public ProgressCellRenderer() { super(SwingConstants.HORIZONTAL, 0, 10000); setBorderPainted(false); setStringPainted(true); }
Example 17
Source File: MultiLabelTaskManagerPanel.java From moa with GNU General Public License v3.0 | 4 votes |
public ProgressCellRenderer() { super(SwingConstants.HORIZONTAL, 0, 10000); setBorderPainted(false); setStringPainted(true); }
Example 18
Source File: AuxiliarTaskManagerPanel.java From moa with GNU General Public License v3.0 | 4 votes |
public ProgressCellRenderer() { super(SwingConstants.HORIZONTAL, 0, 10000); setBorderPainted(false); setStringPainted(true); }
Example 19
Source File: JGrid.java From nextreports-designer with Apache License 2.0 | 3 votes |
/** * Returns the scroll increment (in pixels) that completely exposes one new * row or column (depending on the orientation). * * This method is called each time the user requests a unit scroll. * * @param visibleRect * the view area visible within the viewport * @param orientation * either <code>SwingConstants.VERTICAL</code> or * <code>SwingConstants.HORIZONTAL</code> * @param direction * less than zero to scroll up/left, greater than zero for * down/right * @return the "unit" increment for scrolling in the specified direction * @see Scrollable#getScrollableUnitIncrement */ public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) { if (orientation == SwingConstants.HORIZONTAL) { return DEFAULT_COLUMN_WIDTH; } else { return DEFAULT_ROW_HEIGHT; } }
Example 20
Source File: AxisMarksComputer.java From netbeans with Apache License 2.0 | 3 votes |
public Abstract(ChartContext context, int orientation) { this.context = context; this.orientation = orientation; horizontal = orientation == SwingConstants.HORIZONTAL; reverse = horizontal ? context.isRightBased() : context.isBottomBased(); }