Java Code Examples for javax.swing.JLabel#setBorder()

The following examples show how to use javax.swing.JLabel#setBorder() . 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: AbstractPlUmlEditor.java    From netbeans-mmd-plugin with Apache License 2.0 6 votes vote down vote up
@Nonnull
protected JLabel makeLinkLabel(@Nonnull final String text, @Nonnull final Runnable onClick,
                               @Nonnull final String toolTip, @Nonnull final Icon icon) {
  final JLabel result = new JLabel(text, icon, JLabel.RIGHT);
  final Font font = result.getFont().deriveFont(Font.BOLD);
  final Map attributes = font.getAttributes();
  attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
  result.setFont(font.deriveFont(attributes));
  result.setForeground(UiUtils.DARK_THEME ? Color.YELLOW : Color.BLUE);
  result.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
  result.setToolTipText(toolTip);
  result.addMouseListener(new MouseAdapter() {
    @Override
    public void mouseClicked(@Nonnull final MouseEvent e) {
      onClick.run();
    }
  });
  result.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 16));
  return result;
}
 
Example 2
Source File: SettingsPropertyPanel.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Creates a panel with a heading.
 *
 * @param labelText
 *            The text for the heading
 *
 * @return The panel
 */
private JPanel createSubGroupPanel(String labelText) {
	JLabel subGroupLabel = new JLabel();
	Font font = subGroupLabel.getFont();
	font = font.deriveFont(Font.BOLD, 14f);
	subGroupLabel.setFont(font);
	subGroupLabel.setForeground(SettingsTabs.COLOR_SUBGROUP);
	subGroupLabel.setText(labelText);
	int top = SUBGROUP_TOP_MARGIN;
	if (isFirstSubGroup) {
		isFirstSubGroup = false;
		top = FIRST_SUBGROUP_TOP_MARGIN;
	}
	subGroupLabel.setBorder(BorderFactory.createEmptyBorder(top, 0, 7, 0));

	JPanel subGroupPanel = new JPanel();
	subGroupPanel.setLayout(new BoxLayout(subGroupPanel, BoxLayout.LINE_AXIS));
	subGroupPanel.add(subGroupLabel);
	subGroupPanel.add(Box.createHorizontalGlue());
	return subGroupPanel;
}
 
Example 3
Source File: ImageCombatViewer.java    From magarena with GNU General Public License v3.0 6 votes vote down vote up
public ImageCombatViewer(final SwingGameController aController) {
    controller = aController;
    controller.registerChoiceViewer(this);

    setLayout(new BorderLayout(6,0));
    setOpaque(false);

    final JPanel leftPanel=new JPanel(new BorderLayout());
    leftPanel.setOpaque(false);
    add(leftPanel,BorderLayout.WEST);

    if (MagicStyle.getTheme().hasValue(Theme.ICON_SMALL_COMBAT)) {
        final JLabel combatLabel = new JLabel(MagicStyle.getTheme().getIcon(Theme.ICON_SMALL_COMBAT));
        combatLabel.setOpaque(true);
        combatLabel.setBackground(MagicStyle.getTheme().getColor(Theme.COLOR_ICON_BACKGROUND));
        combatLabel.setPreferredSize(new Dimension(24, 24));
        combatLabel.setBorder(FontsAndBorders.BLACK_BORDER);
        leftPanel.add(combatLabel, BorderLayout.NORTH);
    }

    permanentsViewer=new ImagePermanentsViewer(controller);
    add(permanentsViewer,BorderLayout.CENTER);
}
 
Example 4
Source File: SummaryCellRenderer.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public Component getListCellRendererComponent (JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
    Action[] actions = ((AbstractSummaryView.ActionsItem) value).getParent().getUserData().getActions();
    id = ((AbstractSummaryView.ActionsItem) value).getItemId();
    removeAll();
    labels = new HashMap<Component, Action>(actions.length);
    Component comp = dlcr.getListCellRendererComponent(list, "<html><a href=\"action\">ACTION_NAME</a>", index, isSelected, cellHasFocus); //NOI18N
    setBackground(comp.getBackground());
    for (Action a : actions) {
        JLabel label = getLabelFor((String) a.getValue(Action.NAME), isSelected ? comp.getForeground() : LINK_COLOR);
        label.setForeground(comp.getForeground());
        label.setBackground(comp.getBackground());
        label.setBorder(BorderFactory.createEmptyBorder());
        labels.put(label, a);
        add(label);
    }
    if (linkerSupport.getLinker(ActionHyperlink.class, id) == null) {
        linkerSupport.add(new ActionHyperlink(), id);
    }
    return this;
}
 
