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

The following examples show how to use javax.swing.JTextArea#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: SettingsPage.java    From xdm with GNU General Public License v2.0 5 votes vote down vote up
private JTextArea createTextArea(String name, Font font) {
	JTextArea textArea = new JTextArea();
	textArea.setOpaque(false);
	textArea.setWrapStyleWord(true);
	textArea.setLineWrap(true);
	textArea.setEditable(false);
	textArea.setForeground(Color.WHITE);
	textArea.setText(StringResource.get(name));
	textArea.setFont(font);
	return textArea;
}
 
Example 2
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 3
Source File: BasicQOptionPaneUI.java    From pumpernickel with MIT License 5 votes vote down vote up
@Override
protected void updateSecondaryMessage(QOptionPane pane) {
	super.updateSecondaryMessage(pane);
	JTextArea secondaryText = getSecondaryMessageTextArea(pane);
	Dimension secondaryTextSize = TextSize.getPreferredSize(secondaryText,
			getInt(pane, KEY_MESSAGE_WIDTH));
	Insets insets = getInsets(pane, KEY_SECONDARY_MESSAGE_INSETS);
	secondaryTextSize.width += insets.left + insets.right;
	secondaryTextSize.height += insets.top + insets.bottom;
	secondaryText.setPreferredSize(secondaryTextSize);
	secondaryText.setMinimumSize(secondaryTextSize);
	secondaryText.setEnabled(getBoolean(pane, KEY_TEXT_EDITABLE));
	secondaryText.setOpaque(false);
}
 
Example 4
Source File: NativeExecutionUserNotificationImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private JComponent createMessageComponent(String message) {
    final JTextArea textArea = new JTextArea(message.trim());
    int fontSize = textArea.getFont().getSize();
    textArea.setFont(new Font("Monospaced", Font.PLAIN, fontSize)); //NOI18N
    textArea.setEditable(false);
    textArea.setOpaque(false);
    return textArea;
}
 
Example 5
Source File: GeneralPropertiesProvider.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
public PropertiesPanel createPanel(JmxApplication dataSource) {
    PropertiesPanel panel = new PropertiesPanel();
    panel.setLayout(new BorderLayout());
    JTextArea textArea = new JTextArea() {
        public Dimension getMinimumSize() {
            Dimension prefSize = getPreferredSize();
            Dimension minSize = super.getMinimumSize();
            prefSize.width = 0;
            if (minSize.height < prefSize.height) return prefSize;
            else return minSize;
        }
    };
    textArea.setBorder(BorderFactory.createEmptyBorder());
    textArea.setOpaque(false);
    // Nimbus LaF doesn't respect setOpaque(false), this is a workaround.
    // May cause delays for remote X sessions due to color transparency.
    if (UIManager.getLookAndFeel().getID().equals("Nimbus")) // NOI18N
        textArea.setBackground(new Color(0, 0, 0, 0));
    textArea.setEditable(false);
    textArea.setLineWrap(true);
    textArea.setWrapStyleWord(true);
    textArea.setText(NbBundle.getMessage(GeneralPropertiesProvider.class, "MSG_ConnectionProperties")); // NOI18N
    textArea.setCaretPosition(0);
    textArea.setMinimumSize(new Dimension(1, 1));
    panel.add(textArea, BorderLayout.CENTER);
    return panel;
}
 
Example 6
Source File: ConfirmDialog.java    From megamek with GNU General Public License v2.0 5 votes vote down vote up
private void addQuestion(String question) {
    JTextArea questionLabel = new JTextArea(question);
    questionLabel.setEditable(false);
    questionLabel.setOpaque(false);
    c.gridheight = 2;
    c.insets = new Insets(5, 5, 5, 5);
    gridbag.setConstraints(questionLabel, c);
    getContentPane().add(questionLabel);
}
 
Example 7
Source File: MassageYesNo.java    From JAVA-MVC-Swing-Monopoly with Apache License 2.0 5 votes vote down vote up
private void addTextArea() {
	textArea = new JTextArea();
	textArea.setText("���˸�ȥ����");
	textArea.setBounds(18, 39, 230, 50);
	textArea.setSelectedTextColor(Color.BLUE);
	textArea.setOpaque(false);
	textArea.setEditable(false);
	textArea.setLineWrap(true);
	add(textArea);
}
 
Example 8
Source File: JFancyBox.java    From pumpernickel with MIT License 5 votes vote down vote up
protected static JComponent createContent(String text) {
	JTextArea textArea = new JTextArea(text);
	Dimension d = TextSize.getPreferredSize(textArea, 500);
	textArea.setPreferredSize(d);
	textArea.setEditable(false);
	textArea.setWrapStyleWord(true);
	textArea.setLineWrap(true);
	textArea.setOpaque(false);
	return textArea;
}
 
