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

The following examples show how to use javax.swing.JTextArea#setMargin() . 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: ShowPanel.java    From HubPlayer with GNU General Public License v3.0 6 votes vote down vote up
private void init() {
	libraryPanel = new LibraryPanel();

	// 歌词面板处理
	lrcPanel = new JPanel(new GridLayout());
	textArea = new JTextArea();

	// 文本域设置不可编辑、透明、左间距、自动换行
	textArea.setEditable(false);
	textArea.setLineWrap(true);
	textArea.setMargin(new Insets(0, 175, 0, 0));
	textArea.setOpaque(false);

	textArea.setFont(new Font("PLAN", Font.PLAIN, 14));
	lrcPanel.add(textArea);

	// 其他面板
	MVPanel = new JScrollPane(new JLabel("MV"));
	radioPanel = new JScrollPane(new JLabel("电台"));
	livePanel = new JScrollPane(new JLabel("直播"));
}
 
Example 2
Source File: ImportBuilder.java    From raccoon4 with Apache License 2.0 5 votes vote down vote up
@Override
protected JPanel assemble() {
	ActionLocalizer al = Messages.getLocalizer();
	importUrls = new JButton(al.localize("appdownload"));
	importUrls.addActionListener(this);
	ButtonBarBuilder bbb = new ButtonBarBuilder().add(importUrls);
	list = new JTextArea(15, 45);
	list.setMargin(new Insets(2, 2, 2, 2));
	DialogBuilder db = new DialogBuilder(new AdapterBuilder(new JScrollPane(
			list))).withTitle(Messages.getString(ID + ".title"))
			.withSubTitle(Messages.getString(ID + ".subtitle")).withButtons(bbb);
	return db.build(globals);
}
 
Example 3
Source File: DataPanel.java    From DiskBrowser with GNU General Public License v3.0 5 votes vote down vote up
private JScrollPane setPanel (JTextArea outputPanel, String tabName)
// ---------------------------------------------------------------------------------//
{
  outputPanel.setEditable (false);
  outputPanel.setMargin (new Insets (5, 5, 5, 5));

  JScrollPane outputScrollPane =
      new JScrollPane (outputPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
          ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
  outputScrollPane.setBorder (null);              // remove the ugly default border
  add (outputScrollPane, tabName);
  return outputScrollPane;
}
 
Example 4
Source File: HonoCommanderSamplerUI.java    From hono with Eclipse Public License 2.0 5 votes vote down vote up
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));
}
 
Example 5
Source File: TableCellLongTextRenderer.java    From WhiteRabbit with Apache License 2.0 5 votes vote down vote up
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
	final JTextArea jtext = new JTextArea();
	jtext.setText((String)value);
	jtext.setWrapStyleWord(true);                    
	jtext.setLineWrap(true);   
	jtext.setFont(table.getFont());
	jtext.setSize(table.getColumn(table.getColumnName(column)).getWidth(), (int)jtext.getPreferredSize().getHeight());
	
	jtext.setMargin(new Insets(10,5,10,5));
     	
	return jtext;
}
 
Example 6
Source File: UiUtils.java    From pgptool with GNU General Public License v3.0 5 votes vote down vote up
private static JScrollPane getScrollableMessage(String msg) {
	JTextArea textArea = new JTextArea(msg);
	textArea.setLineWrap(true);
	textArea.setWrapStyleWord(true);
	textArea.setEditable(false);
	textArea.setMargin(new Insets(5, 5, 5, 5));
	textArea.setFont(new JTextField().getFont()); // dirty fix to use better font
	JScrollPane scrollPane = new JScrollPane();
	scrollPane.setPreferredSize(new Dimension(700, 150));
	scrollPane.getViewport().setView(textArea);
	return scrollPane;
}
 
Example 7
Source File: MyTableCellRenderer.java    From mts with GNU General Public License v3.0 5 votes vote down vote up
public JTextArea getJTextArea(boolean selected)
{
    JTextArea jTextArea = new JTextArea();
    jTextArea.setMargin(new Insets(0,0,0,0));
    jTextArea.setLineWrap(true);
    jTextArea.setWrapStyleWord(false);
    jTextArea.setFont(Font.decode("Monospaced"));
    jTextArea.setToolTipText("Click to expand");
    return jTextArea;
}
 
