javax.swing.SwingConstants Java Examples
The following examples show how to use
javax.swing.SwingConstants.
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: CommunityDialog.java From WorldGrower with GNU General Public License v3.0 | 7 votes |
private void createDeitiesPanel(World world, int infoPanelWidth, int infoPanelHeight, JPanel infoPanel) { JPanel deitiesPanel = JPanelFactory.createJPanel("Deities"); deitiesPanel.setLayout(null); deitiesPanel.setBounds(510, 363, infoPanelWidth + 5, infoPanelHeight); infoPanel.add(deitiesPanel, DEITIES_KEY); DeityAttributes deityAttributes = GroupPropertyUtils.getVillagersOrganization(world).getProperty(Constants.DEITY_ATTRIBUTES); String deityTooltip = "deity hapiness indicator: if a deity becomes unhappy, they may lash out against the population"; for(int i=0; i<Deity.ALL_DEITIES.size(); i++) { Deity deity = Deity.ALL_DEITIES.get(i); Image image = imageInfoReader.getImage(deity.getBoonImageId(), null); JLabel nameLabel = JLabelFactory.createJLabel(deity.getName(), image); nameLabel.setBounds(15, 30 + 40 * i, 150, 50); nameLabel.setHorizontalAlignment(SwingConstants.LEFT); nameLabel.setToolTipText(deityTooltip); deitiesPanel.add(nameLabel); JProgressBar relationshipProgresBar = JProgressBarFactory.createHorizontalJProgressBar(deityAttributes.getMinHapinessValue(), deityAttributes.getMaxHapinessValue(), imageInfoReader); relationshipProgresBar.setBounds(175, 40 + 40 * i, 300, 30); relationshipProgresBar.setValue(deityAttributes.getHappiness(deity)); relationshipProgresBar.setToolTipText(deityTooltip); deitiesPanel.add(relationshipProgresBar); } }
Example #2
Source File: CompositeButtonPainter.java From rapidminer-studio with GNU Affero General Public License v3.0 | 6 votes |
/** * Draws the component border. * * @param g * the graphics context */ public void paintBorder(Graphics g) { Shape borderShape; int radius = RapidLookAndFeel.CORNER_DEFAULT_RADIUS; switch (position) { case SwingConstants.LEFT: borderShape = new RoundRectangle2D.Double(0, 0, button.getWidth() + radius, button.getHeight() - 1, radius, radius); RapidLookTools.drawButtonBorder(button, g, borderShape); break; case SwingConstants.CENTER: borderShape = new Rectangle2D.Double(0, 0, button.getWidth() + radius, button.getHeight() - 1); RapidLookTools.drawButtonBorder(button, g, borderShape); break; default: borderShape = new RoundRectangle2D.Double(-radius, 0, button.getWidth() + radius - 1, button.getHeight() - 1, radius, radius); RapidLookTools.drawButtonBorder(button, g, borderShape); // special case, right button has a left border borderShape = new Line2D.Double(0, 0, 0, button.getHeight()); RapidLookTools.drawButtonBorder(button, g, borderShape); break; } }
Example #3
Source File: JavaViewHierarchyRandomTest.java From netbeans with Apache License 2.0 | 6 votes |
public void testNewlineLineOne() throws Exception { loggingOn(); RandomTestContainer container = createContainer(); JEditorPane pane = container.getInstance(JEditorPane.class); Document doc = pane.getDocument(); doc.putProperty("mimeType", "text/plain"); ViewHierarchyRandomTesting.initRandomText(container); ViewHierarchyRandomTesting.addRound(container).setOpCount(OP_COUNT); ViewHierarchyRandomTesting.testFixedScenarios(container); RandomTestContainer.Context context = container.context(); // Clear document contents DocumentTesting.remove(context, 0, doc.getLength()); DocumentTesting.insert(context, 0, "\n"); EditorPaneTesting.moveOrSelect(context, SwingConstants.NORTH, false); EditorPaneTesting.moveOrSelect(context, SwingConstants.SOUTH, true); EditorPaneTesting.performAction(context, pane, DefaultEditorKit.deleteNextCharAction); DocumentTesting.undo(context, 1); }
Example #4
Source File: PluginErrorPanel.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
public PluginErrorPanel() { setOpaque(false); setBorder(new EmptyBorder(50, 10, 0, 10)); setLayout(new BorderLayout()); noResultsTitle.setForeground(Color.WHITE); noResultsTitle.setHorizontalAlignment(SwingConstants.CENTER); noResultsDescription.setFont(FontManager.getRunescapeSmallFont()); noResultsDescription.setForeground(Color.GRAY); noResultsDescription.setHorizontalAlignment(SwingConstants.CENTER); add(noResultsTitle, BorderLayout.NORTH); add(noResultsDescription, BorderLayout.CENTER); setVisible(false); }
Example #5
Source File: GlobalSearchDialog.java From rapidminer-studio with GNU Affero General Public License v3.0 | 6 votes |
/** * Sets up the GUI card responsible for displaying no result information on an "All Studio" search to the user. */ private void setupNoResultGloballyGUI() { JPanel noResultPanel = new JPanel(); noResultPanel.setName(CARD_NO_RESULTS_GLOBALLY); noResultPanel.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); noResultPanel.setOpaque(false); noResultPanel.setBorder(TOP_BORDER); // no results label JLabel noResults = new JLabel(I18N.getGUIMessage("gui.dialog.global_search.no_results.label")); noResults.setIcon(INFORMATION_ICON); noResults.setFont(noResults.getFont().deriveFont(FONT_SIZE_NO_RESULTS)); noResults.setHorizontalAlignment(SwingConstants.LEFT); gbc.weightx = 1.0d; gbc.weighty = 1.0d; gbc.fill = GridBagConstraints.BOTH; gbc.insets = new Insets(3, 10, 3, 10); noResultPanel.add(noResults, gbc); rootPanel.add(noResultPanel, CARD_NO_RESULTS_GLOBALLY); }
Example #6
Source File: InterBoard.java From audiveris with GNU Affero General Public License v3.0 | 6 votes |
/** * Creates a new InterBoard object. * * @param sheet the related sheet * @param selected true for pre-selected, false for collapsed */ public InterBoard (Sheet sheet, boolean selected) { super(Board.INTER, sheet.getInterIndex().getEntityService(), true); this.sheet = sheet; // Force a constant height for the shapeIcon field, despite variation in size of the icon Dimension dim = new Dimension( constants.shapeIconWidth.getValue(), constants.shapeIconHeight.getValue()); shapeIcon.setPreferredSize(dim); shapeIcon.setMaximumSize(dim); shapeIcon.setMinimumSize(dim); details.setToolTipText("Grade details"); details.setHorizontalAlignment(SwingConstants.CENTER); paramAction = new ParamAction(); // Initial status grade.setEnabled(false); details.setEnabled(false); defineLayout(); }
Example #7
Source File: VerticalLayout.java From consulo with Apache License 2.0 | 6 votes |
private int layout(ArrayList<Component> list, int y, int width, Insets insets) { for (Component component : list) { if (component.isVisible()) { Dimension size = component.getPreferredSize(); int x = 0; if (myAlignment == -1) { size.width = width; } else if (myAlignment != SwingConstants.LEFT) { x = width - size.width; if (myAlignment == SwingConstants.CENTER) { x /= 2; } } component.setBounds(x + insets.left, y + insets.top, size.width, size.height); y += size.height + myGap; } } return y; }
Example #8
Source File: ObjectivePanel.java From triplea with GNU General Public License v3.0 | 6 votes |
@Override public Component getTableCellRendererComponent( final JTable table, final Object value, final boolean isSelected, final boolean hasFocus, final int row, final int column) { adaptee.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); final JLabel renderer = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); renderer.setHorizontalAlignment(SwingConstants.CENTER); if (value == null) { renderer.setBorder(BorderFactory.createEmptyBorder()); } else if (value.toString().contains("T")) { renderer.setBorder(BorderFactory.createMatteBorder(2, 2, 2, 2, Color.green)); } else if (value.toString().contains("U")) { renderer.setBorder(BorderFactory.createMatteBorder(2, 2, 2, 2, Color.blue)); } else if (value.toString().contains("u")) { renderer.setBorder(BorderFactory.createMatteBorder(2, 2, 2, 2, Color.cyan)); } else { renderer.setBorder(BorderFactory.createEmptyBorder()); } return renderer; }
Example #9
Source File: AbstractXMLNavigatorContent.java From netbeans with Apache License 2.0 | 6 votes |
public void showError(final String message) { if (!SwingUtilities.isEventDispatchThread()) { SwingUtilities.invokeLater(new Runnable() { public void run() { showError(message); } }); return; } removeAll(); msgLabel.setIcon(null); msgLabel.setForeground(Color.GRAY); msgLabel.setText(NbBundle.getMessage(AbstractXMLNavigatorContent.class, message)); msgLabel.setHorizontalAlignment(SwingConstants.CENTER); add(emptyPanel, BorderLayout.CENTER); revalidate(); repaint(); }
Example #10
Source File: CharacterTabs.java From pcgen with GNU Lesser General Public License v2.1 | 6 votes |
private void initComponents() { CharacterManager.getCharacters().addListListener(this); frame.getSelectedCharacterRef().addReferenceListener(this); setTabPlacement(SwingConstants.BOTTOM); addChangeListener(this); setSharedComponent(infoTabbedPane); //Initialize popup menu PCGenActionMap actions = frame.getActionMap(); popupMenu.add(actions.get(PCGenActionMap.NEW_COMMAND)); popupMenu.add(actions.get(PCGenActionMap.CLOSE_COMMAND)); popupMenu.add(actions.get(PCGenActionMap.SAVE_COMMAND)); popupMenu.add(actions.get(PCGenActionMap.SAVEAS_COMMAND)); addMouseListener(new PopupMouseAdapter() { @Override public void showPopup(final MouseEvent e) { popupMenu.setVisible(true); popupMenu.show(e.getComponent(), e.getX(), e.getY() - popupMenu.getHeight()); } }); }
Example #11
Source File: AbstractConfigurationPanel.java From rapidminer-studio with GNU Affero General Public License v3.0 | 6 votes |
protected void addSeperatorToPanel(JPanel addTarget) { if (!(addTarget.getLayout() instanceof GridBagLayout)) { throw new RuntimeException("JPanel with GridBagLayout is mandatory!"); } JSeparator separator = new JSeparator(SwingConstants.HORIZONTAL); GridBagConstraints itemConstraint = new GridBagConstraints(); itemConstraint.gridx = GridBagConstraints.RELATIVE; itemConstraint.weightx = 1.0; itemConstraint.gridwidth = GridBagConstraints.REMAINDER; // end row itemConstraint.fill = GridBagConstraints.HORIZONTAL; itemConstraint.insets = new Insets(0, 5, 5, 5); addTarget.add(separator, itemConstraint); }
Example #12
Source File: NoWebServiceClientsPanel.java From netbeans with Apache License 2.0 | 5 votes |
/** Creates a new instance of NoWebServiceClientsPanel */ public NoWebServiceClientsPanel(String text) { setLayout(new GridBagLayout()); label = new JLabel(text); label.setVerticalAlignment(SwingConstants.CENTER); label.setHorizontalAlignment(SwingConstants.CENTER); GridBagConstraints gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; add(label, gridBagConstraints); }
Example #13
Source File: IdentityPanel.java From gcs with Mozilla Public License 2.0 | 5 votes |
/** * Creates a new identity panel. * * @param sheet The sheet to display the data for. */ public IdentityPanel(CharacterSheet sheet) { super(new ColumnLayout(2, 2, 0), I18n.Text("Identity")); createLabelAndField(this, sheet, Profile.ID_NAME, I18n.Text("Name:"), null, SwingConstants.LEFT); createLabelAndField(this, sheet, Profile.ID_TITLE, I18n.Text("Title:"), null, SwingConstants.LEFT); createLabelAndField(this, sheet, Profile.ID_PLAYER_NAME, I18n.Text("Player:"), null, SwingConstants.LEFT); }
Example #14
Source File: BoxTabbedPaneUI.java From pumpernickel with MIT License | 5 votes |
private void installExtraComponents(Container container, List<JComponent> components, boolean forceReinstall) { if (components == null) components = new ArrayList<>(); Component[] oldComponents = container.getComponents(); if (!Arrays.asList(oldComponents).equals(components)) { forceReinstall = true; } if (forceReinstall) { container.removeAll(); GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.gridy = 100; c.weightx = 1; c.weighty = 1; c.fill = GridBagConstraints.BOTH; for (JComponent jc : components) { container.add(jc, c); if (tabs.getTabPlacement() == SwingConstants.LEFT) { c.gridy--; } else if (tabs.getTabPlacement() == SwingConstants.RIGHT) { c.gridy++; } else { c.gridx++; } jc.removeComponentListener(extraComponentListener); jc.addComponentListener(extraComponentListener); for (Component oldComponent : oldComponents) { if (components.contains(oldComponent)) { oldComponent .removeComponentListener(extraComponentListener); } } } container.revalidate(); } refreshExtraContainerVisibility(); }
Example #15
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 #16
Source File: NationTypeDetailPanel.java From freecol with GNU General Public License v2.0 | 5 votes |
/** * Builds the details panel for the given nation type. * * @param nationType - the IndianNationType * @param panel the panel to use */ private void buildIndianNationTypeDetail(IndianNationType nationType, JPanel panel) { List<RandomChoice<UnitType>> skills = nationType.getSkills(); panel.setLayout(new MigLayout("wrap 2, gapx 20", "", "")); JLabel name = Utility.localizedHeaderLabel(nationType, FontLibrary.FontSize.SMALL); panel.add(name, "span, align center, wrap 40"); panel.add(Utility.localizedLabel("colopedia.nationType.aggression")); panel.add(Utility.localizedLabel("colopedia.nationType." + nationType.getAggression().getKey())); panel.add(Utility.localizedLabel("colopedia.nationType.settlementNumber")); panel.add(Utility.localizedLabel("colopedia.nationType." + nationType.getNumberOfSettlements().getKey())); panel.add(Utility.localizedLabel("colopedia.nationType.typeOfSettlements")); panel.add(new JLabel(Messages.getName(nationType.getCapitalType()), new ImageIcon(getImageLibrary() .getScaledSettlementTypeImage(nationType.getCapitalType())), SwingConstants.CENTER)); List<String> regionNames = toList(map(nationType.getRegions(), n -> Messages.getName(n))); panel.add(Utility.localizedLabel("colopedia.nationType.regions")); panel.add(new JLabel(join(", ", regionNames))); panel.add(Utility.localizedLabel("colopedia.nationType.skills"), "top, newline 20"); GridLayout gridLayout = new GridLayout(0, 2); gridLayout.setHgap(10); JPanel unitPanel = new JPanel(gridLayout); unitPanel.setOpaque(false); for (RandomChoice<UnitType> choice : skills) { unitPanel.add(getUnitButton(choice.getObject())); } panel.add(unitPanel); }
Example #17
Source File: MaskTable.java From snap-desktop with GNU General Public License v3.0 | 5 votes |
VisibilityHR() { ImageIcon icon = UIUtils.loadImageIcon("icons/EyeIcon10.gif"); this.setBorder(UIManager.getBorder("TableHeader.cellBorder")); this.setText(null); this.setIcon(icon); this.setHorizontalAlignment(SwingConstants.CENTER); this.setPreferredSize(this.getPreferredSize()); }
Example #18
Source File: JTabbedPaneJavaElementTest.java From marathonv5 with Apache License 2.0 | 5 votes |
protected JComponent makeTextPanel(String text) { JPanel panel = new JPanel(false); JLabel filler = new JLabel(text); filler.setHorizontalAlignment(SwingConstants.CENTER); panel.setLayout(new GridLayout(1, 1)); panel.add(filler); return panel; }
Example #19
Source File: IOPortTip.java From drmips with GNU General Public License v3.0 | 5 votes |
/** * Constructor. * @param id Identifier of the input/output. * @param value Value in the input/output. */ public IOPortTip(String id, String value) { super(); this.id = id; setFont(FONT); setForeground(TEXT_COLOR); setBackground(BACKGROUND_COLOR); setOpaque(true); setBorder(BorderFactory.createLineBorder(BORDER_COLOR)); setVerticalAlignment(SwingConstants.CENTER); setValue(value); }
Example #20
Source File: FlatTableHeaderUI.java From FlatLaf with Apache License 2.0 | 5 votes |
@Override public void paintBorder( Component c, Graphics g, int x, int y, int width, int height ) { if( origBorder != null ) origBorder.paintBorder( c, g, x, y, width, height ); if( sortIcon != null ) { int xi = x + ((width - sortIcon.getIconWidth()) / 2); int yi = (sortIconPosition == SwingConstants.TOP) ? y + UIScale.scale( 1 ) : y + height - sortIcon.getIconHeight() - 1 // for gap - (int) (1 * UIScale.getUserScaleFactor()); // for bottom border sortIcon.paintIcon( c, g, xi, yi ); } }
Example #21
Source File: NumberPercentRenderer.java From visualvm with GNU General Public License v2.0 | 5 votes |
public NumberPercentRenderer(ProfilerRenderer renderer) { valueRenderer = renderer; percentRenderer = new PercentRenderer() { public void setForeground(Color foreground) { if (foreground == null) foreground = Color.BLACK; super.setForeground(UIUtils.getDisabledForeground(foreground)); } public Dimension getPreferredSize() { if (percentSize == null) percentSize = super.getPreferredSize(); return percentSize; } }; percentRenderer.changeFontSize(-1); percentRenderer.setMargin(3, 0, 3, 3); percentRenderer.setHorizontalAlignment(SwingConstants.TRAILING); percentRenderer.setMaxValue(100); percentRenderer.setValue(9999, -1); int fixedWidth = percentRenderer.getPreferredSize().width; percentSize.width = fixedWidth; renderers = new ProfilerRenderer[] { valueRenderer, percentRenderer }; setOpaque(true); setHorizontalAlignment(SwingConstants.TRAILING); }
Example #22
Source File: bug6416920.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) { if(OSInfo.getOSType() != OSInfo.OSType.WINDOWS){ return; } bug6416920 test = new bug6416920(); test.layout.padSelectedTab(SwingConstants.TOP, 0); if (test.rects[0].width < 0) { throw new RuntimeException("A selected tab isn't painted properly " + "in the scroll tab layout under WindowsLookAndFeel " + "in Windows' \"Windows XP\" theme."); } }
Example #23
Source File: LWLabelPeer.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Converts {@code Label} alignment constant to the {@code JLabel} constant. * If wrong Label alignment provided returns default alignment. * * @param alignment {@code Label} constant. * * @return {@code JLabel} constant. */ private static int convertAlignment(final int alignment) { switch (alignment) { case Label.CENTER: return SwingConstants.CENTER; case Label.RIGHT: return SwingConstants.RIGHT; default: return SwingConstants.LEFT; } }
Example #24
Source File: JavaViewHierarchyRandomTest.java From netbeans with Apache License 2.0 | 5 votes |
public void testGap() throws Exception { loggingOn(); RandomTestContainer container = createContainer(); JEditorPane pane = container.getInstance(JEditorPane.class); Document doc = pane.getDocument(); doc.putProperty("mimeType", "text/plain"); ViewHierarchyRandomTesting.initRandomText(container); ViewHierarchyRandomTesting.addRound(container).setOpCount(OP_COUNT); RandomTestContainer.Context context = container.context(); // Clear document contents DocumentTesting.insert(context, 0, "a\tb\tc\td\te\tf\n"); EditorPaneTesting.setCaretOffset(context, 1); DocumentTesting.insert(context, 1, "x"); EditorPaneTesting.setCaretOffset(context, 5); EditorPaneTesting.typeChar(context, 'y'); EditorPaneTesting.moveOrSelect(context, SwingConstants.EAST, true); EditorPaneTesting.typeChar(context, 'z'); EditorPaneTesting.moveOrSelect(context, SwingConstants.WEST, true); EditorPaneTesting.moveOrSelect(context, SwingConstants.WEST, true); EditorPaneTesting.moveOrSelect(context, SwingConstants.WEST, true); EditorPaneTesting.typeChar(context, 'u'); // EditorPaneTesting.moveOrSelect(context, SwingConstants.NORTH, true); // EditorPaneTesting.typeChar(context, 'y'); // EditorPaneTesting.performAction(context, pane, DefaultEditorKit.deleteNextCharAction); DocumentTesting.undo(context, 1); DocumentTesting.redo(context, 1); DocumentTesting.undo(context, 2); }
Example #25
Source File: JSpinField.java From MeteoInfo with GNU Lesser General Public License v3.0 | 5 votes |
/** * JSpinField constructor with given minimum and maximum vaues and initial * value 0. */ public JSpinField(int min, int max) { super(); setName("JSpinField"); this.min = min; if (max < min) max = min; this.max = max; value = 0; if (value < min) value = min; if (value > max) value = max; darkGreen = new Color(0, 150, 0); setLayout(new BorderLayout()); textField = new JTextField(); textField.addCaretListener(this); textField.addActionListener(this); textField.setHorizontalAlignment(SwingConstants.RIGHT); textField.setBorder(BorderFactory.createEmptyBorder()); textField.setText(Integer.toString(value)); textField.addFocusListener(this); spinner = new JSpinner() { private static final long serialVersionUID = -6287709243342021172L; private JTextField textField = new JTextField(); public Dimension getPreferredSize() { Dimension size = super.getPreferredSize(); return new Dimension(size.width, textField.getPreferredSize().height); } }; spinner.setEditor(textField); spinner.addChangeListener(this); // spinner.setSize(spinner.getWidth(), textField.getHeight()); add(spinner, BorderLayout.CENTER); }
Example #26
Source File: HeaderCell.java From gcs with Mozilla Public License 2.0 | 5 votes |
/** Create a new header cell. */ public HeaderCell() { super(SwingConstants.CENTER); mSortSequence = -1; mSortAscending = true; mAllowSort = true; }
Example #27
Source File: TestTextPosInPrint.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private static void doTest() throws Exception { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); f = new JFrame(); f.setLocationRelativeTo(null); panel = new JPanel(); panel.setLayout(new BorderLayout()); Font font = new Font("Serif", Font.PLAIN, 12); JLabel l1 = new JLabel(" 1. ABCDE"); l1.setHorizontalAlignment(SwingConstants.LEFT); JLabel l2 = new JLabel(" 2. ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"); l2.setHorizontalAlignment(SwingConstants.LEFT); //JLabel l3 = new JLabel(" 3. ABCDE "); JLabel l3 = new JLabel(" 3. ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"); l3.setHorizontalAlignment(SwingConstants.LEFT); panel.add(BorderLayout.NORTH, l1); panel.add(BorderLayout.CENTER, l2); panel.add(BorderLayout.SOUTH, l3); f.getContentPane().add(BorderLayout.NORTH, panel); f.setSize(400, 300); f.setVisible(true); job.setPrintable(new TestTextPosInPrint()); if (job.printDialog()) { try { job.print(); } catch (PrinterException pe) { throw new RuntimeException(pe); } } }
Example #28
Source File: ScrollAction.java From netbeans with Apache License 2.0 | 5 votes |
private int getDefaultIncrement() { Component content = scrollPane.getViewport().getView(); Point position = scrollPane.getViewport().getViewPosition(); int increment = isHorizontal ? 30 : 8; Dimension viewSize = scrollPane.getViewport().getExtentSize(); if( content instanceof Scrollable ) { increment = ((Scrollable)content).getScrollableUnitIncrement( new Rectangle( position, viewSize ), isHorizontal ? SwingConstants.HORIZONTAL : SwingConstants.VERTICAL, isScrollLeft ? -1 : 1 ); } return increment; }
Example #29
Source File: IOStatPostParser.java From nmonvisualizer with Apache License 2.0 | 5 votes |
protected void addComponents(JPanel content, GridBagConstraints labelConstraints, GridBagConstraints fieldConstraints) { date = new JSpinner(new SpinnerDateModel(new Date(TimeHelper.today()), null, null, Calendar.DAY_OF_WEEK)); date.setEditor(new DateEditor(date, "MMM dd yyyy")); JLabel dateLabel = new JLabel("Date:"); dateLabel.setFont(Styles.LABEL); dateLabel.setHorizontalAlignment(SwingConstants.TRAILING); content.add(dateLabel, labelConstraints); content.add(date, fieldConstraints); }
Example #30
Source File: ProfilerTable.java From netbeans with Apache License 2.0 | 5 votes |
static boolean isLeadingAlign(Component component) { int alignment; if (component instanceof ProfilerRenderer) { alignment = ((ProfilerRenderer)component).getHorizontalAlignment(); } else if (component instanceof JLabel) { alignment = ((JLabel)component).getHorizontalAlignment(); } else { alignment = SwingConstants.LEADING; } return alignment == SwingConstants.LEADING || alignment == SwingConstants.LEFT || alignment == SwingConstants.CENTER; }