javax.swing.JTextArea#setBorder ( )源码实例Demo

下面列出了javax.swing.JTextArea#setBorder ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: java-photoslibrary   文件: ShareAlbumToolPanel.java
private JTextArea getMetadataTextArea(Album album) {
  JTextArea metadataTextArea = new JTextArea();
  metadataTextArea.setBorder(METADATA_BORDER);
  metadataTextArea.setLayout(
      new GridLayout(2 /* rows */, 1 /* cols */, 0 /* unset hgap */, 10 /* vgap */));
  metadataTextArea.setEditable(false);
  metadataTextArea.setLineWrap(true);
  metadataTextArea.append(String.format("URL: %s", album.getProductUrl()));
  if (album.hasShareInfo()) {
    metadataTextArea.append(
        String.format("\nShare URL: %s", album.getShareInfo().getShareableUrl()));
    metadataTextArea.append(
        String.format("\nShare Token: %s", album.getShareInfo().getShareToken()));
  }
  return metadataTextArea;
}
 
源代码2 项目: osp   文件: MultiLineToolTipUI.java
@Override
public Dimension getPreferredSize(JComponent c) {
	String tipText = ((JToolTip)c).getTipText();
	if (tipText==null)
		return new Dimension(0,0);
	textArea = new JTextArea(tipText);
	textArea.setBorder(BorderFactory.createEmptyBorder(0, 2, 2, 2));
  rendererPane.removeAll();
	rendererPane.add(textArea);
	textArea.setWrapStyleWord(true);
	textArea.setLineWrap(false);

	Dimension dim = textArea.getPreferredSize();		
	dim.height += 2;
	dim.width += 2;
	return dim;
}
 
源代码3 项目: visualvm   文件: GeneralPropertiesProvider.java
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;
}
 
源代码4 项目: hono   文件: HonoCommanderSamplerUI.java
private void setDescriptionTextAreaDesign(final JTextArea jTextArea, final JPanel parentPanel) {
    jTextArea.setLineWrap(true);
    jTextArea.setWrapStyleWord(true);
    jTextArea.setEditable(false);
    jTextArea.setMargin(new Insets(15, 15, 15, 15));
    jTextArea.setBackground(parentPanel.getBackground());
    jTextArea.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY, 1));
}
 
