本文整理汇总了Java中javax.swing.JTextArea.setFont方法的典型用法代码示例。如果您正苦于以下问题:Java JTextArea.setFont方法的具体用法?Java JTextArea.setFont怎么用?Java JTextArea.setFont使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JTextArea
的用法示例。
在下文中一共展示了JTextArea.setFont方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ImagePicker
import javax.swing.JTextArea; //导入方法依赖的package包/类
public ImagePicker() {
noImage = new JTextArea(1,10);
noImage.setFont(FONT);
noImage.setText("Double-click here to add new image");
noImage.addMouseListener(this);
noImage.setEditable(false);
noImage.setLineWrap(true);
noImage.setWrapStyleWord(true);
noImage.setMinimumSize(new Dimension(15, 32));
icon = new OpIcon();
imageView = new JLabel(icon);
imageView.addMouseListener(this);
imageViewer = new JPanel(new BorderLayout());
imageScroller = new ScrollPane(
imageView,
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
imageViewer.add(imageScroller, BorderLayout.CENTER);
select = new JComboBox(ArrayUtils.prepend(GameModule.getGameModule().getDataArchive().getImageNames(), NO_IMAGE));
select.addItemListener(this);
setLayout(new BoxLayout(this,BoxLayout.Y_AXIS));
add(noImage);
add(select);
}
示例2: 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);
}
示例3: jButton1ActionPerformed
import javax.swing.JTextArea; //导入方法依赖的package包/类
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
try {
//JOptionPane pane = new JOptionPane();
//pane.setMessageType(JOptionPane.INFORMATION_MESSAGE);
JDialog dialog = new JDialog((Frame)null, "Result of COAP GET for bulb " + bulb.getName(), false);
JTextArea msg = new JTextArea(bulb.getJsonObject().toString(4) + "\n");
msg.setFont(new Font("monospaced", Font.PLAIN, 10));
msg.setLineWrap(true);
msg.setWrapStyleWord(true);
JScrollPane scrollPane = new JScrollPane(msg);
dialog.getContentPane().add(scrollPane);
dialog.setSize(350, 350);
//dialog.pack();
dialog.setVisible(true);
} catch (JSONException ex) {
Logger.getLogger(BulbPanel.class.getName()).log(Level.SEVERE, null, ex);
}
}
示例4: createAndShow
import javax.swing.JTextArea; //导入方法依赖的package包/类
public void createAndShow() throws Exception{
Preferences Config = TEdit.getConfig();
JTextArea area = new JTextArea(10,40);
area.setEditable(false);
String Font_Name = Config.get("FONT_NAME","Monospaced");
int Font_Size = Config.getInt("FONT_SIZE",12);
int Font_Style = Config.getInt("FONT_STYLE",Font.PLAIN);
area.setFont(new Font(Font_Name,Font_Style,Font_Size));
JScrollPane scroll = new JScrollPane(area,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
this.add(scroll,BorderLayout.CENTER);
if(txt == null){
BufferedReader br = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream("org/ioblako/edit/resources/Help.txt"), "UTF-8"));
for (int c = br.read(); c != -1; c = br.read()) sb.append((char)c);
txt=sb.toString();
}
area.setText(txt);
this.setTitle("Help");
this.pack();
this.setVisible(true);
}
示例5: 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);
}
示例6: run
import javax.swing.JTextArea; //导入方法依赖的package包/类
@Override
public void run() {
JFrame jframe = new JFrame(windowLabel == null
? getResourceString("editpad.name")
: windowLabel);
Runnable closer = () -> {
jframe.setVisible(false);
jframe.dispose();
closeMark.run();
};
jframe.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
closer.run();
}
});
jframe.setLocationRelativeTo(null);
jframe.setLayout(new BorderLayout());
JTextArea textArea = new JTextArea(initialText);
textArea.setFont(new Font("monospaced", Font.PLAIN, 13));
jframe.add(new JScrollPane(textArea), BorderLayout.CENTER);
jframe.add(buttons(closer, textArea), BorderLayout.SOUTH);
jframe.setSize(800, 600);
jframe.setVisible(true);
}
示例7: initialize
import javax.swing.JTextArea; //导入方法依赖的package包/类
private void initialize() {
txtArea = new JTextArea();
txtArea.setFont(new Font(Font.SANS_SERIF, 0, 12));
txtArea.setEditable(false);
JScrollPane sp = new JScrollPane(txtArea);
sp.setBounds(5, 5, 600, 410);
frame.getContentPane().add(sp);
btnOk = new JButton("OK");
btnOk.setFont(new Font(Font.SANS_SERIF, 0, 12));
btnOk.setBounds(510, 420, 95, 20);
btnOk.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
frame.dispose();
}
});
frame.getContentPane().add(btnOk);
txtArea.append(new Utils().getLicenseFile());
txtArea.setCaretPosition(0);
}
示例8: createNiceMessages
import javax.swing.JTextArea; //导入方法依赖的package包/类
private JComponent createNiceMessages()
{
JLabel heading = new JLabel("<html><font size=+1>" + title + "</font></html>");
JTextArea body = new JTextArea(message);
body.setHighlighter(null);
body.setEditable(false);
body.setFocusable(false);
body.setOpaque(false);
body.setBorder(null);
body.setLineWrap(true);
body.setWrapStyleWord(true);
body.setFont(heading.getFont());
final int[] rows = new int[]{heading.getPreferredSize().height, TableLayout.FILL};
final int[] columns = new int[]{TableLayout.FILL};
TableLayout layout = new TableLayout(rows, columns, 5, 5);
JPanel all = new JPanel(layout);
all.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
all.add(heading, new Rectangle(0, 0, 1, 1));
all.add(body, new Rectangle(0, 1, 1, 1));
return all;
}
示例9: init
import javax.swing.JTextArea; //导入方法依赖的package包/类
private void init() {
// GraphVisualization
RenderContext<AbstractPlanNode, PlanNodeGraph.Edge> context = this.visualizationPanel.getRenderContext();
context.setEdgeShapeTransformer(new EdgeShape.Line<AbstractPlanNode, PlanNodeGraph.Edge>());
context.setVertexFontTransformer(new GraphVisualizationPanel.VertexFontTransformer<AbstractPlanNode>(true));
// PlanFragmentBoundaries boundaryPainter = new PlanFragmentBoundaries();
// this.visualizationPanel.addPostRenderPaintable(boundaryPainter);
// Full Plan Tab
JPanel textInfoPanel = new JPanel();
textInfoPanel.setLayout(new BorderLayout());
JTextArea textInfoTextArea = new JTextArea();
textInfoTextArea.setEditable(false);
textInfoTextArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
textInfoTextArea.setText(PlanNodeUtil.debug(this.root));
textInfoPanel.add(new JScrollPane(textInfoTextArea), BorderLayout.CENTER);
// Node Field Tab
this.nodeField = new JTextArea();
this.nodeField.setEditable(false);
this.nodeField.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
this.nodeField.setText("");
JPanel textInfoPanel2 = new JPanel(new BorderLayout());
textInfoPanel2.add(new JScrollPane(this.nodeField), BorderLayout.CENTER);
this.tabbedPane = new JTabbedPane();
this.tabbedPane.add("Full Plan", textInfoPanel);
this.tabbedPane.add("Selected Node", textInfoPanel2);
JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, visualizationPanel, this.tabbedPane);
splitPane.setDividerLocation(AbstractViewer.DEFAULT_WINDOW_HEIGHT - 500);
this.mainPanel.add(splitPane, BorderLayout.CENTER);
}
示例10: 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);
}
}
}
示例11: getTextComponent
import javax.swing.JTextArea; //导入方法依赖的package包/类
/** Helper method returns a JTextArea containing the given text. */
private JComponent getTextComponent(String text) {
final JTextArea ta = OurUtil.textarea(text, 10, 10, false, true);
final JScrollPane ans = new JScrollPane(ta, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED) {
private static final long serialVersionUID = 0;
@Override
public void setFont(Font font) {
ta.setFont(font);
}
};
ans.setBorder(new OurBorder(true, false, true, false));
return ans;
}
示例12: 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;
}
示例13: getGraphCellEditorComponent
import javax.swing.JTextArea; //导入方法依赖的package包/类
/**
* Initialises the editor component with the edit string of the user
* object of <tt>value</tt> (which is required to be a {@link JCell}).
*/
@Override
public Component getGraphCellEditorComponent(org.jgraph.JGraph graph, Object value,
boolean isSelected) {
AspectJCell jCell = (AspectJCell) value;
// fill the set of labels for autocompletion
this.labels.clear();
this.labels.addAll(prefixes);
AspectJModel jmodel = (AspectJModel) graph.getModel();
TypeGraph type = jmodel.getResourceModel().getGrammar().getTypeGraph();
for (TypeLabel label : type.getLabels()) {
this.labels.add(label.text());
}
JTextArea result = getEditorComponent();
// scale with the jGraph
Font font = Options.getLabelFont().deriveFont(jCell.getVisuals().getFont());
font = (font != null) ? font : graph.getFont();
if (graph.getScale() != 1) {
double scale = graph.getScale();
Dimension size = result.getSize();
size.height *= scale;
size.width *= scale;
result.setSize(size);
font = font.deriveFont((float) (font.getSize() * scale));
}
result.setFont(font);
String editString = ((AspectJCell) value).getUserObject().toEditString();
result.setText(editString);
result.selectAll();
return result;
}
示例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: setScreen
import javax.swing.JTextArea; //导入方法依赖的package包/类
private static void setScreen(JTextArea myScreen) {
myScreen.setFont(new Font("Arial", Font.PLAIN, 16));
myScreen.setMargin(new Insets(5, 5, 5, 5));
}