Java Code Examples for javax.swing.JTextField#setOpaque()

The following examples show how to use javax.swing.JTextField#setOpaque() . 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: FreeColStringInputDialog.java    From freecol with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a dialog to input a string field.
 *
 * @param freeColClient The {@code FreeColClient} for the game.
 * @param frame The owner frame.
 * @param modal True if this dialog should be modal.
 * @param tmpl A {@code StringTemplate} to explain the action to the user.
 * @param defaultValue The default value appearing in the text field.
 * @param okKey A key displayed on the "ok"-button.
 * @param cancelKey A key displayed on the optional "cancel"-button.
 */
public FreeColStringInputDialog(FreeColClient freeColClient, JFrame frame,
                                boolean modal, StringTemplate tmpl,
                                String defaultValue,
                                String okKey, String cancelKey) {
    super(freeColClient, frame);

    textField = new JTextField(defaultValue);
    textField.setOpaque(false);
    JPanel panel = new JPanel(new BorderLayout()) {
            @Override
            public void requestFocus() {
                textField.requestFocus();
            }
        };
    panel.setOpaque(false);

    panel.add(Utility.localizedTextArea(tmpl));
    panel.add(textField, BorderLayout.PAGE_END);

    initializeInputDialog(frame, modal, panel, null, okKey, cancelKey);
}
 
Example 2
Source File: SimpleMeanColourFeatureDemo.java    From COMP3204 with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public JPanel getComponent(int width, int height) throws IOException {
	final JPanel base = super.getComponent(width, height);

	featureField = new JTextField();
	featureField.setOpaque(false);
	featureField.setBorder(null);
	featureField.setFont(Font.decode("Monaco-48"));
	featureField.setHorizontalAlignment(JTextField.CENTER);
	final GridBagConstraints c = new GridBagConstraints();
	c.gridx = 0;
	c.gridy = 1;
	c.fill = GridBagConstraints.HORIZONTAL;
	base.add(featureField, c);

	return base;
}
 
Example 3
Source File: TomatoLinearClassifierDemo.java    From COMP3204 with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void createFeatureField() {
	featureField = new JTextField();
	featureField.setOpaque(false);
	featureField.setFont(Font.decode("Monaco-24"));
	featureField.setHorizontalAlignment(JTextField.CENTER);
	featureField.setEditable(false);
	featureField.setBorder(null);
}
 
Example 4
Source File: KNNDemo.java    From COMP3204 with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void createFeatureField() {
	featureField = new JTextField();
	featureField.setOpaque(false);
	featureField.setFont(Font.decode("Monaco-24"));
	featureField.setHorizontalAlignment(JTextField.CENTER);
	featureField.setEditable(false);
	featureField.setBorder(null);
}
 
Example 5
Source File: LinearClassifierDemo.java    From COMP3204 with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void createFeatureField() {
	featureField = new JTextField();
	featureField.setOpaque(false);
	featureField.setFont(Font.decode("Monaco-24"));
	featureField.setHorizontalAlignment(JTextField.CENTER);
	featureField.setEditable(false);
	featureField.setBorder(null);
}
 
Example 6
Source File: TomatoKNNClassifierDemo.java    From COMP3204 with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void createFeatureField() {
	featureField = new JTextField();
	featureField.setOpaque(false);
	featureField.setFont(Font.decode("Monaco-24"));
	featureField.setHorizontalAlignment(JTextField.CENTER);
	featureField.setEditable(false);
	featureField.setBorder(null);
}
 
Example 7
Source File: FlatSpinnerUI.java    From FlatLaf with Apache License 2.0 5 votes vote down vote up
@Override
protected JComponent createEditor() {
	JComponent editor = super.createEditor();

	// explicitly make non-opaque
	editor.setOpaque( false );
	JTextField textField = getEditorTextField( editor );
	if( textField != null )
		textField.setOpaque( false );

	updateEditorColors();
	return editor;
}
 