源代码5 项目: visualvm   文件: GeneralPropertiesProvider.java
public PropertiesPanel createPanel(ApplicationSupport.CurrentApplication dataSource) {
    PropertiesPanel panel = new PropertiesPanel();
    panel.setLayout(new BorderLayout());
    JTextArea textArea = new JTextArea(NbBundle.getMessage(
            GeneralPropertiesProvider.class, "MSG_ConnectionProperties")) { // NOI18N
        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.setCaretPosition(0);
    textArea.setMinimumSize(new Dimension(1, 1));
    panel.add(textArea, BorderLayout.CENTER);

    return panel;
}
 
源代码6 项目: rapidminer-studio   文件: ConnectionInfoPanel.java
/**
 * Adds a JTextArea with the given text
 *
 * @param text
 * 		The text
 */
private JComponent createTextArea(StringProperty text) {
	// Without the TextArea the GUI is collapsing
	JTextArea multi = new JTextArea(text.get());
	multi.setFont(OPEN_SANS_12);
	// update text
	text.addListener(l -> {
		if (!multi.getText().equals(text.get())) {
			SwingTools.invokeLater(() -> multi.setText(text.get()));
		}
	});
	multi.setWrapStyleWord(true);
	multi.setLineWrap(true);
	multi.setEditable(editable);
	if (!editable) {
		multi.setHighlighter(null);
		multi.setComponentPopupMenu(null);
		multi.setInheritsPopupMenu(false);
		multi.setBackground(getBackground());
		multi.setBorder(BorderFactory.createEmptyBorder());
	} else {
		multi.getDocument().addDocumentListener(new TextChangedDocumentListener(text));
		multi.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
	}
	if (!isTypeKnown) {
		multi.setForeground(UNKNOWN_TYPE_COLOR);
	}
	return createWithScrollPane(multi);
}
 
源代码7 项目: otroslogviewer   文件: PreviewComponent.java
public PreviewComponent() {
  super(new MigLayout());
  titleLabel = new JLabel(Messages.getMessage("preview.label"));
  nameLabel = new JLabel();
  contentArea = new JTextArea();
  contentArea.setEditable(false);
  border = BorderFactory.createTitledBorder(Messages.getMessage("preview.fileContent"));
  contentArea.setBorder(border);
  contentArea.setAutoscrolls(false);
  contentArea.setFont(new Font("Courier New", Font.PLAIN, contentArea.getFont().getSize()));

  contentScrollPane = new JScrollPane(contentArea);
  contentScrollPane.setAutoscrolls(false);

  progressBar = new JProgressBar();
  progressBar.setStringPainted(true);
  progressBar.setMaximum(1);
  enabledCheckBox = new JCheckBox(Messages.getMessage("preview.enable"), true);
  enabledCheckBox.setMnemonic(Messages.getMessage("preview.enable.mnemonic").charAt(0));
  enabledCheckBox.setRolloverEnabled(true);
  enabledCheckBox.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent actionEvent) {
      boolean enabled = enabledCheckBox.isSelected();
      progressBar.setEnabled(enabled);
      contentScrollPane.setEnabled(enabled);
      contentArea.setEnabled(enabled);
      nameLabel.setEnabled(enabled);
      titleLabel.setEnabled(enabled);
    }
  });

  add(titleLabel, "dock north, gap 5 5 5 5, center");
  add(nameLabel, "dock north, gap 5 5 5 5");
  add(contentScrollPane, "dock center, gap 5 5 5 5");
  add(enabledCheckBox, "dock south, gap 0 5 5 5");
  add(progressBar, "dock south, gap 5 5 5 5");
}
 
