Results 1 to 7 of 7
Thread: add remove swing components
- 10-09-2008, 08:16 AM #1
Senior Member
- Join Date
- Dec 2007
- Location
- Spain
- Posts
- 570
- Rep Power
- 6
- 10-09-2008, 08:49 AM #2
Senior Member
- Join Date
- Aug 2008
- Posts
- 384
- Rep Power
- 5
it should work. Try setVisible(false) and setVisible(true) else.
I die a little on the inside...
Every time I get shot.
- 10-09-2008, 02:13 PM #3
Can you post a small, simple program that demonstrates what you are trying to do?
A JFrame with some panels and a button. Nothing else.
-
Agrees (again) with Norm. Why don't you show us in code, or if you can't do that with a screen capture, just exactly what it is you are trying to do. As a first guess though, I'd suggest you look into the CardLayout, a layout that allows you to swap JPanels (or any JComponent) as desired.
- 10-09-2008, 04:39 PM #5
Senior Member
- Join Date
- Dec 2007
- Location
- Spain
- Posts
- 570
- Rep Power
- 6
this actually did it
setVisible(false) and setVisible(true).
fieldPanel.setPreferredSize(new Dimension(40, 40));
fieldPanel.setLayout(new GridLayout(4,2));
//fieldPanel.setLayout(new BoxLayout(fieldPanel, BoxLayout.Y_AXIS));
fieldPanel.setAlignmentX(Component.LEFT_ALIGNMENT) ;
fieldPanel.add( new JLabel(" md1 "), BorderLayout.LINE_END);
fieldPanel.add(md0field, BorderLayout.CENTER);
fieldPanel.add( new JLabel(" md2 "), BorderLayout.LINE_END);
fieldPanel.add(md1field, BorderLayout.CENTER);
fieldPanel.add( new JLabel(" md3 "), BorderLayout.LINE_END);
fieldPanel.add(md2field, BorderLayout.CENTER);
fieldPanel.add( new JLabel(" delay"), BorderLayout.LINE_END);
fieldPanel.add(delayfield, BorderLayout.CENTER);
testPanel.add(fieldPanel);
So it concerns the fieldPanel
wrote at the constructor:
buildPanel();
drawPanel();
fieldPanel.setVisible(false);
At some button:
here is the result:Java Code:if (source == midipedalTest) { if (midipedalTest.isSelected()) { infoPane.setText(pedaltext); fieldPanel.setVisible(true); ed.md.setPedaldata0(Integer.parseInt(md0field.getText())); ed.md.setPedaldata1(Integer.parseInt(md1field.getText())); ed.md.setPedaldata2(Integer.parseInt(md2field.getText())); ed.setDelay(Integer.parseInt(delayfield.getText())); pedtest = new PedaltestThread(); pedtest.start(); } else { stoptest=true; fieldPanel.setVisible(false); synchronized (ed.md.getPedlock()){ // while in play thread waitloop sleeps ed.md.getPedlock().notify(); // notify the pedal test of fboController } } }
WILLEM DRAGSTRA WEB SITE
- 10-09-2008, 04:47 PM #6
Senior Member
- Join Date
- Dec 2007
- Location
- Spain
- Posts
- 570
- Rep Power
- 6
by the way supamagier I could not see your
games on my macbook because of this:
java.lang.UnsupportedClassVersionError: Bad version number in .class file
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java :620)
at java.security.SecureClassLoader.defineClass(Secure ClassLoader.java:124)
at sun.applet.AppletClassLoader.findClass(AppletClass Loader.java:177)
at java.lang.ClassLoader.loadClass(ClassLoader.java:3 06)
at sun.applet.AppletClassLoader.loadClass(AppletClass Loader.java:119)
at java.lang.ClassLoader.loadClass(ClassLoader.java:2 51)
at sun.applet.AppletClassLoader.loadCode(AppletClassL oader.java:605)
at sun.applet.AppletPanel.createApplet(AppletPanel.ja va:723)
at sun.plugin.AppletViewer.createApplet(AppletViewer. java:1861)
at jep.AppletFramePanel.createApplet(AppletFramePanel .java:189)
at sun.applet.AppletPanel.runLoader(AppletPanel.java: 652)
at sun.applet.AppletPanel.run(AppletPanel.java:326)
at jep.AppletFramePanel.run(AppletFramePanel.java:176 )
at java.lang.Thread.run(Thread.java:613)
- 10-09-2008, 07:37 PM #7
Similar Threads
-
Problem In Swing Components
By SANDY_INDIA in forum AWT / SwingReplies: 1Last Post: 07-19-2008, 10:23 PM -
Swing Components Placing
By ne2000 in forum EclipseReplies: 2Last Post: 06-23-2008, 08:00 AM -
Tab order on swing components
By ashvin@projectdemo.biz in forum AWT / SwingReplies: 1Last Post: 05-31-2008, 10:06 AM -
Where is it best to declare swing components?
By MacNstuff in forum AWT / SwingReplies: 1Last Post: 02-06-2008, 12:59 AM -
HTML on Swing Components
By Java Tip in forum Java TipReplies: 0Last Post: 11-27-2007, 09:51 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks