Java Code Examples for javax.swing.JTextArea#setFocusable()

The following examples show how to use javax.swing.JTextArea#setFocusable() . 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: NotifyDescriptor.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
* Define a descriptive message to be reported.  In the most common
* usage, the message is just a <code>String</code>.  However, the type
* of this parameter is actually <code>Object</code>.  Its interpretation depends on
* its type:
* <dl compact>
* <dt><code>Object[]</code><dd> A recursively interpreted series of messages.
* <dt>{@link Component}<dd> The <code>Component</code> is displayed in the dialog.
* <dt>{@link javax.swing.Icon}<dd> The <code>Icon</code> is wrapped in a {@link JLabel} and displayed in the dialog.
* <dt>anything else<dd> The {@link Object#toString string representation} of the object.
* </dl>
*
* @param newMessage the <code>Object</code> to report
* @see #getMessage
*/
public void setMessage(Object newMessage) {
    checkMessageValidity(newMessage);
    Object oldMessage = message;

    if (newMessage instanceof String) {
        // bugfix #25457, use JTextArea for word-wrapping
        JTextArea area = new JTextArea((String) newMessage);
        area.setPreferredSize(new Dimension(SIZE_PREFERRED_WIDTH, SIZE_PREFERRED_HEIGHT));
        area.setBackground(UIManager.getColor("Label.background")); // NOI18N
        area.setBorder(BorderFactory.createEmptyBorder());
        area.setLineWrap(true);
        area.setWrapStyleWord(true);
        area.setEditable(false);
        area.setFocusable(true);
        area.getAccessibleContext().setAccessibleName(NbBundle.getMessage(NotifyDescriptor.class, "ACN_NotifyDescriptor_MessageJTextArea")); // NOI18N
        area.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(NotifyDescriptor.class, "ACD_NotifyDescriptor_MessageJTextArea")); // NOI18N
        newMessage = area;
    }

    message = newMessage;
    firePropertyChange(PROP_MESSAGE, oldMessage, newMessage);
}
 
Example 2
Source File: ErrorPanel.java    From freecol with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates an error panel containing the log file.
 *
 * @param freeColClient The {@code FreeColClient} for the game.
 */
