javax.swing.JLabel Java Examples

The following examples show how to use javax.swing.JLabel. 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: LegendPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
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 #2
Source File: GameboardGUI.java    From Spark with Apache License 2.0 6 votes vote down vote up
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 #3
Source File: NaturalPanel.java    From EchoSim with Apache License 2.0 6 votes vote down vote up
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 #4
Source File: NPComponentUtils.java    From Swing9patch with Apache License 2.0 6 votes vote down vote up
/**
 * 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 File: WorldTableRow.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
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 #6
Source File: SchemaTreeTraverser.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 #7
Source File: SignalButton.java    From Ardulink-2 with Apache License 2.0 6 votes vote down vote up
/**
 * 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 #8
Source File: Test6968363.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
@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 #9
Source File: ParameterTableRenderer.java    From RobotBuilder with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@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 #10
Source File: DefaultLogAxisEditor.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * 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 #11
Source File: CodeSetupPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@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 #12
Source File: IntroPanel.java    From littleluck with Apache License 2.0 6 votes vote down vote up
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 #13
Source File: UICalculatorInputArea.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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 #14
Source File: SwingLogPanel.java    From org.alloytools.alloy with Apache License 2.0 6 votes vote down vote up
/** 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 #15
Source File: LargeIconsDisplayer.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
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 #16
Source File: ProxySettingsForm.java    From azure-devops-intellij with MIT License 6 votes vote down vote up
/**
 * @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 #17
Source File: Help.java    From Scripts with GNU General Public License v3.0 5 votes vote down vote up
/** Adds a customized heading to the specified panel. */
void addHeaderLabel(final JPanel p, final String label) {
	final JLabel lbl = new JLabel(label);
	lbl.setForeground(Color.DARK_GRAY);
	lbl.setBorder(new EmptyBorder(10, 3, 0, 0));
	final Font lblFont = lbl.getFont();
	lbl.setFont(lblFont.deriveFont((float) (lblFont.getSize() - 1.5)));
	p.add(lbl);
}
 
Example #18
Source File: MainPanel.java    From freecol with GNU General Public License v2.0 5 votes vote down vote up
/**
 * The constructor that will add the items to this panel.
 *
 * @param freeColClient The {@code FreeColClient} for the game.
 */
public MainPanel(FreeColClient freeColClient) {
    super(freeColClient, null,
          new MigLayout("wrap 1, insets n n 20 n", "[center]"));

    boolean canContinue = FreeColDirectories
        .getLastSaveGameFile() != null;

    ActionManager am = getFreeColClient().getActionManager();
    JButton newButton = new JButton(am.getFreeColAction(NewAction.id));
    JButton openButton = new JButton(am.getFreeColAction(OpenAction.id));
    JButton mapEditorButton = new JButton(am.getFreeColAction(MapEditorAction.id));
    JButton optionsButton = new JButton(am.getFreeColAction(PreferencesAction.id));
    JButton aboutButton = new JButton(am.getFreeColAction(AboutAction.id));
    JButton quitButton = new JButton(am.getFreeColAction(QuitAction.id));

    setCancelComponent(quitButton);
    okButton.setAction(am.getFreeColAction((canContinue)
            ? ContinueAction.id
            : NewAction.id));

    JLabel logoLabel = new JLabel(new ImageIcon(ImageLibrary
            .getUnscaledImage("image.flavor.Title")));
    logoLabel.setBorder(new CompoundBorder(new EmptyBorder(2,2,0,2),
            new BevelBorder(BevelBorder.LOWERED)));
    add(logoLabel);

    add(okButton, "newline 20, width 70%");
    if (canContinue) add(newButton, "width 70%");
    add(openButton, "width 70%");
    add(mapEditorButton, "width 70%");
    add(optionsButton, "width 70%");
    add(aboutButton, "width 70%");
    add(quitButton, "width 70%");

    setSize(getPreferredSize());
}
 
