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

The following examples show how to use javax.swing.JTextArea#setBackground() . 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: MissingDragExitEventTest.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private static void initAndShowUI() {
    frame = new JFrame("Test frame");

    frame.setSize(SIZE, SIZE);
    frame.setLocationRelativeTo(null);
    final JTextArea jta = new JTextArea();
    jta.setBackground(Color.RED);
    frame.add(jta);
    jta.setText("1234567890");
    jta.setFont(jta.getFont().deriveFont(150f));
    jta.setDragEnabled(true);
    jta.selectAll();
    jta.setDropTarget(new DropTarget(jta, DnDConstants.ACTION_COPY,
                                     new TestdropTargetListener()));
    jta.addMouseListener(new TestMouseAdapter());
    frame.setVisible(true);
}
 
Example 2
Source File: JTableLogs.java    From mts with GNU General Public License v3.0 6 votes vote down vote up
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
	TextEvent textEvent = (TextEvent) value;
    JTextArea jTextArea = super.getJTextArea(isSelected);

    if (null == value) {
        jTextArea.setText("");
        jTextArea.setBackground(Color.WHITE);
        jTextArea.setForeground(Color.BLACK);
    }
    else {
     
     if (null != textEvent.getTopic()) {
         jTextArea.setText(textEvent.getTopic().toString());
     }
     else {
         jTextArea.setText("");
     }
	
     jTextArea.setForeground(GuiHelper.getColorForLevel(textEvent.getLevel()));
     jTextArea.setBackground(GuiHelper.getColorForTopic(textEvent.getTopic()));
    }
    return jTextArea;
}
 
Example 3
Source File: MissingDragExitEventTest.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private static void initAndShowUI() {
    frame = new JFrame("Test frame");

    frame.setSize(SIZE, SIZE);
    frame.setLocationRelativeTo(null);
    final JTextArea jta = new JTextArea();
    jta.setBackground(Color.RED);
    frame.add(jta);
    jta.setText("1234567890");
    jta.setFont(jta.getFont().deriveFont(150f));
    jta.setDragEnabled(true);
    jta.selectAll();
    jta.setDropTarget(new DropTarget(jta, DnDConstants.ACTION_COPY,
                                     new TestdropTargetListener()));
    jta.addMouseListener(new TestMouseAdapter());
    frame.setVisible(true);
}
 
Example 4
Source File: MissingDragExitEventTest.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private static void initAndShowUI() {
    frame = new JFrame("Test frame");

    frame.setSize(SIZE, SIZE);
    frame.setLocationRelativeTo(null);
    final JTextArea jta = new JTextArea();
    jta.setBackground(Color.RED);
    frame.add(jta);
    jta.setText("1234567890");
    jta.setFont(jta.getFont().deriveFont(150f));
    jta.setDragEnabled(true);
    jta.selectAll();
    jta.setDropTarget(new DropTarget(jta, DnDConstants.ACTION_COPY,
                                     new TestdropTargetListener()));
    jta.addMouseListener(new TestMouseAdapter());
    frame.setVisible(true);
}
 
Example 5
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 6
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 7
Source File: GeoCodingPanel.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private void addRowWithTextField(String name, String value) {
    contentLayout.setCellColspan(currentRow++, 1, 5);
    contentPanel.add(getCorrectlyColouredLabel(name));
    final JTextArea textArea = new JTextArea(value);
    textArea.setBackground(getBackgroundColor());
    textArea.setEditable(false);
    contentPanel.add(textArea);
    dataAsTextBuilder.append(name).append("/t").append(value).append("/n");
}
 
Example 8
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 9
Source File: UI.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static JTextArea createTextArea(int columns, String message) {
    JTextArea text = new JTextArea(message);
    text.setBackground(null);
    text.setEditable(false);
    text.setColumns(columns);
    text.setLineWrap(true);
    text.setWrapStyleWord(true);
    return text;
}
 
Example 10
Source File: Utilities.java    From javamelody with Apache License 2.0 5 votes vote down vote up
/**
 * Affiche un texte scrollable non éditable dans une popup.
 * @param component Parent
 * @param title Titre de la popup
 * @param text Texte
 */
