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

The following examples show how to use javax.swing.JTextArea#setForeground() . 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: ConsoleFrame.java    From seventh with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @return the text area
 */
private JTextArea setupTextArea(JPanel contentPane) {
    JPanel textAreaPanel = new JPanel(new BorderLayout());
    
    JTextArea text = new JTextArea(NUMBER_OF_ROWS, NUMBER_OF_COLUMNS);
    text.setText(this.welcomeBanner);
    
    text.setFont(new Font("Courier New", Font.PLAIN, 12));
    text.setLineWrap(true);
    text.setWrapStyleWord(true);        
    text.setEditable(false);
            
    text.setBackground(Color.BLUE);
    text.setForeground(Color.YELLOW);
    
    JScrollPane scrollPane = new JScrollPane(text);
    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);        
    scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    
    textAreaPanel.add(scrollPane, BorderLayout.CENTER);
    contentPane.add(textAreaPanel);
    
    return text;
}
 
Example 2
Source File: ClientEditConfigPanel.java    From logging-log4j2 with Apache License 2.0 6 votes vote down vote up
private void createWidgets() {
    configTextArea = new JTextArea(CONFIG_TEXT_ROWS, CONFIG_TEXT_COLS);
    // configTextArea.setEditable(false);
    configTextArea.setBackground(Color.white);
    configTextArea.setForeground(Color.black);
    configTextArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, configTextArea.getFont().getSize()));
    final JScrollPane scrollConfig = new JScrollPane(configTextArea);

    locationTextField = new JTextField(LOCATION_TEXT_COLS);
    locationLabel = new JLabel("Location: ");
    locationLabel.setLabelFor(locationTextField);
    buttonSendLocation = new JButton(actionReconfigureFromLocation);
    buttonSendConfigText = new JButton(actionReconfigureFromText);

    final JPanel north = new JPanel();
    north.setLayout(new BoxLayout(north, BoxLayout.LINE_AXIS));
    north.add(locationLabel);
    north.add(locationTextField);
    north.add(buttonSendLocation);
    north.add(Box.createRigidArea(new Dimension(HORIZONTAL_GAP, 0)));
    north.add(buttonSendConfigText);

    this.setLayout(new BorderLayout());
    this.add(north, BorderLayout.NORTH);
    this.add(scrollConfig, BorderLayout.CENTER);
}
 
Example 3
Source File: GlobalSearchDialog.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Sets up the GUI card responsible for displaying error information to the user.
 */
private void setupErrorGUI() {
	JPanel errorPanel = new JPanel();
	errorPanel.setName(CARD_ERROR);
	errorPanel.setLayout(new GridBagLayout());
	errorPanel.setOpaque(false);
	errorPanel.setBorder(TOP_BORDER);

	errorText = new JTextArea();
	errorText.setLineWrap(true);
	errorText.setWrapStyleWord(true);
	errorText.setForeground(ERROR_TEXT_COLOR);
	errorText.setBackground(Colors.WINDOW_BACKGROUND);
	errorText.setEditable(false);
	errorText.setBorder(null);

	GridBagConstraints gbc = new GridBagConstraints();
	gbc.weightx = 1.0d;
	gbc.weighty = 1.0d;
	gbc.fill = GridBagConstraints.BOTH;
	gbc.insets = new Insets(5, 5, 5, 5);
	errorPanel.add(errorText, gbc);

	rootPanel.add(errorPanel, CARD_ERROR);
}
 
Example 4
Source File: ChatMainPane.java    From osrsclient with GNU General Public License v2.0 6 votes vote down vote up
public void addChanPanel(String chanName) {

        JTextArea messagePanel = new JTextArea();
        messagePanel.setLineWrap(true);
        messagePanel.setBackground(new Color(71, 71, 71));
        messagePanel.setForeground(Color.white);
        messagePanel.setFont(ircFont);
        messagePanel.setEditable(false);
        DefaultCaret dc = (DefaultCaret) messagePanel.getCaret();
        dc.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);

        JTextArea userPanel = new JTextArea();
        userPanel.setBackground(new Color(71, 71, 71));

        messagePanels.put(chanName, messagePanel);
        userPanels.put(chanName, userPanel);
       
    }
 
Example 5
Source File: LogManagerPanel.java    From software-demo with MIT License 5 votes vote down vote up
/**
 * Create the panel.
 */