Example 8
Source File: ExtendedExample.java    From SpeechToText-REST with MIT License 4 votes vote down vote up
public ExtendedExample() {

    super(new BorderLayout());

    keyField = new JTextField(32);
    modeBox = new JComboBox<>(SpeechAPI.RecognitionMode.values());
    languageBox = new JComboBox<>(SpeechAPI.Language.values());
    formatBox = new JComboBox<>(SpeechAPI.OutputFormat.values());

    log = new JTextArea(20, 40);
    log.setMargin(new Insets(5, 5, 5, 5));
    log.setEditable(false);
    log.setLineWrap(true);
    JScrollPane logScrollPane = new JScrollPane(log);

    fc = new JFileChooser();
    fc.setFileFilter(new FileNameExtensionFilter("WAV audio files", "wav"));

    openButton = new JButton("Transcribe File", UIManager.getIcon("FileView.directoryIcon"));
    openButton.addActionListener(this);

    micButton = new JButton("Use Microphone", UIManager.getIcon("Tree.expandedIcon"));
    micButton.addActionListener(this);

    JPanel midPanel = new JPanel();
    midPanel.add(openButton);
    midPanel.add(micButton);

    JPanel knobs = new JPanel(new GridLayout(0, 2));
    knobs.add(new JLabel("Recognition mode:"));
    knobs.add(modeBox);
    knobs.add(new JLabel("Recognition language:"));
    knobs.add(languageBox);
    knobs.add(new JLabel("Output format:"));
    knobs.add(formatBox);

    midPanel.add(knobs);

    openButton.setEnabled(false);
    micButton.setEnabled(false);

    JPanel keyPanel = new JPanel();
    keyPanel.add(new JLabel("Please, enter your subscription key:"));
    keyPanel.add(keyField);
    keyField.setEditable(true);

    keyField.addActionListener((ActionEvent e) -> {
      if (bootstrapped)
        return;

      String text = keyField.getText();
      if (text != null && text.length() == 32) {
        log.append(String.format("Using subscription key '%s' to  generate an access token...", text));
        CompletableFuture.supplyAsync(() -> {
          return new RenewableAuthentication(text);
        }).thenAccept(this::bootstrap);
      } else if (text != null) {
        log.append(String.format("Subscription key is too %s.\n", text.length() < 32 ? "short" : "long"));
      }
    });

    add(keyPanel, BorderLayout.NORTH);
    add(midPanel, BorderLayout.CENTER);
    add(logScrollPane, BorderLayout.SOUTH);

    languageBox.setSelectedItem(SpeechAPI.Language.en_US);
  }
 
