Results 1 to 9 of 9
Thread: Table for component
- 11-26-2010, 02:54 AM #1
Member
- Join Date
- Nov 2010
- Posts
- 6
- Rep Power
- 0
Table for component
Does somebody know how make a class which can show component in table which can increase component in this table by horizontally and vertically?
I try something but I have problem with set a size...
this class is inside class Tabulka (Table)
I am sorry but I am Czech and I writte this program by Czech... i hope you understand it...Java Code:private class ZmenaVelikostiHorizontalne { /** Prepážka, whitch is before */ private final Prepazka PREDCHOZI_PREPAZKA; /** Prepážka, whitch is now */ private final Prepazka SOUCASNA_PREPAZKA; private int muzeSeMaximalneRoztahnout; private final int muzeSeMinimalneZmensit = 10; private final Component soucasna; private final Component predchozi; /** x of mouse where user press*/ private int zacalNa; /**position where was Prepazka when user press the Prepazka*/ Point poziceSoucasne; private int sirkaPriZmacknutiSoucasne; private int sirkaPriZmacknutiPredchozi; private int ipadxSoucasnaStart; ZmenaVelikostiHorizontalne(Component c, Component predchozi, final Prepazka p, Prepazka predchoziPrepazka) { this.SOUCASNA_PREPAZKA=p; this.PREDCHOZI_PREPAZKA = predchoziPrepazka; this.soucasna = c; this.predchozi = predchozi; akctivateOfListeneru(p); } private void akctivateOfListeneru(Prepazka p) { p.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { zacalNa = MouseInfo.getPointerInfo().getLocation().x; sirkaPriZmacknutiSoucasne = soucasna.getSize().width;//gbl.getConstraints(soucasne).ipadx; sirkaPriZmacknutiPredchozi = predchozi.getSize().width;//gbl.getConstraints(predchozi).ipadx; poziceSoucasne=SOUCASNA_PREPAZKA.getLocation(); GridBagConstraints gbc = gbl.getConstraints(soucasna); ipadxSoucasnaStart=gbc.ipadx; } }); p.addMouseMotionListener(new MouseMotionAdapter() { @Override public void mouseDragged(MouseEvent e) { int xSoucasne = zacalNa- MouseInfo.getPointerInfo().getLocation().x; posunutiSoucasne(xSoucasne); setSize(); } }); } private void setSize(){ int predchoziX=0; if(PREDCHOZI_PREPAZKA!=null) predchoziX=PREDCHOZI_PREPAZKA.getPozice().x; int soucasnaX=SOUCASNA_PREPAZKA.getPozice().x; GridBagConstraints gbc = gbl.getConstraints(predchozi); int ipadxPredchozi=soucasnaX-predchoziX; if(ipadxPredchozi<predchozi.getPreferredSize().width) ipadxPredchozi=predchozi.getPreferredSize().width; gbc.ipadx=ipadxPredchozi; gbl.setConstraints(predchozi, gbc); int ipadxSoucasna=ipadxSoucasnaStart-ipadxPredchozi+sirkaPriZmacknutiPredchozi; if((ipadxSoucasna+soucasna.getSize().width)<soucasna.getPreferredSize().width) ipadxSoucasna=0; gbc = gbl.getConstraints(soucasna); gbc.ipadx=ipadxSoucasna; gbl.setConstraints(soucasna, gbc); soucasna.setMinimumSize(new java.awt.Dimension(ipadxSoucasna+soucasna.getPreferredSize().width,soucasna.getSize().width)); } /** * shift Prepazka depend on mouse * */ private void posunutiSoucasne(int o) { SOUCASNA_PREPAZKA.setLocation(poziceSoucasne.x-o,poziceSoucasne.y); } }Last edited by VojtechSejkora; 11-26-2010 at 03:00 AM.
-
I'm not sure that I fully understand your question, but perhaps you could use a JTable for your needs. You would likely need to create your own cell renderer and editor, but that's not too hard to do. For better help, consider posting the smallest compilable program that illustrates your problem.
- 11-26-2010, 04:06 AM #3
Member
- Join Date
- Nov 2010
- Posts
- 6
- Rep Power
- 0
And can I add to JTable for example JButton? I try it but it add only toString of this Component:(
-
As far as I understand it, when viewing a cell, you can render a JButton, and when editing the cell you can show a JButton. But the Swing tutorials can show this better than I can explain it.
Another option is to add a grid of JPanels to a container that uses GridLayout, and which is best for you will depend on your specific requirements.
- 11-26-2010, 04:48 AM #5
Member
- Join Date
- Nov 2010
- Posts
- 6
- Rep Power
- 0
when I would use GridLayout user could not set size of one component in row
he can widen only all component in panel... but I want to user could widen single component.
I hope you understand me...
- 11-26-2010, 04:49 AM #6
Take a look at this blog post by camickr:can I add to JTable for example JButton?
Table Button Column « Java Tips Weblog
db
- 11-26-2010, 05:03 AM #7
Member
- Join Date
- Nov 2010
- Posts
- 6
- Rep Power
- 0
nice.... but I don't know what I will add to this Tabulka before when I add. I can add Label,Panel,Button,Choice all what is descendant of Component....
- 11-26-2010, 05:18 AM #8
Member
- Join Date
- Nov 2010
- Posts
- 6
- Rep Power
- 0
I need this.
YouTube - a_Screen_Stream.avi
commentary is in czech, but i hole you understand what i need
- 11-28-2010, 12:23 AM #9
Member
- Join Date
- Nov 2010
- Posts
- 6
- Rep Power
- 0
Similar Threads
-
Cannot add component to JPanel
By adi.shoukat in forum NetBeansReplies: 7Last Post: 12-10-2010, 11:12 PM -
Component to use ?
By pbaudru in forum AWT / SwingReplies: 2Last Post: 02-17-2010, 09:55 AM -
How to repaint.refresh the table (table model) with combo box selection envent
By man4ish in forum AWT / SwingReplies: 1Last Post: 01-08-2010, 06:19 AM -
Last focused component
By Gajesh Tripathi in forum AWT / SwingReplies: 2Last Post: 11-21-2009, 05:45 PM -
add component to component
By Omarero in forum New To JavaReplies: 7Last Post: 05-17-2009, 02:39 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks