Java Code Examples for javax.swing.JPanel

The following examples show how to use javax.swing.JPanel. 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 want to check out the right sidebar which shows the related API usage.
Example 1
@Override
public Component createPageComponent() {
    JPanel panel = new JPanel(new BorderLayout(4, 4));
    panel.setBorder(new EmptyBorder(4, 4, 4, 4));
    panel.add(new JLabel("Available layers:"), BorderLayout.NORTH);

    LayerSourcePageContext context = getContext();
    modelCRS = (CoordinateReferenceSystem) context.getLayerContext().getCoordinateReferenceSystem();

    WMSCapabilities wmsCapabilities = (WMSCapabilities) context.getPropertyValue(
            WmsLayerSource.PROPERTY_NAME_WMS_CAPABILITIES);
    layerTree = new JTree(new WmsTreeModel(wmsCapabilities.getLayer()));
    layerTree.setRootVisible(false);
    layerTree.setShowsRootHandles(true);
    layerTree.setExpandsSelectedPaths(true);
    layerTree.setCellRenderer(new MyDefaultTreeCellRenderer());
    layerTree.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    layerTree.getSelectionModel().addTreeSelectionListener(new LayerTreeSelectionListener());
    panel.add(new JScrollPane(layerTree), BorderLayout.CENTER);
    infoLabel = new JLabel(" ");
    panel.add(infoLabel, BorderLayout.SOUTH);
    getContext().setPropertyValue(WmsLayerSource.PROPERTY_NAME_SELECTED_LAYER, null);
    return panel;
}
 
Example 2
Source Project: ramus   Source File: StatusPanel.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * This method initializes this
 *
 * @return void
 */
private void initialize() {
    double[][] size = {{5, TableLayout.FILL, 5},
            {5, TableLayout.FILL, 5}};
    this.setLayout(new TableLayout(size));
    final GridLayout gridLayout3 = new GridLayout();
    JPanel child = new JPanel(gridLayout3);
    this.setSize(351, 105);
    gridLayout3.setRows(3);
    gridLayout3.setColumns(2);
    gridLayout3.setHgap(5);
    gridLayout3.setVgap(5);
    child.add(getJRadioButton(), null);
    child.add(getJRadioButton1(), null);
    child.add(getJRadioButton2(), null);
    child.add(getJRadioButton3(), null);
    child.add(getJRadioButton4(), null);
    child.add(getJTextField(), null);
    this.add(child, "1,1");
}
 
Example 3
Source Project: openjdk-8-source   Source File: TestObject.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void validate(XMLDecoder decoder) {
    JPanel panel = (JPanel) decoder.readObject();
    if (2 != panel.getComponents().length) {
        throw new Error("unexpected component count");
    }
    JButton button = (JButton) panel.getComponents()[0];
    if (!button.getText().equals("button")) { // NON-NLS: hardcoded in XML
        throw new Error("unexpected button text");
    }
    if (SwingConstants.CENTER != button.getVerticalAlignment()) {
        throw new Error("unexpected vertical alignment");
    }
    JLabel label = (JLabel) panel.getComponents()[1];
    if (!label.getText().equals("label")) { // NON-NLS: hardcoded in XML
        throw new Error("unexpected label text");
    }
    if (button != label.getLabelFor()) {
        throw new Error("unexpected component");
    }
}
 
Example 4
Source Project: netbeans   Source File: DocumentsDlg.java    License: Apache License 2.0 6 votes vote down vote up
private JPanel createListView () {
    JPanel panel = new JPanel();
    // Defined size in #36907 - surrounding controls will add to this size
    // and result is desired 540x400. Note that we can't hardcode size of
    // whole dialog to work correctly with different font size
    panel.setPreferredSize(new Dimension(375, 232));
    panel.setLayout(new BorderLayout());
    listView = new ListView();
    // proper border for the view
    listView.setBorder((Border)UIManager.get("Nb.ScrollPane.border")); // NOI18N
    listView.setPopupAllowed(false);
    listView.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(DocumentsDlg.class, "ACSD_ListView"));
    //view.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    listView.getInputMap( JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT ).put( KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "closeSelected") ;//NOI18N
    listView.getActionMap().put( "closeSelected", new AbstractAction() {//NOI18N
        @Override
        public void actionPerformed( ActionEvent e ) {
            closeDocuments(e );
        }

    });
    panel.add(listView, BorderLayout.CENTER);
    return panel;
}
 
