zoukankan      html  css  js  c++  java
  • CardLayout实现分页效果

    因为人数过多,所以打算分成两页,之前我用的方法是建立两个panel,然后通过加载不同的panel来实现翻页的效果,无意中看到了cardlayout这个布局,发现用它来实现真是太容易了。

    首先,建立一个cardlayout布局对象:

       1:  out=new CardLayout();
       2:  this.getContentPane().setLayout(out);

    然后将这需要承载两个页面的panel加载两个页面就行了

       1:  this.getContentPane().add("panel1",panel);
       2:  this.getContentPane().add("panel2",panel2);

    要显示哪个就用show()方法就行了

       1:  MainFrame.this.out.show(MainFrame.this.getContentPane(), "panel2");
  • 相关阅读:
    Electron中git, npm,webpack使用
    Luogu_2061_[USACO07OPEN]城市的地平线City Horizon
    Luogu_1080_国王游戏
    Luogu_2878_[USACO07JAN]保护花朵Protecting the Flowers
    GYOJ_1812_股票(stock)
    JXJJOI2018_三题
    JXJJOI2018_T3_catch
    JXJJOI2018_T1_market
    JXJJOI2018_T2_tank
    Luogu_2876_[USACO07JAN]解决问题Problem Solving
  • 原文地址:https://www.cnblogs.com/wenning/p/2792593.html
Copyright © 2011-2022 走看看