public LogManagerPanel() {
	setBounds(0, 0, 1165, 725);
	setLayout(null);
	
	JButton btnNewButton = new JButton("日志刷新");
	btnNewButton.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
			//重新加载日志
			initData();
		}
	});
	btnNewButton.setBounds(29, 29, 93, 23);
	add(btnNewButton);
	
	JPanel panel = new JPanel();
	panel.setBackground(Color.WHITE);
	panel.setBounds(10, 81, 1145, 611);
	panel.setBorder(BorderFactory.createTitledBorder("日志列表:"));
	add(panel);
	panel.setLayout(null);
	
	textArea = new JTextArea();
	textArea.setForeground(Color.GREEN);
	textArea.setBackground(Color.BLACK);
	textArea.setFont(new Font("Monospaced", Font.PLAIN, 17));
	JScrollPane js = new JScrollPane(textArea);
	js.setBounds(25, 25, 1100, 570);
	panel.add(js);
	initData();
}
 
Example 6
Source File: AbstractDataMonitorView.java    From ET_Redux with Apache License 2.0 5 votes vote down vote up
private void rawDataFilePathTextFactory() throws IOException {
    // show rawdatafile path
    rawDataFilePathTextArea = new JTextArea(//
            "Monitoring Raw data location: "
            + rawDataFileHandler.getAcquisitionModel().getRawDataFile().getCanonicalPath());

    rawDataFilePathTextArea.setBounds(leftMargin + 50, topMargin, parentDimension.width - 100, 40);
    rawDataFilePathTextArea.setLineWrap(true);
    rawDataFilePathTextArea.setEditable(false);
    rawDataFilePathTextArea.setForeground(Color.RED);
    this.add(rawDataFilePathTextArea, JLayeredPane.DEFAULT_LAYER);
}
 
Example 7
Source File: DataDetails.java    From chipster with MIT License 4 votes vote down vote up
/**
 * @param panel2 
 * @return A String containing descriptions of the chosen dataset's
 * 		   attributes - that is, name, date, and details about the
 * 		   operation (including parameters) that produced it.
 */
private JPanel createParameterTable(JPanel panel) {

	final int TOOL_WIDTH = 250;
	
		
	OperationRecord operationRecord = datas.get(0).getOperationRecord();			
	if (operationRecord != null) {

		Collection<ParameterRecord> params = operationRecord.getParameters();

		if (params != null) {
			for (ParameterRecord parameterRecord : params) {

				// find out default value and human readable value
				OperationDefinition tool = application.getOperationDefinition(operationRecord.getNameID().getID());
				
				String defaultValue = null;
				String valueString = null;
									
				if (tool != null) {
					defaultValue = tool.getParameterDefaultValue(parameterRecord);
					valueString = tool.getHumanReadableParameterValue(parameterRecord);
					
				} else {						
					valueString = parameterRecord.getValue();
				}

				JTextArea name = new JTextArea(parameterRecord.getNameID().getDisplayName());					
				JTextArea value =  new JTextArea(valueString);
				
				name.setLineWrap(true);
				value.setLineWrap(true);
				
				name.setWrapStyleWord(true);
				value.setWrapStyleWord(true);
				
				name.setEditable(false);
				value.setEditable(false);

				// fade out default values
				if (defaultValue != null && defaultValue.equals(parameterRecord.getValue())) {
					value.setForeground(Color.gray);
				}
				
				panel.add(name, "split 2, gapx " + INDENTION + ", width " + TOOL_WIDTH);
				panel.add(value, "growx, pushx, wrap");
			}
		}
	}

	return panel;
}
 