Example 5
Source File: OverviewPanelProvider.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
private JPanel initTermCountsPanel() {
  JPanel panel = new JPanel(new BorderLayout());
  panel.setOpaque(false);

  JLabel label = new JLabel(MessageUtils.getLocalizedMessage("overview.label.available_fields"));
  label.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0));
  panel.add(label, BorderLayout.PAGE_START);

  TableUtils.setupTable(termCountsTable, ListSelectionModel.SINGLE_SELECTION, new TermCountsTableModel(),
      new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
          listeners.selectField(e);
        }
      }, TermCountsTableModel.Column.NAME.getColumnWidth(), TermCountsTableModel.Column.TERM_COUNT.getColumnWidth());
  JScrollPane scrollPane = new JScrollPane(termCountsTable);
  panel.add(scrollPane, BorderLayout.CENTER);

  panel.setOpaque(false);
  return panel;
}
 
Example 6
Source File: IncludedFractionsDesktopPane.java    From ET_Redux with Apache License 2.0 5 votes vote down vote up
private void ShowTitle() {

        JLabel includedFractions_label = new javax.swing.JLabel();
        includedFractions_label.setBackground(new java.awt.Color(102, 102, 102));
        includedFractions_label.setForeground(new java.awt.Color(255, 255, 255));
        includedFractions_label.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        includedFractions_label.setText("Included Fractions");
        includedFractions_label.setBorder(
                javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        includedFractions_label.setOpaque(true);
        includedFractions_label.setBounds(0, 0, getWidth(), 18);
        add(includedFractions_label, javax.swing.JLayeredPane.DEFAULT_LAYER);

    }
 
Example 7
Source File: AggregatorTableController.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private void addDataRow(AggregatorItem ac) {
    EmptyBorder emptyBorder = new EmptyBorder(2, 2, 2, 2);

    JLabel typeLabel = new JLabel(getTypeText(ac));
    typeLabel.setBorder(emptyBorder);

    JLabel sourceBandsLabel = new JLabel(getSourceBandsText(ac));
    sourceBandsLabel.setBorder(emptyBorder);

    JLabel parametersLabel = new JLabel(getParametersText(ac));
    parametersLabel.setBorder(emptyBorder);

    JLabel targetBandsLabel = new JLabel(getTargetBandsText(ac));
    targetBandsLabel.setBorder(emptyBorder);

    final AbstractButton editButton = ToolButtonFactory.createButton(UIUtils.loadImageIcon("/org/esa/snap/resources/images/icons/Edit16.gif"),
                                                                     false);
    editButton.setRolloverEnabled(true);
    editButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            int rowIndex = grid.findDataRowIndex(editButton);
            editAggregatorItem(aggregatorItems.get(rowIndex), rowIndex);
        }
    });

    grid.addDataRow(
        /*1*/ typeLabel,
        /*2*/ sourceBandsLabel,
        /*3*/ parametersLabel,
        /*4*/ targetBandsLabel,
        /*5*/ editButton);

    aggregatorItems.add(ac);
}
 
Example 8
Source File: MeasurementSetPanel.java    From opensim-gui with Apache License 2.0 5 votes vote down vote up
public static JPanel getTitleLabel() {
   JPanel titlePanel = new JPanel();
   titlePanel.setLayout(new BoxLayout(titlePanel, BoxLayout.X_AXIS));

   titlePanel.add(Box.createRigidArea(new Dimension(1,HEIGHT)));

   JLabel measurementsLabel = new JLabel("Measurements");
   measurementsLabel.setHorizontalAlignment(SwingConstants.CENTER);
   measurementsLabel.setBorder(measurementControlsBorder);
   Dimension dim = new Dimension(BUTTON_WIDTH+MEASUREMENT_NAME_WIDTH+2,HEIGHT);
   measurementsLabel.setMinimumSize(dim);
   measurementsLabel.setMaximumSize(dim);
   measurementsLabel.setPreferredSize(dim);
   titlePanel.add(measurementsLabel);

   JLabel markerPairsLabel = new JLabel("Marker Pairs");
   markerPairsLabel.setHorizontalAlignment(SwingConstants.CENTER);
   markerPairsLabel.setBorder(markerPairControlsBorder);
   markerPairsLabel.setMinimumSize(new Dimension(0,HEIGHT));
   markerPairsLabel.setMaximumSize(new Dimension(9999,HEIGHT));
   markerPairsLabel.setPreferredSize(dim);
   titlePanel.add(markerPairsLabel);

   titlePanel.add(Box.createRigidArea(new Dimension(1,HEIGHT)));

   return titlePanel;
}
 
