本文整理汇总了Java中javax.swing.JTextArea.setBackground方法的典型用法代码示例。如果您正苦于以下问题:Java JTextArea.setBackground方法的具体用法?Java JTextArea.setBackground怎么用?Java JTextArea.setBackground使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JTextArea
的用法示例。
在下文中一共展示了JTextArea.setBackground方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: erzeugeMedienAnzeiger
import javax.swing.JTextArea; //导入方法依赖的package包/类
/**
* Erzeugt das Panel in dem die Mediendetails angezeigt werden.
*/
private void erzeugeMedienAnzeiger()
{
JScrollPane medienAnzeigerScrollPane = new JScrollPane();
medienAnzeigerScrollPane.setPreferredSize(new Dimension(-1, 160));
medienAnzeigerScrollPane.setSize(-1, -1);
medienAnzeigerScrollPane.setBorder(BorderFactory.createTitledBorder(
null, "Ausgewählte Medien", TitledBorder.LEADING,
TitledBorder.DEFAULT_POSITION, UIConstants.HEADER_FONT));
medienAnzeigerScrollPane.setBackground(UIConstants.BACKGROUND_COLOR);
medienAnzeigerScrollPane.getVerticalScrollBar()
.setBackground(UIConstants.BACKGROUND_COLOR);
medienAnzeigerScrollPane.getHorizontalScrollBar()
.setBackground(UIConstants.BACKGROUND_COLOR);
_medienAnzeigerTextArea = new JTextArea();
_medienAnzeigerTextArea.setBackground(UIConstants.BACKGROUND_COLOR);
medienAnzeigerScrollPane.setViewportView(_medienAnzeigerTextArea);
_medienAnzeigerTextArea.setEditable(false);
_medienAnzeigerTextArea.setFont(UIConstants.TEXT_FONT);
_hauptPanel.add(medienAnzeigerScrollPane, BorderLayout.CENTER);
}
示例2: createOthersPanel
import javax.swing.JTextArea; //导入方法依赖的package包/类
void createOthersPanel() {
othersPanel = new JPanel(new BorderLayout(10, 10));
othersPanel.setBackground(Color.WHITE);
othersPanel.setBorder(new EmptyBorder(0, 20, 0, 20));
JTextArea txt1 = new JTextArea(StringResource.getString("BI_LBL_6"));
txt1.setBorder(new EmptyBorder(20, 20, 20, 20));
txt1.setBackground(bgColor);
txt1.setOpaque(false);
txt1.setWrapStyleWord(true);
txt1.setEditable(false);
txt1.setLineWrap(true);
othersPanel.add(txt1, BorderLayout.NORTH);
JPanel biPanel = new JPanel(new GridLayout(2, 1, 20, 20));
biPanel.setBorder(new EmptyBorder(20, 20, 20, 20));
biPanel.add(btn1);
biPanel.add(btn2);
biPanel.setBackground(Color.WHITE);
othersPanel.add(biPanel);
othersPanel.add(autoStart, BorderLayout.SOUTH);
}
示例3: initAndShowUI
import javax.swing.JTextArea; //导入方法依赖的package包/类
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);
}
示例4: erzeugeKundenAnzeiger
import javax.swing.JTextArea; //导入方法依赖的package包/类
/**
* Erzeugt das Panel in dem die Kundendetails angezeigt werden.
*/
private void erzeugeKundenAnzeiger()
{
JScrollPane medienAnzeigerScrollPane = new JScrollPane();
medienAnzeigerScrollPane.setPreferredSize(new Dimension(-1, 160));
medienAnzeigerScrollPane.setSize(-1, -1);
medienAnzeigerScrollPane.setBorder(BorderFactory.createTitledBorder(
null, "Ausgewählter Kunde", TitledBorder.LEADING,
TitledBorder.DEFAULT_POSITION, UIConstants.HEADER_FONT));
medienAnzeigerScrollPane.setBackground(UIConstants.BACKGROUND_COLOR);
medienAnzeigerScrollPane.getVerticalScrollBar()
.setBackground(UIConstants.BACKGROUND_COLOR);
medienAnzeigerScrollPane.getHorizontalScrollBar()
.setBackground(UIConstants.BACKGROUND_COLOR);
_kundenAnzeigerTextArea = new JTextArea();
_kundenAnzeigerTextArea.setBackground(UIConstants.BACKGROUND_COLOR);
medienAnzeigerScrollPane.setViewportView(_kundenAnzeigerTextArea);
_kundenAnzeigerTextArea.setEditable(false);
_kundenAnzeigerTextArea.setFont(UIConstants.TEXT_FONT);
_hauptPanel.add(medienAnzeigerScrollPane, BorderLayout.CENTER);
}
示例5: getTitleComponent
import javax.swing.JTextArea; //导入方法依赖的package包/类
private JComponent getTitleComponent (String msg) {
JTextArea area = new JTextArea (msg);
area.setWrapStyleWord (true);
area.setLineWrap (true);
area.setEditable (false);
area.setOpaque (false);
area.setBorder(BorderFactory.createEmptyBorder());
area.setBackground(new Color(0, 0, 0, 0));
area.putClientProperty(JTextPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
return area;
}
示例6: createWarningPanel
import javax.swing.JTextArea; //导入方法依赖的package包/类
/**
* Creates the panel to be shown when the table is empty
* @param msg message to be shown on the panel
* @return created warning panel
*/
protected JPanel createWarningPanel(String msg) {
JPanel warning = new JPanel(new GridBagLayout());
JPanel innerPanel = new JPanel(new BorderLayout());
// Adds image
JLabel icon = new JLabel("");
icon.setIcon(JMTImageLoader.loadImage("Triangle"));
icon.setHorizontalAlignment(SwingConstants.CENTER);
icon.setBorder(BorderFactory.createEmptyBorder(BORDERSIZE, BORDERSIZE, BORDERSIZE, BORDERSIZE));
innerPanel.add(icon, BorderLayout.NORTH);
// Adds Text Area
JTextArea text = new JTextArea();
text.setOpaque(false);
text.setEditable(false);
text.setWrapStyleWord(true);
text.setLineWrap(true);
text.setText(msg);
text.setBorder(BorderFactory.createEmptyBorder(BORDERSIZE, BORDERSIZE, BORDERSIZE, BORDERSIZE));
text.setBackground(icon.getBackground());
JScrollPane textPane = new JScrollPane(text);
textPane.setBorder(new EmptyBorder(0, 0, 0, 0));
innerPanel.add(textPane, BorderLayout.CENTER);
innerPanel.setBorder(BorderFactory.createEtchedBorder());
innerPanel.setPreferredSize(warningBoxSize);
warning.add(innerPanel);
return warning;
}
示例7: WarningMessage
import javax.swing.JTextArea; //导入方法依赖的package包/类
public WarningMessage(String ErrMessage) {
setBounds(100, 100, 650, 500);
this.getContentPane().setLayout(new BorderLayout());
{
JPanel buttonPane = new JPanel();
buttonPane.setBackground(new Color(144, 238, 144));
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
getContentPane().add(buttonPane, BorderLayout.SOUTH);
{
JButton cancelButton = new JButton("OK");
cancelButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
dispose();
}
});
cancelButton.setFont(new Font("Times New Roman", Font.BOLD, 12));
cancelButton.setHorizontalAlignment(SwingConstants.LEFT);
buttonPane.add(cancelButton);
}
}
{
JLabel label = new JLabel("Warning!");
label.setBackground(new Color(144, 238, 144));
label.setHorizontalAlignment(SwingConstants.CENTER);
label.setForeground(new Color(100, 0, 0));
label.setFont(new Font("Times New Roman", Font.BOLD, 24));
getContentPane().add(label, BorderLayout.NORTH);
}
{
JScrollPane scrollPane = new JScrollPane();
getContentPane().add(scrollPane, BorderLayout.CENTER);
{
JTextArea txtErrMessage = new JTextArea();
txtErrMessage.setText(ErrMessage);
txtErrMessage.setFont(new Font("Monospaced", Font.PLAIN, 13));
txtErrMessage.setBackground(new Color(144, 238, 144));
scrollPane.setViewportView(txtErrMessage);
txtErrMessage.setCaretPosition(0);
txtErrMessage.setEditable(false);
}
}
}
示例8: addDisplay
import javax.swing.JTextArea; //导入方法依赖的package包/类
/** Create a simple one-line text display, a non-editable value that
* is set externally using the setDisplay() method.
* @param name The name used to identify the entry (when calling get).
* @param label The label to attach to the entry.
* @param theValue Default string to display.
*/
public void addDisplay(String name, String label, String theValue) {
JLabel lbl = new JLabel(label + ": ");
lbl.setBackground(_background);
// NOTE: JLabel would be a reasonable choice here, but at
// least in the current version of swing, JLabel.setText() does
// not work.
JTextArea displayField = new JTextArea(theValue, 1, 10);
displayField.setEditable(false);
displayField.setBackground(_background);
_addPair(name, lbl, displayField, displayField);
}
示例9: addTextArea
import javax.swing.JTextArea; //导入方法依赖的package包/类
public void addTextArea(
String name,
String label,
String theValue,
Color background) {
JLabel lbl = new JLabel(label + ": ");
lbl.setBackground(_background);
JTextArea textArea = new JTextArea(theValue, _height, _width);
textArea.setEditable(true);
textArea.setBackground(background);
QueryScrollPane textPane = new QueryScrollPane(textArea);
_addPair(name, lbl, textPane, textPane);
textArea.addFocusListener(new QueryFocusListener(name));
}
示例10: getInfoPane
import javax.swing.JTextArea; //导入方法依赖的package包/类
private JScrollPane getInfoPane() {
// Create a text pane
JTextArea infoPane = new JTextArea();
infoPane.setEditable(false);
infoPane.setBackground(Color.WHITE);
// Text font
Font font = new Font("Lucida Sans Typewriter", Font.PLAIN, 12);
infoPane.setFont(font);
infoPane.setTabSize(4);
// Get the message and the stack trace from the exception and put them
// in text pane.
String info = this.simulator.getModel()
.getExplorationStats()
.getReport();
infoPane.setText(info);
// Pane to create the scroll bars.
JScrollPane scrollPane = new JScrollPane();
scrollPane.setPreferredSize(new Dimension(700, 500));
scrollPane.setBorder(BorderFactory.createTitledBorder(null,
STATS_HEADER_TEXT,
TitledBorder.DEFAULT_JUSTIFICATION,
TitledBorder.DEFAULT_POSITION));
scrollPane.setViewportView(infoPane);
return scrollPane;
}
示例11: StartPagePanel
import javax.swing.JTextArea; //导入方法依赖的package包/类
/**
* Create the panel.
*/
public StartPagePanel() {
setLayout(null);
btnNewButton = new JButton("Play");
btnNewButton.setFont(new Font("Lucida Grande", Font.PLAIN, 20));
btnNewButton.setBounds(141, 84, 149, 52);
add(btnNewButton);
btnMakeDeck = new JButton("Make Deck");
btnMakeDeck.setFont(new Font("Lucida Grande", Font.PLAIN, 20));
btnMakeDeck.setBounds(141, 144, 149, 52);
add(btnMakeDeck);
btnOpenPack = new JButton("Open Pack");
btnOpenPack.setFont(new Font("Lucida Grande", Font.PLAIN, 20));
btnOpenPack.setEnabled(false);
btnOpenPack.setBounds(141, 208, 149, 52);
add(btnOpenPack);
JLabel lblHearthstone = new JLabel("Hearthstone");
lblHearthstone.setFont(new Font("Lucida Grande", Font.PLAIN, 30));
lblHearthstone.setBounds(131, 32, 178, 36);
add(lblHearthstone);
lblWelcome = new JLabel("Welcome, ");
lblWelcome.setFont(new Font("Lucida Grande", Font.PLAIN, 20));
lblWelcome.setBounds(391, 100, 224, 25);
add(lblWelcome);
lblYouAreRank = new JLabel("You are rank ");
lblYouAreRank.setFont(new Font("Lucida Grande", Font.PLAIN, 20));
lblYouAreRank.setBounds(391, 142, 265, 25);
add(lblYouAreRank);
JLabel lblYouHave = new JLabel("You have ");
lblYouHave.setFont(new Font("Lucida Grande", Font.PLAIN, 20));
lblYouHave.setBounds(391, 173, 224, 25);
add(lblYouHave);
JTextArea txtrAllPropertiesBelong = new JTextArea();
txtrAllPropertiesBelong.setText("All properties belong to their respective owners.\nDeveloped by Imran Khaliq.");
txtrAllPropertiesBelong.setBounds(391, 262, 303, 32);
txtrAllPropertiesBelong.setBackground(this.getBackground());
add(txtrAllPropertiesBelong);
btnLogout = new JButton("Logout");
btnLogout.setBounds(6, 265, 117, 29);
add(btnLogout);
btnCollection = new JButton("Collection");
btnCollection.setFont(new Font("Lucida Grande", Font.PLAIN, 20));
btnCollection.setBounds(466, 208, 149, 52);
add(btnCollection);
}
示例12: CustomizerPane
import javax.swing.JTextArea; //导入方法依赖的package包/类
public CustomizerPane(JPanel categoryView, CategoryModel categoryModel, ProjectCustomizer.CategoryComponentProvider componentProvider) {
initComponents();
this.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(CustomizerPane.class,"AD_CustomizerPane")); // NOI18N
this.componentProvider = componentProvider;
fillConstraints = new GridBagConstraints();
fillConstraints.gridwidth = GridBagConstraints.REMAINDER;
fillConstraints.gridheight = 1;
fillConstraints.fill = GridBagConstraints.BOTH;
fillConstraints.weightx = 1.0;
fillConstraints.weighty = 1.0;
categoryModel.addPropertyChangeListener( new CategoryChangeListener() );
categoryPanel.add( categoryView, fillConstraints );
errorIcon = new JLabel();
errorPanel = new JPanel(new BorderLayout(errorIcon.getIconTextGap(), 0)); // cf. BasicLabelUI.layoutCL
errorPanel.add(errorIcon, BorderLayout.LINE_START);
errorIcon.setVerticalAlignment(SwingConstants.TOP);
errorMessageValue = new JTextArea();
errorMessageValue.setLineWrap(true);
errorMessageValue.setWrapStyleWord(true);
errorMessageValue.setBorder(BorderFactory.createEmptyBorder());
errorMessageValue.setBackground(customizerPanel.getBackground());
errorMessageValue.setEditable(false);
errorPanel.add(errorMessageValue, BorderLayout.CENTER);
// put it into under categoryView
errMessConstraints = new GridBagConstraints();
errMessConstraints.gridx = 0;
errMessConstraints.gridy = 1;
errMessConstraints.gridwidth = 1;
errMessConstraints.gridheight = 1;
errMessConstraints.insets = new Insets(12, 0, 0, 0);
errMessConstraints.fill = GridBagConstraints.HORIZONTAL;
customizerPanel.add(errorPanel, errMessConstraints);
/*Preferences prefs = NbPreferences.forModule(org.netbeans.modules.project.uiapi.CustomizerPane.class);
int paneWidth = prefs.getInt(CUSTOMIZER_DIALOG_WIDTH, 0);
int paneHeight = prefs.getInt(CUSTOMIZER_DIALOG_HEIGHT, 0);
if (paneWidth != 0 && paneHeight != 0) {
previousDimension = new Dimension(paneWidth, paneHeight);
}*/
setCategory( categoryModel.getCurrentCategory() );
}
示例13: Cart
import javax.swing.JTextArea; //导入方法依赖的package包/类
public Cart() {
DecimalFormat money = new DecimalFormat("0.00");
System.out.println("CREATING CART");
resetCartFields();
//add(shoppingList);
scroll = generateScrollPane();
sub = new JTextArea();
tot = new JTextArea();
fTot = new JTextArea();
updatePriceFields();
Font font = new Font(sub.getFont().getFontName(), Font.PLAIN, 24);
sub.setFont(font);
tot.setFont(font);
fTot.setFont(font);
sub.setBackground(null);
tot.setBackground(null);
fTot.setBackground(null);
sub.setEditable(false);
tot.setEditable(false);
fTot.setEditable(false);
setLayout(new GridLayout(4,1));
add(scroll);
add(sub);
add(tot);
add(fTot);
//pricing.add(subP);
//pricing.add(totP);
//pricing.add(fTotP);
//add(pricing);
}
示例14: 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"));
}
}
示例15: UnknownParametersInfoDialog
import javax.swing.JTextArea; //导入方法依赖的package包/类
public UnknownParametersInfoDialog(Frame owner, List<UnknownParameterInformation> unknownParameters) {
super(owner, "Unknown Parameters", true);
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
setLayout(new BorderLayout());
setModal(true);
// text
JTextArea text = new JTextArea();
text.setLineWrap(true);
text.setWrapStyleWord(true);
text.setBackground(getBackground());
text.setEditable(false);
String textString = "The following table shows all parameters which are not (no longer) valid. This can happen for several reasons. First, a mistake in the parameter name can cause this error. Second, a parameter was removed and is now no longer supported. Third, a parameter was replaced by a (set of) other parameter(s). Please ensure that the process still performs the desired task by checking the parameter settings manually.";
text.setText(textString);
text.setBorder(BorderFactory.createEmptyBorder(11, 11, 11, 11));
add(text, BorderLayout.NORTH);
// table
ExtendedJTable table = new ExtendedJTable(new UnknownParametersTableModel(unknownParameters), true, true, true);
ExtendedJScrollPane pane = new ExtendedJScrollPane(table);
pane.setBorder(BorderFactory.createEmptyBorder(11, 11, 11, 11));
add(pane, BorderLayout.CENTER);
// ok button
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
JButton okButton = new JButton("Ok");
okButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
ok();
}
});
buttonPanel.add(okButton);
add(buttonPanel, BorderLayout.SOUTH);
setSize(640, 480);
setLocationRelativeTo(owner);
}