Changing the size of a jbutton inside a jtable

Hi,
I have found this example for adding a jbutton to a jtable:
http://forum.java.sun.com/thread.jspa?forumID=57&threadID=715330
however, I have cannot seem to figure out how to set the size of the jbutton. Currently, the jbutton is filled to the size of the cell within the jtable, but i want to have it a bit smaller and centered (the rows of my table are rather large in hieght)
I tried the setSize()
setPrefferedSize()
setMinimumSize()
setMaximumSize()methods, but nothing seems to work. Has anyone been able to do this?

Use a JPanel instead of a JButton as cell renderer. Put a button inside the panel - use FlowLayout.

Similar Messages

  • How to change the size of the text inside a label?

    Hello,
    I would like to change the size of the text inside a label.
    Is there any way to do it Web DynPro?

    Hello Roy,
    Not possible. WDLabelDesign contains only 2 values: STANDARD and LIGHT. As workaround you can use TextView. It supports a lot of "designs" (e.g. label_small).
    Best regards, Maksim Rashchynski.

  • Changing the size of a JComboBox

    Greetings,
    I am trying to build a mechanism to perform zooming on a JPanel with an arbitrary collection of components (including nested JPanels). I've tried a number of things with little success. The following is my most promising contraption. It can zoom labels, textfields, checkboxes, and buttons. However, for some reason, the combo box refuses to accept a changes to its size. I'm not sure why this is the case. Its font changes size appropriately.
    Anyway, I'm running in JDK 1.4, and the following program lays out a palette of components. To change the size of the components, hit F1 to zoom in, and F2 to zoom out.
    import java.awt.Component;
    import java.awt.Container;
    import java.awt.Dimension;
    import java.awt.Font;
    import java.awt.KeyEventPostProcessor;
    import java.awt.KeyboardFocusManager;
    import java.awt.event.KeyEvent;
    import java.awt.geom.AffineTransform;
    import javax.swing.JButton;
    import javax.swing.JCheckBox;
    import javax.swing.JComboBox;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JTextField;
    public class Demo extends JPanel
        public class Zoomer
            private double m_zoom = 1;
            private JPanel m_panel;
            public Zoomer(JPanel panel)
                m_panel = panel;
            private AffineTransform getTransform()
                return AffineTransform.getScaleInstance(m_zoom, m_zoom);
            private Font transform(Font font)
                return font.deriveFont(getTransform());
            private Dimension transform(Dimension dimension)
                Dimension retval = new Dimension();
                retval.setSize(dimension.getWidth() * m_zoom, dimension.getHeight() * m_zoom);
                return retval;
            private void performZoom(Container container)
                Component[] components = container.getComponents();
                for(int i = 0; i < components.length; i++)
                    Component component = (Component)components;
    component.setFont(transform(component.getFont()));
    component.setSize(transform(component.getSize()));
    for(int i = 0; i < components.length; i++)
    Component component = components[i];
    if(component instanceof Container)
    performZoom((Container)component);
    public double getZoom()
    return m_zoom;
    public void setZoom(double zoom)
    if(zoom > 8.0 || zoom < 0.125) return;
    m_zoom = zoom;
    performZoom(m_panel);
    public void zoom(double factor)
    setZoom(getZoom() * factor);
    public Demo()
    JPanel panel = new JPanel();
    panel.add(buildPanel());
    panel.add(buildPanel());
    final Zoomer zoomer = new Zoomer(panel);
    add(panel);
    KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventPostProcessor(new KeyEventPostProcessor()
    public boolean postProcessKeyEvent(KeyEvent e)
    if(e.getID() != KeyEvent.KEY_PRESSED) return false;
    if(e.getKeyCode() == KeyEvent.VK_F1)
    zoomer.zoom(1.2);
    if(e.getKeyCode() == KeyEvent.VK_F2)
    zoomer.zoom(1/1.2);
    return false;
    private JPanel buildPanel()
    JPanel panel = new JPanel();
    panel.add(new JLabel("label: "));
    panel.add(new JTextField("Hello World"));
    panel.add(new JCheckBox("checkbox"));
    panel.add(new JComboBox(new String[] { "Bread", "Milk", "Butter" }));
    panel.add(new JButton("Hit Me!"));
    return panel;
    * Create the GUI and show it. For thread safety, this method should be
    * invoked from the event-dispatching thread.
    private static void createAndShowGUI()
    // Create and set up the window.
    JFrame frame = new JFrame("Demo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    // Create and set up the content pane.
    Demo newContentPane = new Demo();
    newContentPane.setOpaque(true); // content panes must be opaque
    frame.setContentPane(newContentPane);
    // Display the window.
    frame.pack();
    frame.setVisible(true);
    public static void main(String[] args)
    // Schedule a job for the event-dispatching thread:
    // creating and showing this application's GUI.
    javax.swing.SwingUtilities.invokeLater(new Runnable()
    public void run()
    createAndShowGUI();

    component.setSize(transform(component.getSize()));First of all the above line is not needed. The LayoutManager will determine the bounds (size and location) of each component in the container based on the rules of the LayoutManager. The Flow Layout is the default layout manager for a panel and it simply uses the preferred size of the component as the size of the component.
    So what happens is that when you change the font of the component you are changing the preferred size of the component.
    So why doesn't the combo box work? Well I took a look at the preferred size calculation of the combo box (from the BasicComboBoxUI) and it actually caches the preferred size. The combo box uses a renderer, so the value is cached for performance one would assume. The method does recalculate the size when certain properties change. Note the isDisplaySizeDirty flag used in the code below:
             else if (propertyName.equals("prototypeDisplayValue")) {
                    isMinimumSizeDirty = true;
                    isDisplaySizeDirty = true;
                    comboBox.revalidate();
             else if (propertyName.equals("renderer")) {
                    isMinimumSizeDirty = true;
                    isDisplaySizeDirty = true;
                    comboBox.revalidate();
                }It also handles a Font property change as well:
                else if ( propertyName.equals( "font" ) ) {
                    listBox.setFont( comboBox.getFont() );
                    if ( editor != null ) {
                        editor.setFont( comboBox.getFont() );
                    isMinimumSizeDirty = true;
                    comboBox.validate();
                }but notice that the isDisplaySizeDirty flag is missing. This would seem to be a bug (but I don't know why two flags are required).
    Anyway, the following change to your code seems to work:
    // component.setSize(transform(component.getSize()));
    if (component instanceof JComponent)
         ((JComponent)component).updateUI();
    }

  • How do you change the size of pictures?

    Hello,
    I'm a new Mac user. How do you change the size of pictures in iPhoto? Sometimes when sending e-mails, the picture files are extremely large and take a long time to load... Is there any way you can make the picture or file smaller? Like on a PC, you can open the photo in the Paint program and just reduce the size... Is there anything like this for the Mac?
    Thanks!

    Assuming that you're accessing your email package from INSIDE iPhoto, you're given a choice of picture sizes. Personally, I've found "medium" to be a good compromise but you might prefer "small" (iPhoto will tell you the file size).
    If you don't know what I'm talking about, first go iPhoto Preferences > General and select your email client. Then, go to the View menu and select Show in Toolbar > Email.

  • I want to change the size and color of text in call out boxes and text boxes. How can I do this? Jack

    I want to change the size and color of text in call out boxes and text boxes. How can I do this? Jack

    Highlite the text inside the text box and then press Ctrl+E.

  • Changing the size of a background on Question Slides

    Hi All,
    I have a Question Pool and I would like the background of the slides to be the same as one i use for a ppt presentation. I have copied the background and used the 'Paste as Background' option you get when right-clicking. It pastes the image but the image is smaller than the slide itself. Does anyone know how to change the size of the background so that it fits the size of the slide?
    Thanks.

    Hi there
    Okay, so it would seem to me that you may not fully understand Captivate and resolutions. So heres the deal.
    It appears that you are expecting the image to stetch to fill the entire computer screen. You stated you cannot get the image to size beyond 1440 pixels. Well, this is because your project is sized at 1440 pixels.
    Remember, the Captivate movie will usually be played back to the viewer from inside a web browser. Normally you want the movie size to be smaller than the surrounding browser. Like this:
    In the example above, the White part of what is inside the browser may be the width of the Captivate movie.
    Does this make better sense?
    Cheers... Rick
    Helpful and Handy Links
    Captivate Wish Form/Bug Reporting Form
    Adobe Certified Captivate Training
    SorcererStone Blog
    Captivate eBooks

  • How Can I Change the Size of My Home Page So That It Fills the Screen?

    I have a PowerBook G4. Up until a couple of weeks ago when I opened Safari the home page filled the screen. Something has happened and now it fills only a portion of the screen. I can move the page around, change the size slightly by using the green button next to the minimizing button, but nothing I do will enlarge it to fill the screen. I have gone to View and Preferences, but find nothing to resolve this. Please help!

    You're welcome Maureen. Glad I could help.
    Thanks for the and Aloha from Big Island.

  • How do I change the size of a windows partition on my MacBook?

    How do I change the size of a windows partition on my MacBook?

    CampTune $19 from Paragon-Software is your best bet.
    http://www.paragon-software.com/mac/

  • What is happening when I change the size of the image in the program sequence window?

    I noticed that I can change the image size of my exported file. I imported a 720 x 480 DV file into CS5.5. I went to my program sequence window and changed the settings to show the smallest image in that window. I then clicked on the image and used the handles that appear to make that small image large enough to nearly fill the screen. When I exported my final file and played the resulting WMV, the image on my screen was nearly twice as large as it would have been if I had not previously altered the image size in the program sequence window. I had to do this alteration for each clip in my timeline, or the unaltered ones would stay at the smaller size. The quality did not seem to be significantly impaired. I learned about this on a youtube video. The person who did the video claimed that this was a simple and quick way to upgrade standard video to HD. Of course this is not true. He was only changing the size of the resulting video. Does anyone know what is really happing when you do this procedure and why it changes the size of the exported  video?

    The size (resolution) of the exported video is not affected by anything you do while editing.  It is dependant solely on the resolution set in the export settings.
    Ideally you want to edit in an sequence that matches your media\, which will be the same size or larger than the required export.  In other words, the same or smaller is OK.  Making things bigger in post is not the best option.  If you need things bigger, shoot them bigger.

  • Troubles by changing the size of a bookmark header text Repot generation Toolkit

    Hello everyone
    I'm having  troubles getting the size of  a header text formatted into a different font size, I attach the code I'm using to get the work done.
    At the end I get all I want from the report generation toolkit but the text size in the header and footer . Does Anyone have a clue?
    Well the image is too small I'm getting an error when I try to post a bigger one. The thing is that the VI's used here to change the size are append report text.vi and format text.vi. The first one is used to insert text through bookmarks in the header and footer  (it works just gereat) and the second one is intended to change the size of the inserted text (it doesn't work at all) I've already used shift registers in the for loop but I get the same results. The last VI is dispose report.vi
    thanks in advance
    Attachments:
    Maquina Etdos Verifica Reporte.vi ‏94 KB

    Hello Julio9,
     sorry for the waiting I had to clean the block diagram up and take into account some data security issues before I could post the information you asked me to. I have to tell you that I already came out with a patch for the issue nonetheless it is not the correct way to solve it and I would appretiate if you or anyone else could help me to do it right.
    Here is what I changed:
    In my code at the Initialize state (within the state machine) there is the New Report.vi I opened it to get also the new report SubVI.vi opened, afterwards I selected the NI_Word.lvclass: new report subvi.vi and opened it in its code yoou can easly see the double numeric constant value for the size of the text inserted as default. I just changed it from 12 to 8 to correct the formatting. As the outcome all the text inserted through the bookmarks have the default size (8 pts). 
    I attached the new version of my code with all the documents you will need. Please follow these steps:
    1.-Open the project named Verifica Temperaturas 2010.lvproj
    2.-Run the main vi named Maquina Etdos verifica reporte 2.vi
    3.-Check the option Laboratorio de Refrigeradores:
    4.-Click OK
    5.-Complete the information as shown:
    (For Selecciona Machote pick the word document named Document.doc attached in the .zip file. For the Selecciona Archivo de temperaturas pick the Estacion1_21-02-2012.txt file also attached in the .zip file)
    6.-Press Siguiente
    After completing the steps you'll see how the document in created. As expected the size of the text in the header is 8 pts.
    Attachments:
    Verificacion_Camaras.zip ‏359 KB

  • Changing the size of a drop down list

    Hi Everyone,
    Is there anyway to change the size of a drop down list?  For example, our customer would like to make the drop down list for the Ship-To field on the logistics tab of the sales orders longer.  Currently, they cannot see the full name when they scroll through it.  Is this possible?  Depending on what Customer Code they enter, the field size appears to change.
    Thank you in advance for your help.
    Amanda

    I am using Tahoma size 10 as well. 
    Is the drop down size somehow related to the size of the first few records?  So, if those are shorter than those at the end, perhaps it doesn't adjust for the size of the bottom records.  For example, in our customer's database here's a sampling of what they have entered and the order:
    Wal-Mart 6124
    Wal-Mart 6125
    Wal-Mart 6126
    Wal-Mart 7001
    Wal-Mart Supercenter 1111
    Wal-Mart Supercenter 2094
    Wal-Mart Supercenter 3475
    The drop down box is large enough to see the Wal-Mart 6124, etc. but not large enough to see the Wal-Mart Supercenter ones at the bottom of the list (keep in mind there are over 100 ship-to's for this Business Parnter).  Does it maybe only look at the first fifty records or something like that?
    Thanks again,
    Amanda

  • Changing the Size of A screen at runtime

    Is it possible to change the size of a screen , just before it is called, or to move it it after it has been called.
    Bascally I'm using
    CALL FUNCTION 'Z_SIM_TEST' starting new task 'PDF Spools'
    to create a new screen asynchronously, in a new session, and want the user to be aware that the older session is still there?
    Thanks.

    you can use CALL SCREEN 2009 STARTING AT x-cor y-cor ENDIGN AT x-cor y-cor to put the screen. You can change x and y coordinates.

  • Changing the size of a document in Pages?

    How can you change the size of a document in pages? I need to change a poster size document to 8.5 x 11?

    Nevermind. Found it! Sorry, new to Mac

  • Changing the Size of generated graph in excel report generation toolkit

    Hi, i am trying to build a report generation vi for my Structural health monitoring system in which i need to export 3 graphs in to an excel report. The idea is to have the report on a single page, but when i paste them along with the ceiling and pillar deviation percentages, the report just exceeds the page limit. I wanted to know whether one can change the size of the graphs in excel? One can do it in word(tried that), but i dont want to use the bookmark option as it intend to put this up as a webservice in the next step. I am using LabVIEW 2009 Thanks.
    LabVIEW 8.2,8.6,2009...still learning
    Attachments:
    Report Generation SHM.vi ‏30 KB

    Hi,
    I haven't tried this myself, but looking through the report generation toolkit the "Excel format image VI" (in the Excel specific tab of the Report Genertaion window) looks to be the one you are after. The help entry for the VI says to: "Use this VI to format any type of image in a worksheet, including front panel images, images from a file, and graphs"
    Hopefully this will help.
    -CC 
    "If anyone needs me, I'll be in the Angry Dome!"

  • Changing the size of fonts in InDesign's menus and toolbars?

    Is it possible to change the size of fonts in InDesign's menus and toolbars? I'd love for the Control Panel at the top to be a bit easier to read.

    Thanks Bob, didn't see it anywhere but figured it was worth asking. I think the size is a little biased toward people with better vision than me but I guess I'll have to live with that.
    Jon

Maybe you are looking for

  • HP Laser Jet printing problems

    We have a HP Laserjet 2430 dtn  - Networked .   If we have more than 2 machines sending prints to the machine it doesn't pringt and waits for manual intervention i.e. asks which tray you want to print from ? - any suggestions?  I have gone to each ma

  • "Open new windows in a new tab istead" ALWAYS checks itself back on even when I don't want it to...

    I do not wish to have tabbed browsing, period! I want ALL links to open in a new window, ALWAYS! Every time I restart Firefox, the box checks itself back on. This has been going on for the past several YEARS. Beyond frustrating. Chrome is looking bet

  • File- XI- RFC produces no output on remote system...

    My RFC call is not producing the output I expected. (scenario: file ->XI->remote RFC call) When I go into the debugger for the RFC and plug in the same values as in my text file, I get no error messages, and I get my desired output (creates a Purch R

  • Forms like boarding passes,UPS labels print too small

    I have two HP OfficeJet 6400 series printers that I use with several computers, laptops and desktops. Even though I have the box checked to print to actual size in the Properties section, when I print forms like boarding passes and UPS labels, they o

  • Multiple simultaneous release against qty contract

    Hello Experts I have a blanket contract. I am releasing this contract through sales order creation (VA01). But when two users are simultaneously releasing the contract in VA01 then in the dialog box of "Create with reference" system gives one of the