Example 8
Source File: JDateChooser.java    From jeveassets with GNU General Public License v2.0 5 votes vote down vote up
public JDateChooser(boolean allowEmptyDates) {
	super(new DefaultDatePickerSettings(allowEmptyDates));

	JTextField jTextField = getComponentDateTextField();
	jTextField.setEditable(false);
	jTextField.setBorder(null);
	jTextField.setOpaque(false);
	jTextField.setHorizontalAlignment(JTextField.CENTER);
	JButton jButton = getComponentToggleCalendarButton();
	jButton.setIcon(Images.EDIT_DATE.getIcon());
	jButton.setText("");
}
 
Example 9
Source File: TomatoLinearClassifierDemo.java    From COMP3204 with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public Component getComponent(int width, int height) throws IOException {
	points = new ArrayList<double[]>();
	classes = new ArrayList<Integer>();
	classifier = new SimplePerceptron();

	circle = new Circle(VIDEO_WIDTH / 2, VIDEO_HEIGHT / 2, VIDEO_HEIGHT / 8);

	vc = new VideoCaptureComponent(VIDEO_WIDTH, VIDEO_HEIGHT);
	vc.getDisplay().addVideoListener(this);

	// the main panel
	final JPanel base = new JPanel();
	base.setOpaque(false);
	base.setPreferredSize(new Dimension(width, height));
	base.setLayout(new GridBagLayout());

	// left hand side (video, features)
	final Box videoCtrls = Box.createVerticalBox();
	videoCtrls.setOpaque(false);
	videoCtrls.add(vc);
	videoCtrls.add(Box.createVerticalStrut(10));
	final JPanel colourspacesPanel = createColourSpaceButtons();
	videoCtrls.add(colourspacesPanel);
	createFeatureField();
	videoCtrls.add(Box.createVerticalStrut(10));
	videoCtrls.add(featureField);
	base.add(videoCtrls);

	// right hand box
	final Box rightPanel = Box.createVerticalBox();
	rightPanel.setOpaque(false);
	image = new MBFImage(GRAPH_WIDTH, GRAPH_HEIGHT, ColourSpace.RGB);
	image.fill(RGBColour.WHITE);
	imageComp = new DisplayUtilities.ImageComponent(true, false);
	imageComp.setShowPixelColours(false);
	imageComp.setShowXYPosition(false);
	imageComp.setAllowZoom(false);
	imageComp.setAllowPanning(false);
	rightPanel.add(imageComp);
	final JPanel classCtrlsCnt = new JPanel(new GridLayout(1, 2));

	// learning controls
	final JPanel learnCtrls = new JPanel(new GridLayout(0, 1));
	classType = new JComboBox<String>();
	for (final String c : CLASSES)
		classType.addItem(c);
	learnCtrls.add(classType);
	final JButton learnButton = new JButton("Learn");
	learnButton.setActionCommand("button.learn");
	learnButton.addActionListener(this);
	learnCtrls.add(learnButton);
	classCtrlsCnt.add(learnCtrls);

	// classification controls
	final JPanel classCtrls = new JPanel(new GridLayout(0, 1));
	classCtrls.setOpaque(false);
	guess = new JTextField(8);
	guess.setOpaque(false);
	guess.setFont(Font.decode("Monaco-24"));
	guess.setHorizontalAlignment(JTextField.CENTER);
	guess.setEditable(false);
	classCtrls.add(guess);
	classCtrlsCnt.add(classCtrls);

	rightPanel.add(classCtrlsCnt);

	base.add(rightPanel);

	redraw();
	return base;
}
 