Example 5
Source Project: bigtable-sql   Source File: AboutBoxDialog.java    License: Apache License 2.0 6 votes vote down vote up
private JPanel createButtonBar()
	{
		_closeBtn.addActionListener(new ActionListener()
		{
			public void actionPerformed(ActionEvent evt)
			{
				setVisible(false);
			}
		});

		final ButtonBarBuilder builder = new ButtonBarBuilder();
		builder.addGlue();
//		builder.addGridded(new JButton("Alter"));
//		builder.addRelatedGap();
		builder.addGridded(_closeBtn);

		return builder.getPanel();
	}
 
Example 6
Source Project: megamek   Source File: GameOptionsDialog.java    License: GNU General Public License v2.0 6 votes vote down vote up
public void refreshOptions() {
    panOptions.removeAll();
    optionComps = new HashMap<>();

    for (Enumeration<IOptionGroup> i = options.getGroups(); i.hasMoreElements();) {
        IOptionGroup group = i.nextElement();

        JPanel groupPanel = addGroup(group);

        for (Enumeration<IOption> j = group.getOptions(); j.hasMoreElements();) {
            IOption option = j.nextElement();
            addOption(groupPanel, option);
        }
    }

    addSearchPanel();

    // Make the width accomadate the longest game option label
    // without needing to scroll horizontally.
    setSize(Math.max(getSize().width, maxOptionWidth + 30), Math.max(getSize().height, 400));

    validate();
}
 
Example 7
Source Project: ramus   Source File: SectorNameEditor.java    License: GNU General Public License v3.0 6 votes vote down vote up
private Component getReplacemetPanel() {
    JPanel group = new JPanel(new GridLayout(0, 1));
    group.setBorder(BorderFactory.createTitledBorder(ResourceLoader
            .getString("ArrowReplacementType.name")));
    group.add(safe = new JRadioButton("ArrowReplacementType.safe"));
    group.add(children = new JRadioButton("ArrowReplacementType.branching"));
    group.add(all = new JRadioButton("ArrowReplacementType.everywhere"));
    safe.setSelected(true);

    ButtonGroup g = new ButtonGroup();
    g.add(children);
    g.add(all);
    g.add(safe);

    setReplaceEnable(false);

    return group;
}
 
Example 8
Source Project: netbeans   Source File: FmtOptions.java    License: Apache License 2.0 6 votes vote down vote up
protected CategorySupport(String mimeType, Defaults.Provider provider, Preferences preferences, String id,
        JPanel panel, String previewText, String[]... forcedOptions) {
    this.mimeType = mimeType;
    this.provider = provider;
    this.preferences = preferences;
    this.id = id;
    this.panel = panel;
    this.previewText = previewText != null ? previewText : NbBundle.getMessage(FmtOptions.class, "SAMPLE_Default"); //NOI18N

    // Scan the panel for its components
    scan(panel, components);

    // Initialize the preview preferences
    Preferences forcedPrefs = new PreviewPreferences();
    for (String[] option : forcedOptions) {
        forcedPrefs.put( option[0], option[1]);
    }
    this.previewPrefs = new ProxyPreferences(preferences, forcedPrefs);

    // Load and hook up all the components
    loadFrom(preferences);
    addListeners();
}
 
Example 9
Source Project: zap-extensions   Source File: ClientComponent.java    License: Apache License 2.0 6 votes vote down vote up
protected void initUi() {
    // Common
    buttonShowView =
            new JToggleButton(
                    new ImageIcon(
                            HttpPanelComponentInterface.class.getResource(
                                    ExtensionPlugNHack.CLIENT_ACTIVE_ICON_RESOURCE)));

    buttonShowView.setToolTipText(BUTTON_TOOL_TIP);

    panelOptions = new JPanel();
    panelOptions.add(views.getSelectableViewsComponent());

    informationLabel = new JLabel();
    panelMoreOptions = new JPanel();
    panelMoreOptions.add(informationLabel);

    initViews();

    // All
    panelMain = new JPanel(new BorderLayout());
    panelMain.add(views.getViewsPanel());

    setSelected(false);
}
 
