Resize small jtable within jframe

Hi, I have a small jtable in a jframe and would like to enable the user to resize this table by dragging its edges via mouse? How can I do this?
thx
D.

Try adding the JScrollPane onto a JPanel with GridLayout and add the JPanel to the north of the content pane of the JFrame using BorderLayout.
Is this what you intended to do?

Similar Messages

  • Add several small jtables into jframe

    Hi,
    I am trying to implement a GUI where a desired number of small tables can be added into a frame when the user clicks the menu item "new module" in the menu. So far, I can just add one table. For that, I have implemented an action listener. The table is created in a method called createTable().
    Here is the code fragment:
    ActionListener editListener = new ActionListener() {
                                  public void actionPerformed(ActionEvent editEvent) {
                                       if (editEvent.getActionCommand().equalsIgnoreCase("New Module"))
                                            //event1.getActionCommand();     
                                            //Container frame = new Container();
                                            createTable();
                                            tablearea.add(jTable1);
                                            repaint();                                   }...}
                             };Does anyone have an idea how I could implement the functionality that when the user clicks the menu item several times, new tables are painted in the frame differing in their positions (e.g. next to each other).

    a) you need a LayoutManager in your tablearea-Panel. Maybe GridLayout is what you need or the more complex GridBagLayout. However, the BoxLayout is a look worth too!
    b) depending on the LayoutManager you use, you have to do a little more than just to 'add' the table - depending on the Manager. GridBagLayout (for instance) need a configured GridBagConstraints-Object.
    c) try tablearea.validate() or tablearea.invalidate() to repaint the content (look javadoc about both methods).
    Regards,
    Martin

  • How do I resize an image within a drop zone (not the drop zone itself) in motion 5?

    How do I resize an image within a drop zone (not the drop zone itself) in motion 5?

    I think others would be able to help if you describe a little more why you'd like to do this. Given that drop zones are a way of passing images into Motion that you want to manipulate, resizing a drop zone is the equivalent of resizing the image.
    If you're having a problem with an image from Final Cut being too big or too small, select the Drop Zone in the inspector and make sure the Fit parameter is set to 'Fit' - 'Center' will result in images dropped not being scaled to fit the Drop Zone. 'Stretch' will force the dropped image to fill the space defined by the drop zone,
    If the image is already cropped and scaled up in Final Cut Pro, that is the information that Motion gets - you can't scale down the image to see more of the edges that have been cropped off.
    If you want more than one copy of the image passed via the drop zone, use Make Clone Layer from the Object menu.

  • JTable in JPanel last Column resize clips JTable doesnt repaint JPanel

    I have a JTable in a JPanel, when I drag the last column of the JTableHeader (u can see the column resizing as the text of the Table HeaderColumn moves with the drag) the JTable is outside the JPanel. Only when u click on another component and then click back on the JTableHeader does it repaint.
    I have tried jPanel.revalidate(); in the mouseDragged event of MouseMotionListener on the JTableHeader and all manner or repaints and fireTableStructureChanged. But I dont understand the order of events.
    The last bug to fix!!!
    NB I dont want to use scrollpane as its not necessary and as many tables are synchronized with one table it makes repaints less smooth
    Thanks Paul

    Well, I didn't find an answer but I did find a solution.
    The JPanel is the problem. I use it to help with layout which is not obvious in this example.
    As you can see in the code the JTable is placed in a JScrollPane which is place in a JPanel which is placed in a JTabbedPane.
    If I use Box instead of JPanel the JTable in the JScrollPane in the Box in the TabbedPane in the JFrame resizes correclty.
    So although JPanel is resizable with setSize it does not get resized when it's JFrame gets resized.
    I would still like to know why?
    ////////KBS
    JTabbedPane myTP = new JTabbedPane();
    Box myOne = Box.createHorizontalBox();
    Box myTwo = Box.createHorizontalBox();
    myOne.add(pane);
    myTP.add("One", myOne);
    myTP.add("Two", myTwo);
    ////////KBS

  • Jtable in jframe,??? any way to do this.

    is there any way of inserting JTable in jframe.
    if yes let me know
    another q.
    i am displaying jtable and i want to put a button in front of each row.
    eg:
    id col1 col2 col3 col4
    ===============================
    1 abc 12 23 e001 (button1 here)
    2 abc 12 23 e001 (button2 here)
    3 abc 12 23 e001 (button3 here)
    4 abc 12 23 e001 (button4 here)
    5 abc 12 23 e001 (button5 here)
    and when i scroll this table the button should dynamically get respective row  id...
    i need to know by what way we can get this dynamically allocating button to resp row no..
    as if in case if i click on buttong 3 id 3 should be fetched.
    and as i scroll through
    to id 179 and on clicking the respective button i should get respective id i.e 179
    any help .please

    is there any way of inserting JTable in jframe.Read the JTable API and follow the link to the Swing tutorial on "How to Use Tables"
    another q.What is a "q"?

  • Editing timelapses in Lightroom- looks very different if there´s a small change within the frame

    Hi
    We´re having some serious issues with editing timelapses in Lightroom (5.6). What seems to happen over and over again, is that if there´s a small change within the frame (such as a bird flying past, people walking), the editing result varies greatly compared to the previoius frame. It´s easiest to understand what I mean by viewing the examples below.
    Here there´s one picture without a boat in the frame, and a few seconds later there´s a boat in a small part of the frame. The camera is set to full manual, and the two JPGs which show the unedited pictures shows that the background and sky in both pictures look exactly the same. However, after pasting the same editing setting on both pictures, the picture with the boat looks vastly different (shadow areas are much darker). It´s the same result weather it is a white boat, a black bird or a person walking in/out of the frame. The picture gets much darker, and leads to some serious flicker in the timelapse which can be impossible to get rid of.
    I assume that as there´s a small change in the histogram when the boat enters the frame, this change affects what Lightroom thinks of as shadows/highlights on so on? The example below has some heavy editing applied (shadows up, highlights down, clarity). You can see the settings that have been adjusted in the screenshots below. Does LR change what it considers shadows/highlights based on the histogram, or are there standard settings? If this is the case, it would be much better for timelapsers if Lightroom had standard values for what is considered shadows/highlights, so that two pictures where the only difference is a person walking on the street or not, would look the same with the same editing settings applied. What I find strange if LR works like I´m asking here, why does the picture get darker whether it is a white boat or a black bird changing the histogram slightly. Shouldn´t they then have the opposite effect of each other?
    Any ideas what is causing the difference, and what I can do about it? Thanks!

    In these forums you are only talking to other users like yourself, not Apple. Be sure to repost your info in the channel Apple has set up for it:
    http://www.apple.com/feedback/imovie_iOS.html

  • Rendering a JTable within a JTable Cell

    How can one render a JTable within another JTable cell?

    You could return JTable in your TableCellRenderer.
    Denis Krukovsky
    http://sourceforge.net/projects/dotuseful/

  • How to add JFrame within JFrame

    Hi,
    I want to add jFrame within JFrame just like JInternalFrame, But I don't want to use JInternalFrame.

    Im not really sure why you would want to do this, but what you could do is add the JFrame's contentPane to a JPanel, and then put it in the other one.
    So lets say you have two JFrame objects: frame1 and frame2
    JPanel frame2Content = new JPanel();
    frame2Content.add(frame2.getContentPane());
    frame1.getContentPane().add(frame2Content);Depending on your layout manager, that would allow you to put frame2's components, as a panel, somewhere in frame1.

  • Resizing the JTable Cell horizontal width

    Sir/Madam,
    How can i resize the JTable cell's horizontal width. I know the JTable's column width can be resized. I dont want to resize the entire JTable column. But i need to resize individual JTable cell's horizontal width. Thanks in advance.

    I think that's not possible. What kind of results are you expecting ? If the cells of a column are different widths, what are you going to do with the extra space of the narrower cells ?
    What are you displaying in the cells ? Maybe you can narrow the contents of the cells, and not the cells.

  • Dynamic resize of JButton and JFrame in response to Font

    Im supposed to increase the font size of the text with JButton by 1 within each click.
    Eventually the text becomes shorter and less visible like WORD becomes WOR... then WO... etc
    How to make the button always resize with text so that the text is fully visible and JFrame always resize with button so that the button doesn't change its position within the Frame ?
    edit:
    I managed to make buttons resize with increasing font
    by making
    JButton b = new JButton("button");
    b.setHorizontalTextPosition(CENTER);
    b.setVerticalTextPosition(CENTER);However the window size doesnt increase with components ;[
    any help would be appretiated.
    Edited by: pimpcane on Dec 11, 2007 12:16 PM

    Ok I managed to get it working moreless by
    adding pack() to the actionPerformed(...) function
    public void actionPerformed(ActionEvent e)
                 int index = Integer.parseInt(e.getActionCommand());
              int size = buttons[index].getFont().getSize();
              size++;
              buttons[index].setFont(new Font(name, style, size));
              pack();
    }The problem is in the task im given it is forbidden to use pack();
    Is there any other method to obtain the same result of JFrame resizing dynamically in response to components resize ?
    Edited by: pimpcane on Dec 12, 2007 12:13 PM
    Edited by: pimpcane on Dec 12, 2007 12:15 PM

  • Resize smaller not working for JTextArea

    I have a series of JTextAreas and JTextFields being added to a JPanel. The problem is I want them to always be the same size as the JPanel in the horizontal direction. This works fine for expanding the window, the JTextAreas and JTextFields expand with the panel to the edge, but then when I try to shrink the window the fields keep their maximum width as their width so when input is given to the field it does not word wrap until it has reached the edge of the maximum width rather than the current width.
    Here's the relevant code:
    JPanel rightSide = new JPanel();
           GridBagLayout gridBag = new GridBagLayout();
           GridBagConstraints constraints = new GridBagConstraints();
           rightSide.setLayout(gridBag);
           constraints.fill = GridBagConstraints.BOTH;
           rightSide.setBackground(BGCOLOR);
           Iterator iter = leafs.iterator();
           constraints.fill = GridBagConstraints.BOTH;
           constraints.weighty = 0.0;
           constraints.weightx = 1.0;
           constraints.gridwidth = GridBagConstraints.REMAINDER;
           while(iter.hasNext()){
             compare = (LeafItem)iter.next();
             textComponent =  compare.getComponent();
             //if the leaf needs a textArea put it in a scrollPane
             if(textComponent.getClass().equals(JScrollPane.class)){
               JLabel label = new JLabel(compare.getDescriptiveName());
               JTextArea textArea = new JTextArea();
               textArea.setLineWrap(true);
               textArea.setWrapStyleWord(true);
               if(HAS_BORDER)
              textArea.setBorder(blackline);
               gridBag.setConstraints(label, constraints);
               gridBag.setConstraints(textArea, constraints);         
               rightSide.add(label);
               rightSide.add(textArea);
             else{
               JLabel label = new JLabel(compare.getDescriptiveName());
               JTextField text = new JTextField();
               gridBag.setConstraints(label, constraints);
               gridBag.setConstraints(text, constraints);
               rightSide.add(label);
               rightSide.add(text);
           rightSide.setBorder
             (BorderFactory.createEmptyBorder(5, 10, 10, 10));
           JPanel remainder = new JPanel();
           remainder.setBackground(BGCOLOR);
           constraints.weighty = 1.0;
           constraints.weightx = 0.0;
           gridBag.setConstraints(remainder, constraints);
           rightSide.add(remainder);
           JScrollPane scrollPane = new JScrollPane
             (rightSide, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
              JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
           splitPane.setRightComponent(scrollPane);
         }

    I'm thinking it may be a bug with JSplitPane.Hm ... maybe our understanding of the JSplitPane is wrong in this context - I try to imagine, if it is normally needed, that components within one of this panes should be resized so that they fit the viewport. If I think about that, I have to say "normally not" - so, I guess, that is not a bug, it should be done in another way.
    Also I do not really understand, in which way you want them to be resized - if you shift the pane separator, the components should not be resized, or do you want them to be resized so that they fit the smaller viewport too?- And if you want them to resize, what if you hide one pane totally?-
    When asking myself this questions, it seems to me, that JSplitPane works correct the way it does it - the effect, you want, must be done in another way and also more specified, I guess.
    greetings Marsian

  • Drawing a picture within JFrame when I've already created a JFrame

    Hi everyone,
    I was wondering if you could help me out with this problem I'm getting. I'm creating a program to simulate an 'elevator.' When first creating the project I created a brand new 'Java GUI Form' : 'JFrame Form'. From here I went on to drag-and-drop various command buttons and labels to create the user interface (the 'inside' of an elevator). Here is where my question comes in. On the very left of my interface I want to have the program draw a simulation of a box (the elevator) moving up and down with the 'floor numbers' the user pushes. However i don't know how to access the coding of the jFrame object that I created through the design editor so i can input the coding.
    First Question: What do i have to 'write' that would force that box to print into the current JFrame?
    Second Question: What Code (and where do i put it) essentially 'locks' the JFrame from being resized?

    Here, maybe by putting this it might help you recognize what i'm trying to say. The code i'm trying to put in is:
    JFrame window = new JFrame ("Drawing");
            window.setBounds(200,200,700,500);
            window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            window.setVisible(true);
            Container contentPane = window.getContentPane();
            contentPane.setBackground(new Color(125, 125, 125));
            Graphics g = contentPane.getGraphics();* This is a portion of the code
    When run, this program creates a NEW JFRAME WINDOWS, i'm trying to make it run inside an already existing JFrame, whose variable Name i dont know how to find.

  • Unable to grow and shrink a JTable within a JScrollPane

    I need help with the following: I want to display a JTable component with a calendar like design. Dragging the size of the parent component (having a border to drag) should dynamically adapt the JTable' size and its cells. Since the JTable has a minimum size shrinking the parent component should show scrollbars if the minimum size is reached horizontal or vertical respectively.
    I have the JTable put ijnto the viewport of a scrollpane and the scrollpane is the child component of a JPanel. So dragging appears with the panel.
    The JTable cells do nicely but from a specific size on there is a grey area on the lower part of the JPanel which is not repainted. What is causing this? What do I have to do? I'm lost in the jungle of invalidate(), repaint(), update(), doLayout() etc.
    Here is my SSCCE (at least I hope it is one):
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.event.ComponentAdapter;
    import java.awt.event.ComponentEvent;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.ListSelectionModel;
    import javax.swing.UIManager;
    import javax.swing.table.AbstractTableModel;
    import javax.swing.table.TableColumn;
    import javax.swing.table.TableModel;
    //public class MyComponent extends JScrollPane
    public class MyComponent extends JPanel
    ///   class data
         static public final long serialVersionUID = -1L;
         static public final int c_ColWidth = 29;
         static public final int c_RowHeight = 18;
         static public final int c_TableWidth = 930;
         static public final int c_TableHeight = 234;
    ///   instance data
         private String[] m_strColHeader = {
              "01", "02", "03", "04", "05", "06", "07", "08", "09", "10",
              "11", "12", "13", "14", "15", "16", "17", "18", "19", "20",
              "21", "22", "23", "24", "25", "26", "27", "28", "29", "30",
              "31",
         private Object[][] m_Data = new Object[12][33];// data array
         private TableModel m_DataModel = new AbstractTableModel() {
              static public final long serialVersionUID = -1L;
              public int getColumnCount() { return m_strColHeader.length; }
              public int getRowCount() { return m_Data != null ? m_Data.length : 0; }
              public Object getValueAt(int row, int col) { return m_Data[row][col]; }
              public String getColumnName(int col) { return m_strColHeader[col]; }
              public Class getColumnClass(int col) { return String.class; }
              public boolean isCellEditable(int row, int col) { return false; }
              public void setValueAt(Object aValue, int row, int col) {
                   m_Data[row][col] = aValue;
         protected BorderLayout myLayout = new BorderLayout();
         protected JTable tableView = new JTable(m_DataModel);
         protected JScrollPane scrollPane = new JScrollPane(tableView);
    ///   public class methods
         static public void main(String[] args)
              try
                   UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
              catch(Exception e)
                   e.printStackTrace();
              MyComponent comp1 = new MyComponent();
              JFrame frame = new JFrame("MyComponent");
              frame.addWindowListener(new WindowAdapter() {
                   public void windowClosing(WindowEvent e) {
                        System.exit(0);
              frame.getContentPane().add(comp1);
              frame.pack();
              frame.setVisible(true);
    ///   constructors
         public MyComponent()
              try
                   jbInit();
                   initTable();
              catch(Exception ex)
                   ex.printStackTrace();
    ///   protected instance methods
         protected void initTable()
              // do nor allow user interaction with calendar view
              tableView.getTableHeader().setReorderingAllowed(false);
              tableView.getTableHeader().setResizingAllowed(false);
              //tableView.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
              tableView.setRowHeight(c_RowHeight);
              // adapt all CellRenderers
              for (int i = 0; i < m_DataModel.getColumnCount(); i++)
                   TableColumn column = tableView.getColumn(tableView.getColumnName(i));
                   column.setMinWidth(c_ColWidth);
                   column.setPreferredWidth(c_ColWidth);
    ///   private instance methods
         private void jbInit() throws Exception
              this.setLayout(myLayout);
              this.add(scrollPane, BorderLayout.CENTER);
              scrollPane.getViewport().setMinimumSize(new Dimension(c_TableWidth, c_TableHeight));
              scrollPane.getViewport().setPreferredSize(new Dimension(c_TableWidth, c_TableHeight));
              tableView.setPreferredSize(new Dimension(c_TableWidth, c_TableHeight));
              addComponentListener(new MyComponent_componentAdapter(this));
    ///   event handling
         public void componentBoundsChanged(ComponentEvent e)
              scrollPane.setBounds(0, 0, getWidth(), getHeight());
              scrollPane.getViewport().setBounds(0, 0, getWidth(), getHeight());
              //tableView.setBounds(0, 0, getWidth(), getHeight());
              tableView.setSize(scrollPane.getViewport().getWidth(), scrollPane.getViewport().getHeight());
              tableView.setRowHeight(getBounds().height / 13 < c_RowHeight ?
                        c_RowHeight : getBounds().height / 13);
              System.out.println("componentBoundsChanged: getBounds() = " + getBounds());
              System.out.println("componentBoundsChanged: getSize() = " + getSize());
              System.out.println("componentBoundsChanged: getViewport().getBounds() = " + scrollPane.getViewport().getBounds());
              System.out.println("componentBoundsChanged: getViewport().getSize() = " + scrollPane.getViewport().getSize());
              System.out.println("componentBoundsChanged: tableView.getBounds() = " + tableView.getBounds());
              System.out.println("componentBoundsChanged: tableView.getSize() = " + tableView.getSize());
    ///   event adapters
    class MyComponent_componentAdapter extends ComponentAdapter
         protected MyComponent adaptee;
         MyComponent_componentAdapter(MyComponent adaptee)
              this.adaptee = adaptee;
         public void componentMoved(ComponentEvent e)
              adaptee.componentBoundsChanged(e);
         public void componentResized(ComponentEvent e)
              adaptee.componentBoundsChanged(e);
    }

    I guess i am facing exactly opposite problem.
    What i want to do is, I have nested tables in a scroll pane. So I don't want a scroll pane to show exactly whatever visible rows are there in Table (No extra space). If i expand any row, i want scroll pane to be able to show expanded.

  • PSE7 ~ I'm inserting a .jpg image into a project, need to resize smaller and it ends up blurry!

    Please help!
    I am creating a birthday invitation for my daughter using PSE7.  I found a few .jpeg images on the web that I want to use.  The images should be okay size-wise (a 66kb image) when I try to insert this image onto the invitation (size of the invite is 5x7) - image takes up maybe 1/6th of overall invitation.  When I insert this image into the project, it is HUGE.  I need to resize it to reduce, but when I do for some reason it becomes very blurry.  I can't figure this out!  At the very least a 66kb image should be able to be inserted onto this 5x7 invitation as a 1" square and be crisp at that size??  Ugghh!
    I hope I am being clear in my request...the image in question is pictured below.  When this image is inserted into my PSE project, it would be about 2" high on a 5"x7" invitation...
    Also, when I save the whole invitation as a jpg for printing, it's only 120kb file size...shouldn't it be much larger?  Am I missing a global setting somewhere that's messing everything up??  Many thanks in advance to anybody offering suggestions...

    You're thinking in the wrong terms. You need to be focusing more on ppi (pixels per inch) rather than the file size in KB. Start by  making sure your main image is at 300 ppi (you may have to start over from scratch). If the graphics are now way too small when you bring them in, remove them and try a lower resolution, but you don't want to go below about 220 usually (it depends on your printer how low you can go and get away with it).
    Go to Image>Resize>Image size to check your invite's ppi, but my guess is that you started at something like 72 ppi. If you did, I'd start over, unless you have enough pixels that when you change the ppi to 300 (with Resample Image turned OFF) it's still large enough.

  • How does one loop playback of small selections within the timeline?

    How does one loop a selection of footage from within the timeline? I'm trying to edit students' tapping hands and pencils on desks into small timed chunks that will play back as seamless loops and I need to be able to slowly shorten or elongate sections of footage as it plays and repeates until the loop matches the timing of the song we are making. I'm using PE8 and can't seen to find an easy way to do this. Surely there is one! Is there?

    I appreciate the help everbody, but It looks like I didn't state my question effectively. Let me try again.
    It will be easier if I explain what it is I am used to. This is what I need to know how to do in PE8, because the school in which I teach AV has chosen PE8 for my classes and won't let me install anything else.
    In Sony Vegas - all versions, you can click and drag to quickly make a selection of video and audio. You can do this while video is rolling and you can then choose to have your A&V loop within this selection. I have seen replies on this forum where this feature within Vegas was treated as if it were a dumb thing. It's not dumb once you realize what it can be used to do for you. While continuing to loop within your slelection, you can move this selection throughout your timeline, rough tuning where you want your loop to be. If your loop needs to be exactly 66 frames, for instance, you could first set this selection at 66 frames and then move it up and down the timlene until you find the best place to cut. Or, in the case of trying to find where some sound within your selection makes a seamless loop, you can increase or decrease the size of your selection on the fly as the selection continues to repeat.
    How do you do that in PE8? If it can't do it, can the full version of Premiere?
    Thanks again for the help.
    -Chris

Maybe you are looking for

  • How to back up iTunes Library

    How do I back up my iTunes library to an external hard drive (my backup drive)?

  • Select data from an MS Access db?

    Can I use ODBC to select data from an MS Access Database from 'within' Oracle. For instance with SQL*Plus or within a stored procedure? If so, where can I find detailed documentation about how to do this. If not, is there another way?

  • KE5Z takes long time

    Hello Gurus, We have an issue. KE5Z report takes quite a long time to fetch the results. The porpblem is if I give the year as 2008 it would fetch the results in 7 secs. But for the same input parameters if i Give year as 2011 it takes 7 mins. I have

  • MacBook Pro Retina 13' 2015 [MF840] (rattle inside macbook)

    Hey people plz help! I have a prolem with my MacBook Pro MF840 Searching the way to solve my problem I visited few apple authorized stores in Ukraine, and I asked if I can try to shake new models MacBook Pro 13' (MF839, MF840, MF841) to find out if t

  • Splice audio from video then re-join

    This is going to be hard to describe but I'm just wondering if this is possible with iMovie in an easier way. I have 2 clips...one is text the other is video from my camera. I want the audio from the camera clip to play during the text clip and then