本文整理了Java中javax.swing.JTextArea.setPreferredSize()
方法的一些代码示例,展示了JTextArea.setPreferredSize()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTextArea.setPreferredSize()
方法的具体详情如下:
包路径:javax.swing.JTextArea
类名称:JTextArea
方法名:setPreferredSize
暂无
代码示例来源:origin: ballerina-platform/ballerina-lang
/**
* Method generated by IntelliJ IDEA GUI Designer
* >>> IMPORTANT!! <<<
* DO NOT edit this method OR call it in your code!
*
* @noinspection ALL
*/
private void $$$setupUI$$$() {
rootPanel = new JPanel();
rootPanel.setLayout(new GridLayoutManager(2, 3, new Insets(0, 0, 0, 0), -1, -1));
repositoriesLabel = new JLabel();
repositoriesLabel.setText("Additional repositories");
rootPanel.add(repositoriesLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
final Spacer spacer1 = new Spacer();
rootPanel.add(spacer1, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false));
final Spacer spacer2 = new Spacer();
rootPanel.add(spacer2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
final JScrollPane scrollPane1 = new JScrollPane();
rootPanel.add(scrollPane1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
repositoriesTextArea = new JTextArea();
repositoriesTextArea.setMaximumSize(new Dimension(420, 2147483647));
repositoriesTextArea.setMinimumSize(new Dimension(300, 10));
repositoriesTextArea.setPreferredSize(new Dimension(300, 50));
repositoriesTextArea.setText(ResourceBundle.getBundle("com/github/gtache/lsp/LSPBundle").getString("coursier.settings.textarea.basetext"));
repositoriesTextArea.setToolTipText("Insert one resolver by line");
scrollPane1.setViewportView(repositoriesTextArea);
}
代码示例来源:origin: geotools/geotools
/** {@inheritDoc} */
@Override
public JPanel createControlPanel() {
JPanel panel = new JPanel(new BorderLayout());
categoryList = new JList(new CategoryListModel());
categoryList.setPreferredSize(new Dimension(LIST_WIDTH, DEFAULT_HEIGHT));
categoryList.setBorder(BorderFactory.createTitledBorder("Categories"));
categoryList.addListSelectionListener(
new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
showInfo(categoryList.getSelectedIndex());
}
});
panel.add(categoryList, BorderLayout.WEST);
textArea = new JTextArea();
textArea.setPreferredSize(new Dimension(TEXT_AREA_WIDTH, DEFAULT_HEIGHT));
textArea.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
textArea.setLineWrap(true);
textArea.setEditable(false);
panel.add(textArea, BorderLayout.CENTER);
categoryList.setSelectedIndex(0);
return panel;
}
代码示例来源:origin: fossasia/neurolab-desktop
messageOutputTextList.setPreferredSize(new Dimension(500, 360));
messageOutputTextList.setEditable(false);
JScrollPane mPane = new JScrollPane(messageOutputTextList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
代码示例来源:origin: org.netbeans.api/org-openide-dialogs
area.setPreferredSize(new Dimension(SIZE_PREFERRED_WIDTH, SIZE_PREFERRED_HEIGHT));
area.setBackground(UIManager.getColor("Label.background")); // NOI18N
area.setBorder(BorderFactory.createEmptyBorder());
代码示例来源:origin: RaiMan/SikuliX2
int w = width * ta.getFontMetrics(ta.getFont()).charWidth('m');
int h = (int) (lines * ta.getFontMetrics(ta.getFont()).getHeight());
ta.setPreferredSize(new Dimension(w, h));
ta.setMaximumSize(new Dimension(w, 2 * h));
ta.setText(text);
代码示例来源:origin: pentaho/mondrian
cdataTextArea.setLayout(new java.awt.BorderLayout());
cdataTextArea.setEditable(true);
cdataTextArea.setPreferredSize(new java.awt.Dimension(100, 300));
cdataTextArea.setMinimumSize(new java.awt.Dimension(100, 100));
代码示例来源:origin: pentaho/mondrian
cdataTextArea.setLayout(new java.awt.BorderLayout());
cdataTextArea.setEditable(true);
cdataTextArea.setPreferredSize(new java.awt.Dimension(100, 300));
cdataTextArea.setMinimumSize(new java.awt.Dimension(100, 100));
代码示例来源:origin: stackoverflow.com
JTextArea textArea = new JTextArea(text);
textArea.setPreferredSize(new Dimension(500, 50));
代码示例来源:origin: stackoverflow.com
JPanel view = new JPanel( );
view.setSize( 800, 600 );
view.setLayout( new BorderLayout( ) );
JPanel topArea = new JPanel( );
JTextArea textArea = new JTextArea( );
textArea.setPreferredSize( new Dimension( 0, 50 ) );
view.add( topArea, BorderLayout.CENTER );
view.add( textArea, BorderLayout.SOUTH );
代码示例来源:origin: stackoverflow.com
JTextArea users = new JTextArea();
users.setPreferredSize(new Dimension(100, users.getHeight()));
add(users, BorderLayout.EAST);
代码示例来源:origin: stackoverflow.com
JTextArea ta = new JTextArea();
ta.setPreferredSize(new Dimension(310, 325));
ta.setMinimumSize(new Dimension(310, 325));
代码示例来源:origin: sing-group/GC4S
private JComponent getPreviewFontPanel() {
previewFontPanel = new JScrollPane();
previewFontPanel.setBorder(createTitledBorder(
createLoweredBevelBorder(), "Font preview"));
previewFontPanel.setViewportView(sampleText);
sampleText.setMinimumSize(new Dimension(100, 100));
sampleText.setPreferredSize(new Dimension(100, 100));
sampleText.setEditable(false);
return previewFontPanel;
}
代码示例来源:origin: stackoverflow.com
public JTextArea createTextAreaFitToText(String message, Dimension minimalSize){
JTextArea aMessagePanel = new JTextArea();
aMessagePanel.setText(message);
/*for modelToView to work, the text area has to be sized. It doesn't matter if it's visible or not.*/
aMessagePanel.setPreferredSize(minimalSize);
aMessagePanel.setSize(minimalSize);
Rectangle r = aMessagePanel.modelToView(aMessagePanel.getDocument().getLength());
Dimension d = new Dimension(minimalSize.width, r.y + r.height);
aMessagePanel.setPreferredSize(d);
return aMessagePanel;
}
代码示例来源:origin: stackoverflow.com
final JFrame frame = new JFrame();
frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
frame.setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.fill = GridBagConstraints.BOTH;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
frame.add(Box.createGlue(), gbc);
final JTextArea textArea = new JTextArea("SE");
textArea.setPreferredSize(new Dimension(50, 50));
textArea.setOpaque(true);
textArea.setBackground(Color.RED);
gbc = new GridBagConstraints();
gbc.gridx = 1;
gbc.gridy = 1;
gbc.fill = GridBagConstraints.NONE;
gbc.weightx = 0.0;
gbc.weighty = 0.0;
frame.add(textArea, gbc);
frame.setSize(640, 480);
frame.setVisible(true);
代码示例来源:origin: stackoverflow.com
messageField.setPreferredSize(new Dimension(470, 300));
messageField.setMargin(new Insets(10, 10, 10, 10));
messageBoard.add(messageField);
typeField.setPreferredSize(new Dimension(350, 100));
typeField.setMargin(new Insets(10, 10, 10, 10));
typeBoard.add(typeField);
代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide
area.setPreferredSize (new Dimension(SIZE_PREFERRED_WIDTH, SIZE_PREFERRED_HEIGHT));
area.setBackground (UIManager.getColor ("Label.background")); // NOI18N
area.setBorder (BorderFactory.createEmptyBorder ());
代码示例来源:origin: stackoverflow.com
static void decorate(JTextArea a, final BufferedImage img) {
a.setUI(new javax.swing.plaf.basic.BasicTextAreaUI() {
@Override
protected void paintBackground(Graphics g) {
g.drawImage(img, 0, 0, null);
}
});
a.setPreferredSize(new Dimension(img.getWidth(), img.getHeight()));
a.setForeground(Color.white);
a.setCaretColor(Color.lightGray);
}
代码示例来源:origin: org.geotools/gt-swing
/**
* {@inheritDoc}
*/
@Override
public JPanel createControlPanel() {
JPanel panel = new JPanel(new BorderLayout());
categoryList = new JList(new CategoryListModel());
categoryList.setPreferredSize(new Dimension(LIST_WIDTH, DEFAULT_HEIGHT));
categoryList.setBorder(BorderFactory.createTitledBorder("Categories"));
categoryList.addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
showInfo(categoryList.getSelectedIndex());
}
});
panel.add(categoryList, BorderLayout.WEST);
textArea = new JTextArea();
textArea.setPreferredSize(new Dimension(TEXT_AREA_WIDTH, DEFAULT_HEIGHT));
textArea.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
textArea.setLineWrap(true);
textArea.setEditable(false);
panel.add(textArea, BorderLayout.CENTER);
categoryList.setSelectedIndex(0);
return panel;
}
代码示例来源:origin: sc.fiji/TrakEM2_
Editor(final DLabel l) {
super(getShortTitle());
label = l;
jta = new JTextArea(label.title.equals(" ") ? "" : label.title, 5, 20); // the whole text is the 'title' in the Displayable class.
jta.setLineWrap(true);
jta.setWrapStyleWord(true);
final JScrollPane jsp = new JScrollPane(jta);
jta.setPreferredSize(new Dimension(200,200));
getContentPane().add(jsp);
pack();
setVisible(true);
final Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
final Rectangle box = this.getBounds();
setLocation((screen.width - box.width) / 2, (screen.height - box.height) / 2);
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
addWindowListener(this);
new ToFront(this);
}
代码示例来源:origin: Exslims/MercuryTrade
this.jsonArea.setMinimumSize(new Dimension(450, 550));
this.jsonArea.setEditable(true);
this.jsonArea.setPreferredSize(new Dimension(450, 550));
this.jsonArea.setBackground(AppThemeColor.ADR_TEXT_ARE_BG);
container.add(this.jsonArea, AppThemeColor.ADR_BG);
内容来源于网络,如有侵权,请联系作者删除!