public static void showTextInPopup(Component component, String title, String text) {
	final JTextArea textArea = new JTextArea();
	textArea.setText(text);
	textArea.setEditable(false);
	textArea.setCaretPosition(0);
	// background nécessaire avec la plupart des look and feels dont Nimbus,
	// sinon il reste blanc malgré editable false
	textArea.setBackground(Color.decode("#E6E6E6"));
	final JScrollPane scrollPane = new JScrollPane(textArea);

	final JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 0, 5));
	final MButton clipBoardButton = new MButton(
			I18NAdapter.getString("Copier_dans_presse-papiers"));
	clipBoardButton.addActionListener(new ActionListener() {
		@Override
		public void actionPerformed(ActionEvent e) {
			textArea.selectAll();
			textArea.copy();
			textArea.setCaretPosition(0);
		}
	});
	buttonPanel.setOpaque(false);
	buttonPanel.add(clipBoardButton);

	final Window window = SwingUtilities.getWindowAncestor(component);
	final JDialog dialog = new JDialog((JFrame) window, title, true);
	final JPanel contentPane = new JPanel(new BorderLayout());
	contentPane.add(scrollPane, BorderLayout.CENTER);
	contentPane.add(buttonPanel, BorderLayout.SOUTH);
	dialog.setContentPane(contentPane);
	dialog.pack();
	dialog.setLocationRelativeTo(window);
	dialog.setVisible(true);
}
 
Example 11
Source File: GeneralPropertiesProvider.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
public PropertiesPanel createPanel(JvmstatApplication 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,
            PropertiesImpl.isLocalConnection(dataSource) ?
            "MSG_ConnectionPropertiesDefault" : "MSG_ConnectionPropertiesCustom")); // NOI18N
    textArea.setMinimumSize(new Dimension(1, 1));
    textArea.setCaretPosition(0);
    panel.add(textArea, BorderLayout.CENTER);
    return panel;
}
 
Example 12
Source File: EducationalRun.java    From KEEL with GNU General Public License v3.0 5 votes vote down vote up
/**
    * <p>
 * This method initializes areaTextoInforme
 *</p>
 * @return javax.swing.JTextArea
 */
private JTextArea getReportTextArea()
{
	JTextArea reportTextArea = new JTextArea();
	reportTextArea.setEditable(false);
	reportTextArea.setBackground(new Color(119,119,119));
	return reportTextArea;
}
 
Example 13
Source File: TransferViewBuilder.java    From raccoon4 with Apache License 2.0 4 votes vote down vote up
@Override
protected JPanel assemble() {
	peers = new Vector<TransferPeerBuilder>();
	GridBagConstraints spacerConstraints = new GridBagConstraints();
	spacerConstraints.gridx = GridBagConstraints.REMAINDER;
	spacerConstraints.gridy = GridBagConstraints.RELATIVE;
	spacerConstraints.weightx = 1;
	spacerConstraints.weighty = 1;
	spacerConstraints.fill = GridBagConstraints.BOTH;

	list = new JPanel();
	list.setLayout(new GridBagLayout());
	contentConstraints = new GridBagConstraints();
	contentConstraints.gridx = GridBagConstraints.REMAINDER;
	contentConstraints.gridy = GridBagConstraints.RELATIVE;
	contentConstraints.fill = GridBagConstraints.HORIZONTAL;
	contentConstraints.anchor = GridBagConstraints.NORTH;
	contentConstraints.insets.bottom = 3;

	ActionLocalizer al = Messages.getLocalizer();
	trim = new JButton(al.localize("trimdownloads"));
	trim.addActionListener(this);
	list.add(new JPanel(), spacerConstraints);
	
	
	JPanel cont = new JPanel();
	cont.setLayout(new GridBagLayout());
	GridBagConstraints contgbc = new GridBagConstraints();
	if (!globals.get(Traits.class).isAvailable("4.0.x")) {
		JTextArea txt = new JTextArea(Messages.getString(ID + ".booster.plug"));
		txt.setLineWrap(true);
		txt.setWrapStyleWord(true);
		txt.setPreferredSize(new Dimension(ITEMWIDTH + 2 * 10,50));
		txt.setEditable(false);
		txt.setBackground(null);
		txt.setForeground(Color.RED);
		cont.add(txt,contgbc);
		contgbc.gridx=0;
		contgbc.gridy =1;
		contgbc.insets = new Insets(5,5,5,5);
		contgbc.anchor=GridBagConstraints.NORTHEAST;
		order=new JButton(Messages.getString(ID + ".booster.ok"));
		order.addActionListener(this);
		cont.add(order,contgbc);
		contgbc.gridy=2;
		contgbc.gridx=0;
	}

	JScrollPane tmp = new JScrollPane(list);
	tmp.setBorder(BorderFactory.createEmptyBorder());
	tmp.getVerticalScrollBar().setUnitIncrement(20);
	tmp.setPreferredSize(new Dimension(ITEMWIDTH + 2 * 10, 400));
	tmp.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
	
	contgbc.weightx=1;
	contgbc.weighty=1;
	cont.add(tmp,contgbc);

	JPanel ret = new DialogBuilder(cont)
			.withTitle(Messages.getString(ID + ".title"))
			.withSubTitle(Messages.getString(ID + ".subtitle"))
			.withButtons(new ButtonBarBuilder().add(trim)).build(globals);

	globals.get(TransferManager.class).setPeer(this);
	return ret;
}
 
