本帖最后由 zhaoxiatengkong_1 于 2010-01-08 15:55:11 编辑

解决方案 »

  1.   

    好像不行吧, 我要的是从east 到west 的那种垂直折叠面板  就是点击一下就靠边隐藏 再次点击就又出现的那种  我现在是为编写一个应用程序而需要的这种折叠式菜单  由于以前没做过  ,所以 希望哪位最好能给个示例的代码 
      

  2.   

    <FRAME name=divline src="divline.htm" noResize scrolling=no>
    divline.htm<html>
    <head>
    <title>divline</title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    </head>
    <STYLE type=text/css>.o1 {
    FONT-SIZE: 10px; COLOR: #ffffff; BACKGROUND-COLOR: #718bd6; TEXT-DECORATION: none
    }
    BODY {
    MARGIN: 0px; BACKGROUND-COLOR: #f6f6f6
    }
    </STYLE><SCRIPT language=javascript>
    <!--
    var iniCols, noCols, o_mf, o_ms, s;
    function ini() {
    o_mf = parent.document.getElementById("mainframe");
    o_ms = document.getElementById("menuSwitch");
    noCols = iniCols = o_mf.cols;
    if ((pos = noCols.indexOf(",")) != -1) {
    noCols = "0" + noCols.substring(pos);
    }
    s = false;
    }
    function changeLeft(){
    s = !s;
    o_mf.cols = s ? noCols : iniCols;
    o_ms.innerHTML = s ? "&#9658;" : "&#9668;";
    }
    //-->
    </SCRIPT><BODY onload=ini() >
    <TABLE height="100%" cellSpacing=0 cellPadding=0 width="100%"  style="BORDER-RIGHT: #4096ee 1px solid;BORDER-TOP: #4096ee 1px solid; Z-INDEX: 1; LEFT: 10px; BORDER-LEFT: #4096ee 1px solid;WIDTH: 10px; BORDER-BOTTOM: #4096ee 1px solid;">
      <TBODY>
      <TR>
        <TD><A class=o1 id=menuSwitch href="javascript:changeLeft();">&#9668;</A> 
      </TD></TR></TBODY></TABLE></BODY></HTML>
    楼主试试
      

  3.   

    是不是看起来这个样子?
    package test;import java.awt.BorderLayout;
    import java.awt.GridLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;public class TestDrawer extends JFrame implements ActionListener { private static final long serialVersionUID = 1L; public JButton btn1 = new JButton("TestBTN1"); public JButton btn2 = new JButton("TestBTN2"); public JButton btn3 = new JButton("TestBTN3"); public JLabel lab1 = new JLabel("TestLab1"); public JLabel lab2 = new JLabel("TestLab2"); public JLabel lab3 = new JLabel("TestLab3"); public JPanel panel = new JPanel(); public int i = 1; public TestDrawer() {
    init();
    } private void init() {
    this.setTitle("TestDrawer");
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.getContentPane().setLayout(new BorderLayout());
    this.getContentPane().add(getCenterPanel(), BorderLayout.CENTER);
    this.pack();
    this.setVisible(true);
    } private JPanel getCenterPanel() {
    panel.setLayout(new GridLayout(3, 1));
    panel.add(btn1);
    panel.add(btn2);
    panel.add(btn3);
    btn1.addActionListener(this);
    btn2.addActionListener(this);
    btn3.addActionListener(this);
    return panel;
    } public void actionPerformed(ActionEvent e) {
    if (e.getSource().equals(btn1)) {
    i++;
    if (i % 2 == 0) {
    panel.setLayout(new GridLayout(4, 1));
    panel.removeAll();
    panel.add(btn1);
    panel.add(lab1);
    panel.add(btn2);
    panel.add(btn3);
    } else {
    panel.setLayout(new GridLayout(3, 1));
    panel.removeAll();
    panel.add(btn1);
    panel.add(btn2);
    panel.add(btn3);
    }
    panel.validate();
    panel.repaint();
    }
    } /**
     * @param args
     */
    public static void main(String[] args) {
    new TestDrawer();
    }
    }
      

  4.   

    什么gui?
    b/s的话用JavaScript+css好做,Google “js tab”很多,也有JavaScript框架有现成的。
    c/s的话用swing咯
      

  5.   

    谢谢 各位的帮助  我想要实现的是想 VS2008 那个IDE里当要编程GUI时,要用到的工具箱差不多功能的折叠式面板,就是, 我点击一下就把这工具箱的整个面板给隐藏了,再次点击,则又弹了出来  急切得到高人的帮助, 在线等!!!!!!!
      

  6.   

    [code]http://www.open-open.com/open92161.htm
    看一下这个吧![/code]
      

  7.   

    http://www.open-open.com/open92161.htm
      

  8.   

    难道真的没人用JAVA做过这个类似折叠式的面板???  请高人指点!!! 急需帮助, 项目要到期了, 在线等!!!!!!!!!
      

  9.   

    MigLayout 布局管理器支持将某个部件隐藏.
    Example Code:import net.miginfocom.swing.MigLayout;import javax.swing.*;
    import java.awt.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;/**
    * @author Skjalg Bjorndal
    */
    public class MigFrame extends JFrame {    final JButton button1 = new JButton("Hello World");
        final JButton button2 = new JButton("Hello There");
        final JButton button3 = new JButton("Hello Again");
        final JButton button4 = new JButton("Hello 4 U");
        public MigFrame(boolean hideButton4) {
            setPreferredSize(new Dimension(600, 400));
            initGUI(hideButton4);
        }    private void initGUI(boolean hideButton4) {
            JPanel panel = new JPanel(new MigLayout("fill, hidemode 3, nocache, debug"));
            getContentPane().add(panel);
            panel.add(createButtonPanel(), "dock south");
            panel.add(button1, "dock west, growx");
            panel.add(button2, "dock west");
            JPanel panelClient = new JPanel(new MigLayout("flowy, fill"));
            panelClient.add(button3, "dock north, growy");
            if (!hideButton4) {
                panelClient.add(button4, "growy, dock south");
                setLocation(620, 200);
            } else {
                setLocation(10, 200);
            }
            panel.add(panelClient, "dock west, growx");        pack();
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);    }    JPanel createButtonPanel() {
            JPanel panel = new JPanel(new MigLayout());
            JToggleButton hideButton = new JToggleButton("Hide");
            hideButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    button1.setVisible(!button1.isVisible());
                    button4.setVisible(!button4.isVisible());
                    getContentPane().validate();
                }
            });
            panel.add(hideButton);
            return panel;
        }    public static void main(String[] args) {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    final MigFrame fm = new MigFrame(true);
                    fm.setVisible(true);
                    final MigFrame fm2 = new MigFrame(false);
                    fm2.setVisible(true);
                }
            });
        }
    }
      

  10.   

    我估计是把不同的布局综合在一起用,单一的布局是不能实现这个功能的。
    我还有个疑问,层一般是网页中用到的术语,如果你是编网页,没必要用全java,可以用dreamveawer来实现层,在层中插入applet等java程序也未尝不可
      

  11.   

    怎么提示找不到软件包:import net.miginfocom.swing.MigLayout; 这个在java类库中有吗???  怎么解决???
      

  12.   

    从这个连接下载
    http://www.migcalendar.com/miglayout/versions/3.7.2/