JLabel Max height

Hi all,
I'm creating a JScrollPane for something like a horizontal pie chart. Then I also create another JPanel for row header view. In the row header JPanel, I'm basically adding JLabel's to name each row. Thus I want the JLabel to line up with each row in the pie chart.
I've tried setPreferredSize(), setSize() and setMaximumSize() (and also tried doing them all at once!). However, it only gives me a "minimum" size. When I make the JScrollPane smaller, the JLabel stays at the defined size and the set location. If I enlarge the JScrollPane so that its height is larger than the total height of the JLabels, the JLabels are automatically resized.
My question is, how can I fix a JLabel's size?
My code:
JPanel rh = new JPanel(new GridLayout(3, 1));
JLabel l1 = new JLabel("row 1");
l1.setPreferredSize(new Dimension(200, 100));
l1.setMaximumSize(new Dimension(200, 100));
l1.setSize(new Dimension(200, 100));
rh.add(l1);
rh.setPreferredSize(new Dimension(600, 100));
rh.setMaximumSize(new Dimension(600, 100));
rh.setSize(new Dimension(600, 100));
theSP.setRowHeaderView(rh);
Thanks all!

The resizing comes from GridLayout.
either use GridbagLayout (where you can do virtually anything) or put a Panel with null or Flowlayout or any other Layoutr that does not change size into your gridlayout and put you component on that panel.