Example 10
Source Project: runelite   Source File: ClockTabPanel.java    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
private JPanel createHeaderPanel(String title, String type, boolean largePadding, ActionListener actionListener)
{
	JPanel panel = new JPanel(new BorderLayout());
	panel.setBorder(new EmptyBorder(largePadding ? 11 : 0, 0, 0, 0));
	panel.setBackground(ColorScheme.DARK_GRAY_COLOR);

	JLabel headerLabel = new JLabel(title);
	headerLabel.setForeground(Color.WHITE);
	headerLabel.setFont(FontManager.getRunescapeSmallFont());
	panel.add(headerLabel, BorderLayout.CENTER);

	JButton addButton = new JButton(ADD_ICON);
	addButton.setRolloverIcon(ADD_ICON_HOVER);
	SwingUtil.removeButtonDecorations(addButton);
	addButton.setPreferredSize(new Dimension(14, 14));
	addButton.setToolTipText("Add a " + type);
	addButton.addActionListener(actionListener);
	panel.add(addButton, BorderLayout.EAST);

	return panel;
}
 
Example 11
Source Project: jsyn   Source File: InstrumentBrowser.java    License: Apache License 2.0 6 votes vote down vote up
public InstrumentBrowser(InstrumentLibrary library) {
    this.library = library;
    JPanel horizontalPanel = new JPanel();
    horizontalPanel.setLayout(new GridLayout(1, 2));

    final JList<VoiceDescription> instrumentList = new JList<VoiceDescription>(library.getVoiceDescriptions());
    setupList(instrumentList);
    instrumentList.addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting() == false) {
                int n = instrumentList.getSelectedIndex();
                if (n >= 0) {
                    showPresetList(n);
                }
            }
        }
    });

    JScrollPane listScroller1 = new JScrollPane(instrumentList);
    listScroller1.setPreferredSize(new Dimension(250, 120));
    add(listScroller1);

    instrumentList.setSelectedIndex(0);
}
 
Example 12
Source Project: ramus   Source File: AttributeEditorPanel.java    License: GNU General Public License v3.0 6 votes vote down vote up
public AttributeEditorPanel() {
    super(new BorderLayout());
    okc = new JPanel(new GridLayout(1, 3, 5, 0));

    JButton ok = new JButton(okAction);

    cancel = new JButton(cancelAction);

    apply = new JButton(applyAction);

    addOk(ok, okc);
    okc.add(apply);
    okc.add(cancel);
    JPanel panel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 5, 5));
    panel.add(okc);
    this.add(panel, BorderLayout.SOUTH);
    setAttributeEditor(null, null, null, null, false, null);
}
 
Example 13
protected JPanel createDefaultFieldsPanel() {
    JPanel fieldsPanel = new JPanel();

    GroupLayout layout = new GroupLayout(fieldsPanel);
    fieldsPanel.setLayout(layout);
    layout.setAutoCreateGaps(true);

    layout.setHorizontalGroup(
            layout.createSequentialGroup()
                    .addComponent(getCharsetLabel())
                    .addComponent(getCharsetComboBox()));

    layout.setVerticalGroup(
            layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(getCharsetLabel())
                    .addComponent(getCharsetComboBox()));
    return fieldsPanel;
}
 
Example 14
Source Project: jdk8u-jdk   Source File: Test6657026.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    UIManager.setLookAndFeel(new MetalLookAndFeel());

    ThreadGroup group = new ThreadGroup("$$$");
    Thread thread = new Thread(group, new Test6657026());
    thread.start();
    thread.join();

    new JInternalFrame().setContentPane(new JPanel());
}
 
Example 15
Source Project: jacamo   Source File: SchemeDisplay.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
public SchemeDisplay(String title){
    setTitle(".:: "+title+" SCHEME-MANAGEMENT CONSOLE ::.");
    setSize(400,400);

    JPanel panel = new JPanel();
    setContentPane(panel);
    panel.setLayout(new BoxLayout(panel,BoxLayout.Y_AXIS));

    JPanel p1 = new JPanel();
    p1.add(new JLabel("Scheme name"));
    schemeName = new JTextField(10);
    p1.add(schemeName);
    panel.add(p1);

    JPanel p2 = new JPanel();
    commitMission = new JButton("commitMission");
    missionToCommit = new JTextField(10);
    p2.add(commitMission);
    p2.add(missionToCommit);
    panel.add(p2);

    JPanel p3 = new JPanel();
    leaveMission = new JButton("leaveMission");
    missionToLeave = new JTextField(10);
    p3.add(leaveMission);
    p3.add(missionToLeave);
    panel.add(p3);

    JPanel p4 = new JPanel();
    goalAchieved = new JButton("goalAchieved");
    goalToAchieve = new JTextField(10);
    p4.add(goalAchieved);
    p4.add(goalToAchieve);
    panel.add(p4);

}
 