Example 9
Source File: SplashScreen.java    From chipster with MIT License 5 votes vote down vote up
public SplashScreen(Icon icon) {
	frame = new JFrame();
	frame.setLayout(null);
	frame.setUndecorated(true);		
	frame.setSize(icon.getIconWidth(), icon.getIconHeight()+TEXT_HEIGHT);
	frame.setLocationRelativeTo(null);  
	frame.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
	frame.getRootPane().setBorder(new LineBorder(VisualConstants.SPLASH_BORDER_COLOR, 1));
	
	JLabel imageLabel = new JLabel(icon);
	imageLabel.setSize(icon.getIconWidth(), icon.getIconHeight());
	frame.add(imageLabel);
	imageLabel.setLocation(0, 0);
	textLabel = new JLabel();
	textLabel.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10));
	
	textLabel.setFont(VisualConstants.SPLASH_SCREEN_FONT);
	
	textPanel = new JPanel(new BorderLayout());
	textPanel.setLocation(0, icon.getIconHeight());
	textPanel.setSize(icon.getIconWidth(), TEXT_HEIGHT);
	textPanel.setBackground(Color.WHITE);
	textPanel.setOpaque(true);
	textPanel.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, VisualConstants.SPLASH_BORDER_COLOR));
	textPanel.add(textLabel);
	
	frame.add(textPanel);
	frame.setVisible(true);
}
 
Example 10
Source File: DayChooser.java    From javamoney-examples with Apache License 2.0 5 votes vote down vote up
public
void
doMouseEvent(MouseEvent event)
{
  JLabel label = (JLabel)event.getSource();

  if(label.isEnabled() == true)
  {
    if(Integer.parseInt(label.getText()) != getSelectedDay())
    {
      if(event.getID() == MOUSE_CLICKED && event.getButton() == BUTTON1)
      {
        getCalendar().set(DATE, Integer.valueOf(label.getText()).intValue());
        displayDays();

        getActionSignaler().sendSignal(DayChooser.this, ACTION_DAY_SELECTED);
      }
      else if(event.getID() == MOUSE_ENTERED)
      {
        label.setBorder(BORDER_SELECTED);
      }
      else if(event.getID() == MOUSE_EXITED)
      {
        label.setBorder(BORDER_NORMAL);
      }
    }
    else if(event.getClickCount() == 2)
    {
      getActionSignaler().sendSignal(DayChooser.this, ACTION_DAY_CHOSEN);
    }
  }
}
 
Example 11
Source File: FileBasedCache.java    From sc2gears with Apache License 2.0 5 votes vote down vote up
/**
 * Empties the cache: deletes all files in the cache.<br>
 * Displays a modal info dialog about the fact that the cache is being emptied.
 * @param owner optional owner of the info dialog
 */
protected static void emptyCache_( final String cacheEntity, final Dialog owner, final String infoTextKey, final String cacheFolder ) {
	System.out.println( "Clearing " + cacheEntity + " cache..." );
	
	final JDialog infoDialog = owner == null ? new JDialog() : new JDialog( owner );
	infoDialog.setModal( true );
	infoDialog.setTitle( Language.getText( "general.infoTitle" ) );
	final JLabel infoLabel = new JLabel( Language.getText( infoTextKey ) );
	infoLabel.setFont( infoLabel.getFont().deriveFont( Font.ITALIC ) );
	infoLabel.setBorder( BorderFactory.createEmptyBorder( 25, 35, 25, 35 ) );
	infoDialog.getContentPane().add( infoLabel );
	infoDialog.pack();
	if ( owner == null )
		infoDialog.setLocationRelativeTo( null );
	else
		GuiUtils.centerWindowToWindow( infoDialog, owner );
	
	new NormalThread( cacheEntity + " cache emptier" ) {
		@Override
		public void run() {
			final File[] cacheFiles = new File( cacheFolder ).listFiles();
			if ( cacheFiles != null )
				for ( final File cacheFile : cacheFiles )
					deleteFile( cacheFile );
			
			infoDialog.dispose();
		}
	}.start();
	
	infoDialog.setVisible( true );
}
 