Example 9
Source File: XTextAreaPeer.java    From openjdk-jdk8u-backup 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 openjdk-jdk9 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: DatabaseManagerSwing.java    From evosql with Apache License 2.0 4 votes vote down vote up
private void initGUI() {

        JPanel pCommand = new JPanel();

        pResult = new JPanel();
        nsSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, pCommand,
                                     pResult);

        // Added: (weconsultants@users)
        nsSplitPane.setOneTouchExpandable(true);
        pCommand.setLayout(new BorderLayout());
        pResult.setLayout(new BorderLayout());

        Font fFont = new Font("Dialog", Font.PLAIN, 12);

        txtCommand = new JTextArea(7, 40);

        txtCommand.setMargin(new Insets(5, 5, 5, 5));
        txtCommand.addKeyListener(this);

        txtCommandScroll = new JScrollPane(txtCommand);
        txtResult        = new JTextArea(25, 40);

        txtResult.setMargin(new Insets(5, 5, 5, 5));

        txtResultScroll = new JScrollPane(txtResult);

        txtCommand.setFont(fFont);
        txtResult.setFont(new Font("Courier", Font.PLAIN, 12));
        pCommand.add(txtCommandScroll, BorderLayout.CENTER);

        gResult = new GridSwing();

        TableSorter sorter = new TableSorter(gResult);

        tableModel   = sorter;
        gResultTable = new JTable(sorter);

        sorter.setTableHeader(gResultTable.getTableHeader());

        gScrollPane = new JScrollPane(gResultTable);

        gResultTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        gResult.setJTable(gResultTable);

        //getContentPane().setLayout(new BorderLayout());
        pResult.add(gScrollPane, BorderLayout.CENTER);

        // Set up the tree
        rootNode    = new DefaultMutableTreeNode("Connection");
        treeModel   = new DefaultTreeModel(rootNode);
        tTree       = new JTree(treeModel);
        tScrollPane = new JScrollPane(tTree);

        // System.out.println("Adding mouse listener");
        tTree.addMouseListener(this);
        tScrollPane.setPreferredSize(new Dimension(200, 400));
        tScrollPane.setMinimumSize(new Dimension(70, 100));
        txtCommandScroll.setPreferredSize(new Dimension(560, 100));
        txtCommandScroll.setMinimumSize(new Dimension(180, 100));
        gScrollPane.setPreferredSize(new Dimension(460, 300));

        ewSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, tScrollPane,
                                     nsSplitPane);

        // Added: (weconsultants@users)
        ewSplitPane.setOneTouchExpandable(true);
        fMain.getContentPane().add(ewSplitPane, BorderLayout.CENTER);

        // Added: (weconsultants@users)
        jStatusLine = new JLabel();
        iReadyStatus =
            new JButton(new ImageIcon(CommonSwing.getIcon("StatusReady")));

        iReadyStatus.setSelectedIcon(
            new ImageIcon(CommonSwing.getIcon("StatusRunning")));

        pStatus = new JPanel();

        pStatus.setLayout(new BorderLayout());
        pStatus.add(iReadyStatus, BorderLayout.WEST);
        pStatus.add(jStatusLine, BorderLayout.CENTER);
        fMain.getContentPane().add(pStatus, "South");
        doLayout();

        if (fMain instanceof java.awt.Window) {
            ((java.awt.Window) fMain).pack();
        } else {
            ((Container) fMain).validate();
        }
    }
 
Example 12
Source File: HistoryScreen.java    From chipster with MIT License 4 votes vote down vote up
/**
 * Initializes a new history screen.
 */
public HistoryScreen() {
	frame = new JFrame("History");
	JPanel contentPane = new JPanel(new GridBagLayout());
	
	checkBoxes.put("title", new JCheckBox("Step title"));
	checkBoxes.put("name", new JCheckBox("Dataset name"));
	checkBoxes.put("date", new JCheckBox("Creation date"));
	checkBoxes.put("oper", new JCheckBox("Applied analysis tool"));
	checkBoxes.put("versions", new JCheckBox("Chipster version"));
	checkBoxes.put("param", new JCheckBox("Parameters"));
	checkBoxes.put("notes", new JCheckBox("User notes"));
	checkBoxes.put("code", new JCheckBox("Source code"));

	for (JCheckBox box : checkBoxes.values()) {
		box.setSelected(true);
		box.addActionListener(this);
	}
	
	checkBoxes.get("notes").setSelected(false);
	checkBoxes.get("date").setSelected(false);
	checkBoxes.get("code").setSelected(false);
	checkBoxes.get("param").setEnabled(checkBoxes.get("oper").isSelected());
       checkBoxes.get("code").setEnabled(checkBoxes.get("oper").isSelected() && !application.isStandalone());
	
	saveButton = new JButton("Save...");
	saveButton.setPreferredSize(BUTTON_SIZE);
	saveButton.addActionListener(this);
	
	closeButton = new JButton("Close");
	closeButton.setPreferredSize(BUTTON_SIZE);
	closeButton.addActionListener(this);
	
	textArea = new JTextArea();
	textArea.setText(getHistoryText());
	textArea.setMargin(new Insets(2, 2, 2, 2));
	textArea.setLineWrap(true);
	textArea.setWrapStyleWord(true);
	textArea.addCaretListener(this);
	
	JScrollPane textAreaScroller = new JScrollPane(textArea);
	textAreaScroller.setPreferredSize(new Dimension(500, 250));	
	
	JLabel topLabel = new JLabel("Show for Datasets:");
	
	GridBagConstraints c = new GridBagConstraints();
	c.anchor = GridBagConstraints.WEST;
	c.insets.set(10, 2, 1, 2);
	c.gridx = 0; c.gridy = 0;
	contentPane.add(topLabel, c);
	c.insets.set(1, 2, 0, 10);
	c.gridwidth = 1;
	c.gridy++;
	contentPane.add(checkBoxes.get("title"), c);
	c.gridy++;
	contentPane.add(checkBoxes.get("name"), c);
	c.gridy++;
	contentPane.add(checkBoxes.get("date"), c);
	c.gridx++; c.gridy = 1;
	contentPane.add(checkBoxes.get("versions"), c);
	c.gridy++;
	contentPane.add(checkBoxes.get("oper"), c);
	c.gridy++;
	//c.insets.set(1, 20, 0, 2);
	contentPane.add(checkBoxes.get("param"), c);
	c.gridx++; c.gridy = 1;
     	contentPane.add(checkBoxes.get("code"), c);
	c.gridy++;
       c.insets.set(1, 2, 0, 2);
       contentPane.add(checkBoxes.get("notes"), c);
	c.insets.set(10, 2, 1, 2);
	c.gridx = 0; c.gridy += 3;
	c.gridwidth = 3;
	c.weightx = 1;
	c.weighty = 1;
	c.fill = GridBagConstraints.BOTH;		
	contentPane.add(textAreaScroller, c);
	c.insets.set(2, 2, 2, 2);
	c.gridx = 0; c.gridy++;
	c.gridwidth = 1;
	c.weightx = 0;
	c.weighty = 0;
	c.fill = GridBagConstraints.NONE;
	contentPane.add(saveButton, c);
	c.gridx++;
	c.anchor = GridBagConstraints.EAST;
	contentPane.add(closeButton, c);
	
	frame.setContentPane(contentPane);
	frame.pack();
	frame.setResizable(true);
	frame.setLocationRelativeTo(null);  // centered on screen
}
 