Example #19
Source File: NoWebServiceClientsPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** 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 #20
Source File: SwingStrategySelectionPanel.java    From atdl4j with MIT License 5 votes vote down vote up
public JPanel buildStrategySelectionPanel(Window aParentContainer, Atdl4jOptions atdl4jOptions)
{
	setAtdl4jOptions( atdl4jOptions );
	
	JPanel panel = new JPanel(new BorderLayout());
	// label
	JLabel strategiesDropDownLabel = new JLabel("Strategy");
	panel.add( strategiesDropDownLabel, BorderLayout.WEST );

	// dropDownList
	strategiesDropDown = new JComboBox();
	strategiesDropDown.setEditable( false );
	
	panel.add(strategiesDropDown, BorderLayout.CENTER);

	if ( Atdl4jConfig.getConfig().getStrategyDropDownItemDepth() != null )
	{
		strategiesDropDown.setMaximumRowCount( Atdl4jConfig.getConfig().getStrategyDropDownItemDepth().intValue() );
	}
	// tooltip
	strategiesDropDown.setToolTipText("Select a Strategy");
	// action listener
	strategiesDropDown.addItemListener( new ItemListener()	{

		@Override
		public void itemStateChanged(ItemEvent e) {
			if (e.getStateChange() == ItemEvent.SELECTED) {
			    firePreStrategySelectedEvent();
				int index = strategiesDropDown.getSelectedIndex();
				selectDropDownStrategy( index );
			}
		}
	} );

	return panel;
}
 
Example #21
Source File: HubRegistrationDialog.java    From arcusplatform with Apache License 2.0 5 votes vote down vote up
@Override
protected Component createContents() {
   JLabel label = new JLabel("Waiting for the hub to be registered, this will wait indefinitely, hit 'Cancel' to exit.");
   JButton cancel = new JButton("Cancel");
   cancel.addActionListener((e) -> this.dispose());
   
   JPanel panel = new JPanel(new BorderLayout());
   panel.add(label, BorderLayout.CENTER);
   panel.add(cancel, BorderLayout.SOUTH);
   return panel;
}
 
Example #22
Source File: RoarPreferencePanel.java    From Spark with Apache License 2.0 5 votes vote down vote up
private JPanel makeGroupChatPanel() {
    JPanel groupPanel = new JPanel();
    groupPanel.setLayout(new GridBagLayout());
    groupPanel.setBorder(BorderFactory.createTitledBorder(RoarResources.getString("roar.group")));

    final JCheckBox enableDifferentGroup = new JCheckBox(RoarResources.getString("roar.group.different"));
    JCheckBox disableGroup = new JCheckBox(RoarResources.getString("roar.group.disable"));
    JTextField durationGroup = new JTextField();

    enableDifferentGroup.addActionListener( e -> toggleDifferentSettingsForGroup(enableDifferentGroup.isSelected()) );

    int rowcount = 0;
    groupPanel.add(enableDifferentGroup,
            new GridBagConstraints(0, rowcount, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, INSETS, 0, 0));

    rowcount++;
    groupPanel.add(new JLabel(RoarResources.getString("roar.duration")),
            new GridBagConstraints(0, rowcount, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, INSETS, 0, 0));
    groupPanel.add(durationGroup,
            new GridBagConstraints(1, rowcount, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, INSETS, 0, 0));

    rowcount++;
    groupPanel.add(disableGroup,
            new GridBagConstraints(0, rowcount, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, INSETS, 0, 0));

    _components.put("group.different.enabled", enableDifferentGroup);
    _components.put("group.duration", durationGroup);
    _components.put("group.disable", disableGroup);

    return groupPanel;
}
 
Example #23
Source File: JColorTable.java    From jeveassets with GNU General Public License v2.0 5 votes vote down vote up
public MyComboBox() {

			jPanel = new JPanel();

			GroupLayout layout = new GroupLayout(jPanel);
			jPanel.setLayout(layout);
			layout.setAutoCreateGaps(false);
			layout.setAutoCreateContainerGaps(false);

			jDefault = new JNullableLabel();
			jDefault.setHorizontalAlignment(JLabel.CENTER);
			jDefault.setVerticalAlignment(JLabel.CENTER);
			jDefault.setOpaque(true);

			jPickerIcon = new JLabel(Images.SETTINGS_COLOR_PICKER.getIcon());
			jPickerIcon.setHorizontalTextPosition(JLabel.CENTER);
			jPickerIcon.setHorizontalAlignment(JLabel.CENTER);
			jPickerIcon.setVerticalAlignment(JLabel.CENTER);
			jPickerIcon.setOpaque(true);

			layout.setHorizontalGroup(
			layout.createSequentialGroup()
					.addComponent(jDefault, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, Integer.MAX_VALUE)
					.addComponent(jPickerIcon, 16, 16, 16)
			);
			layout.setVerticalGroup(
				layout.createParallelGroup(GroupLayout.Alignment.LEADING)
					.addComponent(jDefault, 0, 0, Integer.MAX_VALUE)
					.addComponent(jPickerIcon, 0, 0, Integer.MAX_VALUE)
			);
		}
 