Example 12
Source File: NeuriteTracerResultsDialog.java    From SNT with GNU General Public License v3.0 5 votes vote down vote up
private JPanel tracingPanel() {

		final JPanel tracingOptionsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
		useSnapWindow = new JCheckBox("Enable cursor [s]napping within: XY", plugin.snapCursor);
		useSnapWindow.setBorder(new EmptyBorder(0, 0, 0, 0));
		useSnapWindow.addItemListener(this);
		tracingOptionsPanel.add(useSnapWindow);

		final SpinnerModel xy_model = new SpinnerNumberModel(plugin.cursorSnapWindowXY * 2,
				SimpleNeuriteTracer.MIN_SNAP_CURSOR_WINDOW_XY, SimpleNeuriteTracer.MAX_SNAP_CURSOR_WINDOW_XY * 2, 2);
		snapWindowXYsizeSpinner = new JSpinner(xy_model);
		((DefaultEditor) snapWindowXYsizeSpinner.getEditor()).getTextField().setEditable(false);
		snapWindowXYsizeSpinner.addChangeListener(this);
		tracingOptionsPanel.add(snapWindowXYsizeSpinner);

		final JLabel z_spinner_label = leftAlignedLabel("Z", isStackAvailable());
		z_spinner_label.setBorder(new EmptyBorder(0, 2, 0, 0));
		tracingOptionsPanel.add(z_spinner_label);
		final SpinnerModel z_model = new SpinnerNumberModel(plugin.cursorSnapWindowZ * 2,
				SimpleNeuriteTracer.MIN_SNAP_CURSOR_WINDOW_Z, SimpleNeuriteTracer.MAX_SNAP_CURSOR_WINDOW_Z * 2, 2);
		snapWindowZsizeSpinner = new JSpinner(z_model);
		((DefaultEditor) snapWindowZsizeSpinner.getEditor()).getTextField().setEditable(false);
		snapWindowZsizeSpinner.addChangeListener(this);
		snapWindowZsizeSpinner.setEnabled(isStackAvailable());
		tracingOptionsPanel.add(snapWindowZsizeSpinner);
		// tracingOptionsPanel.setBorder(new EmptyBorder(0, 0, 0, 0));
		return tracingOptionsPanel;
	}
 