Example 8
Source File: IdeOptions.java    From CQL with GNU Affero General Public License v3.0 4 votes vote down vote up
public void apply(IdeOption o, JTextArea a) {

		switch (o) {
		case CLEAR_WHITESPACE_LINES:
			// case TAB_LINE_COLOR:
		case BOOKMARKING_ENABLED:
		case NUMBER_COLOR:
		case OUTLINE_ELONGATED:
		case FILE_PATH:
		case BOOKMARK_COLOR:
		//case OUTLINE_DELAY:
		case HTML_COLOR:
		case LINE_NUMBERS:
		case OUTLINE_FONT:
		case LOOK_AND_FEEL:
			// case SPELL_CHECK:
		case COMMENT_COLOR:
		case KEYWORD_1_COLOR:
		case KEYWORD_2_COLOR:
		case SYMBOL_COLOR:
		case OUTLINE_TYPES:
		case QUOTE_COLOR:
		case BRACKET_MATCH_BG_COLOR:
		case BRACKET_MATCH_BORDER_COLOR:
		case CURRENT_LINE_HIGHLIGHT_COLOR:
		case MARGIN_LINE_COLOR:
		case MARK_ALL_HIGHLIGHT_COLOR:
		case AUTO_CLOSE_BRACES:
		case AUTO_INDENT:
		case LINE_HIGHLIGHT:
		case MARK_OCCURANCES:
		case SHOW_MARGIN:
		case FADE_CURRENT_LINE:
		case FOLDING:
		case MATCH_BRACKET:
		case ROUNDED_EDGES:
		case SHOW_MATCHED_POPUP:
		case TABS_EMULATED:
		case ANIMATE_MATCH:
		case MARGIN_COLS:
		case ENABLE_OUTLINE:
		case OUTLINE_ON_LEFT:
		case OUTLINE_PREFIX_KIND:
		case ANTIALIASING:
		case TAB_LINES:

			return;

		case BACKGROUND_COLOR:
			a.setBackground(getColor(o));
			return;

		case CARET_COLOR:
			a.setCaretColor(getColor(o));
			return;

		case FONT:
			a.setFont(getFont(o));
			return;
		case FOREGROUND_COLOR:
			a.setForeground(getColor(o));
			return;
		case LINE_WRAP:
			return;
		case SELECTION_COLOR:
			a.setSelectionColor(getColor(o));
			return;
		case TAB_SIZE:
			a.setTabSize(getNat(o));
			return;

		default:
			Util.anomaly();
		}
	}
 
Example 9
Source File: XTextAreaPeer.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void installUI(JComponent c) {
    super.installUI(c);

    jta = (JTextArea) c;

    JTextArea editor = jta;

    UIDefaults uidefaults = XToolkit.getUIDefaults();

    String prefix = getPropertyPrefix();
    Font f = editor.getFont();
    if ((f == null) || (f instanceof UIResource)) {
        editor.setFont(uidefaults.getFont(prefix + ".font"));
    }

    Color bg = editor.getBackground();
    if ((bg == null) || (bg instanceof UIResource)) {
        editor.setBackground(uidefaults.getColor(prefix + ".background"));
    }

    Color fg = editor.getForeground();
    if ((fg == null) || (fg instanceof UIResource)) {
        editor.setForeground(uidefaults.getColor(prefix + ".foreground"));
    }

    Color color = editor.getCaretColor();
    if ((color == null) || (color instanceof UIResource)) {
        editor.setCaretColor(uidefaults.getColor(prefix + ".caretForeground"));
    }

    Color s = editor.getSelectionColor();
    if ((s == null) || (s instanceof UIResource)) {
        editor.setSelectionColor(uidefaults.getColor(prefix + ".selectionBackground"));
    }

    Color sfg = editor.getSelectedTextColor();
    if ((sfg == null) || (sfg instanceof UIResource)) {
        editor.setSelectedTextColor(uidefaults.getColor(prefix + ".selectionForeground"));
    }

    Color dfg = editor.getDisabledTextColor();
    if ((dfg == null) || (dfg instanceof UIResource)) {
        editor.setDisabledTextColor(uidefaults.getColor(prefix + ".inactiveForeground"));
    }

    Border b = new BevelBorder(false,SystemColor.controlDkShadow,SystemColor.controlLtHighlight);
    editor.setBorder(new BorderUIResource.CompoundBorderUIResource(
        b,new EmptyBorder(2, 2, 2, 2)));

    Insets margin = editor.getMargin();
    if (margin == null || margin instanceof UIResource) {
        editor.setMargin(uidefaults.getInsets(prefix + ".margin"));
    }
}
 
