本文整理汇总了Java中javax.swing.JTextArea.setMargin方法的典型用法代码示例。如果您正苦于以下问题:Java JTextArea.setMargin方法的具体用法?Java JTextArea.setMargin怎么用?Java JTextArea.setMargin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JTextArea
的用法示例。
在下文中一共展示了JTextArea.setMargin方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ExtendedExample
import javax.swing.JTextArea; //导入方法依赖的package包/类
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);
}
示例2: 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"));
}
}
示例3: initGUI
import javax.swing.JTextArea; //导入方法依赖的package包/类
private void initGUI() {
JPanel pCommand = new JPanel();
pResult = new JPanel();
nsSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, pCommand,
pResult);
pCommand.setLayout(new BorderLayout());
pResult.setLayout(new BorderLayout());
Font fFont = new Font("Dialog", Font.PLAIN, 12);
txtCommand = new JTextArea(5, 40);
txtCommand.setMargin(new Insets(5, 5, 5, 5));
txtCommand.addKeyListener(this);
txtCommandScroll = new JScrollPane(txtCommand);
txtResult = new JTextArea(20, 40);
txtResult.setMargin(new Insets(5, 5, 5, 5));
txtResultScroll = new JScrollPane(txtResult);
txtCommand.setFont(fFont);
txtResult.setFont(new Font("Courier", Font.PLAIN, 12));
/*
// button replaced by toolbar
butExecute = new JButton("Execute");
butExecute.addActionListener(this);
pCommand.add(butExecute, BorderLayout.EAST);
*/
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);
tScrollPane.setPreferredSize(new Dimension(120, 400));
tScrollPane.setMinimumSize(new Dimension(70, 100));
txtCommandScroll.setPreferredSize(new Dimension(360, 100));
txtCommandScroll.setMinimumSize(new Dimension(180, 100));
gScrollPane.setPreferredSize(new Dimension(460, 300));
ewSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
tScrollPane, nsSplitPane);
fMain.getContentPane().add(ewSplitPane, BorderLayout.CENTER);
doLayout();
fMain.pack();
}
示例4: 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));
}