JFontChooser删除预览面板或强制最大尺寸

时间:2015-05-21 12:13:32

标签: java swing

我使用JFontChooser为文本区域选择字体。我已将JPanel添加到字体选择器中,该JPanel位于包含文本区域的另一个topPanel上方。问题是,如果字体大小太大,字体选择器的预览窗口部分会调整整个内容的大小,占用空间。我尝试在包含字体选择器的面板上强制最大尺寸,但无济于事。

midPanel包含字体选择器和按钮; textArea包含public TextEditorWindow(IConnector connect, FolderSearchComp fs, GuiConstructor gui, LoopControlWindow loopc) { this.connect = connect; this.fs = fs; this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); this.gui = gui; font = fs.getFormatFont(); this.loopc = loopc; initComps(); size = new Dimension(610, Toolkit.getDefaultToolkit().getScreenSize().height - 100); } private void createTopPanel() { topPanel = new JPanel(); topPanel.setLayout(new BorderLayout()); applyButton = new JButton("Apply Font"); applyButton.addActionListener(this); applyButton.setAlignmentX(Component.RIGHT_ALIGNMENT); fc = new JFontChooser(); fc.setAlignmentX(RIGHT_ALIGNMENT); fc.setSelectedFont(font); topPanel.setBorder(BorderFactory.createTitledBorder("Choose a font")); topPanel.add(fc, BorderLayout.CENTER); topPanel.add(applyButton, BorderLayout.SOUTH); topPanel.setMaximumSize(new Dimension(600,300)); } private void createMidPanel() { midPanel = new JPanel(); midPanel.setLayout(new BorderLayout()); textArea = new JTextArea(20,20); textArea.setWrapStyleWord(true); textArea.setLineWrap(true); JScrollPane scroll = new JScrollPane(); scroll.setViewportView(textArea); scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); midPanel.add(scroll, BorderLayout.CENTER); }

db.nodes.aggregate([
 {"$group": {"_id": "$VARIENTS.NAME"}},
 {"$project": {"_id": 0, "TEMPLATE_NAME": "$_id"}}
]);

以下是应用程序所需的默认字体大小的图片。

first

这里的字体非常大。

second

0 个答案:

没有答案