本文整理汇总了Java中javax.swing.JTextArea.setDisabledTextColor方法的典型用法代码示例。如果您正苦于以下问题:Java JTextArea.setDisabledTextColor方法的具体用法?Java JTextArea.setDisabledTextColor怎么用?Java JTextArea.setDisabledTextColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JTextArea
的用法示例。
在下文中一共展示了JTextArea.setDisabledTextColor方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SuspendInfoPanel
import javax.swing.JTextArea; //导入方法依赖的package包/类
public SuspendInfoPanel() {
setLayout(new java.awt.GridBagLayout());
JTextArea infoText = new JTextArea(NbBundle.getMessage(InstancesView.class, "MSG_NotSuspendedApp"));
infoText.setEditable(false);
infoText.setEnabled(false);
infoText.setBackground(getBackground());
infoText.setDisabledTextColor(new JLabel().getForeground());
infoText.setLineWrap(true);
infoText.setWrapStyleWord(true);
infoText.setPreferredSize(
new Dimension(
infoText.getFontMetrics(infoText.getFont()).stringWidth(infoText.getText()),
infoText.getPreferredSize().height));
GridBagConstraints gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
//gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
//gridBagConstraints.weightx = 1.0;
gridBagConstraints.anchor = java.awt.GridBagConstraints.CENTER;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
add(infoText, gridBagConstraints);
infoText.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(InstancesView.class, "MSG_NotSuspendedApp"));
JButton pauseButton = new JButton();
pauseButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
doStopCurrentDebugger();
}
});
org.openide.awt.Mnemonics.setLocalizedText(pauseButton, NbBundle.getMessage(InstancesView.class, "CTL_Pause"));
pauseButton.setIcon(ImageUtilities.loadImageIcon("org/netbeans/modules/debugger/resources/actions/Pause.gif", false));
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.anchor = java.awt.GridBagConstraints.CENTER;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
add(pauseButton, gridBagConstraints);
}
示例2: createMultilineLabel
import javax.swing.JTextArea; //导入方法依赖的package包/类
/**
* Creates a text component to be used as a multi-line, automatically
* wrapping label.
* <p>
* <strong>Restriction:</strong><br>
* The component may have its preferred size very wide.
*
* @param text text of the label
* @param color desired color of the label,
* or {@code null} if the default color should be used
* @return created multi-line text component
*/
public static JTextComponent createMultilineLabel(String text, Color color) {
JTextArea textArea = new JTextArea(text);
textArea.setEditable(false);
textArea.setLineWrap(true);
textArea.setWrapStyleWord(true);
textArea.setEnabled(false);
textArea.setOpaque(false);
textArea.setColumns(25);
textArea.setDisabledTextColor((color != null)
? color
: new JLabel().getForeground());
return textArea;
}
示例3: KeyDemoFrame
import javax.swing.JTextArea; //导入方法依赖的package包/类
public KeyDemoFrame()
{
super("Demonstrating Keystroke Events");
textArea = new JTextArea(10, 15); // set up JTextArea
textArea.setText("Press any key on the keyboard...");
textArea.setEnabled(false);
textArea.setDisabledTextColor(Color.BLACK);
add(textArea); // add textarea to JFrame
addKeyListener(this); // allow frame to process key events
}
示例4: layoutSelectResourcePanel
import javax.swing.JTextArea; //导入方法依赖的package包/类
/**
* @author Marian Petras
*/
static void layoutSelectResourcePanel(final Container thePanel,
final String instructionsText,
final String selectionLabelText,
final Component selectionComp,
final JButton button1,
final JButton button2) {
JTextArea instructions = new JTextArea();
JLabel lblSelection = new JLabel();
instructions.setColumns(20);
instructions.setEditable(false);
instructions.setLineWrap(true);
instructions.setText(instructionsText);
instructions.setWrapStyleWord(true);
instructions.setDisabledTextColor(new JLabel().getForeground());
instructions.setEnabled(false);
instructions.setOpaque(false);
lblSelection.setLabelFor(selectionComp);
Mnemonics.setLocalizedText(lblSelection, selectionLabelText);
JScrollPane scrollPane = new JScrollPane(selectionComp);
Container filesSelection = new JPanel();
GroupLayout layout = new GroupLayout(filesSelection);
filesSelection.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(LEADING)
.addComponent(lblSelection)
.addGroup(layout.createSequentialGroup()
.addComponent(scrollPane, 0, DEFAULT_SIZE, Integer.MAX_VALUE)
.addPreferredGap(RELATED)
.addGroup(layout.createParallelGroup(LEADING)
.addComponent(button1)
.addComponent(button2)))
);
layout.linkSize(SwingConstants.HORIZONTAL, button1, button2);
layout.setVerticalGroup(
layout.createParallelGroup(LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(lblSelection)
.addPreferredGap(RELATED)
.addGroup(layout.createParallelGroup(LEADING)
.addComponent(scrollPane, 0, DEFAULT_SIZE, Integer.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addComponent(button1)
.addPreferredGap(RELATED)
.addComponent(button2))))
);
LayoutStyle layoutStyle = layout.getLayoutStyle();
if (layoutStyle == null) {
layoutStyle = LayoutStyle.getInstance();
}
BorderLayout mainLayout = new BorderLayout();
thePanel.setLayout(mainLayout);
thePanel.add(instructions, BorderLayout.PAGE_START);
thePanel.add(filesSelection, BorderLayout.CENTER);
mainLayout.setVgap(layoutStyle.getPreferredGap(instructions,
lblSelection,
UNRELATED,
SwingConstants.NORTH,
thePanel));
}
示例5: DialogFrame
import javax.swing.JTextArea; //导入方法依赖的package包/类
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();
}
示例6: installUI
import javax.swing.JTextArea; //导入方法依赖的package包/类
@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"));
}
}
示例7: createControlPanelUI
import javax.swing.JTextArea; //导入方法依赖的package包/类
public final void createControlPanelUI() throws Exception {
layout = new GridBagLayout();
mainControlPanel = new JPanel(layout);
instructionPanel = new JPanel(layout);
testPanel = new JPanel(layout);
resultButtonPanel = new JPanel(layout);
controlPanel = new JPanel(layout);
GridBagConstraints gbc = new GridBagConstraints();
String instructions
= "1) Click on MENU using mouse "
+ "\n2) Click on MENU ITEM using mouse "
+ "\n3) Check output on textArea if equal to STRING "
+ "\n\n If correct string, press \"Pass\" "
+ "\n Otherwise, press \"Fail\" ";
instructionTextArea = new JTextArea();
instructionTextArea.setText(instructions);
instructionTextArea.setEnabled(false);
instructionTextArea.setDisabledTextColor(Color.black);
instructionTextArea.setBackground(Color.white);
instructionTextArea.setBorder(
BorderFactory.createLineBorder(Color.black));
gbc.gridx = 0;
gbc.gridy = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
instructionPanel.add(instructionTextArea, gbc);
testTextArea = new JTextArea();
testTextArea.setEnabled(true);
testTextArea.setDisabledTextColor(Color.black);
testTextArea.setBackground(Color.white);
testTextArea.setBorder(
BorderFactory.createLineBorder(Color.black));
gbc.gridx = 0;
gbc.gridy = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
testPanel.add(testTextArea, gbc);
passButton = new JButton("Pass");
passButton.setActionCommand("Pass");
passButton.addActionListener(this);
failButton = new JButton("Fail");
failButton.setActionCommand("Fail");
failButton.addActionListener(this);
gbc.gridx = 0;
gbc.gridy = 0;
resultButtonPanel.add(passButton, gbc);
gbc.gridx = 1;
gbc.gridy = 0;
resultButtonPanel.add(failButton, gbc);
gbc.gridx = 0;
gbc.gridy = 0;
mainControlPanel.add(instructionPanel, gbc);
gbc.gridx = 0;
gbc.gridy = 1;
mainControlPanel.add(testPanel, gbc);
gbc.gridx = 0;
gbc.gridy = 2;
mainControlPanel.add(resultButtonPanel, gbc);
gbc.gridx = 0;
gbc.gridy = 3;
mainControlPanel.add(controlPanel, gbc);
mainFrame = new JFrame("Control Panel");
mainFrame.add(mainControlPanel);
menuBar = new JMenuBar();
menu = new JMenu("MENU");
menuItem = new JMenuItem("MENU ITEM");
menuItem.addActionListener((e) -> {
testTextArea.setText(TEST_STRING);
});
menu.add(menuItem);
menuBar.add(menu);
mainFrame.setJMenuBar(menuBar);
mainFrame.pack();
mainFrame.setDefaultCloseOperation(EXIT_ON_CLOSE);
mainFrame.setVisible(true);
}