Example 13
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 14
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 15
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 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: GameInfoDialog.java    From petscii-bbs with Mozilla Public License 2.0 4 votes vote down vote up
private JComponent createInfoPanel(Resources resources) {
  
  StoryMetadata storyinfo = resources.getMetadata().getStoryInfo();
  Box infopanel = Box.createVerticalBox();
  infopanel.setBorder(BorderFactory.createEmptyBorder(3, 5, 3, 5));
  JComponent panel = infopanel;
  
  // in case cover art is available, stack it into the info panel
  int coverartnum = getCoverartNum(resources);    
  if (coverartnum > 0 && resources.getImages().getNumResources() > 0) {

    Box wholepanel = Box.createHorizontalBox();
    wholepanel.add(createPicturePanel(resources, coverartnum));
    wholepanel.add(infopanel);
    panel = wholepanel;
  }
  
  infopanel.setAlignmentX(Component.LEFT_ALIGNMENT);
  infopanel.setPreferredSize(new Dimension(STD_WIDTH, 400));
  
  List<JLabel> labels = new ArrayList<JLabel>();
  labels.add(new JLabel(storyinfo.getTitle()));
  
  if (storyinfo.getHeadline() != null) {
    
    labels.add(new JLabel(storyinfo.getHeadline()));
  }
    
  labels.add(new JLabel(storyinfo.getAuthor() + " ("
      + storyinfo.getYear() + ")"));
      
  for (JLabel label : labels) {
    
    infopanel.add(label);
    label.setAlignmentX(Component.LEFT_ALIGNMENT);
    
    // Ensure that the label fonts are all bold
    label.setFont(label.getFont().deriveFont(Font.BOLD));
  }
  
  infopanel.add(Box.createVerticalStrut(6));
  
  JTextArea descarea = new JTextArea(storyinfo.getDescription());    
  descarea.setLineWrap(true);
  descarea.setWrapStyleWord(true);
  descarea.setEditable(false);
  Insets margins = new Insets(3, 3, 3, 3);
  descarea.setMargin(margins);
  descarea.setFont(labels.get(0).getFont().deriveFont(Font.PLAIN));
  
  JScrollPane spane = new JScrollPane(descarea);
  spane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
  spane.setPreferredSize(new Dimension(STD_WIDTH, 200));
  spane.setAlignmentX(Component.LEFT_ALIGNMENT);
  infopanel.add(spane);
  return panel;
}
 
Example 18
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 19
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 20
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"));
    }
}