Example 10
Source File: XTextAreaPeer.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void installUI(JComponent c) {
    super.installUI(c);

    jta = (JTextArea) c;

    JTextArea editor = jta;

    UIDefaults uidefaults = XToolkit.getUIDefaults();

    String prefix = getPropertyPrefix();
    Font f = editor.getFont();
    if ((f == null) || (f instanceof UIResource)) {
        editor.setFont(uidefaults.getFont(prefix + ".font"));
    }

    Color bg = editor.getBackground();
    if ((bg == null) || (bg instanceof UIResource)) {
        editor.setBackground(uidefaults.getColor(prefix + ".background"));
    }

    Color fg = editor.getForeground();
    if ((fg == null) || (fg instanceof UIResource)) {
        editor.setForeground(uidefaults.getColor(prefix + ".foreground"));
    }

    Color color = editor.getCaretColor();
    if ((color == null) || (color instanceof UIResource)) {
        editor.setCaretColor(uidefaults.getColor(prefix + ".caretForeground"));
    }

    Color s = editor.getSelectionColor();
    if ((s == null) || (s instanceof UIResource)) {
        editor.setSelectionColor(uidefaults.getColor(prefix + ".selectionBackground"));
    }

    Color sfg = editor.getSelectedTextColor();
    if ((sfg == null) || (sfg instanceof UIResource)) {
        editor.setSelectedTextColor(uidefaults.getColor(prefix + ".selectionForeground"));
    }

    Color dfg = editor.getDisabledTextColor();
    if ((dfg == null) || (dfg instanceof UIResource)) {
        editor.setDisabledTextColor(uidefaults.getColor(prefix + ".inactiveForeground"));
    }

    Border b = new BevelBorder(false,SystemColor.controlDkShadow,SystemColor.controlLtHighlight);
    editor.setBorder(new BorderUIResource.CompoundBorderUIResource(
        b,new EmptyBorder(2, 2, 2, 2)));

    Insets margin = editor.getMargin();
    if (margin == null || margin instanceof UIResource) {
        editor.setMargin(uidefaults.getInsets(prefix + ".margin"));
    }
}
 
Example 11
Source File: ConnectionInfoPanel.java    From rapidminer-studio with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Creates a connection information display panel.
 *
 * @param connection
 * 		the model of the connection to show
 * @param showDescriptions
 * 		if {@code true} descriptions for the headers are displayed
 */
public ConnectionInfoPanel(ConnectionModel connection, boolean showDescriptions) {
	super(new GridBagLayout());
	this.editable = connection.isEditable();
	String connectionType = connection.getType();
	isTypeKnown = ConnectionHandlerRegistry.getInstance().isTypeKnown(connectionType);

	// header with icon, name, and type
	GridBagConstraints gbc = new GridBagConstraints();
	JPanel headerPanel = new JPanel(new GridBagLayout());
	GridBagConstraints headerGbc = new GridBagConstraints();
	headerGbc.gridx = 0;
	headerGbc.gridy = 0;
	headerGbc.anchor = GridBagConstraints.WEST;
	headerGbc.gridheight = 2;
	headerGbc.insets = new Insets(0, 0, 0, 10);
	headerPanel.add(new JLabel(ConnectionI18N.getConnectionIcon(connectionType, IconSize.HUGE)), headerGbc);

	headerGbc.gridx = 1;
	headerGbc.gridheight = 1;
	headerGbc.insets = new Insets(0, 0, 0, 0);
	JLabel nameLabel = new JLabel(connection.getName());
	nameLabel.setToolTipText(connection.getName());
	nameLabel.setFont(OPEN_SANS_SEMIBOLD_24);
	headerPanel.add(nameLabel, headerGbc);

	headerGbc.gridx = 1;
	headerGbc.gridy += 1;
	headerGbc.gridheight = 1;
	JComponent typeComponent = createTypeComponent(connectionType);
	headerPanel.add(typeComponent, headerGbc);

	gbc.gridx = 0;
	gbc.gridy = 0;
	gbc.weightx = 1.0;
	gbc.fill = GridBagConstraints.HORIZONTAL;
	gbc.anchor = GridBagConstraints.NORTHWEST;
	gbc.insets = new Insets(25, 25, 15, 25);
	JPanel headerOuterPanel = new JPanel(new BorderLayout());
	headerOuterPanel.add(headerPanel, BorderLayout.WEST);
	add(headerOuterPanel, gbc);

	gbc.gridy += 1;
	gbc.weightx = 0.8;
	gbc.insets = new Insets(0, 20, 0, 200);
	JSeparator separator = new JSeparator();
	add(separator, gbc);

	// body with location, description, and tags
	JPanel bodyPanel = new JPanel(new GridLayout(3, 2, 30, 20));
	bodyPanel.add(createDescriptionPanel(ConnectionI18N.getConnectionGUILabel("location"),
			ConnectionI18N.getConnectionGUILabel("location_description"), showDescriptions));

	String repositoryName = connection.getLocation() != null ?
			RepositoryLocation.REPOSITORY_PREFIX + connection.getLocation().getRepositoryName() : "";
	JTextArea locArea = new JTextArea(repositoryName);
	locArea.setEditable(false);
	locArea.setHighlighter(null);
	locArea.setLineWrap(true);
	locArea.setComponentPopupMenu(null);
	locArea.setInheritsPopupMenu(false);
	locArea.setBackground(getBackground());
	locArea.setBorder(BorderFactory.createEmptyBorder());
	locArea.setFont(OPEN_SANS_12);
	if (!isTypeKnown) {
		locArea.setForeground(UNKNOWN_TYPE_COLOR);
	}

	bodyPanel.add(locArea);

	bodyPanel.add(createDescriptionPanel(ConnectionI18N.getConnectionGUILabel("description"),
			ConnectionI18N.getConnectionGUILabel("description_description"), showDescriptions));

	bodyPanel.add(createTextArea(connection.descriptionProperty()));

	bodyPanel.add(createDescriptionPanel(ConnectionI18N.getConnectionGUILabel("tags"),
			ConnectionI18N.getConnectionGUILabel("tags_description"), showDescriptions));

	bodyPanel.add(createTagPanel(connection.getTags(), connection::setTags));

	gbc.gridy += 1;
	gbc.weightx = 1.0;
	gbc.weighty = 1.0;
	gbc.fill = GridBagConstraints.BOTH;
	gbc.insets = new Insets(15, 25, 10, 25);
	add(bodyPanel, gbc);
}
 
