preferredsize

Size issues with JTabbedPane and fixed height content

喜夏-厌秋 提交于 2019-12-12 13:08:21
问题 While writing this question I have been able to find a way to get it to behave the way I wanted. Based on this, I am still posting the question as other people might face similar issues. I have the following issues with the sizing of a JTabbedPane used for content that stretches horizontally but has a fixed height. Both options for setTabLayoutPolicy() seem to alter the height of the content and won’t consistently display it at its preferred or minimum height. With the default WRAP_TAB_LAYOUT

Resizing JTextField in JMenuBar

时间秒杀一切 提交于 2019-12-12 05:37:13
问题 I'm trying to add a JTextField as a search bar to a JMenuBar at the top of my JFrame . My problem is that the JTextField keeps getting resized to take up all available space in the JMenuBar , and I don't want it to. I've tried setPreferredSize() and setMaximum Size() , but these didnt work, presumably because the LayoutManager used in the JMenuBar doesn't respect these sizes. I also tried adding the JTextField to a JPanel with a FlowLayout and adding the panel to the JMenuBar , but I get

Change preferred content size of PopOverViewController on fly

爱⌒轻易说出口 提交于 2019-12-12 05:28:38
问题 I am trying to change the preferred content size of a UIPopOverController from inside the childViewController. Firstly I present PopOverViewController this way DateViewController *dateView = [[DatePickerViewController alloc] initWithNibName:@"DateViewController" bundle:nil]; UINavigationController *navController = [[UINavigationController alloc]initWithRootViewController:dateView]; m_tableCell = (NotesCell *)[m_tableView cellForRowAtIndexPath:indexPath]; popViewController = [

JTable update columns header height after multiple header insertion

早过忘川 提交于 2019-12-11 14:27:36
问题 What should be invoked /fired when I added new column to the table but its header label has more lines (using html and br element) than in the already presents headers so the headers will resize accordingly? Before adding After adding This does not happen if when first painting the table a column already has that number of rows (when the label is <html>Card<br>name</html> ). I fire fireTableStructureChanged() in TableModel when new record is added (so new columns are added). 回答1: Starting

How does JButton control it's size?

余生长醉 提交于 2019-12-11 12:43:43
问题 I have added a button to a frame and controlling it's text and/or minimum size with timer. I noticed, that button does grow sometimes, and sometimes does not. If in null layout, then it ignores both text and minimum width changing. If in FlowLayout layout, then it grows if text changing, but ignores minimum width changing. How make it grow in latter case? If minimum width changes, then why doesn't layout manager reshapes button? How to force it to reshape? Note: code below is SSCCE, i.e. it

Swing App - Adjusting Position of East Panel Components

江枫思渺然 提交于 2019-12-11 12:17:15
问题 I have a problem with text field and combo box components which are set on the east panel. For some reason, when I added Box layout to arrange them by Y, some of the components listed above, doesn't align and scale size properly with buttons, just as they should be. import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.FlowLayout; import javax.swing.BorderFactory; import javax.swing.Box; import javax.swing.JButton; import javax.swing.JComboBox; import

Writing a JPanel subclass that will obey GridBagLayout?

别说谁变了你拦得住时间么 提交于 2019-12-11 03:28:37
问题 I built a class that extends JPanel , and I have been setting a size on it every time. But now I need multiple instances of that JPanel sub-class to exist on another panel. I am using GridBagLayout , but my components disappear when I resize the Frame or take away the setSize(800,100) from the JPanel subclass. How do I built components that will obey these layout managers ? I want my custom component to be able to fit to the size that the layout manager asks for. Here is my custom component

Java Swing: problems with width

二次信任 提交于 2019-12-11 02:00:44
问题 I have problems with understanding the behavior of my application. I want to create a simple window ( 1000x700px ), divided into two parts ( 250px and 750px width respectively). I tried the following code: import java.awt.Color; import java.awt.Dimension; import java.awt.FlowLayout; import javax.swing.JFrame; import javax.swing.JPanel; public class Example extends JFrame { private static final long serialVersionUID = 1L; public Example() { this.setSize(1000, 700); this.setTitle("Example");

JScrollPane vertical scrollbar too wide

房东的猫 提交于 2019-12-10 23:56:07
问题 I'm using Netbeans GUI Builder to create a GUI app (so all the code generated is by Netbeans). Everything looks fine in the Preview Design, but when I run the app, the JScrollPane displays badly... ...as you can see, only half of the scrollbar is visible. I have tried manually setting the JScrollBar for the JScrollPane, using my own method: jScrollPane1.setVerticalScrollBar(getScrollBarForScrollPane()); But that gives this result... Maybe there is some property on the JScrollBar or

Changing the size of JTextPane

一个人想着一个人 提交于 2019-12-10 16:15:08
问题 I am new in Java, and I just found this piece of code in StackOverflow: ResizeTextArea. I want to use JTextPane instead of JTextArea . In JTextPane , there is no setRows() method to change the number of the lines. Any help would be appreciated. 回答1: The height of individual lines in a StyledDocument can vary, so the notion of limiting rows in a JTextPane is not useful. You can limit the preferred size of the scroll pane's viewport to some useful fraction of main panel's size, as shown here