【发布时间】:2015-02-19 14:19:06
【问题描述】:
package garage;
import java.awt.CardLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
/**
*
* @author Jela
*/
public class VehicleParts extends JPanel {
public VehicleParts() {
//super();
//JPanel container = new JPanel();
JPanel card1 = new JPanel();
JPanel card2 = new JPanel();
JButton buttonOne = new JButton("Parts");
JButton buttonTwo = new JButton("Stock");
JButton buttonThree = new JButton("Supplier");
add(buttonOne);
add(buttonTwo);
add(buttonThree);
}
}
当按下 buttonOne 时,它应该在同一帧上打开一个 jpanel,并且应该能够返回到该帧,但不知何故按钮没有显示出来。这不是我的主要课程。如果有人有一些提示,请帮助。它应该像这样工作
库存 |零件 |供应商 |
-
-
PANEL 1 -
-
-
-
-
"Previous" "NEXT" -
============================ 如果按下像下一步这样的按钮,它应该转到面板 2,在部件选项卡下
/* * 要更改此许可标头,请在项目属性中选择许可标头。 * 要更改此模板文件,请选择工具 |模板 * 并在编辑器中打开模板。 */ 这是我的主要课程 包车库;
import java.awt.CardLayout;
import java.awt.Dimension;
import javax.swing.*;
/**
*
* @author Jela
*/
public class Garage extends JPanel {
JFrame frame = new JFrame("Garage Management System");
final static JTabbedPane tabbedPane = new JTabbedPane();
JPanel panel = new JPanel();
final static CustomerAccounts customerPanel = new CustomerAccounts();
final static DiagnosisAndRepair diagnosisPanel = new DiagnosisAndRepair();
final static ScheduledMaintenance maintenancePanel = new ScheduledMaintenance();
final static VehicleParts partsPanel = new VehicleParts();
final static VehicleRecords recordsPanel = new VehicleRecords();
CardLayout cl = new CardLayout();
public Garage(){
tabbedPane.addTab("CustomerAccounts", customerPanel);
tabbedPane.addTab("DiagnosisAndRepair", diagnosisPanel);
tabbedPane.addTab("ScheduledMaintenance", maintenancePanel);
tabbedPane.addTab("VehicleParts", partsPanel);
tabbedPane.addTab("VehicleRecords", recordsPanel);
//add(tabbedPane);
frame.setSize(new Dimension(800,600));
frame.add(tabbedPane);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
public static void main(String[] args) {
Garage g = new Garage();
}
}
【问题讨论】:
标签: java jpanel cardlayout