Example 12
Source File: XTextAreaPeer.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void installUI(JComponent c) {
    super.installUI(c);

    jta = (JTextArea) c;

    JTextArea editor = jta;

    UIDefaults uidefaults = XToolkit.getUIDefaults();

    String prefix = getPropertyPrefix();
    Font f = editor.getFont();
    if ((f == null) || (f instanceof UIResource)) {
        editor.setFont(uidefaults.getFont(prefix + ".font"));
    }

    Color bg = editor.getBackground();
    if ((bg == null) || (bg instanceof UIResource)) {
        editor.setBackground(uidefaults.getColor(prefix + ".background"));
    }

    Color fg = editor.getForeground();
    if ((fg == null) || (fg instanceof UIResource)) {
        editor.setForeground(uidefaults.getColor(prefix + ".foreground"));
    }

    Color color = editor.getCaretColor();
    if ((color == null) || (color instanceof UIResource)) {
        editor.setCaretColor(uidefaults.getColor(prefix + ".caretForeground"));
    }

    Color s = editor.getSelectionColor();
    if ((s == null) || (s instanceof UIResource)) {
        editor.setSelectionColor(uidefaults.getColor(prefix + ".selectionBackground"));
    }

    Color sfg = editor.getSelectedTextColor();
    if ((sfg == null) || (sfg instanceof UIResource)) {
        editor.setSelectedTextColor(uidefaults.getColor(prefix + ".selectionForeground"));
    }

    Color dfg = editor.getDisabledTextColor();
    if ((dfg == null) || (dfg instanceof UIResource)) {
        editor.setDisabledTextColor(uidefaults.getColor(prefix + ".inactiveForeground"));
    }

    Border b = new BevelBorder(false,SystemColor.controlDkShadow,SystemColor.controlLtHighlight);
    editor.setBorder(new BorderUIResource.CompoundBorderUIResource(
        b,new EmptyBorder(2, 2, 2, 2)));

    Insets margin = editor.getMargin();
    if (margin == null || margin instanceof UIResource) {
        editor.setMargin(uidefaults.getInsets(prefix + ".margin"));
    }
}
 
Example 13
Source File: XTextAreaPeer.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void installUI(JComponent c) {
    super.installUI(c);

    jta = (JTextArea) c;

    JTextArea editor = jta;

    UIDefaults uidefaults = XToolkit.getUIDefaults();

    String prefix = getPropertyPrefix();
    Font f = editor.getFont();
    if ((f == null) || (f instanceof UIResource)) {
        editor.setFont(uidefaults.getFont(prefix + ".font"));
    }

    Color bg = editor.getBackground();
    if ((bg == null) || (bg instanceof UIResource)) {
        editor.setBackground(uidefaults.getColor(prefix + ".background"));
    }

    Color fg = editor.getForeground();
    if ((fg == null) || (fg instanceof UIResource)) {
        editor.setForeground(uidefaults.getColor(prefix + ".foreground"));
    }

    Color color = editor.getCaretColor();
    if ((color == null) || (color instanceof UIResource)) {
        editor.setCaretColor(uidefaults.getColor(prefix + ".caretForeground"));
    }

    Color s = editor.getSelectionColor();
    if ((s == null) || (s instanceof UIResource)) {
        editor.setSelectionColor(uidefaults.getColor(prefix + ".selectionBackground"));
    }

    Color sfg = editor.getSelectedTextColor();
    if ((sfg == null) || (sfg instanceof UIResource)) {
        editor.setSelectedTextColor(uidefaults.getColor(prefix + ".selectionForeground"));
    }

    Color dfg = editor.getDisabledTextColor();
    if ((dfg == null) || (dfg instanceof UIResource)) {
        editor.setDisabledTextColor(uidefaults.getColor(prefix + ".inactiveForeground"));
    }

    Border b = new BevelBorder(false,SystemColor.controlDkShadow,SystemColor.controlLtHighlight);
    editor.setBorder(new BorderUIResource.CompoundBorderUIResource(
        b,new EmptyBorder(2, 2, 2, 2)));

    Insets margin = editor.getMargin();
    if (margin == null || margin instanceof UIResource) {
        editor.setMargin(uidefaults.getInsets(prefix + ".margin"));
    }
}
 