Example 9
Source File: GeneralPropertiesProvider.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
public PropertiesPanel createPanel(final Host dataSource) {
    PropertiesPanel panel = new PropertiesPanel();
    panel.setLayout(new BorderLayout());
    final JTextArea textArea = new JTextArea() {
        public Dimension getMinimumSize() {
            Dimension prefSize = getPreferredSize();
            Dimension minSize = super.getMinimumSize();
            prefSize.width = 0;
            if (minSize.height < prefSize.height) return prefSize;
            else return minSize;
        }
    };
    textArea.setBorder(BorderFactory.createEmptyBorder());
    textArea.setOpaque(false);
    // Nimbus LaF doesn't respect setOpaque(false), this is a workaround.
    // May cause delays for remote X sessions due to color transparency.
    if (UIManager.getLookAndFeel().getID().equals("Nimbus")) // NOI18N
        textArea.setBackground(new Color(0, 0, 0, 0));
    textArea.setEditable(false);
    textArea.setLineWrap(true);
    textArea.setWrapStyleWord(true);
    String resolving = NbBundle.getMessage(GeneralPropertiesProvider.class, "LBL_Resolving"); // NOI18N
    updateProperties(textArea, resolving, resolving);
    textArea.setMinimumSize(new Dimension(1, 1));
    panel.add(textArea, BorderLayout.CENTER);
    VisualVM.getInstance().runTask(new Runnable() {
        public void run() {
            InetAddress address = dataSource.getInetAddress();
            final String hostname = address.getCanonicalHostName();
            final String ip = address.getHostAddress();
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    updateProperties(textArea, hostname, ip);
                }
            });
        }
    });
    return panel;
}
 
Example 10
Source File: GuiUtils.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a text component to be used as a multi-line, automatically
 * wrapping label.
 * <p>
 * <strong>Restriction:</strong><br>
 * The component may have its preferred size very wide.
 *
 * @param  text  text of the label
 * @param  color  desired color of the label,
 *                or {@code null} if the default color should be used
 * @return  created multi-line text component
 */
public static JTextComponent createMultilineLabel(String text, Color color) {
    JTextArea textArea = new JTextArea(text);
    textArea.setEditable(false);
    textArea.setLineWrap(true);
    textArea.setWrapStyleWord(true);
    textArea.setEnabled(false);
    textArea.setOpaque(false);
    textArea.setColumns(25);
    textArea.setDisabledTextColor((color != null)
                                  ? color
                                  : new JLabel().getForeground());
    
    return textArea;
}
 
Example 11
Source File: PumpernickelShowcaseApp.java    From pumpernickel with MIT License 5 votes vote down vote up
private JTextArea createTextArea(String str, float fontSize) {
	JTextArea t = new JTextArea(str);
	Font font = UIManager.getFont("Label.font");
	if (font == null)
		font = t.getFont();
	t.setFont(font.deriveFont(fontSize));
	t.setEditable(false);
	t.setOpaque(false);
	t.setLineWrap(true);
	t.setWrapStyleWord(true);
	return t;
}
 
Example 12
Source File: BasicQOptionPaneUI.java    From pumpernickel with MIT License 5 votes vote down vote up
@Override
protected void updateMainMessage(QOptionPane pane) {
	super.updateMainMessage(pane);
	JTextArea mainText = getMainMessageTextArea(pane);
	Dimension mainTextSize = TextSize.getPreferredSize(mainText,
			getInt(pane, KEY_MESSAGE_WIDTH));
	Insets insets = getInsets(pane, KEY_MAIN_MESSAGE_INSETS);
	mainTextSize.width += insets.left + insets.right;
	mainTextSize.height += insets.top + insets.bottom;
	mainText.setPreferredSize(mainTextSize);
	mainText.setMinimumSize(mainTextSize);
	mainText.setEnabled(getBoolean(pane, KEY_TEXT_EDITABLE));
	mainText.setOpaque(false);
}
 
Example 13
Source File: mxCellEditor.java    From blog-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 
 */
