本文整理汇总了Java中javax.swing.JTextPane.setFont方法的典型用法代码示例。如果您正苦于以下问题:Java JTextPane.setFont方法的具体用法?Java JTextPane.setFont怎么用?Java JTextPane.setFont使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JTextPane
的用法示例。
在下文中一共展示了JTextPane.setFont方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadScene
import javax.swing.JTextPane; //导入方法依赖的package包/类
@Override
public void loadScene(Container container) {
JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(0, 0, 784, 461);
container.add(scrollPane);
JTextPane textPane = new JTextPane();
textPane.setFont(new Font("Tahoma", Font.PLAIN, 12));
for (int i = 0; i < 50; i++) {
textPane.setText(textPane.getText() + "\n" + i);
}
scrollPane.setViewportView(textPane);
}
示例2: ROCViewer
import javax.swing.JTextPane; //导入方法依赖的package包/类
public ROCViewer(AreaUnderCurve auc) {
setLayout(new BorderLayout());
String message = auc.toString();
criterionName = auc.getName();
// info string
JPanel infoPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
infoPanel.setOpaque(true);
infoPanel.setBackground(Colors.WHITE);
JTextPane infoText = new JTextPane();
infoText.setEditable(false);
infoText.setBackground(infoPanel.getBackground());
infoText.setFont(infoText.getFont().deriveFont(Font.BOLD));
infoText.setText(message);
infoPanel.add(infoText);
add(infoPanel, BorderLayout.NORTH);
// plot panel
plotter = new ROCChartPlotter();
plotter.addROCData("ROC", auc.getRocData());
JPanel innerPanel = new JPanel(new BorderLayout());
innerPanel.add(plotter, BorderLayout.CENTER);
innerPanel.setBorder(BorderFactory.createMatteBorder(5, 0, 10, 10, Colors.WHITE));
add(innerPanel, BorderLayout.CENTER);
}
示例3: CurveViewer
import javax.swing.JTextPane; //导入方法依赖的package包/类
public CurveViewer(CurveCollection curves) {
setLayout(new BorderLayout());
String message = curves.toString();
criterionName = curves.getName();
// info string
JPanel infoPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
infoPanel.setOpaque(true);
infoPanel.setBackground(Colors.WHITE);
JTextPane infoText = new JTextPane();
infoText.setEditable(false);
infoText.setBackground(infoPanel.getBackground());
infoText.setFont(infoText.getFont().deriveFont(Font.BOLD));
infoText.setText(message);
infoPanel.add(infoText);
add(infoPanel, BorderLayout.NORTH);
// plot panel
plotter = new CurveChartPlotter();
plotter.setCurve(curves);
JPanel innerPanel = new JPanel(new BorderLayout());
innerPanel.add(plotter, BorderLayout.CENTER);
innerPanel.setBorder(BorderFactory.createMatteBorder(5, 0, 10, 10, Colors.WHITE));
add(innerPanel, BorderLayout.CENTER);
}
示例4: LicenseWindow
import javax.swing.JTextPane; //导入方法依赖的package包/类
/**
* Create the frame.
*/
public LicenseWindow(final String path) {
setTitle("Coder HPMSA - [License]");
setBounds(100, 100, 550, 550);
setBackground(Color.decode("#066d95"));
setLocationRelativeTo(null);
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
this.setIconImage(Toolkit.getDefaultToolkit().
getImage(getClass().getResource(LOGOPATH)));
final JScrollPane scrollPane = new JScrollPane();
scrollPane.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, null, null, null, null));
getContentPane().add(scrollPane, BorderLayout.CENTER);
editorPane = new JTextPane();
editorPane.setBackground(new Color(255, 255, 240));
editorPane.setFont(new Font("Verdana", Font.PLAIN, 13));
editorPane.setBorder(new EtchedBorder(EtchedBorder.RAISED, null, null));
editorPane.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
editorPane.setEditable(false);
scrollPane.setViewportView(editorPane);
final StyledDocument doc = editorPane.getStyledDocument();
final SimpleAttributeSet center = new SimpleAttributeSet();
StyleConstants.setAlignment(center, StyleConstants.ALIGN_CENTER);
doc.setParagraphAttributes(0, doc.getLength()-1, center, false);
fillEditorPane(path);
setVisible(true);
}
示例5: getStackTracePane
import javax.swing.JTextPane; //导入方法依赖的package包/类
/**
* Creates the pane with the stack trace of an exception.
* @param e the exception to be shown in the pane.
* @return the pane object.
*/
private JScrollPane getStackTracePane(Throwable e) {
// Create a text pane
JTextPane stackTracePane = new JTextPane();
stackTracePane.setEditable(false);
// Text font
Font font = new Font("Serif", Font.PLAIN, 12);
stackTracePane.setFont(font);
// Get the message and the stack trace from the exception and put them
// in text pane.
StringWriter sw = new StringWriter();
e.printStackTrace(new PrintWriter(sw));
stackTracePane.setText("Exception in GROOVE " + sw.toString());
// Extra panel to prevent wrapping of the exception message.
JPanel noWrapPanel = new JPanel(new BorderLayout());
noWrapPanel.add(stackTracePane);
// Pane to create the scroll bars.
JScrollPane scrollPane = new JScrollPane();
scrollPane.setPreferredSize(new Dimension(700, 300));
scrollPane.setBorder(BorderFactory.createTitledBorder(null,
"Exception Stack Trace:",
TitledBorder.DEFAULT_JUSTIFICATION,
TitledBorder.DEFAULT_POSITION));
scrollPane.setViewportView(noWrapPanel);
return scrollPane;
}
示例6: init
import javax.swing.JTextPane; //导入方法依赖的package包/类
private void init() {
txpText = new JTextPane();
txpLines = new JTextPane();
// needed for correct layouting
Insets ins = txpLines.getInsets();
txpLines.setMargin(new Insets(ins.top + 1, ins.left, ins.bottom, ins.right));
textHighlighter = new BookmarkHighlighter();
lineHighlighter = new BookmarkHighlighter();
txpText.setHighlighter(textHighlighter);
//txpText.setMinimumSize(new Dimension(100, 100));
txpText.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
txpText.setEditable(false);
txpLines.setHighlighter(lineHighlighter);
txpLines.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
txpLines.setBackground(Color.LIGHT_GRAY);
txpLines.setEnabled(false);
txpLines.setForeground(Color.BLACK);
txpLines.addMouseListener(mouseInputListener);
fm = txpText.getFontMetrics(txpText.getFont());
JPanel pnlBookmarks = new JPanel();
pnlBookmarks.setLayout(new BorderLayout());
pnlBookmarks.add(txpText, BorderLayout.CENTER);
JScrollPane jspBookmarks = new JScrollPane(pnlBookmarks);
jspBookmarks.setRowHeaderView(txpLines);
jspBookmarks.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
jspBookmarks.getVerticalScrollBar().setUnitIncrement(15);
this.setLayout(new BorderLayout());
this.add(jspBookmarks, BorderLayout.CENTER);
}
示例7: ConsolePanel
import javax.swing.JTextPane; //导入方法依赖的package包/类
public ConsolePanel() {
setLayout(new BorderLayout());
consoleView = new JTextPane();
consoleView.setEditable(false);
consoleView.setFont(FONT);
add(new JScrollPane(consoleView), BorderLayout.CENTER);
}
示例8: okButtonActionPerformed
import javax.swing.JTextPane; //导入方法依赖的package包/类
private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
for (int i=0; i<PrincipalWindow.tabbedPaneProgram.getTabCount(); i++){
JPanel panelToSetFont = (JPanel) PrincipalWindow.tabbedPaneProgram.getComponentAt(i);
JScrollPane scrollpane = (JScrollPane) panelToSetFont.getComponent(0);
JTextPane textPane = (JTextPane) scrollpane.getViewport().getComponent(0);
textPane.setFont(lblPreview.getFont());
textPane.repaint();
}
PrincipalWindow.tabbedPaneProgram.setSelectedIndex(PrincipalWindow.tabbedPaneProgram.getTabCount()-1);
FontFile.saveFont(lblPreview.getFont());
doClose(RET_OK);
}
示例9: NotifyExcPanel
import javax.swing.JTextPane; //导入方法依赖的package包/类
/** Constructor.
*/
private NotifyExcPanel () {
java.util.ResourceBundle bundle = org.openide.util.NbBundle.getBundle(NotifyExcPanel.class);
next = new JButton ();
Mnemonics.setLocalizedText(next, bundle.getString("CTL_NextException"));
// bugfix 25684, don't set Previous/Next as default capable
next.setDefaultCapable (false);
previous = new JButton ();
Mnemonics.setLocalizedText(previous, bundle.getString("CTL_PreviousException"));
previous.setDefaultCapable (false);
details = new JButton ();
details.setDefaultCapable (false);
output = new JTextPane() {
public @Override boolean getScrollableTracksViewportWidth() {
return false;
}
};
output.setEditable(false);
Font f = output.getFont();
output.setFont(new Font("Monospaced", Font.PLAIN, null == f ? 12 : f.getSize() + 1)); // NOI18N
output.setForeground(UIManager.getColor("Label.foreground")); // NOI18N
output.setBackground(UIManager.getColor("Label.background")); // NOI18N
setLayout( new BorderLayout() );
add(new JScrollPane(output));
setBorder( new javax.swing.border.BevelBorder(javax.swing.border.BevelBorder.LOWERED));
next.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_NextException"));
previous.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_PreviousException"));
output.getAccessibleContext().setAccessibleName(bundle.getString("ACSN_ExceptionStackTrace"));
output.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_ExceptionStackTrace"));
getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_NotifyExceptionPanel"));
descriptor = new DialogDescriptor ("", ""); // NOI18N
descriptor.setMessageType (DialogDescriptor.ERROR_MESSAGE);
descriptor.setOptions (computeOptions(previous, next));
descriptor.setAdditionalOptions (new Object[] {
details
});
descriptor.setClosingOptions (new Object[0]);
descriptor.setButtonListener (this);
// bugfix #27176, create dialog in modal state if some other modal
// dialog is opened at the time
// #53328 do not let the error dialog to be created modal unless the main
// window is visible. otherwise the error message may be hidden behind
// the main window thus making the main window unusable
descriptor.setModal( isModalDialogPresent()
&& WindowManager.getDefault().getMainWindow().isVisible() );
setPreferredSize(new Dimension(SIZE_PREFERRED_WIDTH + extraW, SIZE_PREFERRED_HEIGHT + extraH));
dialog = DialogDisplayer.getDefault().createDialog(descriptor);
if( null != lastBounds ) {
lastBounds.width = Math.max( lastBounds.width, SIZE_PREFERRED_WIDTH+extraW );
dialog.setBounds( lastBounds );
}
dialog.getAccessibleContext().setAccessibleName(bundle.getString("ACN_NotifyExcPanel_Dialog")); // NOI18N
dialog.getAccessibleContext().setAccessibleDescription(bundle.getString("ACD_NotifyExcPanel_Dialog")); // NOI18N
}
示例10: draw
import javax.swing.JTextPane; //导入方法依赖的package包/类
public void draw(Graphics g, GamePieceImage defn) {
TextBoxItemInstance tbi = null;
if (defn != null) {
tbi = defn.getTextBoxInstance(getConfigureName());
}
if (tbi == null) {
tbi = new TextBoxItemInstance();
}
Color fg = tbi.getFgColor().getColor();
Color bg = tbi.getBgColor().getColor();
Point origin = layout.getPosition(this);
Rectangle r = new Rectangle(origin.x, origin.y, getWidth(), getHeight());
String s = null;
if (textSource.equals(SRC_FIXED)) {
s = text;
}
else {
if (defn != null) {
if (tbi != null) {
s = tbi.getValue();
}
}
}
Graphics2D g2d = ((Graphics2D) g);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, isAntialias() ?
RenderingHints.VALUE_ANTIALIAS_ON : RenderingHints.VALUE_ANTIALIAS_OFF);
AffineTransform saveXForm = null;
if (getRotation() != 0) {
saveXForm = g2d.getTransform();
AffineTransform newXForm =
AffineTransform.getRotateInstance(Math.toRadians(getRotation()), getLayout().getVisualizerWidth()/2, getLayout().getVisualizerHeight()/2);
g2d.transform(newXForm);
}
if (bg != null) {
g.setColor(bg);
g.fillRect(r.x, r.y, r.width, r.height);
}
JTextPane l = new JTextPane();
if (isHTML) l.setContentType("text/html"); //$NON-NLS-1$
l.setText(s);
l.setSize(width-2, height-2);
l.setBackground(bg != null ? bg : new Color(0,true));
l.setForeground(fg != null ? fg : new Color(0,true));
FontStyle fs = FontManager.getFontManager().getFontStyle(fontStyleName);
Font f = fs.getFont();
l.setFont(f);
final BufferedImage img = ImageUtils.createCompatibleTranslucentImage(
Math.max(l.getWidth(), 1),
Math.max(l.getHeight(), 1)
);
final Graphics2D big = img.createGraphics();
l.paint(big);
big.dispose();
g2d.drawImage(img, origin.x+1, origin.y+1, null);
if (saveXForm != null) {
g2d.setTransform(saveXForm);
}
}
示例11: ReadLogsWindow
import javax.swing.JTextPane; //导入方法依赖的package包/类
/**
* Create the frame.
*/
public ReadLogsWindow() {
setTitle("Coder HPMSA - [Read Logs]");
setBounds(100, 100, 660, 550);
setBackground(Color.decode("#066d95"));
setLocationRelativeTo(null);
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
this.setIconImage(Toolkit.getDefaultToolkit().
getImage(getClass().getResource(LOGOPATH)));
final JScrollPane scrollPane = new JScrollPane();
scrollPane.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, null, null, null, null));
getContentPane().add(scrollPane, BorderLayout.CENTER);
editorPane = new JTextPane();
editorPane.setBackground(new Color(255, 255, 240));
editorPane.setFont(new Font("Verdana", Font.PLAIN, 13));
editorPane.setBorder(new EtchedBorder(EtchedBorder.RAISED, null, null));
editorPane.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
editorPane.setEditable(false);
scrollPane.setViewportView(editorPane);
final JPanel filesPanel = new JPanel();
filesPanel.setPreferredSize(new Dimension(200, 10));
getContentPane().add(filesPanel, BorderLayout.EAST);
filesPanel.setLayout(new BorderLayout(0, 0));
final JScrollPane listScrollPane = new JScrollPane();
listScrollPane.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, null, null, null, null));
listScrollPane.setViewportView(logFilesList());
filesPanel.add(listScrollPane, BorderLayout.CENTER);
final JPanel titlePanel = new JPanel();
titlePanel.setPreferredSize(new Dimension(10, 40));
titlePanel.setBackground(Color.decode("#066d95"));
titlePanel.setAutoscrolls(true);
getContentPane().add(titlePanel, BorderLayout.NORTH);
titlePanel.setLayout(new BorderLayout(0, 0));
final JLabel lblTitle = new JLabel("SYSTEM LOG RECORDS");
lblTitle.setHorizontalTextPosition(SwingConstants.CENTER);
lblTitle.setHorizontalAlignment(SwingConstants.CENTER);
lblTitle.setAutoscrolls(true);
lblTitle.setFont(new Font("Verdana", Font.BOLD, 25));
lblTitle.setForeground(UIManager.getColor("Button.highlight"));
titlePanel.add(lblTitle, BorderLayout.CENTER);
final StyledDocument doc = editorPane.getStyledDocument();
final SimpleAttributeSet center = new SimpleAttributeSet();
StyleConstants.setAlignment(center, StyleConstants.ALIGN_CENTER);
doc.setParagraphAttributes(0, doc.getLength(), center, false);
setVisible(true);
}
示例12: LoginPanel
import javax.swing.JTextPane; //导入方法依赖的package包/类
public LoginPanel() {
JTextPane welcome = new JTextPane();
welcome.setEditable(false);
welcome.setText(message);
welcome.setBackground(this.getBackground());
welcome.setFont(new Font("Arial", Font.BOLD, 16));
//inspired by http://stackoverflow.com/questions/3213045/centering-text-in-a-jtextarea-or-jtextpane-horizontal-text-alignment
//Centering welcome text
StyledDocument doc = welcome.getStyledDocument();
SimpleAttributeSet center = new SimpleAttributeSet();
StyleConstants.setAlignment(center, StyleConstants.ALIGN_CENTER);
doc.setParagraphAttributes(0, doc.getLength(), center, false);
this.setLayout(new BorderLayout());
this.add(welcome, BorderLayout.NORTH);
JPanel infoPanel = new JPanel();
infoPanel.setLayout(new GridLayout(START_ROWS, START_COLUMNS));
JPanel userPnl = new JPanel();
JLabel userLbl = new JLabel("Username");
userPnl.setLayout(new FlowLayout());
userPnl.add(userLbl);
userPnl.add(usernameTxt);
infoPanel.add(userPnl);
JPanel passPnl = new JPanel();
JLabel passLbl = new JLabel("Password");
passPnl.setLayout(new FlowLayout());
passPnl.add(passLbl);
passPnl.add(passwordTxt);
infoPanel.add(passPnl);
JPanel signInBtnPnl = new JPanel();
signInBtnPnl.add(signInBtn);
infoPanel.add(errorLbl);
infoPanel.add(signInBtnPnl);
infoPanel.add(new JPanel());
this.add(infoPanel, BorderLayout.SOUTH);
addImage();
}
示例13: GUI
import javax.swing.JTextPane; //导入方法依赖的package包/类
/**
* Constructor que arma el GUI.
*/
public GUI(){
contenedor=getContentPane();
contenedor.setLayout(null);
/*Creamos el objeto*/
fileChooser=new JFileChooser();
/*Propiedades del Label, lo instanciamos, posicionamos y
* activamos los eventos*/
labelTitulo= new JLabel();
labelTitulo.setText("l Tribunal Supremo Electorial");
labelTitulo.setBounds(110, 20, 180, 23);
areaDeTexto = new JTextArea();
areaDeTexto.setEditable(false);
//para que el texto se ajuste al area
areaDeTexto.setLineWrap(true);
//permite que no queden palabras incompletas al hacer el salto de linea
areaDeTexto.setWrapStyleWord(true);
scrollPaneArea = new JScrollPane();
scrollPaneArea.setBounds(20, 50, 350, 270);
scrollPaneArea.setViewportView(areaDeTexto);
/*Propiedades del boton, lo instanciamos, posicionamos y
* activamos los eventos*/
botonAbrir= new JButton();
botonAbrir.setText("Boton 1");
botonAbrir.setBounds(474, 281, 91, 23);
botonAbrir.addActionListener(this);
/*Agregamos los componentes al Contenedor*/
contenedor.add(labelTitulo);
contenedor.add(scrollPaneArea);
contenedor.add(botonAbrir);
btnNewButton = new JButton("Boton 2");
btnNewButton.setBounds(620, 281, 89, 23);
getContentPane().add(btnNewButton);
btnNewButton.addActionListener(this);
JTextPane txtpnInstruccionesnBoton = new JTextPane();
txtpnInstruccionesnBoton.setEditable(false);
txtpnInstruccionesnBoton.setFont(new Font("Dialog", Font.PLAIN, 14));
txtpnInstruccionesnBoton.setBackground(SystemColor.control);
txtpnInstruccionesnBoton.setText("Instrucciones: \r\nCargar: Cargar datos guategrafo.txt\r\nBoton 1: Preguntar el nombre de la ciudad origen y ciudad destino.\r\nBoton 2: Modificar grafo");
txtpnInstruccionesnBoton.setBounds(440, 50, 269, 101);
getContentPane().add(txtpnInstruccionesnBoton);
txtNoHayArchivo = new JTextField();
txtNoHayArchivo.setEditable(false);
txtNoHayArchivo.setForeground(Color.RED);
txtNoHayArchivo.setFont(new Font("Dialog", Font.BOLD | Font.ITALIC, 14));
txtNoHayArchivo.setText("No hay archivo cargado.");
txtNoHayArchivo.setBackground(Color.DARK_GRAY);
txtNoHayArchivo.setBounds(509, 190, 204, 34);
getContentPane().add(txtNoHayArchivo);
txtNoHayArchivo.setColumns(10);
btnCargar = new JButton("Cargar");
btnCargar.setBounds(410, 197, 89, 23);
getContentPane().add(btnCargar);
btnCargar.addActionListener(this);
//Asigna un titulo a la barra de titulo
setTitle("Proyecto");
//tama�o de la ventana
setSize(750,363);
//pone la ventana en el Centro de la pantalla
setLocationRelativeTo(null);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}