Example 14
Source File: XTextAreaPeer.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void installUI(JComponent c) {
    super.installUI(c);

    jta = (JTextArea) c;

    JTextArea editor = jta;

    UIDefaults uidefaults = XToolkit.getUIDefaults();

    String prefix = getPropertyPrefix();
    Font f = editor.getFont();
    if ((f == null) || (f instanceof UIResource)) {
        editor.setFont(uidefaults.getFont(prefix + ".font"));
    }

    Color bg = editor.getBackground();
    if ((bg == null) || (bg instanceof UIResource)) {
        editor.setBackground(uidefaults.getColor(prefix + ".background"));
    }

    Color fg = editor.getForeground();
    if ((fg == null) || (fg instanceof UIResource)) {
        editor.setForeground(uidefaults.getColor(prefix + ".foreground"));
    }

    Color color = editor.getCaretColor();
    if ((color == null) || (color instanceof UIResource)) {
        editor.setCaretColor(uidefaults.getColor(prefix + ".caretForeground"));
    }

    Color s = editor.getSelectionColor();
    if ((s == null) || (s instanceof UIResource)) {
        editor.setSelectionColor(uidefaults.getColor(prefix + ".selectionBackground"));
    }

    Color sfg = editor.getSelectedTextColor();
    if ((sfg == null) || (sfg instanceof UIResource)) {
        editor.setSelectedTextColor(uidefaults.getColor(prefix + ".selectionForeground"));
    }

    Color dfg = editor.getDisabledTextColor();
    if ((dfg == null) || (dfg instanceof UIResource)) {
        editor.setDisabledTextColor(uidefaults.getColor(prefix + ".inactiveForeground"));
    }

    Border b = new BevelBorder(false,SystemColor.controlDkShadow,SystemColor.controlLtHighlight);
    editor.setBorder(new BorderUIResource.CompoundBorderUIResource(
        b,new EmptyBorder(2, 2, 2, 2)));

    Insets margin = editor.getMargin();
    if (margin == null || margin instanceof UIResource) {
        editor.setMargin(uidefaults.getInsets(prefix + ".margin"));
    }
}
 
Example 15
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 16
Source File: XTextAreaPeer.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void installUI(JComponent c) {
    super.installUI(c);

    jta = (JTextArea) c;

    JTextArea editor = jta;

    UIDefaults uidefaults = XToolkit.getUIDefaults();

    String prefix = getPropertyPrefix();
    Font f = editor.getFont();
    if ((f == null) || (f instanceof UIResource)) {
        editor.setFont(uidefaults.getFont(prefix + ".font"));
    }

    Color bg = editor.getBackground();
    if ((bg == null) || (bg instanceof UIResource)) {
        editor.setBackground(uidefaults.getColor(prefix + ".background"));
    }

    Color fg = editor.getForeground();
    if ((fg == null) || (fg instanceof UIResource)) {
        editor.setForeground(uidefaults.getColor(prefix + ".foreground"));
    }

    Color color = editor.getCaretColor();
    if ((color == null) || (color instanceof UIResource)) {
        editor.setCaretColor(uidefaults.getColor(prefix + ".caretForeground"));
    }

    Color s = editor.getSelectionColor();
    if ((s == null) || (s instanceof UIResource)) {
        editor.setSelectionColor(uidefaults.getColor(prefix + ".selectionBackground"));
    }

    Color sfg = editor.getSelectedTextColor();
    if ((sfg == null) || (sfg instanceof UIResource)) {
        editor.setSelectedTextColor(uidefaults.getColor(prefix + ".selectionForeground"));
    }

    Color dfg = editor.getDisabledTextColor();
    if ((dfg == null) || (dfg instanceof UIResource)) {
        editor.setDisabledTextColor(uidefaults.getColor(prefix + ".inactiveForeground"));
    }

    Border b = new BevelBorder(false,SystemColor.controlDkShadow,SystemColor.controlLtHighlight);
    editor.setBorder(new BorderUIResource.CompoundBorderUIResource(
        b,new EmptyBorder(2, 2, 2, 2)));

    Insets margin = editor.getMargin();
    if (margin == null || margin instanceof UIResource) {
        editor.setMargin(uidefaults.getInsets(prefix + ".margin"));
    }
}
 
