static void GoEnd(JFrame frame, int i) { Image background = new ImageIcon("image/final_" + i + ".png").getImage(); background = background.getScaledInstance(frame.getWidth(), frame.getHeight(), Image.SCALE_DEFAULT); JLabel back = new JLabel(); back.setBounds(0, 0, frame.getWidth(), frame.getHeight()); back.setIcon(new ImageIcon(background)); frame.add(back, 1); frame.validate(); frame.repaint(); if (i == 1) { // 烤好 Talk.say("你成功的通過了這學期", 1); Talk.say("這次經驗也讓你對學習產生濃烈的興趣", 1); Talk.say("讓你大四成為了神,進而順利畢業", 1); } else if (i == 2) { // 系館 Talk.say("經由你的捐贈", 1); Talk.say("資訊系逐漸自成一個校區", 1); Talk.say("而在原系館中庭擺放了一個十倍放大的銅像", 1); Talk.say("用來紀念資訊系傑出校友─大恩碩像", 1); } else if (i == 3) { // 出國 Talk.say("你放棄了學業,踏上了桌球國手之路", 1); Talk.say("過五關斬六將", 1); Talk.say("終於成為了世界桌球王", 1); } else if (i == 4) { // 0分 game over Talk.say("輕輕的我走了", 1); Talk.say("正如我輕輕地來", 1); Talk.say("我揮一揮衣袖", 1); Talk.say("不帶走任何學分", 1); } else if (i == 5) { // final Talk.say("你完成了final project", 1); Talk.say("跟其他同學一起過了OOP", 1); Talk.say("不過大四還有更嚴苛的挑戰在等著你", 1); Talk.say("同學!加油吧!", 1); } }
/** * @param filenames * @exception Exception if internal error */ public ChestImageViewer(String filenames[]) throws Exception { DisplayDeviceArea[] displayDeviceAreas = getPresentationAndImageDeviceAreas(); if (displayDeviceAreas == null) { System.err.println("Cannot determine device display areas"); } else { System.err.println("Found " + displayDeviceAreas.length + " device display areas"); for (int i = 0; i < displayDeviceAreas.length; ++i) { System.err.println("[" + i + "] = " + displayDeviceAreas[i]); displayDeviceAreas[i].getFrame().setBackground(Color.black); displayDeviceAreas[i].getFrame().setVisible(true); } { // Need to actually add something to the unused left display frame, else background will not // be set to black on Windows JPanel backgroundPanel = new JPanel(); backgroundPanel.setBackground(Color.black); displayDeviceAreas[0].getFrame().getContentPane().add(backgroundPanel); displayDeviceAreas[0].getFrame().validate(); } frame = displayDeviceAreas[1].getFrame(); Container content = frame.getContentPane(); content.setLayout(new GridLayout(1, 1)); multiPanel = new JPanel(); // multiPanel.setBackground(Color.black); frameWidth = (int) frame.getWidth(); frameHeight = (int) frame.getHeight(); Dimension d = new Dimension(frameWidth, frameHeight); // multiPanel.setSize(d); multiPanel.setPreferredSize(d); multiPanel.setBackground(Color.black); content.add(multiPanel); // frame.pack(); content.validate(); loadMultiPanelFromSpecifiedFiles(filenames); } }
// --------------------------------initGUI------------------------------------ public void initGUI() { bDeployed = bOpponentDeployed = false; listAT = new LinkedList(); frame.setJMenuBar(new GameMenuBar(this)); panParty = new PartyPanel(200, 480); panStatus = new JPanel(null); oMap = new Map(600, 350); panChat = new ChatPanel(600, 200); Container contentPane = frame.getContentPane(); panParty.setOpaque(true); panStatus.setOpaque(true); panChat.setOpaque(true); panStatus.setPreferredSize(new Dimension(200, 70)); contentPane.add(panStatus); contentPane.add(panParty); contentPane.add(oMap); contentPane.add(panChat); SpringLayout oLayout = new SpringLayout(); contentPane.setLayout(oLayout); oLayout.putConstraint(SpringLayout.WEST, panParty, 0, SpringLayout.WEST, contentPane); oLayout.putConstraint(SpringLayout.NORTH, panParty, 0, SpringLayout.NORTH, contentPane); oLayout.putConstraint(SpringLayout.WEST, panStatus, 0, SpringLayout.WEST, contentPane); oLayout.putConstraint(SpringLayout.SOUTH, panStatus, 0, SpringLayout.SOUTH, contentPane); oLayout.putConstraint(SpringLayout.EAST, oMap, 0, SpringLayout.EAST, contentPane); oLayout.putConstraint(SpringLayout.NORTH, oMap, 0, SpringLayout.NORTH, contentPane); oLayout.putConstraint(SpringLayout.WEST, panChat, 0, SpringLayout.EAST, panStatus); oLayout.putConstraint(SpringLayout.NORTH, panChat, 0, SpringLayout.SOUTH, oMap); oLayout.putConstraint(SpringLayout.EAST, contentPane, 0, SpringLayout.EAST, panChat); oLayout.putConstraint(SpringLayout.SOUTH, contentPane, 0, SpringLayout.SOUTH, panChat); panChat.validate(); panChat.setVisible(true); Insets oInsets = panStatus.getInsets(); int nX = oInsets.left + 5; int nY = oInsets.top + 5; lblStatus1 = new JLabel("Not Connected..."); lblStatus2 = new JLabel("No Party Formed..."); lblStatus3 = new JLabel(); Dimension oSize = lblStatus1.getPreferredSize(); lblStatus1.setBounds(nX, nY, 180, oSize.height); nY += oSize.height + 7; lblStatus2.setBounds(nX, nY, 180, oSize.height); nY += oSize.height + 7; lblStatus3.setBounds(nX, nY, 180, oSize.height); panStatus.add(lblStatus1); panStatus.add(lblStatus2); panStatus.add(lblStatus3); frame.pack(); frame.setResizable(false); frame.setLocation( ((scrBounds.x + scrBounds.width - frame.getWidth()) / 2), ((scrBounds.y + scrBounds.height - frame.getHeight()) / 2)); oMap.addKeyListener(oMap); oMap.setButtonEvents(this); }
private static void initGui() { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception exception) { exception.printStackTrace(); } JFrame frame = new JFrame("DarkBot"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new GridBagLayout()); Insets noInsets = new Insets(0, 0, 0, 0); final JToggleButton sessionsButton = new JToggleButton("Login (0)"); frame.add( sessionsButton, new GridBagConstraints( 0, 0, 2, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, noInsets, 0, 0)); sessionsButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { sessions.set(sessionsButton.isSelected()); synchronized (sessions) { sessions.notifyAll(); } } }); final JToggleButton joinsButton = new JToggleButton("Join (0)"); frame.add( joinsButton, new GridBagConstraints( 0, 1, 2, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, noInsets, 0, 0)); joinsButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { joins.set(joinsButton.isSelected()); synchronized (joins) { joins.notifyAll(); } } }); final JTextField field = new JTextField(); frame.add( field, new GridBagConstraints( 0, 2, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, noInsets, 0, 0)); final JButton button = new JButton("Start"); frame.add( button, new GridBagConstraints( 1, 2, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, noInsets, 0, 0)); button.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (button.getText().startsWith("Start")) { field.setEnabled(false); spamMessage = field.getText(); button.setText("Stop"); } else { spamMessage = null; button.setText("Start"); field.setEnabled(true); } } }); Timer timer = new Timer( 500, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { sessionsButton.setText( sessionsButton.getText().split(" ")[0] + " (" + Integer.toString(sessionCount.get()) + ")"); joinsButton.setText( joinsButton.getText().split(" ")[0] + " (" + Integer.toString(amountJoined.get()) + ")"); } }); timer.setRepeats(true); timer.start(); frame.pack(); frame.setSize(500, frame.getHeight()); frame.setLocationRelativeTo(null); frame.setVisible(true); }
/** * Inizialize frame components * * @throws CMSException * @throws FileNotFoundException * @throws IOException * @throws GeneralSecurityException */ private void initComponents() throws CMSException, FileNotFoundException, IOException, GeneralSecurityException { // ********************************* panel4 = new JPanel(); label2 = new JLabel(); textPane1 = new JTextPane(); panel5 = new JPanel(); textArea1 = new JTextArea(); textArea2 = new JTextArea(); progressBar = new JProgressBar(); textPane2 = new JTextPane(); textField1 = new JTextField(); button1 = new JButton(); panel6 = new JPanel(); button2 = new JButton(); button3 = new JButton(); button4 = new JButton(); GridBagConstraints gbc; // ======== this ======== Container contentPane = getContentPane(); contentPane.setLayout(new GridBagLayout()); ((GridBagLayout) contentPane.getLayout()).columnWidths = new int[] {165, 0, 0}; ((GridBagLayout) contentPane.getLayout()).rowHeights = new int[] {105, 50, 0}; ((GridBagLayout) contentPane.getLayout()).columnWeights = new double[] {0.0, 1.0, 1.0E-4}; ((GridBagLayout) contentPane.getLayout()).rowWeights = new double[] {1.0, 0.0, 1.0E-4}; // ======== panel4 ======== { panel4.setBackground(Color.white); panel4.setLayout(new GridBagLayout()); ((GridBagLayout) panel4.getLayout()).columnWidths = new int[] {160, 0}; ((GridBagLayout) panel4.getLayout()).rowHeights = new int[] {0, 0, 0}; ((GridBagLayout) panel4.getLayout()).columnWeights = new double[] {0.0, 1.0E-4}; ((GridBagLayout) panel4.getLayout()).rowWeights = new double[] {1.0, 1.0, 1.0E-4}; // ---- label2 ---- label2.setIcon( new ImageIcon( "images" + System.getProperty("file.separator") + "logo-freesigner-piccolo.png")); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets.bottom = 5; panel4.add(label2, gbc); // ---- textPane1 ---- textPane1.setFont(new Font("Verdana", Font.BOLD, 12)); textPane1.setText("Lettura\ncertificati\nda token"); textPane1.setEditable(false); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 1; gbc.anchor = GridBagConstraints.NORTHWEST; panel4.add(textPane1, gbc); } gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.fill = GridBagConstraints.BOTH; gbc.insets.bottom = 5; gbc.insets.right = 5; contentPane.add(panel4, gbc); // ======== panel5 ======== { panel5.setBackground(Color.white); panel5.setLayout(new GridBagLayout()); ((GridBagLayout) panel5.getLayout()).columnWidths = new int[] {0, 205, 0, 0}; ((GridBagLayout) panel5.getLayout()).rowHeights = new int[] {100, 0, 30, 30, 0}; ((GridBagLayout) panel5.getLayout()).columnWeights = new double[] {1.0, 0.0, 1.0, 1.0E-4}; ((GridBagLayout) panel5.getLayout()).rowWeights = new double[] {0.0, 0.0, 1.0, 1.0, 1.0E-4}; // ---- textArea1 ---- textArea1.setFont(new Font("Verdana", Font.BOLD, 14)); textArea1.setText("Lettura certificati da token"); textArea1.setEditable(false); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.gridwidth = 3; gbc.fill = GridBagConstraints.VERTICAL; gbc.insets.bottom = 5; panel5.add(textArea1, gbc); // ---- textArea2 ---- textArea2.setFont(new Font("Verdana", Font.PLAIN, 12)); textArea2.setText("Ricerca certificati...\n"); textArea2.setEditable(false); textArea2.setColumns(30); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 1; gbc.gridwidth = 3; gbc.fill = GridBagConstraints.BOTH; panel5.add(textArea2, gbc); progressBar.setValue(0); progressBar.setMaximum(1); progressBar.setStringPainted(true); progressBar.setBounds(0, 0, 300, 150); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 2; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets.bottom = 5; gbc.insets.right = 5; gbc.gridwidth = 3; panel5.add(progressBar, gbc); } gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 0; gbc.fill = GridBagConstraints.BOTH; gbc.insets.bottom = 5; contentPane.add(panel5, gbc); // ======== panel6 ======== { panel6.setBackground(Color.white); panel6.setLayout(new GridBagLayout()); ((GridBagLayout) panel6.getLayout()).columnWidths = new int[] {0, 0, 0, 0}; ((GridBagLayout) panel6.getLayout()).rowHeights = new int[] {0, 0}; ((GridBagLayout) panel6.getLayout()).columnWeights = new double[] {1.0, 1.0, 1.0, 1.0E-4}; ((GridBagLayout) panel6.getLayout()).rowWeights = new double[] {1.0, 1.0E-4}; // ---- button2 ---- button2.setText("Indietro"); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.insets.right = 5; button2.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { frame.hide(); FreeSignerSignApplet nuovo = new FreeSignerSignApplet(); } }); // panel6.add(button2, gbc); // ---- button4 ---- button4.setText("Annulla"); gbc = new GridBagConstraints(); gbc.gridx = 2; gbc.gridy = 0; // panel6.add(button4, gbc); } gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 1; gbc.fill = GridBagConstraints.BOTH; contentPane.add(panel6, gbc); contentPane.setBackground(Color.white); frame = new JFrame(); frame.setContentPane(contentPane); frame.setTitle("Freesigner"); frame.setSize(300, 150); frame.setResizable(false); frame.pack(); Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); frame.setLocation((d.width - frame.getWidth()) / 2, (d.height - frame.getHeight()) / 2); frame.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); timer = new Timer( 10, new ActionListener() { public void actionPerformed(ActionEvent evt) { frame.show(); if (task.getMessage() != null) { String s = new String(); s = task.getMessage(); s = s.substring(0, Math.min(60, s.length())); textArea2.setText(s + " "); progressBar.setValue(task.getStatus()); } if (task.isDone()) { timer.stop(); // Finalizzo la cryptoki, onde evitare // successivi errori PKCS11 "cryptoki alreadi initialized" if ((task != null)) task.libFinalize(); ArrayList slotInfos = task.getSlotInfos(); if ((slotInfos == null) || slotInfos.isEmpty()) { frame.show(); JOptionPane.showMessageDialog( frame, "Controllare la presenza sul sistema\n" + "della libreria PKCS11 impostata.", "Nessun lettore rilevato", JOptionPane.WARNING_MESSAGE); frame.hide(); } else { String st = task.getCRLerror(); if (st.length() > 0) { timer.stop(); JOptionPane.showMessageDialog( frame, "C'è stato un errore nella verifica CRL.\n" + st, "Errore verifica CRL", JOptionPane.ERROR_MESSAGE); frame.hide(); FreeSignerSignApplet nuovo = new FreeSignerSignApplet(); } if (task.getDifferentCerts() == 0) { if (task.getCIr() != null) { JOptionPane.showMessageDialog( frame, "La carta " + task.getCardDescription() + " nel lettore " + conf.getReader() + " non contiene certificati", "Attenzione", JOptionPane.WARNING_MESSAGE); } else JOptionPane.showMessageDialog( frame, task.getMessage(), "Errore:", JOptionPane.ERROR_MESSAGE); } frame.hide(); // confFrame.createTreeAndTokenNodes(task.getSlotInfos()); } } } }); }
/** * factory method to create and display box * * @param parent owner * @param actionList action sequence list */ public static void showActionSequence( JFrame parent, List actionList, oclTask curTask, oclDomain curDomain) { ActionSequence pw = new ActionSequence(parent, actionList, curTask, curDomain); pw.setLocation((int) (0.5 * parent.getWidth()), (int) (0.5 * parent.getHeight())); pw.show(); }