Example 13
Source File: HelpSubtitlesDialog.java    From dualsub with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void initComponents() {
	// Features
	final int marginLeft = 23;
	this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
	this.setResizable(false);
	getContentPane().setLayout(new BorderLayout());
	JPanel panel = new JPanel();
	panel.setLayout(null);
	panel.setPreferredSize(new Dimension(getWidth(), getHeight() + 620));
	panel.setBackground(parent.getBackground());
	JScrollPane scroll = new JScrollPane(panel,
			JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
			JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
	getContentPane().add(scroll);

	// Title
	final String title = I18N.getHtmlText("Window.mergeButton.text");
	setTitle(I18N.getText("Window.name.text"));
	JLabel lblTitle = new JLabel(title);
	lblTitle.setFont(new Font("Lucida", Font.BOLD, 20));
	lblTitle.setBounds(marginLeft, 21, 435, 25);
	panel.add(lblTitle);

	// Content
	JLabel lblContent01 = new JLabel(
			I18N.getHtmlText("HelpSubtitlesDialog.help.01"));
	lblContent01.setBounds(marginLeft, 50, 435, 40);
	panel.add(lblContent01);

	ImageIcon sampleIcon = new ImageIcon(
			ClassLoader.getSystemResource("img/vlc-1.1.11-sample.png"));
	JLabel sampleLabel = new JLabel();
	sampleLabel.setIcon(sampleIcon);
	sampleLabel.setBounds(marginLeft, 90, 435, 334);
	panel.add(sampleLabel);

	ImageIcon sampleIcon2 = new ImageIcon(
			ClassLoader.getSystemResource("img/vlc-2.1.15-sample.png"));
	JLabel sampleLabel2 = new JLabel();
	sampleLabel2.setIcon(sampleIcon2);
	sampleLabel2.setBounds(marginLeft, 424, 435, 318);
	panel.add(sampleLabel2);

	JLabel lblContent02 = new JLabel(
			I18N.getHtmlText("HelpSubtitlesDialog.help.02"));
	lblContent02.setBounds(marginLeft, 742, 435, 100);
	panel.add(lblContent02);

	JLabel lblContent03 = new JLabel(
			I18N.getHtmlText("HelpSubtitlesDialog.help.03"));
	lblContent03.setBounds(marginLeft, 842, 435, 60);
	panel.add(lblContent03);

	JLabel lblContent04 = new JLabel(
			I18N.getHtmlText("HelpSubtitlesDialog.help.04"));
	lblContent04.setBounds(marginLeft, 902, 435, 140);
	panel.add(lblContent04);

	// Borders (for debug purposes)
	if (log.isTraceEnabled()) {
		Border border = BorderFactory.createLineBorder(Color.black);
		lblTitle.setBorder(border);
		lblContent01.setBorder(border);
		lblContent02.setBorder(border);
		lblContent03.setBorder(border);
		lblContent04.setBorder(border);
		panel.setBorder(border);
	}
}
 
Example 14
Source File: RevokedCertsTableCellRend.java    From keystore-explorer with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Returns the rendered cell.
 *
 * @param jtRevokedCerts
 *            The JTable
 * @param value
 *            The value to assign to the cell
 * @param isSelected
 *            True if cell is selected
 * @param row
 *            The row of the cell to render
 * @param col
 *            The column of the cell to render
 * @param hasFocus
 *            If true, render cell appropriately
 * @return The renderered cell
 */
@Override
public Component getTableCellRendererComponent(JTable jtRevokedCerts, Object value, boolean isSelected,
		boolean hasFocus, int row, int col) {
	JLabel cell = (JLabel) super.getTableCellRendererComponent(jtRevokedCerts, value, isSelected, hasFocus, row,
			col);

	if (col == 0) {
		cell.setText(formatSerialNumberAsHexString((BigInteger) value));
	} else {
		cell.setText(StringUtils.formatDate((Date) value));
	}

	cell.setBorder(new EmptyBorder(0, 5, 0, 5));

	return cell;
}
 
Example 15
Source File: ImportClassPanel.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/** Creates new form ImportClassPanel */
   public ImportClassPanel(List<TypeElement> priviledged, List<TypeElement> denied, Font font, JavaSource javaSource, int position, JTextComponent target ) {
       // System.err.println("priviledged=" + priviledged);
       // System.err.println("denied=" + denied);
       this.javaSource = javaSource;
       this.position = position;
       this.target = target;
       createModel(priviledged, denied);
       initComponents();
       setBackground(jList1.getBackground());
       
       if ( model.size() > 0) {
           jList1.setModel( model );
           setFocusable(false);        
           setNextFocusableComponent(jList1);
           jScrollPane1.setBackground( jList1.getBackground() );
           setBackground( jList1.getBackground() );
           if ( font != null ) {
               jList1.setFont(font);
           }
           int modelSize = jList1.getModel().getSize();
           if ( modelSize > 0 ) {
               jList1.setSelectedIndex(0);            
           }
           jList1.setVisibleRowCount( modelSize > 8 ? 8 : modelSize );
           jList1.setCellRenderer( new Renderer( jList1 ) );
           jList1.grabFocus();
       }
       else {            
           remove( jScrollPane1 );
           JLabel nothingFoundJL = new JLabel("<No Classes Found>");
           if ( font != null ) {
               nothingFoundJL.setFont(font);
           }
           nothingFoundJL.setBorder(javax.swing.BorderFactory.createEmptyBorder(2, 4, 4, 4));
           nothingFoundJL.setEnabled(false);
           nothingFoundJL.setBackground(jList1.getBackground());
           //nothingFoundJL.setOpaque(true);
           add( nothingFoundJL );
       }

setA11Y();
   }
 
Example 16
Source File: VCardEditor.java    From Spark with Apache License 2.0 4 votes vote down vote up
/**
    * Displays a users profile.
    * 
    * @param jid
    *            the jid of the user.
    * @param vcard
    *            the users vcard.
    * @param parent
    *            the parent component, used for location handling.
    */
   public void displayProfile(final BareJid jid, VCard vcard, JComponent parent) {
VCardViewer viewer = new VCardViewer(jid);

final JFrame dlg = new JFrame(Res.getString("title.view.profile.for",
	jid));

avatarLabel = new JLabel();
avatarLabel.setHorizontalAlignment(JButton.RIGHT);
avatarLabel.setBorder(BorderFactory.createBevelBorder(0, Color.white,
	Color.lightGray));

// The user should only be able to close this dialog.
Object[] options = { Res.getString("button.view.profile"),
	Res.getString("close") };
final JOptionPane pane = new JOptionPane(viewer,
	JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null,
	options, options[0]);

// mainPanel.add(pane, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0,
// GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 5,
// 5, 5), 0, 0));

dlg.setIconImage(SparkRes.getImageIcon(SparkRes.PROFILE_IMAGE_16x16)
	.getImage());

dlg.pack();
dlg.setSize(350, 250);
dlg.setResizable(true);
dlg.setContentPane(pane);
dlg.setLocationRelativeTo(parent);

PropertyChangeListener changeListener = new PropertyChangeListener() {
    @Override
	public void propertyChange(PropertyChangeEvent e) {
	if (pane.getValue() instanceof Integer) {
	    pane.removePropertyChangeListener(this);
	    dlg.dispose();
	    return;
	}
	String value = (String) pane.getValue();
	if (Res.getString("close").equals(value)) {
	    pane.removePropertyChangeListener(this);
	    dlg.dispose();
	} else if (Res.getString("button.view.profile").equals(value)) {
	    pane.setValue(JOptionPane.UNINITIALIZED_VALUE);
	    SparkManager.getVCardManager().viewFullProfile(jid, pane);
	}
    }
};

pane.addPropertyChangeListener(changeListener);

dlg.addKeyListener(new KeyAdapter() {
    @Override
	public void keyPressed(KeyEvent keyEvent) {
	if (keyEvent.getKeyChar() == KeyEvent.VK_ESCAPE) {
	    dlg.dispose();
	}
    }
});

dlg.setVisible(true);
dlg.toFront();
dlg.requestFocus();
   }
 
Example 17
Source File: DateInterpretationsDesktopPane.java    From ET_Redux with Apache License 2.0 4 votes vote down vote up
private void ShowDateInterpretationPanel(
        AliquotInterface aliquot,
        ValueModel sampleDateModel,
        int width,
        int offset) {

    JPanel ageInterpPanel = new JPanel();
    if (((SampleDateModel)sampleDateModel).isPreferred()){
        ageInterpPanel.setBackground(new java.awt.Color(255, 204, 204));
    }else {
        ageInterpPanel.setBackground(new java.awt.Color(255, 255, 204));
    }

    org.jdesktop.layout.GroupLayout jPanel1Layout =
            new org.jdesktop.layout.GroupLayout(ageInterpPanel);
    ageInterpPanel.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(
            org.jdesktop.layout.GroupLayout.LEADING).add(0, width, Short.MAX_VALUE));
    jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(
            org.jdesktop.layout.GroupLayout.LEADING).add(0, 100, Short.MAX_VALUE));

    ageInterpPanel.setBounds(0, offset * 120 + 25, width, 100);

    JLabel aliquotName_label = new JLabel();
    aliquotName_label.setHorizontalAlignment(SwingConstants.CENTER);
    aliquotName_label.setBorder(
            javax.swing.BorderFactory.createLineBorder(Color.black));
    aliquotName_label.setText(
            "Aliquot: " + aliquot.getAliquotName().trim());
    aliquotName_label.setSize(width, 10);


    try {
        JLabel ageInterpName_label = new JLabel(sampleDateModel.getName());
        org.jdesktop.layout.GroupLayout ageInterpPanelLayout =
                new org.jdesktop.layout.GroupLayout(ageInterpPanel);
        ageInterpPanel.setLayout(ageInterpPanelLayout);
        ageInterpPanelLayout.setHorizontalGroup(
                ageInterpPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(ageInterpPanelLayout.createSequentialGroup().add(ageInterpName_label).addContainerGap(161, Short.MAX_VALUE)).add(aliquotName_label, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 206, Short.MAX_VALUE));
        ageInterpPanelLayout.setVerticalGroup(
                ageInterpPanelLayout.createParallelGroup(//
                org.jdesktop.layout.GroupLayout.LEADING).//
                add(ageInterpPanelLayout.createSequentialGroup().//
                add(aliquotName_label).//
                //addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).//
                add(ageInterpName_label).//
                addContainerGap(60, Short.MAX_VALUE)));
    } catch (Exception e) {
    }


    add(ageInterpPanel);//, javax.swing.JLayeredPane.DEFAULT_LAYER);
}
 