Example 14
Source File: Query.java    From opt4j with MIT License 4 votes vote down vote up
/**
 * Construct a panel with no entries in it.
 */
public Query() {
	_grid = new GridBagLayout();
	_constraints = new GridBagConstraints();
	_constraints.fill = GridBagConstraints.HORIZONTAL;

	// If the next line is commented out, then the PtolemyApplet
	// model parameters will have an entry that is less than one
	// character wide unless the window is made to be fairly large.
	_constraints.weightx = 1.0;
	_constraints.anchor = GridBagConstraints.NORTHWEST;
	_entryPanel.setLayout(_grid);

	// It's not clear whether the following has any real significance...
	// _entryPanel.setOpaque(true);
	setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

	_entryPanel.setAlignmentX(Component.LEFT_ALIGNMENT);

	// Add a message panel into which a message can be placed using
	// setMessage().
	_messageArea = new JTextArea("");
	_messageArea.setFont(new Font("SansSerif", Font.PLAIN, 12));
	_messageArea.setEditable(false);
	_messageArea.setLineWrap(true);
	_messageArea.setWrapStyleWord(true);

	// It seems like setLineWrap is somewhat broken. Really,
	// setLineWrap works best with scrollbars. We have
	// a couple of choices: use scrollbars or hack in something
	// that guesses the number of lines. Note that to
	// use scrollbars, the tutorial at
	// http://java.sun.com/docs/books/tutorial/uiswing/components/simpletext.html#textarea
	// suggests: "If you put a text area in a scroll pane, be
	// sure to set the scroll pane's preferred size or use a
	// text area constructor that sets the number of rows and
	// columns for the text area."
	_messageArea.setBackground(null);

	_messageArea.setAlignmentX(Component.LEFT_ALIGNMENT);

	_messageScrollPane = new JScrollPane(_messageArea);
	_messageScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);

	// Get rid of the border.
	_messageScrollPane.setBorder(BorderFactory.createEmptyBorder());
	_messageScrollPane.getViewport().setBackground(null);

	// Useful for debugging:
	// _messageScrollPane.setBorder(
	// BorderFactory.createLineBorder(Color.pink));
	// We add the _messageScrollPane when we first use it.
	_entryScrollPane = new JScrollPane(_entryPanel);

	// Get rid of the border.
	_entryScrollPane.setBorder(BorderFactory.createEmptyBorder());
	_entryScrollPane.getViewport().setBackground(null);
	_entryScrollPane.setBackground(null);
	add(_entryScrollPane);

	// Setting the background to null allegedly means it inherits the
	// background color from the container.
	_entryPanel.setBackground(null);
}
 
Example 15
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;
}
 
Example 16
Source File: DDChangesPanel.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/** Initializes the Form */
public DDChangesPanel (String caption, final JButton processButton) {
    setLayout (new java.awt.BorderLayout (0, 12));
    setBorder (new EmptyBorder (12, 12, 11, 0));
    
    JTextArea text = new JTextArea ();
    text.setEnabled (false);
    text.setEditable (false);
    text.setDisabledTextColor (UIManager.getColor ("Label.foreground")); // NOI18N
    text.setBackground (UIManager.getColor ("Label.background")); // NOI18N
    text.setLineWrap (true);
    text.setWrapStyleWord (true);
    text.setText (caption);
    add (text, "North"); // NOI18N
    
    changesPanel = new JPanel ();
    changesPanel.setLayout (new java.awt.BorderLayout (5, 5));
    
    JLabel changesLabel = new JLabel ();
    changesLabel.setText (NbBundle.getMessage (DDChangesPanel.class, "LAB_ChangesList"));
    changesLabel.getAccessibleContext ().setAccessibleDescription (NbBundle.getMessage (DDChangesPanel.class, "ACS_ChangesListA11yDesc"));  // NOI18N
    changesPanel.add (changesLabel, "North"); // NOI18N
    
    jScrollPane1 = new JScrollPane ();
    
    listModel = new DefaultListModel ();
    
    changesList = new JList (listModel);
    changesList.setToolTipText (NbBundle.getMessage (DDChangesPanel.class, "HINT_ChangesList"));
    changesList.setCellRenderer (new ChangesListCellRenderer ());
    changesList.addListSelectionListener (new ListSelectionListener () {
        public void valueChanged (ListSelectionEvent e) {
            processButton.setEnabled (!changesList.isSelectionEmpty ());
        }
    });
    changesLabel.setLabelFor (changesList);
    changesLabel.setDisplayedMnemonic (NbBundle.getMessage (DDChangesPanel.class, "LAB_ChangesList_Mnemonic").charAt (0));
    getAccessibleContext().setAccessibleDescription(NbBundle.getMessage (DDChangesPanel.class, "ACS_ChangesListA11yPanelDesc"));
    
    jScrollPane1.setViewportView (changesList);
    
    changesPanel.add (jScrollPane1, "Center"); // NOI18N
    
    add (changesPanel, "Center"); // NOI18N
}
 