Example 17
Source File: BotToolsWindow.java    From wpcleaner with Apache License 2.0 4 votes vote down vote up
/**
 * @return Window components.
 */
@Override
protected Component createComponents() {
  JPanel panel = new JPanel(new GridBagLayout());

  // Initialize constraints
  GridBagConstraints constraints = new GridBagConstraints();
  constraints.fill = GridBagConstraints.BOTH;
  constraints.gridheight = 1;
  constraints.gridwidth = 1;
  constraints.gridx = 0;
  constraints.gridy = 0;
  constraints.insets = new Insets(0, 0, 0, 0);
  constraints.ipadx = 0;
  constraints.ipady = 0;
  constraints.weightx = 1;
  constraints.weighty = 0;

  // Warning
  String txtWarning =
    GT._T("!!! WARNING !!!") + "\n" +
    GT._T("Functions available here are considered as bot tools.") + "\n" +
    GT._T("They may modify a lot of pages in a short period of time.") + "\n" +
    GT._T("On some Wikipedia projects, you may need the bot status for doing this.") + "\n" +
    GT._T("Please, check if you need the bot status by reading the rules of Wikipedia.");
  JTextArea lblWarning = new JTextArea(txtWarning);
  lblWarning.setEditable(false);
  lblWarning.setBackground(getParentComponent().getBackground());
  lblWarning.setForeground(Color.RED);
  panel.add(lblWarning, constraints);
  constraints.gridy++;

  // Tabs
  JTabbedPane pane = new JTabbedPane();
  GeneralToolsPanel generalTools = new GeneralToolsPanel(this);
  pane.addTab(GT._T("General"), generalTools);
  panels.add(generalTools);
  CWToolsPanel cwTools = new CWToolsPanel(this);
  pane.addTab(GT._T("Check Wiki"), cwTools);
  panels.add(cwTools);
  constraints.weighty = 1;
  panel.add(pane, constraints);
  constraints.gridy++;

  // Buttons
  JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
  JButton buttonClose = ActionDispose.createButton(getParentComponent(), true, false);
  buttonPanel.add(buttonClose);
  constraints.fill = GridBagConstraints.HORIZONTAL;
  constraints.gridx = 0;
  constraints.weightx = 1;
  constraints.weighty = 0;
  panel.add(buttonPanel, constraints);
  constraints.gridy++;

  updateComponentState();
  return panel;
}
 
Example 18
Source File: XTextAreaPeer.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void installUI(JComponent c) {
    super.installUI(c);

    jta = (JTextArea) c;

    JTextArea editor = jta;

    UIDefaults uidefaults = XToolkit.getUIDefaults();

    String prefix = getPropertyPrefix();
    Font f = editor.getFont();
    if ((f == null) || (f instanceof UIResource)) {
        editor.setFont(uidefaults.getFont(prefix + ".font"));
    }

    Color bg = editor.getBackground();
    if ((bg == null) || (bg instanceof UIResource)) {
        editor.setBackground(uidefaults.getColor(prefix + ".background"));
    }

    Color fg = editor.getForeground();
    if ((fg == null) || (fg instanceof UIResource)) {
        editor.setForeground(uidefaults.getColor(prefix + ".foreground"));
    }

    Color color = editor.getCaretColor();
    if ((color == null) || (color instanceof UIResource)) {
        editor.setCaretColor(uidefaults.getColor(prefix + ".caretForeground"));
    }

    Color s = editor.getSelectionColor();
    if ((s == null) || (s instanceof UIResource)) {
        editor.setSelectionColor(uidefaults.getColor(prefix + ".selectionBackground"));
    }

    Color sfg = editor.getSelectedTextColor();
    if ((sfg == null) || (sfg instanceof UIResource)) {
        editor.setSelectedTextColor(uidefaults.getColor(prefix + ".selectionForeground"));
    }

    Color dfg = editor.getDisabledTextColor();
    if ((dfg == null) || (dfg instanceof UIResource)) {
        editor.setDisabledTextColor(uidefaults.getColor(prefix + ".inactiveForeground"));
    }

    Border b = new BevelBorder(false,SystemColor.controlDkShadow,SystemColor.controlLtHighlight);
    editor.setBorder(new BorderUIResource.CompoundBorderUIResource(
        b,new EmptyBorder(2, 2, 2, 2)));

    Insets margin = editor.getMargin();
    if (margin == null || margin instanceof UIResource) {
        editor.setMargin(uidefaults.getInsets(prefix + ".margin"));
    }
}
 