Example 18
Source File: BrowserMenu.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void fillContent( JPanel contentPanel ) {
    contentPanel.setLayout( new GridBagLayout() );

    WebBrowser activeBrowser = selectedBrowser;
    ArrayList<ListItemImpl> defaultItems = new ArrayList<>( browsers.size() );
    ArrayList<ListItemImpl> mobileItems = new ArrayList<>( browsers.size() );
    ArrayList<ListItemImpl> phoneGapItems = new ArrayList<>( browsers.size() );
    ListItem selItem = null;
    for( WebBrowser browser : browsers ) {
        ListItemImpl item = new ListItemImpl( browser );
        if( null != activeBrowser && activeBrowser.getId().equals( browser.getId() ) ) {
            selItem = item;
        }
        if( BrowserFamilyId.PHONEGAP.equals( browser.getBrowserFamily() ) ) {
            phoneGapItems.add( item );
        } else if( browser.getBrowserFamily().isMobile() ) {
            mobileItems.add( item );
        } else {
            defaultItems.add( item );
        }
    }

    addSection( contentPanel, defaultItems, NbBundle.getMessage(BrowserMenu.class, "Header_BROWSER"), 0, null, mobileItems.isEmpty() && phoneGapItems.isEmpty() );
    addSection( contentPanel, mobileItems, NbBundle.getMessage(BrowserMenu.class, "Header_MOBILE"), 2, null, phoneGapItems.isEmpty() );
    addSection( contentPanel, phoneGapItems, NbBundle.getMessage(BrowserMenu.class, "Header_PHONEGAP"), 4, createConfigureButton(), true );

    JPanel panel = createBrighterPanel();
    JLabel label = createLabel( NbBundle.getMessage(BrowserMenu.class, "Hint_NB_Connector"));
    Color lightForeground = UIManager.getColor( "Nb.browser.picker.foreground.light" ); //NOI18N
    if( null != lightForeground )
        label.setForeground( lightForeground );
    if( windowsLaF ) {
        label.setEnabled( false );
        panel.setBorder( BorderFactory.createMatteBorder( 1, 0, 0, 0, windowsSeparatorColor));
    }
    label.setBorder( BorderFactory.createEmptyBorder( 16, 17, 5, 5));
    panel.add( label, BorderLayout.WEST );

    contentPanel.add( panel, new GridBagConstraints( 0, 1, GridBagConstraints.REMAINDER, 1, 0.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0,0,0,0), 0, 0 ));

    if( !defaultItems.isEmpty() && !mobileItems.isEmpty() && !windowsLaF ) {
        contentPanel.add( new JSeparator(JSeparator.VERTICAL),
                new GridBagConstraints( 1, 1, 1, 3, 0.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.VERTICAL, new Insets(0,0,0,0), 0, 0 ));
    }

    if( !mobileItems.isEmpty() && !phoneGapItems.isEmpty() && !windowsLaF ) {
        contentPanel.add( new JSeparator(JSeparator.VERTICAL),
                new GridBagConstraints( 3, 1, 1, 3, 0.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.VERTICAL, new Insets(0,0,0,0), 0, 0 ));
    }

    if( !phoneGapItems.isEmpty() ) {
        contentPanel.add( createLabel( NbBundle.getMessage(BrowserMenu.class, "Hint_PhoneGap")),
                new GridBagConstraints( 0, 4, GridBagConstraints.REMAINDER, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10,17,10,10), 0, 0 ));
    }

    if( null != selItem )
        selModel.setSelectedItem( selItem );
    selModel.addChangeListener( this );
}
 
