本文整理汇总了Java中javax.swing.JPanel.setPreferredSize方法的典型用法代码示例。如果您正苦于以下问题:Java JPanel.setPreferredSize方法的具体用法?Java JPanel.setPreferredSize怎么用?Java JPanel.setPreferredSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JPanel
的用法示例。
在下文中一共展示了JPanel.setPreferredSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createUIComponents
import javax.swing.JPanel; //导入方法依赖的package包/类
private void createUIComponents() {
final EditorFactory editorFactory = EditorFactory.getInstance();
previewDocument = editorFactory.createDocument(EMPTY_TEXT);
previewEditor = editorFactory.createEditor(previewDocument, null, JavaFileType.INSTANCE, true);
final EditorSettings settings = previewEditor.getSettings();
settings.setWhitespacesShown(true);
settings.setLineMarkerAreaShown(false);
settings.setIndentGuidesShown(false);
settings.setLineNumbersShown(false);
settings.setFoldingOutlineShown(false);
settings.setRightMarginShown(false);
settings.setVirtualSpace(false);
settings.setWheelFontChangeEnabled(false);
settings.setUseSoftWraps(false);
settings.setAdditionalColumnsCount(0);
settings.setAdditionalLinesCount(1);
previewPanel = (JPanel) previewEditor.getComponent();
previewPanel.setName(PREVIEW_PANEL_NAME);
previewPanel.setPreferredSize(new Dimension(PREFERRED_PREVIEW_WIDTH, PREFERRED_PREVIEW_HEIGHT));
}
示例2: getSplitter
import javax.swing.JPanel; //导入方法依赖的package包/类
private JPanel getSplitter(int widht, int height) {
JPanel splitPane = new JPanel();
Dimension dim = new Dimension(widht, height);
splitPane.setEnabled(false);
splitPane.setPreferredSize(dim);
splitPane.setMaximumSize(dim);
splitPane.setMinimumSize(dim);
return splitPane;
}
示例3: getPanel
import javax.swing.JPanel; //导入方法依赖的package包/类
/**
* set up the thumb image UI
*
* @param f
* @return
*/
JPanel getPanel(final String f) {
setThumbImage(f);
JPanel p = new JPanel() {
@Override
public void paintComponent(Graphics g) {
g.drawImage(thumbs.get(f), 0, 0, null);
}
};
p.setPreferredSize(THUMB_SIZE);
p.setBorder(new LineBorder(Color.LIGHT_GRAY, 3));
JComponent c = getThumbSelector(f);
JComponent cl = setupThumbClose(p);
setupAlignment(p, c, cl);
p.setName(f);
p.addMouseListener(thumbselected);
p.addMouseListener(Listeners.thumbPrevFocus);
thumbList.add(p);
return p;
}
示例4: logDivider
import javax.swing.JPanel; //导入方法依赖的package包/类
/** Write a horizontal separator into the log window. */
public void logDivider() {
if (log == null)
return;
clearError();
StyledDocument doc = log.getStyledDocument();
Style dividerStyle = doc.addStyle("bar", styleRegular);
JPanel jpanel = new JPanel();
jpanel.setBackground(Color.LIGHT_GRAY);
jpanel.setPreferredSize(new Dimension(300, 1)); // 300 is arbitrary,
// since it will
// auto-stretch
StyleConstants.setComponent(dividerStyle, jpanel);
reallyLog(".", dividerStyle); // Any character would do; "." will be
// replaced by the JPanel
reallyLog("\n\n", styleRegular);
log.setCaretPosition(doc.getLength());
lastSize = doc.getLength();
}
示例5: createStatsTable
import javax.swing.JPanel; //导入方法依赖的package包/类
private JPanel createStatsTable(String title, Map<String, String> data) {
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
panel.add(new JLabel(title), BorderLayout.PAGE_START);
StatisticsModel model = new StatisticsModel();
model.setData(data);
JTable table = new JTable(model);
table.setAutoCreateColumnsFromModel(true);
table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
table.setAutoCreateRowSorter(true);
JScrollPane scrollPane = new JScrollPane(table);
table.addNotify();
scrollPane.getViewport().setOpaque(false);
scrollPane.getColumnHeader().setOpaque(false);
panel.add(scrollPane, BorderLayout.CENTER);
panel.setPreferredSize(new Dimension(300, (data.size()+2)*17));
return panel;
}
示例6: prepareControls
import javax.swing.JPanel; //导入方法依赖的package包/类
protected void prepareControls() {
p = new JPanel(new GridLayout(0, 1));
propagateAWTControls(p);
b = new JButton("Space extender");
p.add(b);
p.setPreferredSize(new Dimension(500, 500));
scrollPane = new JScrollPane(p);
f = new JFrame();
f.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
frameClicked++;
}
});
f.getContentPane().add(scrollPane, BorderLayout.CENTER);
((JComponent) f.getContentPane()).setBorder(
BorderFactory.createEmptyBorder(50, 50, 50, 50));
f.setSize(400, 400);
f.setLocationRelativeTo(null);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
}
示例7: createComponent
import javax.swing.JPanel; //导入方法依赖的package包/类
/** Gets component to display. Implements superclass abstract method.
* @return this instance */
protected Component createComponent() {
JPanel panel = new JPanel(new CardLayout());
// Accessibility
panel.getAccessibleContext().setAccessibleDescription(NbBundle.getBundle(ResourceWizardPanel.class).getString("ACS_ResourceWizardPanel"));
panel.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, Integer.valueOf(1));
String msgKey = testWizard ? "TXT_SelectTestResource" //NOI18N
: "TXT_SelectResource"; //NOI18N
panel.setName(NbBundle.getMessage(ResourceWizardPanel.class, msgKey));
panel.setPreferredSize(I18nWizardDescriptor.PREFERRED_DIMENSION);
panel.add(getUI(), CARD_GUI);
return panel;
}
示例8: createComponent
import javax.swing.JPanel; //导入方法依赖的package包/类
/** Gets component to display. Implements superclass abstract method.
* @return <code>AdditionalPanel</code> instance */
protected Component createComponent() {
JPanel panel = new JPanel();
//Accessibility
panel.getAccessibleContext().setAccessibleDescription(NbBundle.getBundle(AdditionalWizardPanel.class).getString("ACS_AdditionalWizardPanel"));
panel.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, Integer.valueOf(2));
panel.setName(NbBundle.getBundle(getClass()).getString("TXT_ModifyAdditional"));
panel.setPreferredSize(I18nWizardDescriptor.PREFERRED_DIMENSION);
panel.setLayout(new GridBagLayout());
GridBagConstraints constraints = new GridBagConstraints();
constraints.weightx = 1.0;
constraints.weighty = 1.0;
constraints.fill = GridBagConstraints.BOTH;
panel.add(getUI(), constraints);
return panel;
}
示例9: erzeugeHauptPanel
import javax.swing.JPanel; //导入方法依赖的package包/类
/**
* Erzeugt das Hauptpanel, in dem sich Verleihkartenauflister,
* Verleihkartenanzeiger und Rücknahme-Button befinden.
*/
private void erzeugeHauptPanel()
{
_hauptPanel = new JPanel();
_hauptPanel.setLayout(new BorderLayout());
_hauptPanel.setPreferredSize(new java.awt.Dimension(-1, -1));
_hauptPanel.setSize(-1, -1);
_hauptPanel.setAutoscrolls(true);
_hauptPanel.setBackground(UIConstants.BACKGROUND_COLOR);
}
示例10: initialize
import javax.swing.JPanel; //导入方法依赖的package包/类
public void initialize() {
JPanel empty = new JPanel();
empty.setPreferredSize(new Dimension(CommonConstants.MAX_GUI_WIDTH_COMMON, CommonConstants.MAX_GUI_HEIGHT_COMMON));
this.setLayout(new BorderLayout());
this.add(empty, BorderLayout.CENTER);
title.setTitleColor(Color.LIGHT_GRAY);
this.setBorder(title);
}
示例11: get_Panel
import javax.swing.JPanel; //导入方法依赖的package包/类
private JPanel get_Panel() {
JPanel panel = new Wallpaper_Panel(new GridBagLayout());
panel.setPreferredSize(new Dimension(340,290));
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.weightx = 1;
c.weighty = 1;
c.gridy = 0; c.gridx = 0;
JPanel topGab = new JPanel();
topGab.setOpaque(false);
panel.add(topGab, c);
c.insets = new Insets(0, 0, 10, 0);//top, left, bott, right
c.gridx = 1;
c.gridy = 1;
panel.add(get_send_butt(), c);
c.gridy = 2;c.gridwidth = 1;
panel.add(get_receive_butt(), c);
c.gridy = 3;
panel.add(get_settings_butt(), c);
c.insets = new Insets(0, 0, 0, 0); // reset to default
c.gridy = 4;
panel.add(get_help_butt(), c);
c.gridx = 2;
c.gridy = 5;
JPanel bottGab = new JPanel();
bottGab.setOpaque(false);
panel.add(bottGab, c);
return panel;
}
示例12: visualizeGraph
import javax.swing.JPanel; //导入方法依赖的package包/类
/**
* Visualize company graph
*/
public void visualizeGraph(String s) {
try {
final File png = new File(s);
png.deleteOnExit();
Tg2Dot.convertGraph(graph, png.getCanonicalPath(),
GraphVizOutputFormat.PNG);
final Image i = ImageIO.read(png);
JPanel panel = new JPanel() {
private static final long serialVersionUID = -891941166683362373L;
@Override
public void paintComponent(Graphics g) {
g.drawImage(i, 0, 0, null);
}
};
panel.setPreferredSize(new Dimension(i.getWidth(panel), i
.getHeight(panel)));
panel.setVisible(true);
JFrame f = new JFrame("Company Graph");
f.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
JScrollPane sp = new JScrollPane(panel);
f.getContentPane().add(sp);
f.setSize(400, 400);
f.setVisible(true);
} catch (IOException e) {
e.printStackTrace();
}
}
示例13: initialize
import javax.swing.JPanel; //导入方法依赖的package包/类
/**
* Initialize the panel
*/
private void initialize() {
// Initialize dialog layout
JPanel panel = new JPanel(new BorderLayout(BORDERSIZE / 2, BORDERSIZE / 2));
panel.setBorder(BorderFactory.createEmptyBorder(BORDERSIZE, BORDERSIZE, BORDERSIZE, BORDERSIZE));
// Adds website image
JPanel tmpPanel = new JPanel(new BorderLayout(BORDERSIZE, BORDERSIZE));
// Adds polimi description
HtmlPanel titleLabel = new HtmlPanel();
titleLabel.setText(GraphStartScreen.HTML_CONTENT_TITLE_HREF);
titleLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
titleLabel.setAlignmentY(Component.CENTER_ALIGNMENT);
titleLabel.setOpaque(false);
tmpPanel.add(titleLabel, BorderLayout.CENTER);
// Adds application title
title = new JLabel();
title.setHorizontalTextPosition(SwingConstants.RIGHT);
title.setHorizontalAlignment(SwingConstants.CENTER);
title.setIconTextGap(BORDERSIZE);
tmpPanel.add(title, BorderLayout.SOUTH);
panel.add(tmpPanel, BorderLayout.NORTH);
// Adds text area
mainArea = new JPanel();
mainArea.setOpaque(false);
BoxLayout mainLayout = new BoxLayout(mainArea, BoxLayout.Y_AXIS);
mainArea.setLayout(mainLayout);
panel.add(mainArea, BorderLayout.CENTER);
JLabel legal = new JLabel(LEGAL);
panel.add(legal, BorderLayout.SOUTH);
panel.setPreferredSize(new Dimension(600,480));
JScrollPane scroll = new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
this.add(scroll, BorderLayout.CENTER);
}
示例14: setup
import javax.swing.JPanel; //导入方法依赖的package包/类
private void setup()
{
header = Icons.getHeader(export);
footer = new Footer();
content = new JPanel(new GridLayout(1, 1));
next = new JButton();
back = new JButton("< Back");
next.addActionListener(this);
back.addActionListener(this);
JPanel buttons = new JPanel(new FlowLayout(FlowLayout.RIGHT));
buttons.add(back);
buttons.add(next);
buttons.setPreferredSize(buttons.getPreferredSize());
final int width = header.getPreferredSize().width;
final int height1 = header.getPreferredSize().height;
final int height2 = buttons.getPreferredSize().height;
final int height3 = footer.getPreferredSize().height;
final int[] rows = new int[]{height1, 300, height2, height3};
final int[] cols = new int[]{width};
JPanel all = new JPanel(new TableLayout(rows, cols, 5, 5));
all.add(header, new Rectangle(0, 0, 1, 1));
all.add(content, new Rectangle(0, 1, 1, 1));
all.add(buttons, new Rectangle(0, 2, 1, 1));
all.add(footer, new Rectangle(0, 3, 1, 1));
getContentPane().add(all);
pack();
setResizable(false);
setTitle(title);
ComponentHelper.centreOnScreen(this);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
updateButtons();
}
示例15: MouseOptions
import javax.swing.JPanel; //导入方法依赖的package包/类
public MouseOptions(OptionsFrame window) {
super(window, new GridLayout(1, 3));
explorer = new ProjectExplorer(getProject());
explorer.setListener(listener);
// Area for adding mappings
addArea.addMouseListener(listener);
// Area for viewing current mappings
model = new MappingsModel();
mappings.setTableHeader(null);
mappings.setModel(model);
mappings.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
mappings.getSelectionModel().addListSelectionListener(listener);
mappings.clearSelection();
JScrollPane mapPane = new JScrollPane(mappings);
// Button for removing current mapping
JPanel removeArea = new JPanel();
remove.addActionListener(listener);
remove.setEnabled(false);
removeArea.add(remove);
// Area for viewing/changing attributes
attrTable = new AttrTable(getOptionsFrame());
GridBagLayout gridbag = new GridBagLayout();
GridBagConstraints gbc = new GridBagConstraints();
setLayout(gridbag);
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.gridheight = 4;
gbc.fill = GridBagConstraints.BOTH;
JScrollPane explorerPane = new JScrollPane(explorer, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
gridbag.setConstraints(explorerPane, gbc);
add(explorerPane);
gbc.weightx = 0.0;
JPanel gap = new JPanel();
gap.setPreferredSize(new Dimension(10, 10));
gridbag.setConstraints(gap, gbc);
add(gap);
gbc.weightx = 1.0;
gbc.gridheight = 1;
gbc.gridx = 2;
gbc.gridy = GridBagConstraints.RELATIVE;
gbc.weighty = 0.0;
gridbag.setConstraints(addArea, gbc);
add(addArea);
gbc.weighty = 1.0;
gridbag.setConstraints(mapPane, gbc);
add(mapPane);
gbc.weighty = 0.0;
gridbag.setConstraints(removeArea, gbc);
add(removeArea);
gbc.weighty = 1.0;
gridbag.setConstraints(attrTable, gbc);
add(attrTable);
getOptions().getMouseMappings().addMouseMappingsListener(listener);
setCurrentTool(null);
}