Example 16
Source Project: netbeans   Source File: VCSCommitPanel.java    License: Apache License 2.0 5 votes vote down vote up
static Component makeHorizontalStrut(JComponent compA,
                                          JComponent compB,
                                          ComponentPlacement relatedUnrelated,
                                          JPanel parent) {
        int width = LayoutStyle.getInstance().getPreferredGap(
                            compA,
                            compB,
                            relatedUnrelated,
                            WEST,
                            parent);
        return Box.createHorizontalStrut(width);
}
 
Example 17
Source Project: zap-extensions   Source File: EncodeDecodeDialog.java    License: Apache License 2.0 5 votes vote down vote up
private void addOutputPanel(OutputPanelModel outputPanelModel, int tabIndex) {
    Component component = getTabbedPane().getComponentAt(tabIndex);
    if (component instanceof JPanel) {
        JPanel parentPanel = (JPanel) component;
        TabModel foundTab = getTabByIndex(tabIndex);
        foundTab.getOutputPanels().add(outputPanelModel);
        ZapTextArea outputField = newField(false);
        addField(parentPanel, outputField, createOutputPanelTitle(outputPanelModel));
        updateEncodeDecodeField(outputField, outputPanelModel);
    }
}
 
Example 18
public final static void main(String[] args){
	System.out.println("draw wedges");
	
	JPanel panel = new CheckPolyCirculinearCurve2DGetParallel2();
	panel.setPreferredSize(new Dimension(500, 400));
	JFrame frame = new JFrame("Draw parallel polyline");
	frame.setContentPane(panel);
	frame.pack();
	frame.setVisible(true);		
}
 
Example 19
private void initGUI() {
	setLayout(new BorderLayout(0, 0));
	calc = new MTGDeckManager();
	table = new JXTable();
	
	
	add(new JScrollPane(table), BorderLayout.CENTER);
	JPanel panel = new JPanel();
	panel.setBackground(Color.WHITE);
	add(panel, BorderLayout.NORTH);

	JLabel lblDrawProbability = new JLabel(MTGControler.getInstance().getLangService().getCapitalize("DRAW_PROBABILITIES"));
	lblDrawProbability.setFont(MTGControler.getInstance().getFont().deriveFont(Font.BOLD, 14));
	panel.add(lblDrawProbability);
}
 
Example 20
/**
 * Adds a tab that contains the given component as well as the injection button on the bottom
 *
 * @param group
 * 		the group that is used for i18n and {@link #getInjectableParameters(ConnectionParameterGroupModel)}
 * @param component
 * 		the content of the tab without the inject functionality
 */
protected void addInjectableTab(ConnectionParameterGroupModel group, JComponent component) {
	JPanel panelAndInject = new JPanel(new GridBagLayout());
	GridBagConstraints c = new GridBagConstraints();
	if (component == null) {
		return;
	}

	c.anchor = GridBagConstraints.WEST;
	c.weighty = 1;
	c.weightx = 1;
	c.fill = GridBagConstraints.BOTH;
	c.gridx = 0;
	c.anchor = GridBagConstraints.NORTHWEST;
	panelAndInject.add(component, c);

	if (getConnectionModel().isEditable()) {
		c.weighty = 0;
		panelAndInject.add(new JSeparator(JSeparator.HORIZONTAL), c);

		c.anchor = GridBagConstraints.SOUTHWEST;
		panelAndInject.add(getInjectionPanel(() -> getInjectableParameters(group)), c);
	}

	String typeKey = getConnectionModel().getType();
	String groupKey = group.getName();
	String title = ConnectionI18N.getGroupName(typeKey, groupKey, ConnectionI18N.LABEL_SUFFIX, groupKey);
	String tip = ConnectionI18N.getGroupName(typeKey, groupKey, ConnectionI18N.TIP_SUFFIX, null);
	Icon icon = ConnectionI18N.getGroupIcon(typeKey, groupKey);

	getTabbedPane().addTab(title, icon, panelAndInject, tip);
}
 