源代码8 项目: gcs   文件: SettingsEditor.java
private JPanel createTopPanel() {
    JPanel panel = new JPanel(new PrecisionLayout().setColumns(2).setMargins(10));
    mShowCollegeInSpells = createCheckBox(panel, I18n.Text("Show the College column in the spells list"), null, mSettings.showCollegeInSpells());
    mBaseWillAndPerOn10 = createCheckBox(panel, I18n.Text("Base Will and Perception on 10 and not IQ"), null, mSettings.baseWillAndPerOn10());
    mUseMultiplicativeModifiers = createCheckBox(panel, I18n.Text("Use Multiplicative Modifiers from PW102 (note: changes point value)"), null, mSettings.useMultiplicativeModifiers());
    mUseModifyingDicePlusAdds = createCheckBox(panel, I18n.Text("Use Modifying Dice + Adds from B269"), null, mSettings.useModifyingDicePlusAdds());
    mUseKnowYourOwnStrength = createCheckBox(panel, I18n.Text("Use strength rules from Knowing Your Own Strength (PY83)"), null, mSettings.useKnowYourOwnStrength());
    mUseReducedSwing = createCheckBox(panel, I18n.Text("Use the reduced swing rules from Adjusting Swing Damage in Dungeon Fantasy"), "From noschoolgrognard.blogspot.com", mSettings.useReducedSwing());
    mUseThrustEqualsSwingMinus2 = createCheckBox(panel, I18n.Text("Use Thrust = Swing - 2"), null, mSettings.useThrustEqualsSwingMinus2());
    mUseSimpleMetricConversions = createCheckBox(panel, I18n.Text("Use the simple metric conversion rules from B9"), null, mSettings.useSimpleMetricConversions());
    JPanel wrapper = new JPanel();
    wrapper.add(createLabel(I18n.Text("Use"), null, SwingConstants.LEFT));
    mLengthUnitsCombo = createCombo(wrapper, LengthUnits.values(), mSettings.defaultLengthUnits(), I18n.Text("The units to use for display of generated lengths"));
    wrapper.add(createLabel(I18n.Text("and"), null, SwingConstants.LEFT));
    mWeightUnitsCombo = createCombo(wrapper, WeightUnits.values(), mSettings.defaultWeightUnits(), I18n.Text("The units to use for display of generated weights"));
    wrapper.add(createLabel(I18n.Text("for display of generated units"), null, SwingConstants.LEFT));
    panel.add(wrapper, new PrecisionLayoutData().setHorizontalSpan(2));
    panel.add(createLabel(I18n.Text("Show User Description"), null, SwingConstants.RIGHT), new PrecisionLayoutData().setHorizontalAlignment(PrecisionLayoutAlignment.END).setLeftMargin(5).setRightMargin(5));
    mUserDescriptionDisplayCombo = createCombo(panel, DisplayOption.values(), mSettings.userDescriptionDisplay(), I18n.Text("Where to display this information"));
    panel.add(createLabel(I18n.Text("Show Modifiers"), null, SwingConstants.RIGHT), new PrecisionLayoutData().setHorizontalAlignment(PrecisionLayoutAlignment.END).setLeftMargin(5).setRightMargin(5));
    mModifiersDisplayCombo = createCombo(panel, DisplayOption.values(), mSettings.modifiersDisplay(), I18n.Text("Where to display this information"));
    panel.add(createLabel(I18n.Text("Show Notes"), null, SwingConstants.RIGHT), new PrecisionLayoutData().setHorizontalAlignment(PrecisionLayoutAlignment.END).setLeftMargin(5).setRightMargin(5));
    mNotesDisplayCombo = createCombo(panel, DisplayOption.values(), mSettings.notesDisplay(), I18n.Text("Where to display this information"));
    String blockLayoutTooltip = Text.wrapPlainTextForToolTip(I18n.Text("Specifies the layout of the various blocks of data on the character sheet"));
    panel.add(createLabel(I18n.Text("Block Layout"), blockLayoutTooltip, SwingConstants.LEFT), new PrecisionLayoutData().setHorizontalSpan(2).setLeftMargin(5).setRightMargin(5));
    mBlockLayoutField = new JTextArea(Preferences.linesToString(mSettings.blockLayout()));
    mBlockLayoutField.setToolTipText(blockLayoutTooltip);
    mBlockLayoutField.getDocument().addDocumentListener(this);
    mBlockLayoutField.setBorder(new CompoundBorder(new LineBorder(), new EmptyBorder(0, 4, 0, 4)));
    panel.add(mBlockLayoutField, new PrecisionLayoutData().setHorizontalSpan(2).setFillAlignment().setGrabSpace(true).setLeftMargin(5).setRightMargin(5));
    return panel;
}
 