Example 19
Source File: XTextAreaPeer.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void installUI(JComponent c) {
    super.installUI(c);

    jta = (JTextArea) c;

    JTextArea editor = jta;

    UIDefaults uidefaults = XToolkit.getUIDefaults();

    String prefix = getPropertyPrefix();
    Font f = editor.getFont();
    if ((f == null) || (f instanceof UIResource)) {
        editor.setFont(uidefaults.getFont(prefix + ".font"));
    }

    Color bg = editor.getBackground();
    if ((bg == null) || (bg instanceof UIResource)) {
        editor.setBackground(uidefaults.getColor(prefix + ".background"));
    }

    Color fg = editor.getForeground();
    if ((fg == null) || (fg instanceof UIResource)) {
        editor.setForeground(uidefaults.getColor(prefix + ".foreground"));
    }

    Color color = editor.getCaretColor();
    if ((color == null) || (color instanceof UIResource)) {
        editor.setCaretColor(uidefaults.getColor(prefix + ".caretForeground"));
    }

    Color s = editor.getSelectionColor();
    if ((s == null) || (s instanceof UIResource)) {
        editor.setSelectionColor(uidefaults.getColor(prefix + ".selectionBackground"));
    }

    Color sfg = editor.getSelectedTextColor();
    if ((sfg == null) || (sfg instanceof UIResource)) {
        editor.setSelectedTextColor(uidefaults.getColor(prefix + ".selectionForeground"));
    }

    Color dfg = editor.getDisabledTextColor();
    if ((dfg == null) || (dfg instanceof UIResource)) {
        editor.setDisabledTextColor(uidefaults.getColor(prefix + ".inactiveForeground"));
    }

    Border b = new BevelBorder(false,SystemColor.controlDkShadow,SystemColor.controlLtHighlight);
    editor.setBorder(new BorderUIResource.CompoundBorderUIResource(
        b,new EmptyBorder(2, 2, 2, 2)));

    Insets margin = editor.getMargin();
    if (margin == null || margin instanceof UIResource) {
        editor.setMargin(uidefaults.getInsets(prefix + ".margin"));
    }
}
 
Example 20
Source File: XTextAreaPeer.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void installUI(JComponent c) {
    super.installUI(c);

    jta = (JTextArea) c;

    JTextArea editor = jta;

    UIDefaults uidefaults = XToolkit.getUIDefaults();

    String prefix = getPropertyPrefix();
    Font f = editor.getFont();
    if ((f == null) || (f instanceof UIResource)) {
        editor.setFont(uidefaults.getFont(prefix + ".font"));
    }

    Color bg = editor.getBackground();
    if ((bg == null) || (bg instanceof UIResource)) {
        editor.setBackground(uidefaults.getColor(prefix + ".background"));
    }

    Color fg = editor.getForeground();
    if ((fg == null) || (fg instanceof UIResource)) {
        editor.setForeground(uidefaults.getColor(prefix + ".foreground"));
    }

    Color color = editor.getCaretColor();
    if ((color == null) || (color instanceof UIResource)) {
        editor.setCaretColor(uidefaults.getColor(prefix + ".caretForeground"));
    }

    Color s = editor.getSelectionColor();
    if ((s == null) || (s instanceof UIResource)) {
        editor.setSelectionColor(uidefaults.getColor(prefix + ".selectionBackground"));
    }

    Color sfg = editor.getSelectedTextColor();
    if ((sfg == null) || (sfg instanceof UIResource)) {
        editor.setSelectedTextColor(uidefaults.getColor(prefix + ".selectionForeground"));
    }

    Color dfg = editor.getDisabledTextColor();
    if ((dfg == null) || (dfg instanceof UIResource)) {
        editor.setDisabledTextColor(uidefaults.getColor(prefix + ".inactiveForeground"));
    }

    Border b = new BevelBorder(false,SystemColor.controlDkShadow,SystemColor.controlLtHighlight);
    editor.setBorder(new BorderUIResource.CompoundBorderUIResource(
        b,new EmptyBorder(2, 2, 2, 2)));

    Insets margin = editor.getMargin();
    if (margin == null || margin instanceof UIResource) {
        editor.setMargin(uidefaults.getInsets(prefix + ".margin"));
    }
}