Example 19
Source File: AboutDialog.java    From SubTitleSearcher with Apache License 2.0 4 votes vote down vote up
private void initComponents() {

		setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
		setIconImage(MainWin.icon);
		setSize(500, 300);
		setResizable(false);

		setLocationRelativeTo(this.getParent());
		setTitle("About " + AppConfig.appTitle);

		JPanel mainPanel = new JPanel(new BorderLayout());
		add(mainPanel);

		JPanel leftPanel = new JPanel();
		mainPanel.add(leftPanel, BorderLayout.WEST);

		ImageIcon iconImg = new ImageIcon(MainWin.icon);
		iconImg.setImage(iconImg.getImage().getScaledInstance((int) (iconImg.getIconWidth() * 0.5), (int) (iconImg.getIconHeight() * 0.5), Image.SCALE_SMOOTH));
		JLabel iconLabel = new JLabel(iconImg);
		iconLabel.setBorder(BorderFactory.createEmptyBorder(6, 10, 6, 10));
		leftPanel.add(iconLabel);

		HyperlinkListener hlLsnr = new HyperlinkListener() {
			@Override
			public void hyperlinkUpdate(HyperlinkEvent e) {
				if (e.getEventType() != HyperlinkEvent.EventType.ACTIVATED)
					return;
				// 超链接标记中必须带有协议指定,e.getURL()才能得到,否则只能用e.getDescription()得到href的内容。
				// JOptionPane.showMessageDialog(InfoDialog.this, "URL:"+e.getURL()+"\nDesc:"+ e.getDescription());
				URL linkUrl = e.getURL();
				if (linkUrl != null) {
					try {
						Desktop.getDesktop().browse(linkUrl.toURI());
					} catch (Exception e1) {
						e1.printStackTrace();
						JOptionPane.showMessageDialog(AboutDialog.this, "超链接错误", "无法打开超链接:" + linkUrl + "\n详情:" + e1, JOptionPane.ERROR_MESSAGE);
					}
				} else {
					JOptionPane.showMessageDialog(AboutDialog.this, "超链接错误", "超链接信息不完整:" + e.getDescription() + "\n请确保链接带有协议信息,如http://,mailto:", JOptionPane.ERROR_MESSAGE);
				}
			}
		};

		JTextPane infoArea = new JTextPane();
		//设置css单位(px/pt)和chrome一致
		infoArea.putClientProperty(JTextPane.W3C_LENGTH_UNITS, true);
		infoArea.addHyperlinkListener(hlLsnr);
		infoArea.setContentType("text/html");
		infoArea.setText(getInfo());
		infoArea.setEditable(false);
		infoArea.setBorder(BorderFactory.createEmptyBorder(2, 10, 6, 10));
		infoArea.setFocusable(false);

		JScrollPane infoAreaScrollPane = new JScrollPane(infoArea);
		infoAreaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
		infoAreaScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
		infoAreaScrollPane.getViewport().setBackground(Color.WHITE);
		mainPanel.add(infoAreaScrollPane, BorderLayout.CENTER);

	}
 