public MetalworksDocumentFrame() {
    super("", true, true, true, true);
    openFrameCount++;
    setTitle("Untitled Message " + openFrameCount);

    JPanel top = new JPanel();
    top.setBorder(new EmptyBorder(10, 10, 10, 10));
    top.setLayout(new BorderLayout());
    top.add(buildAddressPanel(), BorderLayout.NORTH);

    JTextArea content = new JTextArea(15, 30);
    content.setBorder(new EmptyBorder(0, 5, 0, 5));
    content.setLineWrap(true);



    JScrollPane textScroller = new JScrollPane(content,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    top.add(textScroller, BorderLayout.CENTER);


    setContentPane(top);
    pack();
    setLocation(offset * openFrameCount, offset * openFrameCount);

}
 
源代码10 项目: openchemlib-js   文件: JTextDrawingObjectDialog.java
private void init(Component owner) {
      mComboBoxTextSize = new JComboBox(TEXT_SIZE_LIST);
mComboBoxTextSize.setEditable(true);
mComboBoxTextSize.setSelectedItem(""+(int)mTextObject.getSize());

      mComboBoxStyle = new JComboBox(TEXT_STYLE_LIST);
int styleIndex = 0;
for (int i=0; i<TEXT_STYLE.length; i++) {
	if (mTextObject.getStyle() == TEXT_STYLE[i]) {
		styleIndex = i;
		break;
		}
	}
mComboBoxStyle.setSelectedIndex(styleIndex);

JComponent menuPanel = new JPanel();
double[][] size = { { 8, TableLayout.PREFERRED, 4, TableLayout.PREFERRED, 8 },
					{ 8, TableLayout.PREFERRED, 4, TableLayout.PREFERRED, 8 } };
menuPanel.setLayout(new TableLayout(size));

menuPanel.add(new JLabel("Text size:"), "1,1");
menuPanel.add(mComboBoxTextSize, "3,1");
menuPanel.add(new JLabel("Text style:"), "1,3");
menuPanel.add(mComboBoxStyle, "3,3");

mTextArea = new JTextArea(mTextObject.getText(), 3, 20);
      mTextArea.setBorder(BorderFactory.createEtchedBorder());
JPanel textPanel = new JPanel();
      textPanel.setBorder(BorderFactory.createEmptyBorder(0,4,0,4));
textPanel.add(mTextArea);

JButton buttonOK = new JButton("OK");
buttonOK.addActionListener(this);
JButton buttonCancel = new JButton("Cancel");
buttonCancel.addActionListener(this);
JPanel innerButtonPanel = new JPanel();
      innerButtonPanel.setLayout(new GridLayout(1,2,8,0));
      innerButtonPanel.add(buttonCancel);
      innerButtonPanel.add(buttonOK);
      innerButtonPanel.setBorder(BorderFactory.createEmptyBorder(8,8,8,8));
JPanel buttonPanel = new JPanel();
      buttonPanel.setLayout(new BorderLayout());
      buttonPanel.add(innerButtonPanel, BorderLayout.EAST);

getContentPane().setLayout(new BorderLayout());
getContentPane().add(menuPanel,  BorderLayout.NORTH);
getContentPane().add(textPanel,  BorderLayout.CENTER);
getContentPane().add(buttonPanel,  BorderLayout.SOUTH);

getRootPane().setDefaultButton(buttonOK);

pack();
setLocationRelativeTo(owner);

mTextArea.requestFocus();
setVisible(true);
}
 
源代码11 项目: openjdk-jdk9   文件: XTextAreaPeer.java
@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"));
    }
}
 
源代码12 项目: dragonwell8_jdk   文件: XTextAreaPeer.java
@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"));
    }
}
 
源代码13 项目: importer-exporter   文件: ReadMeDialog.java
private void initGUI() {
	setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
	JButton button = new JButton(Language.I18N.getString("common.button.ok"));		

	setLayout(new GridBagLayout()); {
		JPanel main = new JPanel();
		add(main, GuiUtil.setConstraints(0,0,1.0,1.0,GridBagConstraints.BOTH,5,5,5,5));
		main.setLayout(new GridBagLayout());
		{
			JLabel readMeHeader = new JLabel(Language.I18N.getString("menu.help.readMe.information"));
			main.add(readMeHeader, GuiUtil.setConstraints(0,0,1.0,0.0,GridBagConstraints.HORIZONTAL,10,2,2,5));

			JTextArea readMe = new JTextArea();
			readMe.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));				
			readMe.setEditable(false);
			readMe.setBackground(Color.WHITE);
			readMe.setFont(new Font(Font.MONOSPACED, 0, 11));

			try {
				BufferedReader in = new BufferedReader(
						new InputStreamReader(this.getClass().getResourceAsStream("/META-INF/README.txt"), StandardCharsets.UTF_8));

				// read address template
				StringBuilder builder = new StringBuilder();
				String line = null;	
				while ((line = in.readLine()) != null) {
					builder.append(line);
					builder.append("\n");
				}

				readMe.setText(builder.toString());					

			} catch (Exception e) {
				readMe.setText("The README.txt file could not be found.\n\n" + "" +
						"Please refer to the README.txt file provided with the installation package.\n\n");
			}

			readMe.setCaretPosition(0);
			PopupMenuDecorator.getInstance().decorate(readMe);

			JScrollPane scroll = new JScrollPane(readMe);
			scroll.setAutoscrolls(true);
			scroll.setBorder(BorderFactory.createEtchedBorder());

			main.add(scroll, GuiUtil.setConstraints(0,1,1.0,1.0,GridBagConstraints.BOTH,2,0,0,0));

		}

		button.setMargin(new Insets(button.getMargin().top, 25, button.getMargin().bottom, 25));
		add(button, GuiUtil.setConstraints(0,3,0.0,0.0,GridBagConstraints.NONE,5,5,5,5));
	}

	setPreferredSize(new Dimension(600, 400));
	setResizable(true);
	pack();

	button.addActionListener(l -> dispose());
}
 