Example 10
Source File: AbstractGradientDescentDemo.java    From COMP6237 with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public Component getComponent(int width, int height) throws IOException {
	final JPanel base = new JPanel();
	base.setOpaque(false);
	base.setPreferredSize(new Dimension(width, height));
	base.setLayout(new BoxLayout(base, BoxLayout.Y_AXIS));

	chartDataset = new DefaultXYDataset();
	X = createData();
	chartDataset.addSeries("points", X);
	final double[][] lineData = computeLineData();
	chartDataset.addSeries("line", lineData);

	chart = ChartFactory.createXYLineChart(null, "x", "y", chartDataset, PlotOrientation.VERTICAL,
			false, false, false);
	((XYLineAndShapeRenderer) chart.getXYPlot().getRenderer()).setSeriesLinesVisible(0, false);
	((XYLineAndShapeRenderer) chart.getXYPlot().getRenderer()).setSeriesShapesVisible(0, true);
	((NumberAxis) chart.getXYPlot().getDomainAxis()).setRange(-5, 5);
	((NumberAxis) chart.getXYPlot().getRangeAxis()).setRange(-10, 10);

	((XYLineAndShapeRenderer) chart.getXYPlot().getRenderer()).setStroke(new BasicStroke(2.5f));

	chartContainer = new ImageContainer(chart.createBufferedImage(width, height / 2));
	base.add(chartContainer);

	final JPanel bottomPane = new JPanel();
	bottomPane.setPreferredSize(new Dimension(width, height / 2));
	base.add(bottomPane);

	final JPanel controlsdata = new JPanel();
	controlsdata.setLayout(new BoxLayout(controlsdata, BoxLayout.X_AXIS));
	bottomPane.add(controlsdata);
	final JButton button = new JButton("Go");
	controlsdata.add(button);

	button.addActionListener(new ActionListener() {
		@Override
		public void actionPerformed(ActionEvent e) {
			button.setEnabled(false);
			base.requestFocus();
			new Thread(AbstractGradientDescentDemo.this).start();
		}
	});

	paramsField = new JTextField(20);
	paramsField.setOpaque(false);
	paramsField.setFont(Font.decode("Monaco-24"));
	paramsField.setHorizontalAlignment(JTextField.CENTER);
	paramsField.setEditable(false);
	paramsField.setBorder(null);
	paramsField.setText(String.format("%2.2f, %2.2f", params[0], params[1]));
	controlsdata.add(paramsField);

	errorDataset = new DefaultXYDataset();
	errorSeries = new double[][] { { 0 }, { computeError() } };
	errorDataset.addSeries("data", errorSeries);
	errorChart = ChartFactory.createXYLineChart("Error over time",
			"Iteration", "Error", errorDataset,
			PlotOrientation.VERTICAL,
			false, false, false);
	((NumberAxis) errorChart.getXYPlot().getDomainAxis()).setRange(0, 1);
	((NumberAxis) errorChart.getXYPlot().getRangeAxis()).setRange(0, computeError());
	errorContainer = new ImageContainer(errorChart.createBufferedImage((width - 5) / 2, (height - 5) / 2));
	bottomPane.add(errorContainer);

	return base;
}
 
Example 11
Source File: TomatoKNNClassifierDemo.java    From COMP3204 with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public Component getComponent(final int width, final int height) throws IOException {
	points = new ArrayList<double[]>();
	classes = new ArrayList<Integer>();
	k = 1;

	circle = new Circle(VIDEO_WIDTH / 2, VIDEO_HEIGHT / 2, VIDEO_HEIGHT / 8);

	vc = new VideoCaptureComponent(VIDEO_WIDTH, VIDEO_HEIGHT);

	vc.getDisplay().addVideoListener(this);

	// the main panel
	final JPanel base = new JPanel() {
		private static final long serialVersionUID = 1L;

		@Override
		protected void paintComponent(Graphics g) {
			((Graphics2D) g).setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);

			super.paintComponent(g);

			if (bgImage != null)
				g.drawImage(bgImage, 0, 0, width, height, null);
		}
	};
	base.setOpaque(false);
	base.setPreferredSize(new Dimension(width, height));
	base.setLayout(new GridBagLayout());

	// left hand side (video, features)
	final Box videoCtrls = Box.createVerticalBox();
	videoCtrls.add(vc);
	videoCtrls.add(Box.createVerticalStrut(10));
	final JPanel colourspacesPanel = createColourSpaceButtons();
	videoCtrls.add(colourspacesPanel);
	createFeatureField();
	videoCtrls.add(Box.createVerticalStrut(10));
	videoCtrls.add(featureField);
	base.add(videoCtrls);

	// right hand box
	final Box rightPanel = Box.createVerticalBox();
	rightPanel.setOpaque(false);

	guess = new JTextField(8);
	guess.setOpaque(false);
	guess.setFont(Font.decode("Monaco-48"));
	guess.setHorizontalAlignment(JTextField.CENTER);
	guess.setEditable(false);
	rightPanel.add(guess);

	image = new MBFImage(GRAPH_WIDTH, GRAPH_HEIGHT, ColourSpace.RGB);
	image.fill(RGBColour.WHITE);
	imageComp = new DisplayUtilities.ImageComponent(true, false);
	imageComp.setShowPixelColours(false);
	imageComp.setShowXYPosition(false);
	imageComp.setAllowZoom(false);
	imageComp.setAllowPanning(false);
	rightPanel.add(imageComp);
	final JPanel classCtrlsCnt = new JPanel(new GridLayout(1, 2));
	classCtrlsCnt.setOpaque(false);

	// learning controls
	final JPanel learnCtrls = new JPanel(new GridLayout(0, 1));
	learnCtrls.setOpaque(false);
	classType = new JComboBox<String>();
	for (final String c : CLASSES)
		classType.addItem(c);
	learnCtrls.add(classType);
	final JButton learnButton = new JButton("Learn");
	learnButton.setActionCommand("button.learn");
	learnButton.addActionListener(this);
	learnCtrls.add(learnButton);
	classCtrlsCnt.add(learnCtrls);

	// classification controls
	final JPanel classCtrls = new JPanel(new GridLayout(0, 1));
	classCtrls.setOpaque(false);
	final JPanel cnt = new JPanel();
	cnt.setOpaque(false);
	cnt.add(new JLabel("K:"));
	final JSpinner kField = new JSpinner(new SpinnerNumberModel(k, 1, 10, 1));
	kField.addChangeListener(this);
	cnt.add(kField);
	classCtrls.add(cnt);
	classCtrlsCnt.add(classCtrls);

	rightPanel.add(classCtrlsCnt);

	base.add(rightPanel);

	redraw();
	return base;
}
 