Example 21
Source Project: TencentKona-8   Source File: Test4252164.java    License: GNU General Public License v2.0 5 votes vote down vote up
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 22
Source Project: jdal   Source File: ApplicationContextGuiFactory.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public JPanel getPanel(String name) {
	Object bean = context.getBean(name);
	if (bean instanceof JPanel) {
		return (JPanel) bean;
	}
	return null;
}
 
Example 23
Source Project: microba   Source File: Demo.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private JComponent buildDatePickerTab() {
	JPanel panel = new JPanel();
	final DatePicker datePicker = new DatePicker();
	// datePicker.setDateFormat(new SimpleDateFormat("HH dd yyyy"));
	datePicker.setDateFormat(SimpleDateFormat.getDateTimeInstance());
	// datePicker.setStripTime(false);
	datePicker.setEnabled(false);
	datePicker.setKeepTime(true);
	datePicker.setStripTime(false);
	datePicker.setShowNumberOfWeek(true);
	// datePicker.setEnabled(false);
	// datePicker.setPickerStyle(DatePicker.PICKER_STYLE_BUTTON);
	// datePicker.showButtonOnly(false);
	// datePicker.setToolTipText("hello!!!!");
	// datePicker.setShowNumberOfWeek(true);
	
	Map ov = new HashMap();

	ov.put(CalendarPane.COLOR_CALENDAR_GRID_FOREGROUND_ENABLED,
			Color.ORANGE);
	
	datePicker.setColorOverrideMap(ov);

	panel.setLayout(new GridBagLayout());
	panel.add(datePicker, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
			GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(
					5, 5, 5, 5), 0, 0));

	datePicker.addActionListener(new ActionListener() {

		public void actionPerformed(ActionEvent e) {
			System.out.println("DatePicker:" + datePicker.getDate());

		}
	});

	return panel;

}
 
Example 24
Source Project: aurous-app   Source File: Playlist.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * popup panel to add url to playlist
 */
public void additionToPlayListPrompt() {

	if ((Settings.getLastPlayList() == null)
			|| Settings.getLastPlayList().isEmpty()) {
		JOptionPane.showMessageDialog(new JFrame(),
				"You do not have any playlist loaded!", "Uh oh",
				JOptionPane.ERROR_MESSAGE);
		return;
	}

	final JTextField urlField = new JTextField();
	urlField.addMouseListener(new ContextMenuMouseListener());
	urlField.addMouseListener(new MouseAdapter() {
		@Override
		public void mouseClicked(final MouseEvent e) {

		}
	});
	new GhostText("https://www.youtube.com/watch?v=TU3b1qyEGsE", urlField);
	urlField.setHorizontalAlignment(SwingConstants.CENTER);
	final JPanel panel = new JPanel(new GridLayout(0, 1));

	panel.add(new JLabel("Paste media url"));
	panel.add(urlField);

	final int result = JOptionPane.showConfirmDialog(null, panel,
			"Add to Playlist", JOptionPane.OK_CANCEL_OPTION,
			JOptionPane.PLAIN_MESSAGE);

	if (result == JOptionPane.OK_OPTION) {
		addUrlToPlayList(urlField.getText());
	} else {

	}

}
 
Example 25
Source Project: hottub   Source File: FileChooserDemo.java    License: 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);
}
 
Example 26
@Test
public void shouldAddNewPanelAfterDisplayDetailsInvoked() {
    final XQueryDataSourceConfiguration cfg = new XQueryDataSourceConfiguration("name", XQueryDataSourceType.SAXON);
    final ConfigurationChangeListener listener = mock(ConfigurationChangeListener.class);

    GuiActionRunner.execute(new GuiTask() {
        protected void executeInEDT() {
            panel.displayDetails(cfg, listener);

        }
    });
    assertThat(panel.getComponents().length, is(1));
    verify(panel).add(isA(JPanel.class), eq(BorderLayout.NORTH));
}
 