源代码14 项目: chipster   文件: CreateFromTextDialog.java
public CreateFromTextDialog(ClientApplication clientApplication) {
    super(Session.getSession().getFrames().getMainFrame(), true);

    this.setTitle("Create dataset from text");
    this.setModal(true);
    
    // Layout
    GridBagConstraints c = new GridBagConstraints();
    this.setLayout(new GridBagLayout());
    
    // Name label
    nameLabel = new JLabel("Filename");
    c.anchor = GridBagConstraints.WEST;
    c.insets.set(10, 10, 5, 10);
    c.gridx = 0; 
    c.gridy = 0;
    this.add(nameLabel, c);
    
    // Name field
    nameField = new JTextField();
    nameField.setPreferredSize(new Dimension(150, 20));
    nameField.setText("data.txt");
    nameField.addCaretListener(this);
    c.insets.set(0,10,10,10);       
    c.gridy++;
    this.add(nameField, c);
    
    // Folder to store the file
    folderNameCombo = new JComboBox(ImportUtils.getFolderNames(true).toArray());
    folderNameCombo.setPreferredSize(new Dimension(150, 20));
    folderNameCombo.setEditable(true);
    c.insets.set(10,10,5,10);
    c.gridy++;
    this.add(new JLabel("Create in folder"), c);
    c.insets.set(0,10,10,10);
    c.gridy++;
    this.add(folderNameCombo,c);
    
    // Text label
    textLabel = new JLabel("Text");
    c.anchor = GridBagConstraints.WEST;
    c.insets.set(10, 10, 5, 10);
    c.gridy++;
    this.add(textLabel, c);
    
    // Text area
    textArea = new JTextArea();
    textArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
    textArea.setBorder(BorderFactory.createEmptyBorder());
    textArea.addCaretListener(this);
    JScrollPane areaScrollPane = new JScrollPane(textArea);
    areaScrollPane.setVerticalScrollBarPolicy(
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    areaScrollPane.setHorizontalScrollBarPolicy(
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    areaScrollPane.setBorder(BorderFactory.createLineBorder(Color.GRAY));
    areaScrollPane.setPreferredSize(new Dimension(570, 300));
    c.insets.set(0,10,10,10);  
    c.gridy++;
    this.add(areaScrollPane, c);
    
    // OK button
    okButton = new JButton("OK");
    okButton.setPreferredSize(BUTTON_SIZE);
    okButton.addActionListener(this);
    
    // Cancel button
    cancelButton = new JButton("Cancel");
    cancelButton.setPreferredSize(BUTTON_SIZE);
    cancelButton.addActionListener(this);
    
    // Import checkbox
    importCheckBox = new JCheckBox("Import as plain text");
    importCheckBox.setSelected(true);
    c.insets.set(10, 10, 5, 10);
    c.gridy++;
    this.add(importCheckBox, c);
    
    // Buttons pannel
    JPanel buttonsPanel = new JPanel();
    buttonsPanel.add(okButton);
    buttonsPanel.add(cancelButton);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.insets.set(10, 10, 5, 10);
    c.gridy++;
    this.add(buttonsPanel, c);
    
    // Show
    this.pack();
    this.setResizable(false);
    Session.getSession().getFrames().setLocationRelativeToMainFrame(this);
    
    // Default focus
    textArea.requestFocusInWindow();
    this.setVisible(true);
}
 
源代码15 项目: openjdk-jdk8u   文件: XTextAreaPeer.java
@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"));
    }
}
 