Similar Messages

  • Setting max-height with contain for bg image

    Hi , I currently have a simple image that I want to sit in the top right corner, however I would like it to scale so the whole image fills the right hand of the viewport (only if they make the viewport smaller than the original image though). The contain function does this job however it also scales the image upwards should the user go full browser which looks horrible. So my question is can I use ( background-size: contain;) but add a max-height line to it also. I have tried every combination possible but nothing. Im either doing something wrong or it cant be done.
    Site: http://www.stuartskelton.co.uk
    my css is:
    body  {
    margin: 5px;
    background-attachment: fixed;
    background-image: url(../images/neilquote.gif);
    background-repeat: no-repeat;
    background-position: right top;
    background-size: contain;
    Thanks for looking.

    You can't add a max-height to the existing rule, but you could use a media query to change the value of background-size like this:
    body  {
    margin: 5px;
    background-attachment: fixed;
    background-image: url(../images/neilquote.gif);
    background-repeat: no-repeat;
    background-position: right top;
    background-size: contain;
    @media screen and (min-height: 462px) {
        body {
            background-size: 55px 461px;

  • Why no min/max height?

    Since I've started creating responsive content with Edge, once thing has really bugged me - and that's the omission of a Min H and Max H alongside Min W and Max W. I've been told it's not necessary as height can be constrained to width, but I still find myself needing it.
    Two scenarios I've frequently come across:
    • An object is set to 100% width. When a window is resized to a landscape orientation, I want an object's maximum width dictated by it's height to prevent it taking up too much space in the layout. For example, in portrait layout it may be W100%, H10% - turn that to landscape and it might become W100%, H60% if I've constrained the proportions. I want to be able to cap it at say H30%, so after a certain point it's just the width that changes and not the height.
    • I have a series of square images nested within a horizontal scrollable div. I want these images to stay in proportion but always fill to H100% of the container div, regardless of its shape (portrait, landscape). It seems to simple but I just can't make it work without a min/max H functionality.
    Can anyone explain why this feature is missing?
    Thanks

    As you know, IE doesn't support min/max-height/width.
    With regard to HEIGHT, you can work around IE's lack of support for min-height since the way that IE deals with an explicit height is as if it were min-height.  For example, if you have this CSS:
    #foo { min-height:250px; }
    you can *hack* a fix for IE like this -
    #foo {
         min-height:250px;
         _height:250px;
    The "_height" style is ignored by all browsers except IE<8.  For those versions of IE that 'read' that style, they interpret it as 'height' and since IE treats an explicit height value as if it were 'min-height' you are set.  Another way (and a cleaner way in my opinion) would be to add an IE conditional comment to the page, e.g.,
    <!--[if lte IE 7]>
    <style>
    #foo {
         height:250px;
    </style>
    <![endif]-->
    That takes care of min-height.
    The solutions for max-height or min/max-width are not so simple.  Google for IE CSS calculations to see how you might approach them.

  • Patience running thin. max HEIGHT after I publish to bizcat.

    what a piece of garbage.  this is only reason i joined creative cloud.  I have a site in progress and when i publish it to view in on business catalyst, the resulting site seems to have a max height, cutting off everything below 600px.  All else is working fine on other sites where site properties, footer, header, etc are in common.
    Can I upload my files for staff member to view and let me know what’s going on.
    It is a cross browser problem.  it works in preview mode, but after it is published there is something lost, or added in translation.
    Please help - my patience for trial and error is running thin.
    http://kkzcom.businesscatalyst.com/ - LINK TO RESULT

    The following email was sent yesterday, and since then I have published the site to a third part host, go daddy, and the problem was carried over to them as well. http://kinetikartz.com/
    Obviosly this is a much larger problem than i had anticipated, which allows me to conclude that muse is the problem and not bizcatalyst.
    An accurate preview comes when i "Preview" the page within muse, as well as when i "Preview in Browser (all browsers)."  Fail seems to come upon uploading to 3rd party FTP.  I'm not sure if it is worth exporting the muse file then uploading it to godaddy but i'll give it a shot.  Time is of the essence may be an overstatement, but it is surely an unexpected distraction, and hopefully a problem with a solution, and to be even more optimistic, a problem on my part so I can be sure to avoid it later under my own control rather than crossing my fingers in hopes that a muse bug may falter my efforts of the 99% of my work which went into the site pre-publishing.
    Thanks

  • Why can't firefox deal with percent max-height of percent max-height?

    I think this is possibly a bug.
    Firefox is not able to use percent max-height of a percent max-height. Chromium does. But it is difficult to explain. Please have a look at this fiddle, with firefox and chromium, you will see the different behaviour by resizing the browser window: http://jsfiddle.net/qx75g/
    I need this for my website but cannot use it, because it does not work with firefox :(
    ( archlinux with firefox 28.0 )

    Okay, so the page on MDN says
    <blockquote>The percentage is calculated with respect to the height of the generated box's containing block. If the height of the containing block is not specified explicitly (i.e., it depends on content height), and this element is not absolutely positioned, the percentage value is treated as none.</blockquote>
    https://developer.mozilla.org/en-US/docs/Web/CSS/max-height
    That seems to be copied more or less verbatim from CSS2 Level 1: http://www.w3.org/TR/CSS2/visudet.html#min-max-heights
    Which makes me think that it isn't like to change in the near future...
    Any reason not to set height:50% for .inner? How does leaving that unspecified benefit the layout?

  • Setting application max height to 100%

    My application is set to take up 100% of the width and height
    of the browser area. This works great as long as the child
    components fit. But when one of the child components gets taller
    than the available browser height, the application also gets
    taller, and scrollbars are added to the application. I would rather
    have the scrollbar on the child component. If I set the application
    scrollbar policy to "off", the application is *still* too big, and
    it just cuts off below the end of the browser window. How can I
    force the application to be 100% of the browser width all the
    time?

    I don't have time to try things and feel like I know what I'm
    doing, but is any of this related?
    http://blogs.adobe.com/aharui/2008/01/flex_and_scalemodes.html

  • PanelBox Stretch between min and max height

    Hello,
    I am using JDeveloper 11.1.1.6 and my client requests in the application that I am currently developing a PanelBox that stretches its height according to the content inside it. There is a minimum height (which can be greater than the height of the content) and a maximum height (which, if is exceeded by the content, should display a scroll bar).
    If you have any suggestions on how I could achieve this (including modifying the CSS file) please let me know.
    Best regards,
    Toma

    Hi,
    have a look at the "type" property if this helps
    af:panelBox tag documentation
    Frank

  • Captivate 8 scalable content max height/width

    Hello,
    I'm using Captivate 8 and using the scalable settings, however I only want the screen to downscale from set screen size as when the screen is enlarged past it's original size everything gets really blurry. Is there anyway to set a maximum height or width within captivate or by changing the code in css/js/html files?
    Help is much appreciated! Thanks

    Hi,
    I ran across thesame issue, I'm using Cp6, and found the solution in modifying /assets/js/CPLibrary.js file in following way:
    Line 23528 there is following function:
    function SetScaleAndPosition()
    Line 23576 there is following condition:
      if(cp.verbose)
      cp.log(cp.model.data.project.shc);
      cp.log(cp.movie.m_scaleFactor);
      cp.log(cp.shouldScale);
    Prior to that condition from line 23576, I placed this code:
      if( (cp.movie.m_scaleFactor >= 1.0))
      return true;
    This limits scaling to 100% only, or lower.
    However, when using scalable html5 content in Cp6, I encountered problems with smart shapes buttons (they do not work), so, if what is above works for You, I would appreciate, if You could inform me, if, in Cp8, there is no problem with smart shapes buttons when using scalable html5, thanks in advance.

  • Listview inside Grid with Rowdefinition of height Auto ? and Max Height of 100 not display scrollviewer on load

    <Grid Grid.Column="0" Grid.Row="0" x:Name="grdValues">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" MaxHeight="100"></RowDefinition>
                    <RowDefinition Height="5" ></RowDefinition>
                    <RowDefinition Height="Auto" MaxHeight="100"></RowDefinition>
                    <RowDefinition Height="5" ></RowDefinition>
                    <RowDefinition Height="Auto" MaxHeight="100"></RowDefinition>
                    <RowDefinition Height="Auto" MaxHeight="100"></RowDefinition>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="300"></ColumnDefinition>
                </Grid.ColumnDefinitions>
                    <ListView x:Name="lstGenericList"
                                      Margin="4,0,0,0" Grid.Column="0" Grid.Row="0"
                                        ItemsSource="{Binding Items}"
                                        ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                                        ScrollViewer.VerticalScrollBarVisibility="Auto">
                        </ListView>
                <GridSplitter  Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ResizeDirection="Rows"  ResizeBehavior="PreviousAndNext"   Height="5"></GridSplitter>
                <!--<Separator Height="2" Grid.Row="2" />-->
                <ListView x:Name="lstBrandList"
                                      Grid.Column="0" Grid.Row="2" Margin="4,0,0,0"
                                        ItemsSource="{Binding Items}" 
                                        ScrollViewer.HorizontalScrollBarVisibility="Auto"
                                        ScrollViewer.VerticalScrollBarVisibility="Auto"
                          VerticalContentAlignment="Stretch"
                          VirtualizingStackPanel.IsVirtualizing="True" 
                           VirtualizingStackPanel.VirtualizationMode="Recycling">
                    <ListView.ItemContainerStyle>
                        <Style TargetType="{x:Type ListViewItem}">
                            <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
                            <Setter Property="Focusable" Value="false"/>
                        </Style>
                    </ListView.ItemContainerStyle>
                </ListView>
                <GridSplitter  Grid.Row="3" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ResizeDirection="Rows"  ResizeBehavior="PreviousAndNext"   Height="5"></GridSplitter>
                <!--<Separator Height="2" Grid.Row="2" />-->
                <ListView x:Name="lstBrandListv"
                                      Grid.Column="0" Grid.Row="4" Margin="4,0,0,0"
                                        ItemsSource="{Binding Itemsa}" 
                                        ScrollViewer.HorizontalScrollBarVisibility="Auto"
                                        ScrollViewer.VerticalScrollBarVisibility="Auto">
                </ListView>
            </Grid>

    I should think it is a combination of auto and stretch you have there on the sizing which makes it impossible for anything to work out how big it's supposed to be inside a scrollviewer... in an auto height row.
    EG I would take this off:
    VerticalContentAlignment="Stretch"
    And any other stretches in there.
    See what happens.
    Think about giving the rows some sort of an actual height.
    Hope that helps.
    Technet articles: Uneventful MVVM;
    All my Technet Articles

  • Text Box Max Height

    It appears as though there is a height restriction on Keynote '09 for Mac text boxes.
    Even though I set the height to 1500 px, it only will show 1000 px of text.
    I'm attempting to create the affect of scrolling text, and need more text to be displayed on one slide.
    Any inspirations?

    Actually, I have not found this to be the case.
    Using a 39 point font, I have easily found that the text box is limited in the amount of text it can handle, and simple doesn't display the extra text at the end.

  • How to set max length to textfield?

    I have a textfield. I want to set maxlength to this textfield. Example, length = 3.
    Help me?

    I succeeded. That link you sent very well. Thanks you. Then it's code:
    JTextFieldLimit.java
    import javax.swing.text.*;
    //import com.sun.java.swing.*;
    //import javax.swing.text.*;
    public class JTextFieldLimit extends PlainDocument {
       private int limit;
       // optional uppercase conversion
       private boolean toUppercase = false;
       JTextFieldLimit(int limit)
        super();
        this.limit = limit;
       JTextFieldLimit(int limit, boolean upper) {
        super();
        this.limit = limit;
        toUppercase = upper;
       public void insertString
         (int offset, String  str, AttributeSet attr)
           throws BadLocationException {
        if (str == null) return;
        if ((getLength() + str.length()) <= limit) {
          if (toUppercase) str = str.toUpperCase();
          super.insertString(offset, str, attr);
    tswing.java
    import java.awt.*;
    import javax.swing.*;
      //import javax.swing.*;
      public class tswing extends JApplet{
        JTextField textfield1;
        JLabel label1;
        public void init() {
          getContentPane().setLayout(new FlowLayout());
          label1 = new JLabel("max 10 chars");
          textfield1 = new JTextField(15);
          getContentPane().add(label1);
          getContentPane().add(textfield1);
          textfield1.setDocument
             (new JTextFieldLimit(10));
    TextField.html
    <html>
    <applet code=tswing width=500 height=500>
    </applet>
    </html>
    By tungld_c0701m+

  • Report Row Height and Column Width

    Hi,
    I have a cell in a report (a description column) that causes the row height to become very large (when there is a lot of text in the description). I can make the column wider on the report attributes page, but there doesn't seem to be any place to influence the maximum height of a row on a report, short of modifying the template.
    Adding style attributes (e.g. max-height:30px) to an element only affects the <span> that the element resides in, not the table cell or row.
    Displaying the column as a text area is a useful workaround. The downside is the border and scroll bars do waste a lot of screen real estate. Does there exist some other way of setting a limit on the height and/or width of a report, report column or report row?
    Oh, and another question- how do make line breaks in this forum? There's no support for <BR> or [br].

    Please reply to this thread, my customer is facing the same issue. He does not have issue with the excel and the pdf output but in the rtf output the table heght increases to accomadate the data.He want it to bevave in the same way as the pdf do.
    Regards,
    Ajay

  • CSS Center gallery caption & add max size

    I'm working on revamping my horrible webpage (if you want a laugh look at the home page code). It was the best I could cobble together 5 years ago. But I've been taking tutorials. etc... And getting better at css. So I want to start fresh.
    On my new site, I'm going to add a jquery photo gallery for my portfolio. I was able to fine-tune much of the css. But am stymied on a few things. I've uploaded a sample.
    http://jamison-design.com/files/NivoSlider/slider.html
    I put notes in the CSS (***NOTE) on the particular issues, but will also mention here.
    1. The caption title on first image is not quite centered. Tried all kinds of things with margins, padding, position. But couldn't figure out the issue.
    2. I like how the image scales when you resize the browser window. BUT, I want to delcare a max height, so the image doesn't get larger than warrants, to keep the resolution good. Again, tried but failed to see what controls that.
    3. Would like to move the previous/forward buttons a set % away from the images. So, if it is a wide image the buttons will be the same distance from the left/right edge as if it is a less wide image. No idea where to even start with that.
    Bonus Question (;-)
    Finally, what controls where the bottom nav buttons are located. I might want to move down a bit...
    Thanks so much in advance. Happy New Year!

    I still can't see prev/next buttons.  Maybe because of your coding errors.  You've got HTML5 code in an XHTML doc.  For best results, use HTML5 doc type with HTML5 code. 
    Go to  Modify > Properties > Title/Encoding >  DTD: HTML5.  It should look like this:
    <!doctype html>
    <html lang="en">
    <head>
    <meta charset="utf-8">
    <title>Nivo Slider Demo</title>
    <!--These <script> tags must be inside your document's <head> tags-->
    <script>var __adobewebfontsappname__="dreamweaver"</script>
    <script src="http://use.edgefonts.net/gruppo:n4:default.js" type="text/javascript"></script>
    <link rel="stylesheet" href="themes/default/default.css" type="text/css" media="screen" />
    <link rel="stylesheet" href="nivo-slider.css" type="text/css" media="screen" />
    <link rel="stylesheet" href="style.css" type="text/css" media="screen" />
    </head>
    I said this before but I think it deserves repeating.  Slider images need to be the same size and ratio. Even if the background color is white, to maintain integrity of the slider, all images must be the same size.
    Best of luck with your project!
    Happy New Year!
    Nancy O.

  • Floating Height of JTextArea (as Renderer/Editor) in a JTable Cell

    Hey Folks,
    I'm kinda struggling with JTextAreas...
    There is this JTable, which consists of three colums (practically there are two - the other one's an ID-Field...) and only one
    of them ist editable für users.
    Left column is a commentary column which has a max of 150 characters - Right column fills automaticly with a user/date stamp.                                                                                                                                                                                    
    The main function is that on showing the table, old comments will be retrieved from database and new ones can be entered.
    This works all fine and is no matter of subject...
    The core of my problem is that there seems to be no straigh-forward way of determine a proper linecount from (a wordwrapped!) JTextArea.
    After a long search in the net, i found this approach:
        private static ArrayList<String> getWrappedLines(JTextArea myTextArea) {
            ArrayList<String> linesList = new ArrayList<String>();
            int length = myTextArea.getDocument().getLength();
            int offset = 0;
            try {
                while (offset < length) {
                    int end = Utilities.getRowEnd(myTextArea, offset);
                    if (end < 0) {
                        break;
                    // Include the last character on the line
                    end = Math.min(end + 1, length);
                    String line =
                        myTextArea.getDocument().getText(offset, end - offset);
                    // Remove the line break character
                    if (line.endsWith("\n")) {
                        line = line.substring(0, line.length() - 1);
                    linesList.add(line);
                    offset = end;
            } catch (BadLocationException e) {
                System.err.println("Bad Location at TextArea");
            return linesList;
        }    This code reads the content of a JTextArea an separates wrapped lines in an array.
    With manual line breaks ("\n") I get Exceptions (Bad Location) which isn't too bad, because
    I was trying to ban manual line breaks anyway...
    The above given method retrieves the lines, while the next sets the new Height (line count multiplied by Font Height) to the row.
        public static void setOptimalRowHeight(JTable table, JTextArea textArea, int row, int column) {
            if (
                row >= 0 &&
                column == VerwaltungsnotizController.IND_VNO_NOTIZ   
                int fontHeight =
                    textArea.getFontMetrics(textArea.getFont()).getHeight();
                ArrayList<String> wrappedLines = getWrappedLines(textArea);
                int nrOfLines = wrappedLines.size();
                int oldSize = table.getRowHeight(row);
                int newSize = (fontHeight * nrOfLines) + 5;
                if (newSize != oldSize) {
                    table.setRowHeight(row, newSize);
         public static void setOptimalRowHeight(JTable table, JTextArea textArea) {
         int row = table.getSelectedRow();
         int column = table.getSelectedColumn();
         if (
              row >= 0 &&
              column == VerwaltungsnotizController.IND_VNO_NOTIZ   
              setOptimalRowHeight(table, textArea, row, column);
         }The above combined Sources are used by two classes, which are "tied" to the table.
    One is the CellEditor (which works almost fine); the other one is the CellRenderer (which fails miserably!)
    CellEditor (with Listener):
    public class VnoCellEditor extends AbstractCellEditor implements TableCellEditor {
        private VnoTextArea textArea;
        private JTable table;
        public VnoCellEditor (JTable table) {
            this.table = table;
            textArea = new VnoTextArea(table);
            textArea.setMaximumInputLength(VerwaltungsnotizController.MAX_INPUT_VNO);
            textArea.addKeyListener(new TextAreaEnterAdapter());
            textArea.setLineWrap(true);
            textArea.setWrapStyleWord(true);
            Document document = textArea.getDocument();
            document.addDocumentListener(new VnoTextAreaDocListener(table, textArea));
        public Component getTableCellEditorComponent(JTable table, Object value,
                                                     boolean isSelected, int row,
                                                     int column) {
            if (value instanceof String) {
                textArea.setText((String)value);
            } else if (value instanceof Integer) {
                Integer intValue = (Integer)value;
                textArea.setText(intValue.toString());
            } else {
                Object objValue = value;
                textArea.setText(objValue.toString());
            System.err.println("Editor - get Component");
            return textArea;
        public Object getCellEditorValue() {
            return textArea.getText();
    public class VnoTextAreaDocListener implements DocumentListener {
        private JTable table;
        private JTextArea textArea;
        public VnoTextAreaDocListener(JTable table, JTextArea textArea) {
            this.table = table;
            this.textArea = textArea;
        public void insertUpdate(DocumentEvent e) {
            VnoTableRowHeightHelper.setOptimalRowHeight(table, textArea);
        public void removeUpdate(DocumentEvent e) {
            VnoTableRowHeightHelper.setOptimalRowHeight(table, textArea);
        public void changedUpdate(DocumentEvent e) {
            //Plain text components don't fire these events
    }As said the editor works almost as planned. On every Keystroke made in Edit-Mode of the table, insertUpdate() or removeUpdate()
    is being called, corresponding to the type of Keystroke ... (duh!)
    The Helpers method is called and the row-height is set real nicely.
    !But!
    when i navigate into an other row, a removeUpdate()-event is beeing thrown and due to the mechanism the cell selection
    gets somehow mixed around and row-heights get switched.
    Maybe this could get improved, but i don't se my error - which wouldn't be nescessary if this event wasn't thrown.
    (for what I don't see a reason anyway ... !)
    CellRenderer:
    public class VnoCellRenderer implements TableCellRenderer {
        private VnoTextArea textArea;
        private int Row = -1;
        private int Column = -1;
        private VnoTableModel jtmVno;
        public VnoCellRenderer(JTable table) {
            this.jtmVno = (VnoTableModel)table.getModel();
            textArea = new VnoTextArea(table);
            textArea.setLayout(new BorderLayout());
            textArea.setLineWrap(true);
            textArea.setWrapStyleWord(true);
        public VnoTextArea getTextArea() {
            return textArea;
        public Component getTableCellRendererComponent(JTable table, Object value,
                                                       boolean isSelected,
                                                       boolean hasFocus, int row,
                                                       int column) {
            Row = row;
            Column = column;
            String tmpValue = null;
            if (value instanceof String) {
                tmpValue = (String)value;
            } else if (value instanceof Integer) {
                tmpValue = ((Integer)value).toString();
            } else {
                tmpValue = value.toString();
            // FARBEN:
            // Normalmodus
            if (jtmVno == null) {
                System.err.println("Table Model noch nicht initialisiert!");
                textArea.setBackground(Color.LIGHT_GRAY);
            } else {
                if (jtmVno.isCellEditable(Row, Column)) {
                    textArea.setBackground(Color.WHITE);
                } else {
                    textArea.setBackground(Color.LIGHT_GRAY);
            textArea.setForeground(Color.BLACK);
            // Für ausgewählte Zeile
            if (isSelected && !hasFocus) {
                textArea.setBackground(CommonConstants.SELECTION_COLOR_BLUE);
                textArea.setForeground(Color.WHITE);
            textArea.setText(tmpValue);
            textArea.setEditable(true);
            if (Column == VerwaltungsnotizController.IND_VNO_NOTIZ) {
                VnoTableRowHeightHelper.setOptimalRowHeight(table, textArea, row, column);
            return textArea;
    }Okay, this is where the shit hits the fan!
    Since with renderers there is no manual content mutation, row-height-settings are not done with listeners.
    I put this at the very end of the getTableCellRendererComponent(), which is called every time a cell gets rendered.
    The main problem here is that at this point my methods can't determine any linewraps at all!
    getWrappedLines() always returns an empty Array (since Utilities.getRowEnd() returns "-1" beforehand...).
    I'm afraid that my methods are called way too early - at a point were the rendering is not completed or has not even started.
    And to accomplish my desired tasks the fully rendered JTextArea would be needed ... ?!
    I have very limited swing experience, so I can only guess about this core features ...
    But i this is the case - my methods should be called later on the rendered cell. But how? from which component?
    Btw: I have written my own JTextArea to limit the input size
    public class VnoTextArea extends JTextArea {
        private JTable table;
        private int _maximumInputLength = 0;
        public VnoTextArea(JTable table) {
            this.table = table;
        public void setMaximumInputLength(int maximumInputLength) {
          if (maximumInputLength != 0) {
            _maximumInputLength = maximumInputLength;
            super.setDocument(new PlainDocument() {
                public void insertString(int offset, String string, AttributeSet attributeSet) throws BadLocationException {
                  StringBuffer buffer = new StringBuffer(string);
                  int size = VnoTextArea.this.getText().length();
                  int bufferSize = buffer.length();
                  if ((size + bufferSize) > _maximumInputLength) {
                    buffer.delete((_maximumInputLength - size), bufferSize);
                  if (size < _maximumInputLength) {
                    super.insertString(offset, buffer.toString(), attributeSet);
                  } else {
                    Toolkit.getDefaultToolkit().beep();
    }I'm sorry for not providing a running example, but it's a pretty huge project...
    Providing all dependencies would go far beyond the scope.
    (and there are many sources which I'm not allowed to post)
    But I hope my examples get down to the core of my problem!
    I also tried different approaches:
    - using getPreferredSize() of the JTextArea (seemed to do nothing useful at all?!)
    - using getLineCount/() of the TextArea (only counts "\n" ...)
    - guessing that every row consist of an average of 20 characters cumpute by myself (low-tech, buggy but fast - unsatisfying)
    With my above mentioned approach I got by far the best results (partially) - but I'm at my wits' end.
    I don't know it any better... And i have tried for days without improvement.
    What would you do?
    vielen Dank im Voraus schon mal für eventuelle Mühen,
    Haye

    no solution - just a couple of comments:
    - never ever change the calling table in a renderer, I mean really NEVER
    - instead, listen to table events and resize the row height as appropriate
    - JTextArea has a somehow weird prefSize calculation (forgot the details, so don't nail me :), so you have to manually set one dimension and then ask the area to calculate the other. In your renderer, you can do something like:
    Component getTableCellRendererComponent(....) {
        int columnWidth = table.getColumnModel().getColumn(column).getWidth();
        textArea.setSize(columnWidth, Short.MAX_VALUE);
        ... here do the normal config
    // then somewhere else, triggered by appropriate change events
    void updateRowHeight(JTable table, int row) {
       int height = table.getRowHeight();
       foreach column {
             TableCellRenderer r = table.getCellRenderer(row, column);
             Component c = table.prepareCellRenderer(r, row, column);
             height = Math.max(height, c.getPreferredSize().height);
       table.setRowHeight(row, height);
    } HTH - ein bißchen wenigstens :-)
    Jeanette

  • How to resize and maintain height and width ratio IR image column

    Hello, I am upgrading from 3.2 to 4.1 reports that include images in report columns. I have had good success with this except for one thing. If the height and width is fixed it distorts the photos, and if I do not have fixed dimensions the image may be too large depending on the original dimensions of the :P1_PHOTO item which is File Browse... BLOB column. I do not want to restrict users ability to upload large image files, or files with different dimensions, but I want them to display as a thumbnail size proportional to the original dimensions in the report, or maybe I need a different approach? Report region template is No Template. I appreciate any suggestions.
    select decode(nvl(dbms_lob.getlength(photo),0),0,null,'<img src="'||apex_util.get_blob_file_src('P1_PHOTO',id)||'" height="75" width="75"/>') photo from table.
    I tried using percent i.e.: width="10%" that does not work.
    I have tried several variations of <style> in page HTML header to change column width, but the image size does not change.
    <style>
    td[headers="PHOTO"] {
    width:75px;
    </style>
    <style>
    #apexir_PHOTO{width: 75px;}
    </style>
    Thanks.

    Try to go with max-width / max-height. However, if you have IE browser, hang on for pain. For some ideas, some links:
    http://wordpress.mfields.org/2011/scaling-images-in-ie8-with-css-max-width/ (ignore object-fit, it is not yet supported on most browser)
    http://stackoverflow.com/questions/3915219/max-width-on-img-tag-not-working-in-ie8
    etc. Be sure to try out your chosen solution on the target browser(s)!
    IE is just nasty :(
    What i have done before is not to have my browser scale my images, especially when the images can be large(r) and you expect quite some traffic. All those extra (kilo)bytes won't help it load faster. I just added an extra column in the table, like photo_thumb, and create a scaled version of the uploaded picture when it is being inserted.
    For example, i have the following process on my apex page, and i'm using wwv_flow_files.
    Have some code:
    IF :P3_FIND_PHOTO IS NOT NULL THEN
       DECLARE
         v_id number;
         v_small_photo blob;
         v_large_photo blob;
         v_mime_type apxt_contacts_img.mime_type%type;
         v_content_type apxt_contacts_img.content_type%type;
       BEGIN
          SELECT blob_content a, blob_content b, mime_type, content_type
          INTO v_small_photo, v_large_photo, v_mime_type, v_content_type
          FROM wwv_flow_files
          WHERE name = :P3_FIND_PHOTO;
          IF lower(v_mime_type) NOT IN ('image/jpg', 'image/jpeg') THEN
             raise_application_error(-20001, 'File for upload is not a jpg!');
          END IF;
          -- Rezise the photo so that it is proportionally 125*125
          -- ordimage is an oracle type able to manipulate all sorts of pictures
          ordimage.process(v_small_photo, 'maxScale=125 125');
          -- If contact is of type personnel, then no need to store
          -- a large photo since it wont be displayed
          IF :P3_CONTACT_TYPE_ID = 2 THEN
            v_large_photo := NULL;
          END IF;
          -- Delete previously uploaded picture
          IF :P3_ID IS NOT NULL THEN
             DELETE FROM apxt_contacts_img
              WHERE contact_id = :P3_ID;
          END IF;
          -- Insert the data into the contacts_img table as a
          -- SELECT from WWV_FLOW_FILES
          INSERT INTO apxt_contacts_img
          (contact_id,
           image_name,
           mime_type,
           content_type,
           filename,
           small_photo,
           large_photo)
          VALUES
          (:P3_ID,
           :P3_LASTNAME,
           v_mime_type,             
           v_content_type,
           :P3_FIND_PHOTO,
           v_small_photo,
           v_large_photo);
          -- Remove the image from the apex wwv_flows_files table
          DELETE FROM wwv_flow_files WHERE name = :P3_FIND_PHOTO;
       END;
    END IF;

Maybe you are looking for

  • How do you connect your macbook pro to a sony bravia tv with a belkin cord????? HELP!!!!!!!!!!!!!!!

    How do you connect you macbook pro to a Sony Bravia tv with a Belkin cord!?!?!?!?!?!?!? We know how to set it up, but what setting do you put your tv on!?!?!? we have tried everything, but it wont work!!!!!!!!! HELP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  • Import Comments data and Dimension Members from csv file via Data Manager

    Dear Experts, I have two questions regarding the data manager. Q1.Is it possible to import "Comments" from the csv file via Data Manager? We'd like to import the amount with "Comments". My image of csv file is like below; ACCOUNT,CATEGORY,TIME,ENTITY

  • Mac Os Classic on MacBookPro?

    On my older laptop, which ran on an earlier version of Mac Os X, there was a way of running both X and classic at the same time. Does the 10.4.10 installed on my computer come with similar capabilities, and if so, how do I make Classic run? If it doe

  • IPhone SDK certifikate problem

    Hello, sorry my english is not the best. I made a distribution_identity.cer and a developer_identity.cer in the apple developer portal. After downloading, i clicked every certificate twice. In Xcode i colud not find any certificate in the projekct op

  • Convenience Key Is Not Working!!!

    Hi, BB fans I just got a BB Torch 9860 phone. However the convenience key is not working. No matter to what option I set it to, it doesn't work. The default Camera also doesn't work. I have enabled the keytones on my phone. I hear the keytone wheneve