public mxCellEditor(mxGraphComponent graphComponent)
{
	this.graphComponent = graphComponent;

	// Creates the plain text editor
	textArea = new JTextArea();
	textArea.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
	textArea.setOpaque(false);

	// Creates the HTML editor
	editorPane = new JEditorPane();
	editorPane.setOpaque(false);
	editorPane.setBackground(new Color(0,0,0,0));
	editorPane.setContentType("text/html");

	// Workaround for inserted linefeeds in HTML markup with
	// lines that are longar than 80 chars
	editorPane.setEditorKit(new NoLinefeedHtmlEditorKit());

	// Creates the scollpane that contains the editor
	// FIXME: Cursor not visible when scrolling
	scrollPane = new JScrollPane();
	scrollPane.setBorder(BorderFactory.createEmptyBorder());
	scrollPane.getViewport().setOpaque(false);
	scrollPane.setVisible(false);
	scrollPane.setOpaque(false);

	// Installs custom actions
	editorPane.getActionMap().put(CANCEL_EDITING, cancelEditingAction);
	textArea.getActionMap().put(CANCEL_EDITING, cancelEditingAction);
	editorPane.getActionMap().put(SUBMIT_TEXT, textSubmitAction);
	textArea.getActionMap().put(SUBMIT_TEXT, textSubmitAction);

	// Remembers the action map key for the enter keystroke
	editorEnterActionMapKey = editorPane.getInputMap().get(enterKeystroke);
	textEnterActionMapKey = editorPane.getInputMap().get(enterKeystroke);
}
 
Example 14
Source File: ParametersPanel.java    From hortonmachine with GNU General Public License v3.0 4 votes vote down vote up
private void addInputs( final List<FieldData> inputsList ) {
    rasterComboList = new ArrayList<>();
    vectorComboList = new ArrayList<>();
    CellConstraints cc = new CellConstraints();
    int row = 1;
    for( FieldData inputField : inputsList ) {
        if (inputField.fieldName.equals(PM_VAR_NAME)) {
            continue;
        }
        String fieldDescription = inputField.fieldDescription;
        String fieldLabel = fieldDescription;
        String fieldTooltip = fieldDescription;

        JTextArea nameLabel = new JTextArea();
        nameLabel.setOpaque(false);
        nameLabel.setLineWrap(true);
        nameLabel.setWrapStyleWord(true);
        nameLabel.setText(fieldLabel);
        nameLabel.setToolTipText(fieldTooltip);
        nameLabel.setEditable(false);

        TypeCheck fileCheck = getFileCheck(inputField);
        if (fileCheck.isOutput) {
            Font font = nameLabel.getFont();
            Font boldFont = new Font(font.getFontName(), Font.BOLD, font.getSize());
            nameLabel.setFont(boldFont);
        }
        this.add(nameLabel, cc.xy(1, row));

        // the rest of it
        int col = 3;

        if (isAtLeastOneAssignable(inputField.fieldType, String.class)) {
            if (inputField.guiHints != null && inputField.guiHints.startsWith(HMConstants.MULTILINE_UI_HINT)) {
                handleTextArea(inputField, row, col, cc);
            } else if (inputField.guiHints != null && inputField.guiHints.startsWith(HMConstants.COMBO_UI_HINT)) {
                handleComboField(inputField, row, col, cc);
            } else {
                handleTextField(inputField, row, col, cc, false, fileCheck);
            }
        } else if (isAtLeastOneAssignable(inputField.fieldType, Double.class, double.class)) {
            handleTextField(inputField, row, col, cc, true, fileCheck);
        } else if (isAtLeastOneAssignable(inputField.fieldType, Float.class, float.class)) {
            handleTextField(inputField, row, col, cc, true, fileCheck);
        } else if (isAtLeastOneAssignable(inputField.fieldType, Integer.class, int.class)) {
            handleTextField(inputField, row, col, cc, true, fileCheck);
        } else if (isAtLeastOneAssignable(inputField.fieldType, Short.class, short.class)) {
            handleTextField(inputField, row, col, cc, true, fileCheck);
        } else if (isAtLeastOneAssignable(inputField.fieldType, Boolean.class, boolean.class)) {
            handleBooleanField(inputField, row, col, cc);
            // } else if (isAtLeastOneAssignable(inputField.fieldType, GridCoverage2D.class)) {
            // handleGridcoverageInputField(inputField, row, col, cc);
            // } else if (isAtLeastOneAssignable(inputField.fieldType, GridGeometry2D.class)) {
            // handleGridgeometryInputField(inputField, row, col, cc);
            // } else if (isAtLeastOneAssignable(inputField.fieldType,
            // SimpleFeatureCollection.class)) {
            // handleFeatureInputField(inputField, row, col, cc);
            // } else if (isAtLeastOneAssignable(inputField.fieldType, HashMap.class)) {
            // handleHashMapInputField(inputField, row, col, cc);
            // } else if (isAtLeastOneAssignable(inputField.fieldType, List.class)) {
            // if (inputField.guiHints != null &&
            // inputField.guiHints.equals(OmsBoxConstants.FILESPATHLIST_UI_HINT)) {
            // handleFilesPathListInputField(inputField, row, col, cc);
            // } else {
            // handleListInputField(inputField, row, col, cc);
        }

        row++;
        this.add(new JSeparator(JSeparator.HORIZONTAL), cc.xy(1, row));
        this.add(new JSeparator(JSeparator.HORIZONTAL), cc.xy(2, row));
        this.add(new JSeparator(JSeparator.HORIZONTAL), cc.xy(3, row));
        row++;

        // row = row + 3;
    }
}
 