源代码16 项目: openjdk-8   文件: XTextAreaPeer.java
@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"));
    }
}
 
源代码17 项目: hottub   文件: XTextAreaPeer.java
@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"));
    }
}
 
源代码18 项目: lucene-solr   文件: CreateIndexDialogFactory.java
private JPanel optionalSettings() {
  JPanel panel = new JPanel(new BorderLayout());
  panel.setOpaque(false);

  JPanel description = new JPanel();
  description.setLayout(new BoxLayout(description, BoxLayout.Y_AXIS));
  description.setOpaque(false);

  JPanel name = new JPanel(new FlowLayout(FlowLayout.LEADING));
  name.setOpaque(false);
  JLabel nameLbl = new JLabel(MessageUtils.getLocalizedMessage("createindex.label.option"));
  name.add(nameLbl);
  description.add(name);

  JTextArea descTA1 = new JTextArea(MessageUtils.getLocalizedMessage("createindex.textarea.data_help1"));
  descTA1.setPreferredSize(new Dimension(550, 20));
  descTA1.setBorder(BorderFactory.createEmptyBorder(2, 10, 10, 5));
  descTA1.setOpaque(false);
  descTA1.setLineWrap(true);
  descTA1.setEditable(false);
  description.add(descTA1);

  JPanel link = new JPanel(new FlowLayout(FlowLayout.LEADING, 10, 1));
  link.setOpaque(false);
  JLabel linkLbl = FontUtils.toLinkText(new URLLabel(MessageUtils.getLocalizedMessage("createindex.label.data_link")));
  link.add(linkLbl);
  description.add(link);

  JTextArea descTA2 = new JTextArea(MessageUtils.getLocalizedMessage("createindex.textarea.data_help2"));
  descTA2.setPreferredSize(new Dimension(550, 50));
  descTA2.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 5));
  descTA2.setOpaque(false);
  descTA2.setLineWrap(true);
  descTA2.setEditable(false);
  description.add(descTA2);

  panel.add(description, BorderLayout.PAGE_START);

  JPanel dataDirPath = new JPanel(new FlowLayout(FlowLayout.LEADING));
  dataDirPath.setOpaque(false);
  dataDirPath.add(new JLabel(MessageUtils.getLocalizedMessage("createindex.label.datadir")));
  dataDirPath.add(dataDirTF);
  dataDirPath.add(dataBrowseBtn);

  dataDirPath.add(clearBtn);
  panel.add(dataDirPath, BorderLayout.CENTER);

  return panel;
}
 