Example 20
Source File: LibraryTreePanel.java    From osp with GNU General Public License v3.0 4 votes vote down vote up
MetadataComboBoxEditor() {
	super(BoxLayout.X_AXIS);
	keyEditField = new MetadataEditField(keyFieldWidth) {
		protected String getDefaultText() {
			return metadata==emptyMetadata? ToolsRes.getString("LibraryTreePanel.Metadata.Name"): null; //$NON-NLS-1$
		}
  	protected Font getEmptyFont() {
  		return font.deriveFont(Font.BOLD+Font.ITALIC);
  	}     	
  	protected Font getDefaultFont() {
  		return font.deriveFont(Font.BOLD);
  	}      	
	};
  entryFields.add(keyEditField);

	keyEditField.setHorizontalAlignment(SwingConstants.RIGHT);
	keyEditField.setFont(keyEditField.getDefaultFont());
	
	valueEditField = new MetadataEditField(0) {
		protected String getDefaultText() {
			return metadata==emptyMetadata? ToolsRes.getString("LibraryTreePanel.Metadata.Value"): null; //$NON-NLS-1$
		}
  	protected Font getEmptyFont() {
  		return font.deriveFont(Font.ITALIC);
  	}     	
  	protected Font getDefaultFont() {
  		return font.deriveFont(Font.PLAIN);
  	}      	
	};
  entryFields.add(valueEditField);
	
	Border border = BorderFactory.createCompoundBorder(keyEditField.getBorder(), BorderFactory.createEmptyBorder(0, 1, 0, 1));
	keyEditField.setBorder(border);
	valueEditField.setBorder(border);

	spacer = new JLabel();
	spacer.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 2));
	add(keyEditField);
	add(spacer);
	add(valueEditField);
}