Example 15
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 16
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 17
Source File: BrowserAddonDlg.java    From xdm with GNU General Public License v2.0 4 votes vote down vote up
private void initUI() {
	setUndecorated(true);

	try {
		if (GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice()
				.isWindowTranslucencySupported(WindowTranslucency.TRANSLUCENT)) {
			if (!Config.getInstance().isNoTransparency()) {
				setOpacity(0.85f);
			}
		}
	} catch (Exception e) {
		Logger.log(e);
	}

	setIconImage(ImageResource.getImage("icon.png"));
	setSize(getScaledInt(400), getScaledInt(300));
	setLocationRelativeTo(null);
	setAlwaysOnTop(true);
	getContentPane().setLayout(null);
	getContentPane().setBackground(ColorResource.getDarkestBgColor());

	JPanel titlePanel = new TitlePanel(null, this);
	titlePanel.setOpaque(false);
	titlePanel.setBounds(0, 0, getScaledInt(400), getScaledInt(50));

	JButton closeBtn = new CustomButton();
	closeBtn.setBounds(getScaledInt(365), getScaledInt(5), getScaledInt(30), getScaledInt(30));
	closeBtn.setBackground(ColorResource.getDarkestBgColor());
	closeBtn.setBorderPainted(false);
	closeBtn.setFocusPainted(false);
	closeBtn.setName("CLOSE");

	closeBtn.setIcon(ImageResource.getIcon("title_close.png", 20, 20));
	closeBtn.addActionListener(this);
	titlePanel.add(closeBtn);

	JLabel titleLbl = new JLabel(StringResource.get("BROWSER_MONITORING"));
	titleLbl.setFont(FontResource.getBiggerFont());
	titleLbl.setForeground(ColorResource.getSelectionColor());
	titleLbl.setBounds(getScaledInt(25), getScaledInt(15), getScaledInt(200), getScaledInt(30));
	titlePanel.add(titleLbl);

	JLabel lineLbl = new JLabel();
	lineLbl.setBackground(ColorResource.getSelectionColor());
	lineLbl.setBounds(0, getScaledInt(55), getScaledInt(400), 1);
	lineLbl.setOpaque(true);
	add(lineLbl);
	add(titlePanel);

	int y = getScaledInt(65);
	int h = getScaledInt(50);
	JTextArea lblMonitoringTitle = new JTextArea();
	lblMonitoringTitle.setOpaque(false);
	lblMonitoringTitle.setWrapStyleWord(true);
	lblMonitoringTitle.setLineWrap(true);
	lblMonitoringTitle.setEditable(false);
	lblMonitoringTitle.setForeground(Color.WHITE);
	lblMonitoringTitle.setText(this.desc);
	lblMonitoringTitle.setFont(FontResource.getNormalFont());
	lblMonitoringTitle.setBounds(getScaledInt(15), y, getScaledInt(370) - getScaledInt(30), h);
	add(lblMonitoringTitle);
	y += h;

	JButton btViewMonitoring = createButton1("CTX_COPY_URL", getScaledInt(15), y);
	btViewMonitoring.setName("COPY");
	add(btViewMonitoring);
	y += btViewMonitoring.getHeight();

}
 
