Java Code Examples for javax.swing.JLabel
The following examples show how to use
javax.swing.JLabel. These examples are extracted from open source projects.
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 Project: netbeans Source File: CodeSetupPanel.java License: Apache License 2.0 | 6 votes |
@Override public TableCellEditor getCellEditor(int row, int column) { if(showParamTypes) { String paramName = (String) tableModel.getValueAt(row, 0); Class type = (column == 2) ? (Class) tableModel.getValueAt(row, 1) : Boolean.class; if (Enum.class.isAssignableFrom(type)) { JComboBox combo = new JComboBox(type.getEnumConstants()); return new DefaultCellEditor(combo); } else if (type == Boolean.class || type == Boolean.TYPE) { JCheckBox cb = new JCheckBox(); cb.setHorizontalAlignment(JLabel.CENTER); cb.setBorderPainted(true); return new DefaultCellEditor(cb); } else if (paramName.toLowerCase().contains(Constants.PASSWORD)) { return new DefaultCellEditor(new JPasswordField()); } } return super.getCellEditor(row, column); }
Example 2
Source Project: Ardulink-2 Source File: SignalButton.java License: Apache License 2.0 | 6 votes |
/** * Create the panel. */ public SignalButton() { setLayout(new BorderLayout(0, 0)); signalButton = new JButton("Send"); signalButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { link.sendCustomMessage(getId(), getValue()); } }); add(signalButton); valuePanel = new JPanel(); add(valuePanel, BorderLayout.NORTH); valueLabel = new JLabel("Value:"); valuePanel.add(valueLabel); textField = new JTextField(); valuePanel.add(textField); textField.setColumns(10); textField.setMinimumSize(getPreferredSize()); }
Example 3
Source Project: plugins Source File: WorldTableRow.java License: GNU General Public License v3.0 | 6 votes |
private JPanel buildPingField(Integer ping) { JPanel column = new JPanel(new BorderLayout()); column.setBorder(new EmptyBorder(0, 5, 0, 5)); pingField = new JLabel("-"); pingField.setFont(FontManager.getRunescapeSmallFont()); column.add(pingField, BorderLayout.EAST); if (ping != null) { setPing(ping); } return column; }
Example 4
Source Project: Swing9patch Source File: NPComponentUtils.java License: Apache License 2.0 | 6 votes |
/** * Creates a new N9Component object. * * @param text the text * @param n9 the n9 * @param is the is * @param foregroundColor the foreground color * @param f the f * @return the j label */ public static JLabel createLabel_root(String text , final NinePatch n9, Insets is , Color foregroundColor, Font f) { JLabel l = new JLabel(text){ public void paintComponent(Graphics g) { n9.draw((Graphics2D)g, 0, 0, this.getWidth(), this.getHeight()); super.paintComponent(g); } }; if(is != null) l.setBorder(BorderFactory.createEmptyBorder(is.top, is.left, is.bottom, is.right)); if(foregroundColor != null) l.setForeground(foregroundColor); if(f != null) l.setFont(f); return l; }
Example 5
Source Project: EchoSim Source File: NaturalPanel.java License: Apache License 2.0 | 6 votes |
private void initLayout() { setLayout(new BorderLayout()); add("Center", new JScrollPane(mTranscript, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER)); JPanel inputBar = new JPanel(); add("South", inputBar); inputBar.setLayout(new TableLayout()); inputBar.add("1,1", new JLabel("Say:")); inputBar.add("+,. fill=h", mInput); inputBar.add("+,.", mSend); inputBar.add("+,.", mStartSession); inputBar.add("+,.", mEndSession); inputBar.add("+,.", mClear); }
Example 6
Source Project: azure-devops-intellij Source File: ProxySettingsForm.java License: MIT License | 6 votes |
/** * @noinspection ALL */ private void $$$loadLabelText$$$(JLabel component, String text) { StringBuffer result = new StringBuffer(); boolean haveMnemonic = false; char mnemonic = '\0'; int mnemonicIndex = -1; for (int i = 0; i < text.length(); i++) { if (text.charAt(i) == '&') { i++; if (i == text.length()) break; if (!haveMnemonic && text.charAt(i) != '&') { haveMnemonic = true; mnemonic = text.charAt(i); mnemonicIndex = result.length(); } } result.append(text.charAt(i)); } component.setText(result.toString()); if (haveMnemonic) { component.setDisplayedMnemonic(mnemonic); component.setDisplayedMnemonicIndex(mnemonicIndex); } }
Example 7
Source Project: org.alloytools.alloy Source File: SwingLogPanel.java License: Apache License 2.0 | 6 votes |
/** Set the font name. */ public void setFontName(String fontName) { if (log == null) return; this.fontName = fontName; log.setFont(new Font(fontName, Font.PLAIN, fontSize)); StyleConstants.setFontFamily(styleRegular, fontName); StyleConstants.setFontFamily(styleBold, fontName); StyleConstants.setFontFamily(styleRed, fontName); StyleConstants.setFontSize(styleRegular, fontSize); StyleConstants.setFontSize(styleBold, fontSize); StyleConstants.setFontSize(styleRed, fontSize); // Changes all existing text StyledDocument doc = log.getStyledDocument(); Style temp = doc.addStyle("temp", null); StyleConstants.setFontFamily(temp, fontName); StyleConstants.setFontSize(temp, fontSize); doc.setCharacterAttributes(0, doc.getLength(), temp, false); // Changes all existing hyperlinks Font newFont = new Font(fontName, Font.BOLD, fontSize); for (JLabel link : links) { link.setFont(newFont); } }
Example 8
Source Project: Spark Source File: GameboardGUI.java License: Apache License 2.0 | 6 votes |
public GameboardGUI() { ClassLoader cl = getClass().getClassLoader(); _bg = new ImageIcon(cl.getResource("water.png")).getImage(); setLayout(new GridLayout(10,10)); _labels = new JLabel[10][10]; for(int x =0 ; x<10;x++) { for(int y=0 ;y < 10; y++) { _labels[x][y] = new JLabel("empty"); _labels[x][y].setBorder(BorderFactory.createLineBorder(Color.lightGray)); add(_labels[x][y]); } } this.setPreferredSize(new Dimension(400,400)); }
Example 9
Source Project: jdk8u_jdk Source File: Test6968363.java License: GNU General Public License v2.0 | 6 votes |
@Override public void run() { if (this.frame == null) { Thread.setDefaultUncaughtExceptionHandler(this); this.frame = new JFrame(getClass().getSimpleName()); this.frame.add(NORTH, new JLabel("Copy Paste a HINDI text into the field below")); this.frame.add(SOUTH, new JTextField(new MyDocument(), "\u0938", 10)); this.frame.pack(); this.frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); this.frame.setLocationRelativeTo(null); this.frame.setVisible(true); } else { this.frame.dispose(); this.frame = null; } }
Example 10
Source Project: littleluck Source File: IntroPanel.java License: Apache License 2.0 | 6 votes |
public IntroPanel() { setLayout(null); setOpaque(false); introImage = new JLabel(new ImageIcon( SwingSet3.class.getResource("resources/images/home_notext.png"))); introImage.setVerticalAlignment(JLabel.TOP); introText = new SlidingLabel(new ImageIcon( SwingSet3.class.getResource("resources/images/home_text.png"))); introText.setVisible(false); introImage.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent event) { slideTextIn(); } }); add(introText); add(introImage); }
Example 11
Source Project: SIMVA-SoS Source File: DefaultLogAxisEditor.java License: Apache License 2.0 | 6 votes |
/** * Creates a panel for editing the tick unit. * * @return A panel. */ @Override protected JPanel createTickUnitPanel() { JPanel tickUnitPanel = super.createTickUnitPanel(); tickUnitPanel.add(new JLabel(localizationResources.getString( "Manual_TickUnit_value"))); this.manualTickUnit = new JTextField(Double.toString( this.manualTickUnitValue)); this.manualTickUnit.setEnabled(!isAutoTickUnitSelection()); this.manualTickUnit.setActionCommand("TickUnitValue"); this.manualTickUnit.addActionListener(this); this.manualTickUnit.addFocusListener(this); tickUnitPanel.add(this.manualTickUnit); tickUnitPanel.add(new JPanel()); return tickUnitPanel; }
Example 12
Source Project: TencentKona-8 Source File: SchemaTreeTraverser.java License: GNU General Public License v2.0 | 6 votes |
/** * Simple constructor. */ public SchemaTreeCellRenderer() { FlowLayout fl = new FlowLayout(FlowLayout.LEFT, 1, 1); this.setLayout(fl); this.iconLabel = new JLabel(); this.iconLabel.setOpaque(false); this.iconLabel.setBorder(null); this.add(this.iconLabel); // add some space this.add(Box.createHorizontalStrut(5)); this.nameLabel = new JLabel(); this.nameLabel.setOpaque(false); this.nameLabel.setBorder(null); this.nameLabel.setFont(nameFont); this.add(this.nameLabel); this.isSelected = false; this.setOpaque(false); this.setBorder(null); }
Example 13
Source Project: knopflerfish.org Source File: LargeIconsDisplayer.java License: BSD 3-Clause "New" or "Revised" License | 6 votes |
public void updateBundleComp(Bundle b) { final JLabel c = (JLabel) getBundleComponent(b); if(c == null) { addBundle(new Bundle[]{b}); return; } c.setToolTipText(Util.bundleInfo(b)); final Icon icon = Util.getBundleIcon(b); c.setIcon(icon); c.invalidate(); c.repaint(); invalidate(); repaint(); }
Example 14
Source Project: netbeans Source File: LegendPanel.java License: Apache License 2.0 | 6 votes |
private void initComponents() { setOpaque(false); setLayout(new BorderLayout()); setBorder(BorderFactory.createEmptyBorder(5, 5, 4, 5)); JPanel legendPanel = new JPanel(new FlowLayout(FlowLayout.TRAILING, 5, 0)); legendPanel.setOpaque(false); gcRootLegend = new JLabel(Bundle.ClassesListController_GcRootString(), BrowserUtils.ICON_GCROOT, SwingConstants.LEFT); gcRootLegendDivider = new JLabel("|"); // NOI18N legendPanel.add(new JLabel(Bundle.ClassesListController_ArrayTypeString(), BrowserUtils.ICON_ARRAY, SwingConstants.LEFT)); legendPanel.add(new JLabel("|")); // NOI18N legendPanel.add(new JLabel(Bundle.ClassesListController_ObjectTypeString(), BrowserUtils.ICON_INSTANCE, SwingConstants.LEFT)); legendPanel.add(new JLabel("|")); // NOI18N legendPanel.add(new JLabel(Bundle.ClassesListController_PrimitiveTypeString(), BrowserUtils.ICON_PRIMITIVE, SwingConstants.LEFT)); legendPanel.add(new JLabel("|")); // NOI18N legendPanel.add(new JLabel(Bundle.ClassesListController_StaticFieldString(), BrowserUtils.ICON_STATIC, SwingConstants.LEFT)); legendPanel.add(new JLabel("|")); // NOI18N legendPanel.add(gcRootLegend); legendPanel.add(gcRootLegendDivider); legendPanel.add(new JLabel(Bundle.ClassesListController_LoopString(), BrowserUtils.ICON_LOOP, SwingConstants.LEFT)); //add(new JLabel("Legend:"), BorderLayout.WEST); add(legendPanel, BorderLayout.EAST); }
Example 15
Source Project: RobotBuilder Source File: ParameterTableRenderer.java License: BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { final JComponent component; if (value instanceof Boolean) { JCheckBox checkBox = new JCheckBox("", (Boolean) value); component = checkBox; } else { JLabel label = new JLabel(String.valueOf(value)); label.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 0)); component = label; } if (!rowValidator.test(row)) { if (isSelected) { component.setBackground(SELECTED_INVALID_COLOR); } else { component.setBackground(INVALID_COLOR); } } else if (isSelected) { component.setBackground(SELECTED_COLOR); } component.setOpaque(true); return component; }
Example 16
Source Project: runelite Source File: UICalculatorInputArea.java License: BSD 2-Clause "Simplified" License | 6 votes |
private JTextField addComponent(String label) { final JPanel container = new JPanel(); container.setLayout(new BorderLayout()); final JLabel uiLabel = new JLabel(label); final FlatTextField uiInput = new FlatTextField(); uiInput.setBackground(ColorScheme.DARKER_GRAY_COLOR); uiInput.setHoverBackgroundColor(ColorScheme.DARK_GRAY_HOVER_COLOR); uiInput.setBorder(new EmptyBorder(5, 7, 5, 7)); uiLabel.setFont(FontManager.getRunescapeSmallFont()); uiLabel.setBorder(new EmptyBorder(0, 0, 4, 0)); uiLabel.setForeground(Color.WHITE); container.add(uiLabel, BorderLayout.NORTH); container.add(uiInput, BorderLayout.CENTER); add(container); return uiInput.getTextField(); }
Example 17
Source Project: visualvm Source File: JComponentBuilders.java License: GNU General Public License v2.0 | 5 votes |
static ComponentBuilder getBuilder(Instance instance, Heap heap) { if (DetailsUtils.isSubclassOf(instance, JLabel.class.getName())) { return new JLabelBuilder(instance, heap); } else if (DetailsUtils.isSubclassOf(instance, JPanel.class.getName())) { return new JPanelBuilder(instance, heap); } else if (DetailsUtils.isSubclassOf(instance, JToolBar.class.getName())) { return new JToolBarBuilder(instance, heap); } else if (DetailsUtils.isSubclassOf(instance, Box.Filler.class.getName())) { return new BoxFillerBuilder(instance, heap); } else if (DetailsUtils.isSubclassOf(instance, Box.class.getName())) { return new BoxBuilder(instance, heap); } else if (DetailsUtils.isSubclassOf(instance, JScrollBar.class.getName())) { return new JScrollBarBuilder(instance, heap); } else if (DetailsUtils.isSubclassOf(instance, JToolBar.Separator.class.getName())) { return new JToolBarSeparatorBuilder(instance, heap); } else if (DetailsUtils.isSubclassOf(instance, JPopupMenu.Separator.class.getName())) { return new JPopupMenuSeparatorBuilder(instance, heap); } else if (DetailsUtils.isSubclassOf(instance, JSeparator.class.getName())) { return new JSeparatorBuilder(instance, heap); } else if (DetailsUtils.isSubclassOf(instance, JProgressBar.class.getName())) { return new JProgressBarBuilder(instance, heap); } else if (DetailsUtils.isSubclassOf(instance, JSlider.class.getName())) { return new JSliderBuilder(instance, heap); } else if (DetailsUtils.isSubclassOf(instance, JSpinner.class.getName())) { return new JSpinnerBuilder(instance, heap); } else if (DetailsUtils.isSubclassOf(instance, JPopupMenu.class.getName())) { return new JPopupMenuBuilder(instance, heap); } return null; }
Example 18
Source Project: zap-extensions Source File: LaunchPanel.java License: Apache License 2.0 | 5 votes |
@Override public JPanel getDescriptionPanel() { JPanel panel = new QuickStartBackgroundPanel(); panel.add( QuickStartHelper.getWrappedLabel("quickstart.launch.panel.message1"), LayoutHelper.getGBC(0, 0, 2, 1.0D, DisplayUtils.getScaledInsets(5, 5, 5, 5))); panel.add( QuickStartHelper.getWrappedLabel("quickstart.launch.panel.message2"), LayoutHelper.getGBC(0, 1, 2, 1.0D, DisplayUtils.getScaledInsets(5, 5, 5, 5))); panel.add( new JLabel(" "), LayoutHelper.getGBC( 0, 2, 2, 1.0D, DisplayUtils.getScaledInsets(5, 5, 5, 5))); // Spacer return panel; }
Example 19
Source Project: runelite Source File: VarInspector.java License: BSD 2-Clause "Simplified" License | 5 votes |
private void addVarLog(VarType type, String name, String old, String neew) { if (!type.getCheckBox().isSelected()) { return; } int tick = client.getTickCount(); SwingUtilities.invokeLater(() -> { if (tick != lastTick) { lastTick = tick; JLabel header = new JLabel("Tick " + tick); header.setFont(FontManager.getRunescapeSmallFont()); header.setBorder(new CompoundBorder( BorderFactory.createMatteBorder(0, 0, 1, 0, ColorScheme.LIGHT_GRAY_COLOR), BorderFactory.createEmptyBorder(3, 6, 0, 0) )); tracker.add(header); } tracker.add(new JLabel(String.format("%s %s changed: %s -> %s", type.getName(), name, old, neew))); // Cull very old stuff for (; tracker.getComponentCount() > MAX_LOG_ENTRIES; ) { tracker.remove(0); } tracker.revalidate(); }); }
Example 20
Source Project: plugins Source File: BookPanel.java License: GNU General Public License v3.0 | 5 votes |
BookPanel(final Book b) { setBorder(new EmptyBorder(3, 3, 3, 3)); setBackground(ColorScheme.DARK_GRAY_COLOR); GroupLayout layout = new GroupLayout(this); this.setLayout(layout); JLabel image = new JLabel(); b.getIcon().addTo(image); JLabel name = new JLabel(b.getShortName()); location.setFont(FontManager.getRunescapeSmallFont()); layout.setVerticalGroup(layout.createParallelGroup() .addComponent(image) .addGroup(layout.createSequentialGroup() .addComponent(name) .addComponent(location) ) ); layout.setHorizontalGroup(layout.createSequentialGroup() .addComponent(image) .addGap(8) .addGroup(layout.createParallelGroup() .addComponent(name) .addComponent(location) ) ); // AWT's Z order is weird. This put image at the back of the stack setComponentZOrder(image, getComponentCount() - 1); }
Example 21
Source Project: visualvm Source File: NotSupportedDisplayer.java License: GNU General Public License v2.0 | 5 votes |
/** * Creates new instance of NotSupportedDisplayer. * * @param object type of the not supported object (any string or predefined constant). */ public NotSupportedDisplayer(String object) { JLabel notSupportedLabel = new JLabel(NbBundle.getMessage(NotSupportedDisplayer.class, "MSG_Not_supported", object), SwingConstants.CENTER); // NOI18N notSupportedLabel.setEnabled(false); setLayout(new BorderLayout()); setOpaque(false); add(notSupportedLabel, BorderLayout.CENTER); }
Example 22
Source Project: netbeans Source File: CustomizerDocumentation.java License: Apache License 2.0 | 5 votes |
/** * This method is called from within the constructor to initialize the form. WARNING: Do NOT modify this code. The content of this method is always regenerated by the Form * Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { providerLabel = new JLabel(); providerComboBox = new JComboBox<PhpDocumentationProvider>(); separator = new JSeparator(); providerPanel = new JPanel(); Mnemonics.setLocalizedText(providerLabel, NbBundle.getMessage(CustomizerDocumentation.class, "CustomizerDocumentation.providerLabel.text")); // NOI18N providerPanel.setLayout(new BorderLayout()); GroupLayout layout = new GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(separator) .addGroup(layout.createSequentialGroup() .addComponent(providerLabel) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(providerComboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addComponent(providerPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) ); layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(providerLabel) .addComponent(providerComboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(separator, GroupLayout.PREFERRED_SIZE, 10, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(providerPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); }
Example 23
Source Project: jmeter-plugins-webdriver Source File: WebDriverConfigGui.java License: Apache License 2.0 | 5 votes |
private JPanel createProxyHostAndPortPanel(JTextField proxyHost, JTextField proxyPort, String label) { JPanel httpPanel = new HorizontalPanel(); JLabel httpProxyHostLabel = new JLabel(label); httpPanel.add(httpProxyHostLabel); httpPanel.add(proxyHost); proxyHost.setEnabled(false); JLabel httpProxyPortLabel = new JLabel("Port:"); httpPanel.add(httpProxyPortLabel); httpPanel.add(proxyPort); proxyPort.setEnabled(false); return httpPanel; }
Example 24
Source Project: mars-sim Source File: ConstructionSitesPanel.java License: GNU General Public License v3.0 | 5 votes |
/** * Constructor * @param manager the settlement construction manager. */ public ConstructionSitesPanel(ConstructionManager manager) { // Use JPanel constructor. super(); this.manager = manager; setLayout(new BorderLayout()); setBorder(new MarsPanelBorder()); JPanel titlePanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); add(titlePanel, BorderLayout.NORTH); JLabel titleLabel = new JLabel("Construction Sites"); titleLabel.setFont(new Font("Serif", Font.BOLD, 16)); titlePanel.add(titleLabel); // Create scroll panel for sites list pane. sitesScrollPane = new JScrollPane(); sitesScrollPane.setPreferredSize(new Dimension(200, 75)); sitesScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); add(sitesScrollPane, BorderLayout.CENTER); // Prepare sites outer list pane. JPanel sitesOuterListPane = new JPanel(new BorderLayout(0, 0)); sitesScrollPane.setViewportView(sitesOuterListPane); // Prepare sites list pane. sitesListPane = new JPanel(); sitesListPane.setLayout(new BoxLayout(sitesListPane, BoxLayout.Y_AXIS)); sitesOuterListPane.add(sitesListPane, BorderLayout.NORTH); // Create the site panels. sitesCache = manager.getConstructionSites(); Iterator<ConstructionSite> i = sitesCache.iterator(); while (i.hasNext()) sitesListPane.add(new ConstructionSitePanel(i.next())); }
Example 25
Source Project: openjdk-8-source Source File: Test4252164.java License: GNU General Public License v2.0 | 5 votes |
private JPanel createUI() { this.rounded = new JLabel("ROUNDED"); // NON-NLS: the label for rounded border this.straight = new JLabel("STRAIGHT"); // NON-NLS: the label for straight border JPanel panel = new JPanel(); panel.add(this.rounded); panel.add(this.straight); update(10); return panel; }
Example 26
Source Project: FoxTelem Source File: DiagnosticTable.java License: GNU General Public License v3.0 | 5 votes |
DiagnosticTable(String t, String fieldName, int conversionType, GraphFrame gf, FoxSpacecraft sat) { this.conversionType = conversionType; title = t; this.fieldName = fieldName; graphFrame = gf; fox = sat; this.setLayout(new BorderLayout()); JLabel titleLabel = new JLabel(title); titleLabel.setFont(new Font("SansSerif", Font.BOLD, Config.graphAxisFontSize + 3)); add(titleLabel, BorderLayout.NORTH); table = addErrorTable(); updateData(); }
Example 27
Source Project: triplea Source File: JFrameBuilderTest.java License: GNU General Public License v3.0 | 5 votes |
@Test void locationRelativeTo() { final JLabel label = new JLabel(); label.setLocation(new Point(10, 10)); final Point defaultLocation = JFrameBuilder.builder().locateRelativeTo(label).build().getLocation(); final Point relativeLocation = JFrameBuilder.builder().build().getLocation(); assertThat( "location should change when setting position relative to another component", defaultLocation, not(equalTo(relativeLocation))); }
Example 28
Source Project: PolyGlot Source File: PLabel.java License: MIT License | 5 votes |
private Dimension getTextSize(JLabel l, Font f) { Dimension size = new Dimension(); g.setFont(f); FontMetrics fm = g.getFontMetrics(f); size.width = fm.stringWidth(l.getText()); size.height = fm.getHeight(); return size; }
Example 29
Source Project: snap-desktop Source File: CustomCrsPanel.java License: GNU General Public License v3.0 | 5 votes |
@Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { final Component component = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); JLabel label = (JLabel) component; if (value != null) { AbstractCrsProvider wrapper = (AbstractCrsProvider) value; label.setText(wrapper.getName()); } return label; }
Example 30
Source Project: hottub Source File: FileChooserDemo.java License: GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("LeakingThisInConstructor") WizardDialog(JFrame frame, boolean modal) { super(frame, "Embedded JFileChooser Demo", modal); cardLayout = new CardLayout(); cardPanel = new JPanel(cardLayout); getContentPane().add(cardPanel, BorderLayout.CENTER); messageLabel = new JLabel("", JLabel.CENTER); cardPanel.add(chooser, "fileChooser"); cardPanel.add(messageLabel, "label"); cardLayout.show(cardPanel, "fileChooser"); chooser.addActionListener(this); JPanel buttonPanel = new JPanel(); backButton = new JButton("< Back"); nextButton = new JButton("Next >"); closeButton = new JButton("Close"); buttonPanel.add(backButton); buttonPanel.add(nextButton); buttonPanel.add(closeButton); getContentPane().add(buttonPanel, BorderLayout.SOUTH); backButton.setEnabled(false); getRootPane().setDefaultButton(nextButton); backButton.addActionListener(this); nextButton.addActionListener(this); closeButton.addActionListener(this); pack(); setLocationRelativeTo(frame); }