private void setMiddle() { Point point = owner.getLocationOnScreen(); int x = point.x; int y = point.y; int width = (int) ((owner.getWidth() - this.getWidth()) / 2); int height = (int) ((owner.getHeight() - this.getHeight()) / 2); this.setLocation(x + width, y + height); }
@Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub width = frame.getWidth(); height = frame.getHeight(); sizeControl.width = width; sizeControl.height = height; if (info.pressed == true && !showGuide) { showGuide = true; } if (back.pressed == true && showGuide) { showGuide = false; } go.x = width / 2; go.y = height / 2; info.x = width / 2; info.y = height / 2 + 150; back.x = 3 * width / 4; back.y = height / 2 + 150; for (int i = 0; i < boomList.size(); i++) { boomList.get(i).updatePosition(); if (Integer.parseInt(boomList.get(i).toString()) <= 0) { boomList.remove(i); } else { for (int ii = 0; ii < gravList.size(); ii++) { gravList.get(ii).pull(boomList.get(i)); if (boomList.get(i).collide(gravList.get(ii))) { boomList.remove(i); } } } } count--; if (count <= 0) { double rand1 = Math.random(); double rand2 = Math.random(); for (int ii = 0; ii < num; ii++) { boomList.add(new boom(rand1 * width, rand2 * height)); } count = delay; } repaint(); }
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); } }
public static void main(String args[]) { Component comp = new Component(); System.out.println("Mineblock Development Console: "); System.out.println("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"); System.out.println("Current Version: " + versionNumber); frame = new JFrame(); frame.add(comp); frame.pack(); realSize = new Dimension(frame.getWidth(), frame.getHeight()); frame.setTitle(name + versionNumber); frame.setResizable(true); frame.setLocationRelativeTo(null); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); comp.start(); }
/** * @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); } }
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(); }
static String[] input(int d, int m, int y) { // input frame for schedule String[] out = new String[4]; // appointment info storage final String[] doctors = {"Dr. Whitehead", "Dr. Namie", "Dr. Liddell"}; final JFrame input = new JFrame("Make Appointment"); Container pane1; JPanel pan = new JPanel(null); JLabel doctor = new JLabel("Choose your Doctor:"); JLabel da = new JLabel("Date:"); /*JLabel day=new JLabel(Integer.toString(d)); JLabel mo=new JLabel("Month:"); JLabel month=new JLabel(Integer.toString(m)); JLabel ye=new JLabel("Year:"); JLabel year=new JLabel(Integer.toString(y));*/ JLabel time = new JLabel("Appointment Time:"); JButton submit = new JButton("Submit"); docName = new JComboBox(doctors); JSpinner timeSpinner = new JSpinner(new SpinnerDateModel()); JSpinner.DateEditor timeEditor = new JSpinner.DateEditor(timeSpinner, "hh:mm a"); timeSpinner.setEditor(timeEditor); timeSpinner.setValue(new Date()); JSpinner dateSpinner = new JSpinner(new SpinnerDateModel()); JSpinner.DateEditor dateEditor = new JSpinner.DateEditor(dateSpinner, "MMM/dd/yyyy"); dateSpinner.setEditor(dateEditor); dateSpinner.setValue(new Date()); input.setSize(330, 375); // Set size to 400x400 pixels pane1 = input.getContentPane(); pane1.setLayout(null); // Apply null layout pan.setLayout(new GridLayout(4, 2, 20, 50)); pane1.setSize((int) (input.getHeight() / 2), (int) (input.getWidth() / 2)); pane1.setLocation( input.getHeight() - ((int) (input.getHeight() / 2)), input.getWidth() - ((int) (input.getWidth() / 2))); // trying to center failed input.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); // Close when X is clicked pane1.add(pan); // pan.add(ye); // pan.add(year); pan.add(da); pan.add(dateSpinner); pan.add(time); pan.add(timeSpinner); pan.add(doctor); pan.add(docName); pan.add(submit); submit.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { fmain.setVisible(true); input.setVisible(false); } }); pan.setBounds(0, 0, 320, 335); input.setResizable(false); input.setVisible(true); return out; }