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

The following examples show how to use javax.swing.JComboBox#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: JMonthChooser.java    From MeteoInfo with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * JMonthChooser constructor with month spinner parameter.
 * 
 * @param hasSpinner
 *            true, if the month chooser should have a spinner component
 */
public JMonthChooser(boolean hasSpinner) {
	super();
	setName("JMonthChooser");
	this.hasSpinner = hasSpinner;

	setLayout(new BorderLayout());

	comboBox = new JComboBox();
	comboBox.addItemListener(this);

	// comboBox.addPopupMenuListener(this);
	locale = Locale.getDefault();
	initNames();

	if (hasSpinner) {
		spinner = new JSpinner() {
			private static final long serialVersionUID = 1L;

			private JTextField textField = new JTextField();

			public Dimension getPreferredSize() {
				Dimension size = super.getPreferredSize();
				return new Dimension(size.width, textField
						.getPreferredSize().height);
			}
		};
		spinner.addChangeListener(this);
		spinner.setEditor(comboBox);
		comboBox.setBorder(new EmptyBorder(0, 0, 0, 0));
		updateUI();

		add(spinner, BorderLayout.WEST);
	} else {
		add(comboBox, BorderLayout.WEST);
	}

	initialized = true;
	setMonth(Calendar.getInstance().get(Calendar.MONTH));
}
 
Example 2
Source File: UIRes.java    From RipplePower with Apache License 2.0 5 votes vote down vote up
public static void addStyle(JComboBox<Object> textField, String labelName) {
	Border line = BorderFactory.createLineBorder(Color.LIGHT_GRAY);
	TitledBorder titled = BorderFactory.createTitledBorder(line, labelName);
	titled.setTitleFont(GraphicsUtils.getFont("Verdana", 0, 13));
	titled.setTitleColor(fontColorTitle);
	Border empty = new EmptyBorder(0, 8, 0, 8);
	CompoundBorder border = new CompoundBorder(titled, empty);
	textField.setBorder(border);
	textField.setForeground(fontColor);
	textField.setFont(GraphicsUtils.getFont("Monospaced", 0, 13));
}
 
Example 3
Source File: ToolBarComponentFactory.java    From chipster with MIT License 5 votes vote down vote up
public static JComboBox<VisualisationMethod> createComboBox() {
	JComboBox<VisualisationMethod> combo = new JComboBox<VisualisationMethod>();
	combo.setBorder(BorderFactory.createCompoundBorder(
			BorderFactory.createMatteBorder(0,0,0,0,Color.LIGHT_GRAY),
			BorderFactory.createEmptyBorder(0,0,0,0)));
	return combo;
}
 