Example 18
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 19
Source File: ChooseDirectory.java    From orbit-image-analysis with GNU General Public License v3.0 4 votes vote down vote up
static void selectDirectory(Component parent, String selectedFile) {
  JDirectoryChooser chooser;

  if (System.getProperty("javawebstart.version") != null) {
    chooser = new JDirectoryChooser(new FakeFileSystemView()) {
      public void rescanCurrentDirectory() {
      }
      public void setCurrentDirectory(File dir) {
      }
    };
  } else {
    chooser = new JDirectoryChooser();
    if (selectedFile != null) {
      chooser.setSelectedFile(new File(selectedFile));
    }
  }
  
  JTextArea accessory = new JTextArea(RESOURCE
    .getString("selectDirectory.message"));
  accessory.setLineWrap(true);
  accessory.setWrapStyleWord(true);
  accessory.setEditable(false);
  accessory.setOpaque(false);
  accessory.setFont(UIManager.getFont("Tree.font"));
  chooser.setAccessory(accessory);

  chooser.setMultiSelectionEnabled(true);

  int choice = chooser.showOpenDialog(parent);
  if (choice == JDirectoryChooser.APPROVE_OPTION) {
    String filenames = "";
    File[] selectedFiles = chooser.getSelectedFiles();
    for (int i = 0, c = selectedFiles.length; i < c; i++) {
      filenames += "\n" + selectedFiles[i];
    }
    JOptionPane.showMessageDialog(parent, RESOURCE.getString(
      "selectDirectory.confirm", new Object[] {filenames}));
  } else {
    JOptionPane.showMessageDialog(parent, RESOURCE
      .getString("selectDirectory.cancel"));
  }
}
 
Example 20
Source File: SplashScreen.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static JPanel createSplashPanel() {
  final ImageIcon picture = IconLoader.getInstance().getAboutDialogPicture();

  // Create the image panel
  final JPanel imagePanel = new JPanel( new BorderLayout() );
  imagePanel.setUI( new BackgroundUI( picture ) );
  imagePanel.setBorder( BorderFactory.createLineBorder( Color.DARK_GRAY ) );

  // Overlay the version
  final JLabel versionLabel = new JLabel();
  final String buildString = ReportDesignerInfo.getInstance().getVersion();
  if ( buildString == null ) {
    versionLabel.setText( Messages.getString( "SplashScreen.DevelopmentVersion" ) );
  } else {
    versionLabel.setText( buildString );
  }
  versionLabel.setText( Messages.getString( "SplashScreen.Version", versionLabel.getText() ) );
  versionLabel.setFont( new Font( Font.SANS_SERIF, Font.BOLD, 14 ) );
  versionLabel.setOpaque( false );
  versionLabel.setBackground( TRANSPARENT );
  versionLabel.setForeground( DARK_GREY );
  versionLabel.setBorder( BORDER );
  versionLabel.setBounds( XLOC, YLOC, TEXT_WIDTH, versionLabel.getPreferredSize().height );

  // Overlay the license
  final String year = new SimpleDateFormat( "yyyy" ).format( new Date() );
  final JTextArea copyrightArea = new JTextArea( Messages.getString( "SplashScreen.Copyright", year ) );
  copyrightArea.setEditable( false );
  copyrightArea.setBounds( XLOC, YLOC + 20, TEXT_WIDTH, LICENSE_HEIGHT );
  copyrightArea.setOpaque( false );
  copyrightArea.setLineWrap( true );
  copyrightArea.setWrapStyleWord( true );
  copyrightArea.setFont( COPYRIGHT_FONT );
  copyrightArea.setEnabled( false );
  copyrightArea.setBackground( TRANSPARENT );
  copyrightArea.setForeground( DARK_GREY );
  copyrightArea.setBorder( BORDER );
  copyrightArea.setDisabledTextColor( copyrightArea.getForeground() );

  // Overlay the copyright
  final JTextArea licenseArea = new JTextArea( Messages.getString( "SplashScreen.License" ) );
  licenseArea.setEditable( false );
  licenseArea.setBounds( XLOC, YLOC + 14 + LICENSE_HEIGHT, TEXT_WIDTH, COPYRIGHT_HEIGHT );
  licenseArea.setOpaque( false );
  licenseArea.setLineWrap( true );
  licenseArea.setWrapStyleWord( true );
  licenseArea.setFont( LICENSE_FONT );
  licenseArea.setEnabled( false );
  licenseArea.setBackground( TRANSPARENT );
  licenseArea.setBorder( BORDER );
  licenseArea.setDisabledTextColor( copyrightArea.getForeground() );

  // Add all the overlays
  final JPanel imagePanelOverlay = new JPanel( null );
  imagePanelOverlay.setOpaque( false );
  imagePanelOverlay.add( versionLabel );
  imagePanelOverlay.add( copyrightArea );
  imagePanelOverlay.add( licenseArea );
  imagePanelOverlay.setBackground( TRANSPARENT );

  imagePanel.add( imagePanelOverlay );
  imagePanel.setPreferredSize( new Dimension( picture.getIconWidth(), picture.getIconHeight() ) );

  return imagePanel;
}