源代码19 项目: netbeans   文件: ToolTipSupport.java
private JTextArea createTextToolTip(final boolean wrapLines) {
    class TextToolTip extends JTextArea {
        public @Override void setSize(int width, int height) {
            Dimension prefSize = getPreferredSize();
            if (width >= prefSize.width) {
                width = prefSize.width;
            } else { // smaller available width
                // Set line wrapping and do super.setSize() to determine
                // the real height (it will change due to line wrapping)
                
                if (wrapLines) {
                    setLineWrap(true);
                    setWrapStyleWord(true);
                }
                
                super.setSize(width, 10000); // the height is unimportant
                prefSize = getPreferredSize(); // re-read new pref width
            }
            if (height >= prefSize.height) { // enough height
                height = prefSize.height;
            } else { // smaller available height
                // Check how much can be displayed - cannot rely on line count
                // because line wrapping may display single physical line
                // into several visual lines
                // Before using viewToModel() a setSize() must be called
                // because otherwise the viewToModel() would return -1.
                super.setSize(width, 10000);
                int offset = viewToModel(new Point(0, height));
                Document doc = getDocument();
                try {
                    if (offset > ELIPSIS.length()) {
                        offset -= ELIPSIS.length();
                        doc.remove(offset, doc.getLength() - offset);
                        doc.insertString(offset, ELIPSIS, null);
                    }
                } catch (BadLocationException ble) {
                    // "..." will likely not be displayed but otherwise should be ok
                }
                // Recalculate the prefSize as it may be smaller
                // than the present preferred height
                height = Math.min(height, getPreferredSize().height);
            }
            super.setSize(width, height);
        }
        @Override
        public void setKeymap(Keymap map) {
            //#181722: keymaps are shared among components with the same UI
            //a default action will be set to the Keymap of this component below,
            //so it is necessary to use a Keymap that is not shared with other JTextAreas
            super.setKeymap(addKeymap(null, map));
        }
    }

    JTextArea tt = new TextToolTip();
    /* See NETBEANS-403. It still appears possible to use Escape to close the popup when the
    focus is in the editor. */
    tt.putClientProperty(SUPPRESS_POPUP_KEYBOARD_FORWARDING_CLIENT_PROPERTY_KEY, true);

    // set up tooltip keybindings
    filterBindings(tt.getActionMap());
    tt.getActionMap().put(HIDE_ACTION.getValue(Action.NAME), HIDE_ACTION);
    tt.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), HIDE_ACTION.getValue(Action.NAME));
    tt.getKeymap().setDefaultAction(NO_ACTION);
    
    Font font = UIManager.getFont(UI_PREFIX + ".font"); // NOI18N
    Color backColor = UIManager.getColor(UI_PREFIX + ".background"); // NOI18N
    Color foreColor = UIManager.getColor(UI_PREFIX + ".foreground"); // NOI18N

    if (font != null) {
        tt.setFont(font);
    }
    if (foreColor != null) {
        tt.setForeground(foreColor);
    }
    if (backColor != null) {
        tt.setBackground(backColor);
    }

    tt.setOpaque(true);
    tt.setBorder(BorderFactory.createCompoundBorder(
        BorderFactory.createLineBorder(tt.getForeground()),
        BorderFactory.createEmptyBorder(0, 3, 0, 3)
    ));
    
    return tt;
}
 
public DialogFrame() {
	
	setType(Type.POPUP);
	setResizable(false);
	
	setModalExclusionType(ModalExclusionType.APPLICATION_EXCLUDE);
	this.setTitle("Approving question");
	this.setPreferredSize(new Dimension(400, 190));
	this.setAlwaysOnTop(isAlwaysOnTopSupported());
	this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	getContentPane().setLayout(new BorderLayout());
	
	final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
	
	this.setLocation(screenSize.width / 2 - 150, screenSize.height / 2 - 75);
	
	this.setIconImage(Toolkit.getDefaultToolkit().
			getImage(getClass().getResource(LOGOPATH)));
	
	final JPanel panel = new JPanel();
	panel.setAutoscrolls(true);
	getContentPane().add(panel, BorderLayout.CENTER);
	panel.setLayout(null);
	
	btnYes = new JButton("YES");
	btnYes.setBorder(new SoftBevelBorder(BevelBorder.RAISED, null, null, null, null));
	btnYes.setBounds(291, 129, 91, 29);
	panel.add(btnYes);
	
	btnNo = new JButton("NO");
	btnNo.setBorder(new SoftBevelBorder(BevelBorder.RAISED, null, null, null, null));
	btnNo.setBounds(199, 129, 91, 29);
	panel.add(btnNo);
	
	lblIcon = new JLabel("");
	lblIcon.setIcon(new ImageIcon(DialogFrame.class.getResource("/com/coder/hms/icons/dialogPane_question.png")));
	lblIcon.setBounds(14, 40, 69, 70);
	panel.add(lblIcon);
	
	
	textArea = new JTextArea();
	textArea.setDisabledTextColor(new Color(153, 204, 255));
	textArea.setBounds(95, 32, 287, 85);
	textArea.setBackground(UIManager.getColor("ComboBox.background"));
	textArea.setBorder(null);
	textArea.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
	textArea.setEditable(false);
	textArea.setFont(new Font("Monospaced", Font.PLAIN, 14));
	textArea.setLineWrap(true);
	panel.add(textArea);
	
	this.pack();
}