public ErrorPanel(FreeColClient freeColClient) {
    super(freeColClient, null, new MigLayout());

    String message = FreeColDirectories.getLogFileContents();
    if (message == null) message = Messages.message("errorPanel.loadError");

    JTextArea textArea = Utility.getDefaultTextArea(message, columnWidth);
    textArea.setFocusable(true);
    textArea.setEditable(false);
    
    JScrollPane scrollPane = new JScrollPane(textArea,
        JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
        JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.getViewport().setOpaque(false);

    add(scrollPane, "height 200:200:, wrap 20");
    add(okButton, "tag ok");
}
 
Example 3
Source File: Utility.java    From freecol with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a text area with standard settings suitable for use in FreeCol
 * panels, without setting its size.
 *
 * @param text The text to display in the text area.
 * @return A suitable text area.
 */
private static JTextArea createTextArea(String text) {
    JTextArea textArea = new JTextArea(text);
    textArea.setOpaque(false);
    textArea.setLineWrap(true);
    textArea.setWrapStyleWord(true);
    textArea.setFocusable(false);
    return textArea;
}
 
Example 4
Source File: DefaultNotificationWindow.java    From 07kit with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Constructs a new display only {@link JTextArea}
 * @param text text that the {@link JTextArea} displays
 * @return a new display only {@link JTextArea}
 */
private JTextArea getTextAreaForDisplay(String text) {
	final JTextArea ta = new JTextArea(text);
	ta.setUI(new BasicTextAreaUI());
	ta.setEditable(false);
	ta.setFocusable(false);
	ta.setOpaque(false);
	ta.setWrapStyleWord(true);
	ta.setLineWrap(true);
	return ta;
}
 
Example 5
Source File: JValidatedInputDialog.java    From jeveassets with GNU General Public License v2.0 5 votes vote down vote up
public JValidatedInputDialog(final Program program, final JDialogCentered jDialogCentered) {
	super(program, "", jDialogCentered.getDialog());

	ListenerClass listener = new ListenerClass();

	jMessage = new JTextArea();
	jMessage.setFocusable(false);
	jMessage.setEditable(false);
	jMessage.setBackground(getDialog().getBackground());
	jMessage.setFont(getDialog().getFont());

	jName = new JTextField();

	jOK = new JButton(DialoguesProfiles.get().ok());
	jOK.setActionCommand(InputDialogAction.OK.name());
	jOK.addActionListener(listener);

	JButton jCancel = new JButton(DialoguesProfiles.get().cancel());
	jCancel.setActionCommand(InputDialogAction.CANCEL.name());
	jCancel.addActionListener(listener);

	layout.setHorizontalGroup(
		layout.createParallelGroup()
			.addComponent(jMessage, 250, 250, 250)
			.addComponent(jName, 250, 250, 250)
			.addGroup(Alignment.TRAILING, layout.createSequentialGroup()
				.addComponent(jOK, Program.getButtonsWidth(), Program.getButtonsWidth(), Program.getButtonsWidth())
				.addComponent(jCancel, Program.getButtonsWidth(), Program.getButtonsWidth(), Program.getButtonsWidth())
			)
	);
	layout.setVerticalGroup(
		layout.createSequentialGroup()
			.addComponent(jMessage)
			.addComponent(jName, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
			.addGroup(layout.createParallelGroup()
				.addComponent(jOK, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
				.addComponent(jCancel, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
			)
	);
}
 
Example 6
Source File: StartupConfigurator.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
private JPanel createStepsPanel() {
    JPanel steps = new JPanel(new VerticalLayout(false)); 
    steps.setBorder(BorderFactory.createEmptyBorder(5, 13, 15, 5));
    steps.setOpaque(false);
    
    start1 = new JTextArea();
    start1.setLineWrap(true);
    start1.setWrapStyleWord(true);
    start1.setEditable(false);
    start1.setFocusable(false);
    start1.setOpaque(false);
    if (UISupport.isNimbusLookAndFeel()) start1.setBackground(new Color(0, 0, 0, 0));
    start1.setCaret(new NullCaret());
    start1.setBorder(BorderFactory.createEmptyBorder());
    steps.add(start1);
    
    final JPanel arg = new JPanel(new BorderLayout(5, 0));
    arg.setOpaque(false);
    TextAreaComponent paramA = createTextArea(1);
    param = paramA.getTextArea();
    updateParam();
    arg.add(paramA, BorderLayout.CENTER);
    JButton link = new JButton(Bundle.BTN_Clipboard()) {
        protected void fireActionPerformed(ActionEvent e) {
            RequestProcessor.getDefault().post(new Runnable() {
                public void run() {
                    StringSelection s = new StringSelection(param.getText());
                    Toolkit.getDefaultToolkit().getSystemClipboard().setContents(s, s);
                    Dialogs.show(Dialogs.info(Bundle.CAP_Clipboard(), Bundle.MSG_Clipboard()));
                }
            });
        }
    };
    arg.add(link, BorderLayout.EAST);
    
    steps.add(createVerticalSpace(8));
    steps.add(arg);
    steps.add(createVerticalSpace(8));
    
    String user = System.getProperty("user.name"); // NOI18N
    if (user != null) user = Bundle.STR_User(user);
    else user = Bundle.STR_CurrentUser();
    start2 = new JTextArea(Bundle.HINT_StartApp(user));
    start2.setLineWrap(true);
    start2.setWrapStyleWord(true);
    start2.setEditable(false);
    start2.setFocusable(false);
    start2.setOpaque(false);
    if (UISupport.isNimbusLookAndFeel()) start2.setBackground(new Color(0, 0, 0, 0));
    start2.setCaret(new NullCaret());
    start2.setBorder(BorderFactory.createEmptyBorder());
    steps.add(start2);
    
    return steps;
}
 
Example 7
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 8
Source File: AccountImportDialog.java    From jeveassets with GNU General Public License v2.0 4 votes vote down vote up
public ImportPanel() {
	JEditorPane jHelp = new JEditorPane("text/html", "<html><body style=\"font-family: " + getFont().getName() + "; font-size: " + getFont().getSize() + "pt\">"
		+ DialoguesAccount.get().shareImportHelp() + "</body></html>");
	((HTMLDocument) jHelp.getDocument()).getStyleSheet().addRule("body { font-family: " + getFont().getFamily() + "; " + "font-size: " + this.getFont().getSize() + "pt; }");
	jHelp.setFont(getFont());
	jHelp.setEditable(false);
	jHelp.setFocusable(false);
	jHelp.setOpaque(false);

	jImportClipboard = new JButton(DialoguesAccount.get().shareImportClipboard() , Images.EDIT_PASTE.getIcon());
	jImportClipboard.setActionCommand(AccountImportAction.SHARE_FROM_CLIPBOARD.name());
	jImportClipboard.addActionListener(listener);

	jImportFile= new JButton(DialoguesAccount.get().shareImportFile(), Images.FILTER_LOAD.getIcon());
	jImportFile.setActionCommand(AccountImportAction.SHARE_FROM_FILE.name());
	jImportFile.addActionListener(listener);

	jImport = new JTextArea();
	jImport.setFont(getFont());
	jImport.setEditable(true);
	jImport.setFocusable(true);
	jImport.setOpaque(true);
	jImport.setLineWrap(true);
	jImport.setWrapStyleWord(false);

	JScrollPane jScroll = new JScrollPane(jImport, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
	jScroll.setBorder(BorderFactory.createLineBorder(this.getBackground().darker(), 1));

	cardLayout.setHorizontalGroup(
		cardLayout.createParallelGroup()
			.addComponent(jHelp)
			.addGroup(cardLayout.createSequentialGroup()
				.addComponent(jScroll)
				.addGroup(cardLayout.createParallelGroup()
					.addComponent(jImportClipboard, Program.getButtonsWidth(), Program.getButtonsWidth(), Program.getButtonsWidth())
					.addComponent(jImportFile, Program.getButtonsWidth(), Program.getButtonsWidth(), Program.getButtonsWidth())
				)
			)
	);
	cardLayout.setVerticalGroup(
		cardLayout.createSequentialGroup()
			.addComponent(jHelp)
			.addGroup(cardLayout.createParallelGroup()
				.addComponent(jScroll)
				.addGroup(cardLayout.createSequentialGroup()
					.addComponent(jImportClipboard, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
					.addComponent(jImportFile, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
				)
			)
	);
}
 
Example 9
Source File: AccountImportDialog.java    From jeveassets with GNU General Public License v2.0 4 votes vote down vote up
public ExportPanel() {
	JLabel jHelp = new JLabel(DialoguesAccount.get().shareExportHelp() );

	jExportClipboard = new JButton(DialoguesAccount.get().shareExportClipboard(), Images.EDIT_COPY.getIcon());
	jExportClipboard.setActionCommand(AccountImportAction.SHARE_TO_CLIPBOARD.name());
	jExportClipboard.addActionListener(listener);

	jExportFile = new JButton(DialoguesAccount.get().shareExportFile(), Images.FILTER_SAVE.getIcon());
	jExportFile.setActionCommand(AccountImportAction.SHARE_TO_FILE.name());
	jExportFile.addActionListener(listener);

	jExport = new JTextArea();
	jExport.setFont(getFont());
	jExport.setEditable(false);
	jExport.setFocusable(true);
	jExport.setOpaque(false);
	jExport.setLineWrap(true);
	jExport.setWrapStyleWord(false);

	JScrollPane jScroll = new JScrollPane(jExport, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
	jScroll.setBorder(BorderFactory.createLineBorder(this.getBackground().darker(), 1));

	cardLayout.setHorizontalGroup(
		cardLayout.createParallelGroup()
			.addComponent(jHelp)
			.addGroup(cardLayout.createSequentialGroup()
				.addComponent(jScroll)
				.addGroup(cardLayout.createParallelGroup()
					.addComponent(jExportClipboard, Program.getButtonsWidth(), Program.getButtonsWidth(), Program.getButtonsWidth())
					.addComponent(jExportFile, Program.getButtonsWidth(), Program.getButtonsWidth(), Program.getButtonsWidth())
				)
			)
	);
	cardLayout.setVerticalGroup(
		cardLayout.createSequentialGroup()
			.addComponent(jHelp)
			.addGroup(cardLayout.createParallelGroup()
				.addComponent(jScroll)
				.addGroup(cardLayout.createSequentialGroup()
					.addComponent(jExportClipboard, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
					.addComponent(jExportFile, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
				)
			)
	);
}
 
Example 10
Source File: ProLogWindow.java    From triplea with GNU General Public License v3.0 4 votes vote down vote up
private void settingsDetailsButtonActionPerformed() {
  final JDialog dialog = new JDialog(this, "Pro AI - Settings Details");
  String message = "";
  if (tabPaneMain.getSelectedIndex() == 0) { // Debugging
    message =
        "Debugging\r\n"
            + "\r\n"
            + "AI Logging: When this is checked, the AI's will output their logs, as they come "
            + "in, so you can see exactly what the AI is thinking.\r\n"
            + "Note that if you check this on, you still have to press OK then reopen the "
            + "settings window for the logs to actually start displaying.\r\n"
            + "\r\n"
            + "Log Depth: This setting lets you choose how deep you want the AI logging to be. "
            + "Fine only displays the high-level events, like the start of a phase, etc.\r\n"
            + "Finer displays medium-level events, such as attacks, reinforcements, etc.\r\n"
            + "Finest displays all the AI logging available. Can be used for detailed analysis, "
            + "but is a lot harder to read through it.\r\n"
            + "\r\n"
            + "Pause AI's: This checkbox pauses all the AI's while it's checked, so you can look "
            + "at the logs without the AI's outputting floods of information.\r\n"
            + "\r\n"
            + "Limit Log History To X Rounds: If this is checked, the AI log information will "
            + "be limited to X rounds of information.\r\n";
  }
  final JTextArea label = new JTextArea(message);
  label.setFont(new Font("Segoe UI", Font.PLAIN, 12));
  label.setEditable(false);
  label.setAutoscrolls(true);
  label.setLineWrap(false);
  label.setFocusable(false);
  label.setWrapStyleWord(true);
  label.setLocation(0, 0);
  dialog.setBackground(label.getBackground());
  dialog.setLayout(new BorderLayout());
  final JScrollPane pane = new JScrollPane();
  pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
  pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
  pane.setViewportView(label);
  dialog.add(pane, BorderLayout.CENTER);
  final JButton button = new JButton("Close");
  button.setMinimumSize(new Dimension(100, 30));
  button.addActionListener(e -> dialog.dispose());
  dialog.add(button, BorderLayout.SOUTH);
  dialog.setMinimumSize(new Dimension(500, 300));
  dialog.setSize(new Dimension(800, 600));
  dialog.setResizable(true);
  dialog.setLocationRelativeTo(this);
  dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
  dialog.setVisible(true);
}
 
Example 11
Source File: AboutBox.java    From jaamsim with Apache License 2.0 4 votes vote down vote up
public AboutBox() {
	super("About");

	setResizable(false);
	setDefaultCloseOperation(FrameBox.HIDE_ON_CLOSE);

	// setup the layout
	int index = 0;
	GridBagLayout layout = new GridBagLayout();
	getContentPane().setLayout(layout);

	// build the default constraints
	GridBagConstraints constraints = new GridBagConstraints();
	constraints.anchor = GridBagConstraints.WEST;
	constraints.gridx = index++;
	constraints.gridy = 0;

	constraints.insets = new Insets( 15, 15, 0, 15 );

	// display the model's name
	String name = GUIFrame.getJaamSimModel().getSimulation().getModelName();
	JLabel lab = new JLabel(name + " Version: " + version);
	lab.setFont(boldFont);
	layout.setConstraints( lab, constraints );
	getContentPane().add( lab );

	StringBuilder msg = new StringBuilder("NOTICE:\n\n");
	msg.append("Licensed under the Apache License, Version 2.0 (the \"License\");\n");
	msg.append("you may not use this file except in compliance with the License.\n");
	msg.append("You may obtain a copy of the License at\n");
	msg.append("\n");
	msg.append("   http://www.apache.org/licenses/LICENSE-2.0\n");
		msg.append("\n");
	msg.append("Unless required by applicable law or agreed to in writing, software\n");
	msg.append("distributed under the License is distributed on an \"AS IS\" BASIS,\n");
	msg.append("WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n");
	msg.append("See the License for the specific language governing permissions and\n");
	msg.append("limitations under the License.");

	JTextArea area = new JTextArea(msg.toString());
	area.setEditable(false);
	area.setFocusable(false);
	area.setBackground(lab.getBackground());
	area.setFont(boldFont);
	constraints.gridy = index++;
	layout.setConstraints( area, constraints );
	getContentPane().add( area );

	JButton closeButton = new JButton("OK");
	closeButton.addActionListener(this);

	constraints.gridy = index++;
	constraints.insets = new Insets( 10, 75, 15, 75 );
	constraints.anchor = GridBagConstraints.CENTER;
	layout.setConstraints( closeButton, constraints );
	getContentPane().add( closeButton );

	setSize( 300, 150 );
	pack();
}