Example 27
Source Project: jdk8u-dev-jdk   Source File: Test4252164.java    License: GNU General Public License v2.0 5 votes vote down vote up
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 28
public PasswordManager() {

		super(ApplicationFrame.getApplicationFrame(), "password_manager", ModalityType.MODELESS, new Object[0]);
		this.clone = new Wallet(Wallet.getInstance());

		credentialsModel = new CredentialsTableModel(clone);
		final JTable table = new JTable(credentialsModel);
		table.setAutoCreateRowSorter(true);
		((DefaultRowSorter<?, ?>) table.getRowSorter()).setMaxSortKeys(1);
		JScrollPane scrollPane = new ExtendedJScrollPane(table);
		scrollPane.setBorder(null);
		JPanel main = new JPanel(new BorderLayout());
		main.add(scrollPane, BorderLayout.CENTER);

		ResourceAction removePasswordAction = new ResourceAction("password_manager_remove_row") {

			private static final long serialVersionUID = 1L;

			@Override
			public void loggedActionPerformed(ActionEvent e) {
				int[] selectedTableRows = table.getSelectedRows();
				ArrayList<Integer> modelRows = new ArrayList<>(selectedTableRows.length);
				for (int i = 0; i <= selectedTableRows.length - 1; i++) {
					modelRows.add(table.getRowSorter().convertRowIndexToModel(selectedTableRows[i]));
				}
				Collections.sort(modelRows);
				for (int i = modelRows.size() - 1; i >= 0; i--) {
					credentialsModel.removeRow(modelRows.get(i));
				}
			}
		};

		JPanel buttonPanel = new JPanel(new BorderLayout());
		buttonPanel.add(makeButtonPanel(new JButton(removePasswordAction), makeOkButton("password_manager_save"),
				makeCancelButton()), BorderLayout.EAST);
		layoutDefault(main, buttonPanel, LARGE);
	}
 
Example 29
Source Project: pumpernickel   Source File: BasicQOptionPaneUI.java    License: MIT License 5 votes vote down vote up
private void installCustomizations(QOptionPane optionPane) {
	JLabel iconLabel = getIconLabel(optionPane);
	JTextArea mainText = getMainMessageTextArea(optionPane);
	JTextArea secondaryText = getSecondaryMessageTextArea(optionPane);
	JPanel footerContainer = getFooterContainer(optionPane);
	JSeparator footerSeparator = getFooterSeparator(optionPane);
	JPanel upperBody = getUpperBody(optionPane);

	installBorder(footerContainer,
			getInsets(optionPane, KEY_FOOTER_INSETS), new Color(0xffDDDDDD));
	installBorder(upperBody, getInsets(optionPane, KEY_UPPER_BODY_INSETS),
			new Color(0xDDffDD));
	installBorder(iconLabel, getInsets(optionPane, KEY_ICON_INSETS),
			new Color(0xffDDff));
	installBorder(mainText, getInsets(optionPane, KEY_MAIN_MESSAGE_INSETS),
			new Color(0xDDDDff));
	installBorder(secondaryText,
			getInsets(optionPane, KEY_SECONDARY_MESSAGE_INSETS), new Color(
					0xDDffff));

	Color separatorColor = getColor(optionPane, KEY_FOOTER_SEPARATOR_COLOR);
	footerSeparator.setVisible(separatorColor != null);
	footerSeparator.setUI(new LineSeparatorUI(separatorColor));

	mainText.setFont(getFont(optionPane, KEY_MAIN_MESSAGE_FONT));
	secondaryText.setFont(getFont(optionPane, KEY_SECONDARY_MESSAGE_FONT));
	mainText.setForeground(getColor(optionPane, KEY_MAIN_MESSAGE_COLOR));
	secondaryText.setForeground(getColor(optionPane,
			KEY_SECONDARY_MESSAGE_COLOR));
	mainText.setDisabledTextColor(getColor(optionPane,
			KEY_MAIN_MESSAGE_COLOR));
	secondaryText.setDisabledTextColor(getColor(optionPane,
			KEY_SECONDARY_MESSAGE_COLOR));

	updateMainMessage(optionPane);
	updateSecondaryMessage(optionPane);
	updateFooter(optionPane);
}
 
Example 30
Source Project: Girinoscope   Source File: CustomAxisEditionDialog.java    License: Apache License 2.0 5 votes vote down vote up
private HtmlPane createNoticePane(JPanel panel) {
    String docUrl = "https://docs.oracle.com/javase/8/docs/api/java/text/DecimalFormat.html";

    StringBuilder notice = new StringBuilder();
    notice.append("<html><body bgcolor='");
    notice.append(HtmlPane.toHexCode(panel.getBackground()));
    notice.append("'>");
    notice.append("<a href='").append(docUrl).append("'>");
    notice.append("Pattern format");
    notice.append("</a></body></html>");

    HtmlPane noticePane = new HtmlPane(notice.toString());
    noticePane.setBorder(BorderFactory.createEmptyBorder());
    return noticePane;
}