Example 17
Source File: DownloadWindow.java    From xdm with GNU General Public License v2.0 4 votes vote down vote up
private void createP2() {

		remove(prgCircle);
		remove(lblSpeed);
		remove(lblStat);
		remove(segProgress);
		remove(lblDet);
		remove(lblETA);
		remove(this.panel);

		titlePanel.remove(closeBtn);
		titlePanel.remove(minBtn);

		JPanel p2 = new JPanel(null);
		p2.setBounds(0, getScaledInt(60), getScaledInt(350), getScaledInt(190));
		p2.setBackground(ColorResource.getDarkestBgColor());

		txtError = new JTextArea();// this.errMsg);
		txtError.setFont(FontResource.getBigFont());
		txtError.setEditable(false);
		txtError.setCaretPosition(0);
		txtError.setWrapStyleWord(true);
		txtError.setLineWrap(true);
		txtError.setBackground(ColorResource.getDarkestBgColor());
		txtError.setForeground(Color.WHITE);

		JScrollPane jsp = new JScrollPane(txtError);
		jsp.setBounds(getScaledInt(25), getScaledInt(20), getScaledInt(300), getScaledInt(100));
		jsp.setBorder(null);

		CustomButton exitBtn = new CustomButton();
		exitBtn.setText(StringResource.get("MSG_OK"));
		applyStyle(exitBtn);
		exitBtn.setBounds(0, 1, getScaledInt(350), getScaledInt(50));
		exitBtn.setName("EXIT");

		JPanel panel2 = new JPanel(null);
		panel2.setBounds(0, getScaledInt(140), getScaledInt(350), getScaledInt(50));
		panel2.setBackground(Color.DARK_GRAY);
		panel2.add(exitBtn);

		p2.add(jsp);
		p2.add(panel2);

		add(p2);

		titleLbl.setText(StringResource.get("MSG_FAILED"));

		invalidate();
		repaint();
	}
 
Example 18
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 19
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 20
Source File: DDChangesPanel.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/** Initializes the Form */
public DDChangesPanel (String caption, final JButton processButton) {
    setLayout (new java.awt.BorderLayout (0, 12));
    setBorder (new EmptyBorder (12, 12, 11, 0));
    
    JTextArea text = new JTextArea ();
    text.setEnabled (false);
    text.setEditable (false);
    text.setDisabledTextColor (UIManager.getColor ("Label.foreground")); // NOI18N
    text.setBackground (UIManager.getColor ("Label.background")); // NOI18N
    text.setLineWrap (true);
    text.setWrapStyleWord (true);
    text.setText (caption);
    add (text, "North"); // NOI18N
    
    changesPanel = new JPanel ();
    changesPanel.setLayout (new java.awt.BorderLayout (5, 5));
    
    JLabel changesLabel = new JLabel ();
    changesLabel.setText (NbBundle.getMessage (DDChangesPanel.class, "LAB_ChangesList"));
    changesLabel.getAccessibleContext ().setAccessibleDescription (NbBundle.getMessage (DDChangesPanel.class, "ACS_ChangesListA11yDesc"));  // NOI18N
    changesPanel.add (changesLabel, "North"); // NOI18N
    
    jScrollPane1 = new JScrollPane ();
    
    listModel = new DefaultListModel ();
    
    changesList = new JList (listModel);
    changesList.setToolTipText (NbBundle.getMessage (DDChangesPanel.class, "HINT_ChangesList"));
    changesList.setCellRenderer (new ChangesListCellRenderer ());
    changesList.addListSelectionListener (new ListSelectionListener () {
        public void valueChanged (ListSelectionEvent e) {
            processButton.setEnabled (!changesList.isSelectionEmpty ());
        }
    });
    changesLabel.setLabelFor (changesList);
    changesLabel.setDisplayedMnemonic (NbBundle.getMessage (DDChangesPanel.class, "LAB_ChangesList_Mnemonic").charAt (0));
    getAccessibleContext().setAccessibleDescription(NbBundle.getMessage (DDChangesPanel.class, "ACS_ChangesListA11yPanelDesc"));
    
    jScrollPane1.setViewportView (changesList);
    
    changesPanel.add (jScrollPane1, "Center"); // NOI18N
    
    add (changesPanel, "Center"); // NOI18N
}