Example #24
Source File: FlatLabelUI.java    From FlatLaf with Apache License 2.0 5 votes vote down vote up
@Override
protected void installComponents( JLabel c ) {
	super.installComponents( c );

	// update HTML renderer if necessary
	updateHTMLRenderer( c, c.getText(), false );
}
 
Example #25
Source File: PluginManagerUI.java    From netbeans with Apache License 2.0 5 votes vote down vote up
void setProgressComponent (final JLabel detail, final JComponent progressComponent) {
    if (SwingUtilities.isEventDispatchThread ()) {
        setProgressComponentInAwt (detail, progressComponent);
    } else {
        SwingUtilities.invokeLater (new Runnable () {
            @Override
            public void run () {
                setProgressComponentInAwt (detail, progressComponent);
            }
        });
    }
}
 
Example #26
Source File: JBreadCrumb.java    From pumpernickel with MIT License 5 votes vote down vote up
public JBreadCrumb() {
	updateUI();
	setFormatter(new BreadCrumbFormatter<T>() {
		public void format(JBreadCrumb<T> container, JLabel label,
				T pathNode, int index) {
			label.setIcon(null);
			label.setText(pathNode.toString());
		}
	});
}
 
Example #27
Source File: ShipStatRenderer.java    From Open-Realms-of-Stars with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Component getListCellRendererComponent(
    final JList<? extends ShipStat> list, final ShipStat value,
    final int index, final boolean isSelected, final boolean cellHasFocus) {
  JLabel renderer = (JLabel) defaultRenderer.getListCellRendererComponent(
      list, value, index, isSelected, cellHasFocus);
  renderer.setFont(GuiStatics.getFontCubellan());
  StringBuilder sb = new StringBuilder();
  sb.append(value.getDesign().getName());
  sb.append(" - ");
  sb.append(value.getDesign().getHull().getSize());
  if (value.isObsolete()) {
    sb.append(" Obsoleted");
  } else {
    sb.append(" Cost/Metal: ");
    sb.append(value.getDesign().getCost());
    sb.append("/");
    sb.append(value.getDesign().getMetalCost());
  }
  renderer.setText(sb.toString());
  if (isSelected) {
    if (value.isObsolete()) {
      renderer.setForeground(GuiStatics.COLOR_GREY_TEXT);
    } else {
      renderer.setForeground(GuiStatics.COLOR_GREEN_TEXT);
    }
    renderer.setBackground(Color.BLACK);
  } else {
    if (value.isObsolete()) {
      renderer.setForeground(GuiStatics.COLOR_GREY_TEXT_DARK);
    } else {
      renderer.setForeground(GuiStatics.COLOR_GREEN_TEXT_DARK);
    }
    renderer.setBackground(Color.BLACK);
  }
  return renderer;
}
 
Example #28
Source File: GlobalSearchCategoryPanel.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Init the GUI.
 *
 * @param provider
 * 		the provider instance, must not be {@code null}
 */
private void initGUI(final GlobalSearchableGUIProvider provider) {
	setLayout(new GridBagLayout());
	GridBagConstraints gbc = new GridBagConstraints();
	setOpaque(false);
	setBorder(TOP_BORDER);

	JLabel i18nName = new JLabel();
	i18nName.setBackground(Colors.WINDOW_BACKGROUND);
	i18nName.setForeground(Color.GRAY);
	i18nName.setOpaque(true);
	i18nName.setVerticalAlignment(SwingConstants.TOP);
	i18nName.setHorizontalAlignment(SwingConstants.LEFT);
	i18nName.setFont(i18nName.getFont().deriveFont(Font.BOLD));
	i18nName.setText(provider.getI18nNameForSearchable());
	i18nName.setMinimumSize(I18N_NAME_SIZE);
	i18nName.setPreferredSize(I18N_NAME_SIZE);
	i18nName.setMaximumSize(I18N_NAME_SIZE);
	i18nName.setBorder(CATEGORY_LABEL_EMPTY_BORDER);

	gbc.gridx = 0;
	gbc.gridy = 0;
	gbc.weighty = 1.0d;
	gbc.fill = GridBagConstraints.VERTICAL;
	add(i18nName, gbc);

	contentPanel = new JPanel();
	contentPanel.setLayout(new GridBagLayout());
	contentPanel.setBorder(DIVIDER_BORDER);
	contentPanel.setBackground(Colors.WHITE);

	gbc.gridx = 1;
	gbc.weightx = 1.0d;
	gbc.weighty = 1.0d;
	gbc.fill = GridBagConstraints.BOTH;
	add(contentPanel, gbc);
}
 
Example #29
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 #30
Source File: FileChooserDemo.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@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);
}