List of usage examples for java.awt CardLayout last
public void last(Container parent)
From source file:Tcpbw100.java
public void init() { //added applet parameters (country,language) to directly influence the language displayed if (getParameter("country") != null) country = getParameter("country"); if (getParameter("language") != null) lang = getParameter("language"); if (getParameter("client") != null) applet_id = getParameter("client"); // try to load the appropriate resource files try {//w w w. j ava2 s . c o m locale = new Locale(lang, country); System.out.println("Interface language set to " + locale.getLanguage() + "_" + locale.getCountry()); messages = ResourceBundle.getBundle("Tcpbw100_msgs", locale); res = ResourceBundle.getBundle("strings", locale); System.out.println("language loaded is :" + res.getLocale()); } catch (Exception e) { JOptionPane.showMessageDialog(null, "Error while loading language files:\n" + e.getMessage()); e.printStackTrace(); } JPanel advancedPanel = new JPanel(new BorderLayout()); final CardLayout cards = new CardLayout(); getContentPane().setLayout(cards); final JFrame popout = new JFrame("Network Diagnostic Tool"); popout.add(advancedPanel); popout.pack(); //blank the labels reset_labels(); showStatus(messages.getString("ready")); failed = false; Randomize = false; cancopy = false; results = new MyTextPane(); results.append("TCP/Web100 Network Diagnostic Tool v" + VERSION + "\n"); results.setEditable(false); advancedPanel.add(new JScrollPane(results), BorderLayout.CENTER); results.append(messages.getString("clickStart") + "\n"); Panel mPanel = new Panel(); startTest = new JButton(messages.getString("start")); startTest.addActionListener(this); startTest2 = new JButton(res.getString("start")); startTest2.addActionListener(this); //mPanel.add(startTest); sTatistics = new JButton(messages.getString("statistics")); sTatistics.addActionListener(this); if (getParameter("disableStatistics") == null) { mPanel.add(sTatistics); } sTatistics.setEnabled(false); deTails = new JButton(messages.getString("moreDetails")); deTails.addActionListener(this); if (getParameter("disableDetails") == null) { mPanel.add(deTails); } deTails.setEnabled(false); mailTo = new JButton(messages.getString("reportProblem")); mailTo.addActionListener(this); if (getParameter("disableMailto") == null) { //mPanel.add(mailTo); } mailTo.setEnabled(false); options = new JButton(messages.getString("options") + "..."); options.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { options.setEnabled(false); showOptions(); options.setEnabled(true); } }); if (getParameter("disableOptions") == null) { mPanel.add(options); } advancedPanel.add(mPanel, BorderLayout.SOUTH); preferIPv6 = new JCheckBox(messages.getString("preferIPv6")); preferIPv6.setSelected(true); defaultTest = new JCheckBox(messages.getString("defaultTests")); defaultTest.setSelected(true); defaultTest.setEnabled(false); SpinnerNumberModel model = new SpinnerNumberModel(); model.setMinimum(new Integer(0)); model.setValue(new Integer(1)); numOfTests.setModel(model); numOfTests.setPreferredSize(new Dimension(60, 20)); delay = new JComboBox(); for (int i = 0; i < delays.length; i++) { delay.addItem(messages.getString(delays[i])); } delay.setSelectedIndex(0); //Autorun functionality isAutoRun = getParameter("autoRun"); if ((isAutoRun != null) && isAutoRun.equals("true")) { pub_errmsg = "Test in progress."; runtest(); } //@@@ getContentPane().add(advancedPanel,""); //try to load the calibri font for the simplified interface. //this will not cause problems even if said font is not available Font very_small_font = new Font("Calibri", Font.PLAIN, 6); Font small_font = new Font("Calibri", Font.PLAIN, 14); Font big_font = new Font("Calibri", Font.PLAIN, 18); startTest2.setFont(small_font); //simplePanel will be the new face of the applet JPanel simplePanel = new JPanel(); simplePanel.setLayout(null); simplePanel.setBackground(Color.WHITE); //simplePanel.setLayout(new BorderLayout()); simplePanel.add(simple_progressBar, BorderLayout.SOUTH); getContentPane().add(simplePanel, ""); cards.last(getContentPane()); simple_progressBar.setMaximum(10); simple_progressBar.setBounds(3, 135, 394, 23); simple_progressBar.setFont(small_font); //simple_progressBar.setIndeterminate(true); simple_progressBar.setIndeterminate(false); simple_progressBar.setValue(0); simple_progressBar.setStringPainted(true); simple_progressBar.setString(res.getString("ready_to_measure")); //position the startTest2 button explicitly //was: simplePanel.add(startTest2,BorderLayout.NORTH); simplePanel.add(startTest2, ""); startTest2.setBounds(3, 164, 195, 30); final class switcherListener implements ActionListener { public void actionPerformed(ActionEvent e) { //@@@cards.next(getContentPane()); if (popout.isVisible()) { popout.setVisible(false); } else { popout.setVisible(true); popout.pack(); } } } //"show details button" - activates the classic NDT interface JButton switchPane = new JButton(res.getString("show_details")); switchPane.setFont(small_font); switchPane.addActionListener(new switcherListener()); simplePanel.add(switchPane, ""); switchPane.setBounds(202, 164, 195, 30); //masterArea, displays the measurement characteristics JPanel masterArea = new JPanel(new GridLayout(0, 2)); //position explicitly simplePanel.add(masterArea, ""); masterArea.setBounds(1, 1, 398, 130); masterArea.setBackground(Color.WHITE); //create the 5 tags that will be placed in the masterArea JLabel dnlTag = new JLabel(res.getString("download")); JLabel uplTag = new JLabel(res.getString("upload")); JLabel rttTag = new JLabel(res.getString("ping")); JLabel lossTag = new JLabel(res.getString("loss")); JLabel jitterTag = new JLabel(res.getString("jitter")); //make the masterAre pretty dnlTag.setHorizontalAlignment(JLabel.RIGHT); uplTag.setHorizontalAlignment(JLabel.RIGHT); rttTag.setHorizontalAlignment(JLabel.RIGHT); lossTag.setHorizontalAlignment(JLabel.RIGHT); jitterTag.setHorizontalAlignment(JLabel.RIGHT); dnlTag.setFont(big_font); uplTag.setFont(big_font); rttTag.setFont(big_font); lossTag.setFont(big_font); jitterTag.setFont(big_font); dnlLbl.setHorizontalAlignment(JLabel.LEFT); uplLbl.setHorizontalAlignment(JLabel.LEFT); rttLbl.setHorizontalAlignment(JLabel.LEFT); lossLbl.setHorizontalAlignment(JLabel.LEFT); jitterLbl.setHorizontalAlignment(JLabel.LEFT); dnlLbl.setFont(big_font); uplLbl.setFont(big_font); rttLbl.setFont(big_font); lossLbl.setFont(big_font); jitterLbl.setFont(big_font); //and finally, place the labels masterArea.add(dnlTag); masterArea.add(dnlLbl); masterArea.add(uplTag); masterArea.add(uplLbl); masterArea.add(rttTag); masterArea.add(rttLbl); masterArea.add(lossTag); masterArea.add(lossLbl); masterArea.add(jitterTag); masterArea.add(jitterLbl); // determine whether to prefer IPv6 or not, this is done only once if (getParameter("disable_ipv6") != null) { preferIPv6.setSelected(false); } }