Example 12
Source File: JTextFieldFactory.java    From WorldGrower with GNU General Public License v3.0 4 votes vote down vote up
private static void setTextFieldProperties(JTextField textField) {
	textField.setOpaque(false);
	textField.setBackground(ColorPalette.DARK_BACKGROUND_COLOR);
	textField.setForeground(ColorPalette.FOREGROUND_COLOR);
	textField.setFont(Fonts.FONT);
}
 
Example 13
Source File: LinearClassifierDemo.java    From COMP3204 with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public Component getComponent(int width, int height) throws IOException {
	points = new ArrayList<double[]>();
	classes = new ArrayList<Integer>();
	classifier = new SimplePerceptron();

	vc = new VideoCaptureComponent(VIDEO_WIDTH, VIDEO_HEIGHT);
	vc.getDisplay().addVideoListener(this);

	// the main panel
	final JPanel base = new JPanel();
	base.setOpaque(false);
	base.setPreferredSize(new Dimension(width, height));
	base.setLayout(new GridBagLayout());

	// left hand side (video, features)
	final Box videoCtrls = Box.createVerticalBox();
	videoCtrls.setOpaque(false);
	videoCtrls.add(vc);
	videoCtrls.add(Box.createVerticalStrut(10));
	final JPanel colourspacesPanel = createColourSpaceButtons();
	videoCtrls.add(colourspacesPanel);
	createFeatureField();
	videoCtrls.add(Box.createVerticalStrut(10));
	videoCtrls.add(featureField);
	base.add(videoCtrls);

	// right hand box
	final Box rightPanel = Box.createVerticalBox();
	rightPanel.setOpaque(false);
	image = new MBFImage(GRAPH_WIDTH, GRAPH_HEIGHT, ColourSpace.RGB);
	image.fill(RGBColour.WHITE);
	imageComp = new DisplayUtilities.ImageComponent(true, false);
	imageComp.setShowPixelColours(false);
	imageComp.setShowXYPosition(false);
	imageComp.setAllowZoom(false);
	imageComp.setAllowPanning(false);
	rightPanel.add(imageComp);
	final JPanel classCtrlsCnt = new JPanel(new GridLayout(1, 2));

	// learning controls
	final JPanel learnCtrls = new JPanel(new GridLayout(0, 1));
	classType = new JComboBox<String>();
	for (final String c : CLASSES)
		classType.addItem(c);
	learnCtrls.add(classType);
	final JButton learnButton = new JButton("Learn");
	learnButton.setActionCommand("button.learn");
	learnButton.addActionListener(this);
	learnCtrls.add(learnButton);
	classCtrlsCnt.add(learnCtrls);

	// classification controls
	final JPanel classCtrls = new JPanel(new GridLayout(0, 1));
	classCtrls.setOpaque(false);
	guess = new JTextField(8);
	guess.setOpaque(false);
	guess.setFont(Font.decode("Monaco-24"));
	guess.setHorizontalAlignment(JTextField.CENTER);
	guess.setEditable(false);
	classCtrls.add(guess);
	classCtrlsCnt.add(classCtrls);

	rightPanel.add(classCtrlsCnt);

	base.add(rightPanel);

	redraw();
	return base;
}
 
