dimevit
23-09-2007, 23:39
Hallo zusammen,
ich hab das folgende Prolem. Dem JSplitpane hab ich 2 panel zugewiesen. Rechts und Links. In beiden Panels hab ich Componenten wie Buttons usw usw. Nun will ich wenn ich auf einem Button clicken, dass die linke Panel verschwindet bzw.
JSplitpane.setDividerLocation( = 0 procent ) und wenn ich wider mal clicke dann
JSplitpane.setDividerLocation( = 40 procent )
Das Problem ist, dass er verkleinert die Linkeseite aber nur bis zur Größe der komponenten, und weiter kann er nicht. weiss jemand wie ich das machen kann
Hier ein kleiner beispiel:
public class SplitPaneSample {
public static void main(String args[]) {
JFrame vFrame = new JFrame("JSplitPane Sample");
vFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLO SE);
JSplitPane vSplitPane = new JSplitPane();
vSplitPane.setOrientation(JSplitPane.VERTICAL_SPLI T);
vFrame.getContentPane().add(vSplitPane, BorderLayout.CENTER);
vFrame.setSize(300, 150);
vFrame.setVisible(true);
JFrame hFrame = new JFrame("JSplitPane Sample");
JSplitPane hSplitPane = new JSplitPane();
JPanel panelRight = new JPanel(new GridLayout());
JButton hide = new JButton();
button.setText("Hide");
panelRight.add(hide);
JButton show= new JButton();
button1.setText("Show");
panel.add(show);
JPanel panelLeft = new JPanel(new GridLayout());
JButton buttonT = new JButton();
buttonT.setText("TEST");
panelLeft.add(buttonT);
JButton button1T = new JButton();
button1T.setText("TEST");
panelLeft.add(button1T);
button.addMouseListener(new HideSplitPanel(hSplitPane));
button1.addMouseListener(new ShowSpitPanel(hSplitPane));
hSplitPane.setRightComponent(panelRight);
hSplitPane.setLeftComponent(panelLeft);
hFrame.getContentPane().add(hSplitPane, BorderLayout.CENTER);
hFrame.setSize(300, 150);
hFrame.setVisible(true);
}
}
Danke,
Dime
ich hab das folgende Prolem. Dem JSplitpane hab ich 2 panel zugewiesen. Rechts und Links. In beiden Panels hab ich Componenten wie Buttons usw usw. Nun will ich wenn ich auf einem Button clicken, dass die linke Panel verschwindet bzw.
JSplitpane.setDividerLocation( = 0 procent ) und wenn ich wider mal clicke dann
JSplitpane.setDividerLocation( = 40 procent )
Das Problem ist, dass er verkleinert die Linkeseite aber nur bis zur Größe der komponenten, und weiter kann er nicht. weiss jemand wie ich das machen kann
Hier ein kleiner beispiel:
public class SplitPaneSample {
public static void main(String args[]) {
JFrame vFrame = new JFrame("JSplitPane Sample");
vFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLO SE);
JSplitPane vSplitPane = new JSplitPane();
vSplitPane.setOrientation(JSplitPane.VERTICAL_SPLI T);
vFrame.getContentPane().add(vSplitPane, BorderLayout.CENTER);
vFrame.setSize(300, 150);
vFrame.setVisible(true);
JFrame hFrame = new JFrame("JSplitPane Sample");
JSplitPane hSplitPane = new JSplitPane();
JPanel panelRight = new JPanel(new GridLayout());
JButton hide = new JButton();
button.setText("Hide");
panelRight.add(hide);
JButton show= new JButton();
button1.setText("Show");
panel.add(show);
JPanel panelLeft = new JPanel(new GridLayout());
JButton buttonT = new JButton();
buttonT.setText("TEST");
panelLeft.add(buttonT);
JButton button1T = new JButton();
button1T.setText("TEST");
panelLeft.add(button1T);
button.addMouseListener(new HideSplitPanel(hSplitPane));
button1.addMouseListener(new ShowSpitPanel(hSplitPane));
hSplitPane.setRightComponent(panelRight);
hSplitPane.setLeftComponent(panelLeft);
hFrame.getContentPane().add(hSplitPane, BorderLayout.CENTER);
hFrame.setSize(300, 150);
hFrame.setVisible(true);
}
}
Danke,
Dime