Example 4
Source File: DesignerTablePanel.java    From nextreports-designer with Apache License 2.0 4 votes vote down vote up
private void createTable() {
        // create the table
        model = new MyTableModel();
        table = new JXTable(model) {

            private Map<Integer, ComboBoxEditor> editors = new HashMap<Integer, ComboBoxEditor>();

            public boolean getScrollableTracksViewportHeight() {
                return getPreferredSize().height < getParent().getHeight();
            }

            public void changeSelection(int rowIndex, int columnIndex,
                                        boolean toggle, boolean extend) {
                if (!dndRecognizer.isDragged()) {
                    super.changeSelection(rowIndex, columnIndex, toggle, extend);
                }
            }

            public TableCellEditor getCellEditor(int row, int column) {
                if (column != 6) {
                    return super.getCellEditor(row, column);
                }
                ComboBoxEditor editor = editors.get(row);
                if (editor == null) {
                    editor = new ComboBoxEditor(new String[]{"", GROUP_BY, SUM, AVG, MIN, MAX, COUNT});
                    editors.put(row, editor);
                }
                return editor;
            }
        };
        tableRowHeader = TableUtil.setRowHeader(table);
        table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        TableColumn col = table.getColumnModel().getColumn(3);
//        col.setCellRenderer(TableCellRenderers.getNewDefaultRenderer(Boolean.class));
        col.setCellRenderer(table.getDefaultRenderer(Boolean.class));
        col.setCellEditor(table.getDefaultEditor(Boolean.class));
        table.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
        // no border
        JTextField tf = new JTextField();
        tf.setBorder(BorderFactory.createEmptyBorder());
        table.setDefaultEditor(Object.class, new DefaultCellEditor(tf));

        col = table.getColumnModel().getColumn(4);
//        col.setCellRenderer(TableCellRenderers.getNewDefaultRenderer(Boolean.class));
        JComboBox sortCombo = new JComboBox(new String[]{"", ASC, DESC});
        sortCombo.setBorder(BorderFactory.createEmptyBorder());
        col.setCellEditor(new ComboBoxEditor(sortCombo));

        col = table.getColumnModel().getColumn(5);
        sortOrderCombo = new JComboBox();
        sortOrderCombo.setBorder(BorderFactory.createEmptyBorder());
        col.setCellEditor(new ComboBoxEditor(sortOrderCombo));

        col = table.getColumnModel().getColumn(6);

        table.setSortable(false);
        table.setColumnControlVisible(true);
        table.getTableHeader().setReorderingAllowed(false);
        table.setHorizontalScrollEnabled(true);

        // highlight table
        table.setHighlighters(HighlighterFactory.createAlternateStriping(Color.WHITE, ColorUtil.PANEL_BACKROUND_COLOR));

        table.getTableHeader().setReorderingAllowed(false);
        
        table.setRolloverEnabled(true);
        table.addHighlighter(new ColorHighlighter(HighlightPredicate.ROLLOVER_ROW, null, Color.RED)); 
    }
 
Example 5
Source File: DumpDatabase.java    From DKO with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static void buildCard1() {
	JPanel card = new JPanel();
	card.setLayout(new BoxLayout(card, BoxLayout.Y_AXIS));
	JLabel title = new JLabel("Welcome to the DKO Database Dumper!");
	title.setAlignmentX(Component.CENTER_ALIGNMENT);
	title.setBorder(new EmptyBorder(15, 20, 15, 20));
	card.add(title);
	JLabel question = new JLabel("What kind of database are you pulling from?");
	question.setAlignmentX(Component.CENTER_ALIGNMENT);
	question.setBorder(new EmptyBorder(5, 10, 5, 10));
	card.add(question);
	String[] databaseTypes = {"SQL Server"};
	final JComboBox dbTypeSelectBox = new JComboBox(databaseTypes);
	dbTypeSelectBox.setBorder(new EmptyBorder(5, 10, 5, 10));
	card.add(dbTypeSelectBox);
	server = new JTextField("jdbc:sqlserver://server:1433");
	server.setBorder(new EmptyBorder(2, 10, 2, 10));
	username = new JTextField("sa");
	username.setBorder(new EmptyBorder(2, 10, 2, 10));
	password = new JPasswordField("password");
	password.setBorder(new EmptyBorder(2, 10, 2, 10));
	card.add(server);
	card.add(username);
	card.add(password);
	cards.add(card, CARD_1);
	final NextListener nexter = new NextListener() {
		@Override
		public void goNext() {
			new Thread(new SchemaGetter()).start();
			cardStack.add(CARD_2);
			cl.show(cards, CARD_2);
		}
		@Override
		public void show() {
			next.setVisible(true);
			finish.setVisible(false);
			Object selectedItem = dbTypeSelectBox.getModel().getSelectedItem();
			next.setEnabled(!"".equals(selectedItem) && !server.getText().isEmpty());
		}
	};
	dbTypeSelectBox.addActionListener(new ActionListener() {
		@Override
		public void actionPerformed(ActionEvent e) {
			nexter.show();
		}
	});
	nexters.put(CARD_1, nexter);
}