Example 14
Source File: AccountSeparatorTableCell.java    From jeveassets with GNU General Public License v2.0 4 votes vote down vote up
public AccountSeparatorTableCell(final AccountManagerDialog accountManagerDialog, final ActionListener actionListener, final JTable jTable, final SeparatorList<OwnerType> separatorList) {
	super(jTable, separatorList);
	this.accountManagerDialog = accountManagerDialog;

	defaultColor = jPanel.getBackground();

	ListenerClass listener = new ListenerClass();

	jSeparatorLabel = new JLabel();
	jSeparatorLabel.setBackground(jTable.getBackground());
	jSeparatorLabel.setOpaque(true);
	jSeparatorLabel.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, jTable.getGridColor()));
	jAccountType = new JLabel();

	jEdit = new JButton(DialoguesAccount.get().edit());
	jEdit.setOpaque(false);
	jEdit.setActionCommand(AccountCellAction.EDIT.name());
	jEdit.addActionListener(actionListener);

	jMigrate = new JButton(DialoguesAccount.get().migrate());
	jMigrate.setOpaque(false);
	jMigrate.setActionCommand(AccountCellAction.MIGRATE.name());
	jMigrate.addActionListener(actionListener);

	jDelete = new JButton(DialoguesAccount.get().delete());
	jDelete.setOpaque(false);
	jDelete.setActionCommand(AccountCellAction.DELETE.name());
	jDelete.addActionListener(actionListener);

	jAccountName = new JTextField();
	jAccountName.addFocusListener(listener);
	jAccountName.setBorder(null);
	jAccountName.setOpaque(false);
	jAccountName.setActionCommand(AccountCellAction.ACCOUNT_NAME.name());
	jAccountName.addActionListener(listener);

	jInvalidLabel = new JLabel(DialoguesAccount.get().accountInvalid());

	jExpiredLabel = new JLabel(DialoguesAccount.get().accountExpired());

	jMigratedLabel = new JLabel(DialoguesAccount.get().accountMigrated());

	jCanMigrateLabel = new JLabel(DialoguesAccount.get().accountCanMigrate());

	jSpaceLabel = new JLabel();

	layout.setHorizontalGroup(
		layout.createParallelGroup()
			.addComponent(jSeparatorLabel, 0, 0, Integer.MAX_VALUE)
			.addGroup(layout.createSequentialGroup()
				.addComponent(jExpand)
				.addGap(1)
				.addComponent(jEdit, Program.getButtonsWidth(), Program.getButtonsWidth(), Program.getButtonsWidth())
				.addComponent(jMigrate, Program.getButtonsWidth(), Program.getButtonsWidth(), Program.getButtonsWidth())
				.addComponent(jDelete, Program.getButtonsWidth(), Program.getButtonsWidth(), Program.getButtonsWidth())
				.addGap(5)
				.addComponent(jAccountType)
				.addGap(5)
				.addComponent(jAccountName, 20, 20, Integer.MAX_VALUE)
				.addGap(10)
				.addComponent(jExpiredLabel)
				.addComponent(jInvalidLabel)
				.addComponent(jMigratedLabel)
				.addComponent(jCanMigrateLabel)
				.addComponent(jSpaceLabel, 20, 20, Integer.MAX_VALUE)
			)
	);
	layout.setVerticalGroup(
		layout.createSequentialGroup()
			.addComponent(jSeparatorLabel, jTable.getRowHeight(), jTable.getRowHeight(), jTable.getRowHeight())
			.addGap(1)
			.addGroup(layout.createParallelGroup()
				.addComponent(jExpand, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
				.addComponent(jAccountType, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
				.addComponent(jEdit, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
				.addComponent(jMigrate, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
				.addComponent(jDelete, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
				.addComponent(jAccountName, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
				.addComponent(jInvalidLabel, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
				.addComponent(jExpiredLabel, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
				.addComponent(jMigratedLabel, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
				.addComponent(jCanMigrateLabel, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
				.addComponent(jSpaceLabel, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
			)
			.addGap(2)
	);
}
 
Example 15
Source File: KNNDemo.java    From COMP3204 with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public Component getComponent(int width, int height) throws IOException {
	points = new ArrayList<double[]>();
	classes = new ArrayList<Integer>();
	k = 1;

	vc = new VideoCaptureComponent(VIDEO_WIDTH, VIDEO_HEIGHT);
	vc.getDisplay().addVideoListener(this);

	// the main panel
	final JPanel base = new JPanel();
	base.setOpaque(false);
	base.setPreferredSize(new Dimension(width, height));
	base.setLayout(new GridBagLayout());

	// left hand side (video, features)
	final Box videoCtrls = Box.createVerticalBox();
	videoCtrls.add(vc);
	videoCtrls.add(Box.createVerticalStrut(10));
	final JPanel colourspacesPanel = createColourSpaceButtons();
	videoCtrls.add(colourspacesPanel);
	createFeatureField();
	videoCtrls.add(Box.createVerticalStrut(10));
	videoCtrls.add(featureField);
	base.add(videoCtrls);

	// right hand box
	final Box rightPanel = Box.createVerticalBox();
	rightPanel.setOpaque(false);
	image = new MBFImage(GRAPH_WIDTH, GRAPH_HEIGHT, ColourSpace.RGB);
	image.fill(RGBColour.WHITE);
	imageComp = new DisplayUtilities.ImageComponent(true, false);
	imageComp.setShowPixelColours(false);
	imageComp.setShowXYPosition(false);
	imageComp.setAllowZoom(false);
	imageComp.setAllowPanning(false);
	rightPanel.add(imageComp);
	final JPanel classCtrlsCnt = new JPanel(new GridLayout(1, 2));

	// learning controls
	final JPanel learnCtrls = new JPanel(new GridLayout(0, 1));
	learnCtrls.setOpaque(false);
	classType = new JComboBox<String>();
	for (final String c : CLASSES)
		classType.addItem(c);
	learnCtrls.add(classType);
	final JButton learnButton = new JButton("Learn");
	learnButton.setActionCommand("button.learn");
	learnButton.addActionListener(this);
	learnCtrls.add(learnButton);
	classCtrlsCnt.add(learnCtrls);

	// classification controls
	final JPanel classCtrls = new JPanel(new GridLayout(0, 1));
	classCtrls.setOpaque(false);
	final JPanel cnt = new JPanel();
	cnt.add(new JLabel("K:"));
	final JSpinner kField = new JSpinner(new SpinnerNumberModel(k, 1, 10, 1));
	kField.addChangeListener(this);
	cnt.add(kField);
	classCtrls.add(cnt);
	guess = new JTextField(8);
	guess.setOpaque(false);
	guess.setFont(Font.decode("Monaco-24"));
	guess.setHorizontalAlignment(JTextField.CENTER);
	guess.setEditable(false);
	classCtrls.add(guess);
	classCtrlsCnt.add(classCtrls);

	rightPanel.add(classCtrlsCnt);

	base.add(rightPanel);

	redraw();
	return base;
}
 
Example 16
Source File: UnitInfoPanel.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
public void init(String unitName, String unitType, String unitDescription) {

		setOpaque(false);
		setLayout(new BorderLayout(10, 20));
		// this.setSize(350, 400); // undecorated 301, 348 ; decorated : 303, 373

		JPanel mainPanel = new JPanel(new FlowLayout());// new BorderLayout());
		mainPanel.setOpaque(false);
		mainPanel.setBackground(new Color(0, 0, 0, 128));
		// setMinimumSize()
		this.add(mainPanel, BorderLayout.NORTH);

		JPanel westPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 10, 10));// new BorderLayout());
		westPanel.setOpaque(false);
		westPanel.setBackground(new Color(0, 0, 0, 128));
		// setMinimumSize()
		this.add(westPanel, BorderLayout.WEST);

		JPanel eastPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 10, 10));// new BorderLayout());
		eastPanel.setOpaque(false);
		eastPanel.setBackground(new Color(0, 0, 0, 128));
		// setMinimumSize()
		this.add(eastPanel, BorderLayout.EAST);

		// Creating the text Input
		JTextField tf1 = new JTextField("", 15);

		tf1.setHorizontalAlignment(JTextField.CENTER);
		tf1.setOpaque(false);
		tf1.setFocusable(false);
		tf1.setBackground(new Color(92, 83, 55, 128));
		tf1.setColumns(20);
		Border border = BorderFactory.createLineBorder(Color.gray, 2);
		tf1.setBorder(border);
		tf1.setText(unitName);
		tf1.setForeground(Color.BLACK);
		tf1.setFont(new Font("Arial", Font.BOLD, 14));

		mainPanel.add(tf1);

		JTextArea ta = new JTextArea();
		String type = "TYPE: ";
		String description = "DESCRIPTION: ";

		ta.setLineWrap(true);
		ta.setFocusable(false);
		ta.setWrapStyleWord(true);
		ta.setText(type + "\n");
		ta.append(unitType + "\n\n");
		ta.append(description + "\n");
		ta.append(unitDescription);
		ta.setCaretPosition(0);
		ta.setEditable(false);
		ta.setForeground(Color.black); 
		ta.setFont(new Font("Dialog", Font.PLAIN, 14));
		ta.setOpaque(false);
		ta.setBackground(new Color(92, 83, 55, 128));

		CustomScroll scr = new CustomScroll(ta);
		scr.setSize(PopUpUnitMenu.D_WIDTH - 50 , PopUpUnitMenu.D_HEIGHT);
		add(scr, BorderLayout.CENTER);

		JPanel southPanel = new JPanel();
		add(southPanel, BorderLayout.SOUTH);
		southPanel.setOpaque(false);
		southPanel.setBackground(new Color(0, 0, 0, 128));
		
		setVisible(true);

	}
 
Example 17
Source File: FlexibleFileWriterGui.java    From jmeter-plugins with Apache License 2.0 4 votes vote down vote up
private JPanel createHelperPanel() {
    JPanel ret = new JPanel(new GridBagLayout());

    GridBagConstraints labelConstraints = new GridBagConstraints();
    labelConstraints.insets = new Insets(0, 0, 10, 0);
    labelConstraints.gridx = 0;
    labelConstraints.fill = GridBagConstraints.HORIZONTAL;
    labelConstraints.gridwidth = 2;

    ret.add(new JLabel("Available sample fields (click any button to copy the field to clipboard):"), labelConstraints);

    GridBagConstraints buttonConstraints = new GridBagConstraints();
    buttonConstraints.insets = new Insets(4, 0, 0, 0);
    buttonConstraints.gridx = 0;
    buttonConstraints.fill = GridBagConstraints.HORIZONTAL;

    GridBagConstraints detailConstraints = new GridBagConstraints();
    detailConstraints.insets = new Insets(4, 10, 0, 0);
    detailConstraints.weightx = 1.0;
    detailConstraints.fill = GridBagConstraints.HORIZONTAL;
    detailConstraints.gridx = 1;
    detailConstraints.anchor = GridBagConstraints.WEST;

    int line = 1;

    CopyAction copyAction = new CopyAction();

    for (int i = 0; i < fields.length / 2; i++) {
        JButton fieldButton = new JButton(fields[2 * i]);
        fieldButton.addActionListener(copyAction);

        JTextField fieldDescription = new JTextField(fields[2 * i + 1]);
        fieldDescription.setEditable(false);
        fieldDescription.setBorder(null);
        fieldDescription.setOpaque(false);

        GuiBuilderHelper.strechItemToComponent(fieldDescription, fieldButton);

        buttonConstraints.gridy = line;
        detailConstraints.gridy = line;

        ret.add(fieldButton, buttonConstraints);
        ret.add(fieldDescription, detailConstraints);

        line++;
    }
    return ret;
}