// Set up the quiz window Quiz() { initializeData(); setTitle("FOSS Quiz App"); setDefaultCloseOperation(EXIT_ON_CLOSE); setSize(440, 400); setLocation(300, 100); setResizable(true); Container cont = getContentPane(); cont.setLayout(null); cont.setBackground(Color.WHITE); bg = new ButtonGroup(); choice1 = new JRadioButton("Choice1", true); choice2 = new JRadioButton("Choice2", false); choice3 = new JRadioButton("Choice3", false); choice4 = new JRadioButton("Choice4", false); bg.add(choice1); bg.add(choice2); bg.add(choice3); bg.add(choice4); lblmess = new JLabel("Choose a correct anwswer"); lblmess.setForeground(Color.BLACK); lblmess.setFont(new Font("Sans_Serif", Font.BOLD, 15)); btnext = new JButton("Next"); btnext.setForeground(Color.WHITE); btnext.setFont(new Font("Sans_Serif", Font.BOLD, 17)); btnext.setBackground(Color.DARK_GRAY); btnext.addActionListener(this); panel = new JPanel(); panel.setBackground(Color.WHITE); panel.setLocation(10, 60); panel.setSize(400, 300); panel.setLayout(new GridLayout(0, 1)); title = new JPanel(); title.setBackground(Color.WHITE); title.setLocation(10, 10); title.setSize(1000, 50); title.setLayout(new GridLayout(1, 0)); title.add(lblmess); panel.add(choice1); panel.add(choice2); panel.add(choice3); panel.add(choice4); panel.add(btnext); cont.add(title); cont.add(panel); setVisible(true); quizAnswerID = 0; readQuestionAnswer(quizAnswerID); }
private JPanel getJContentPane() { if (jContentPane == null) { jLabel6 = new JLabel(); jLabel6.setBounds(new Rectangle(11, 72, 218, 19)); jLabel6.setText("Install log directory:"); jLabel5 = new JLabel(); jLabel5.setBounds(new Rectangle(11, 2, 394, 26)); jLabel5.setText("Advanced Install. Please select your preferences"); ButtonGroup group = new ButtonGroup(); pathSuffix = new JTextArea(); pathSuffix.setBounds(new Rectangle(232, 48, 61, 21)); pathSuffix.setText("BIRCH"); jLabel4 = new JLabel(); jLabel4.setBounds(new Rectangle(22, 351, 312, 20)); jLabel4.setText("* - Automatically detected, recommended."); jLabel3 = new JLabel(); jLabel3.setBounds(new Rectangle(220, 48, 10, 21)); jLabel3.setText(" /"); jLabel2 = new JLabel(); jLabel2.setBounds(new Rectangle(18, 250, 132, 18)); jLabel2.setText("Binaries:"); jLabel1 = new JLabel(); jLabel1.setBounds(new Rectangle(11, 115, 127, 21)); jLabel1.setText("Framework Type:"); jLabel = new JLabel(); jLabel.setBounds(new Rectangle(11, 28, 131, 17)); jLabel.setText("Install directory:"); jContentPane = new JPanel(); jContentPane.setLayout(null); jContentPane.setSize(new Dimension(464, 376)); jContentPane.add(jLabel, null); jContentPane.add(getJButton(), null); jContentPane.add(getJTextArea(), null); jContentPane.add(jLabel3, null); jContentPane.add(pathSuffix, null); jContentPane.add(jLabel1, null); jContentPane.add(getJCheckBox(), null); jContentPane.add(getJCheckBox1(), null); jContentPane.add(jLabel2, null); jContentPane.add(getJCheckBox2(), null); jContentPane.add(getJCheckBox3(), null); jContentPane.add(getJCheckBox4(), null); jContentPane.add(getJCheckBox5(), null); jContentPane.add(getJCheckBox6(), null); jContentPane.add(getLogTextField(), null); jContentPane.add(getLogButton(), null); jContentPane.add(jLabel4, null); jContentPane.add(getWindows32Checkbox(), null); jContentPane.add(getJRadioButton(), null); jContentPane.add(jLabel5, null); jContentPane.add(jLabel6, null); jContentPane.add(getGitRadioButton(), null); jContentPane.add(getGitComboBox(), null); group.add(releaseRadioButton); group.add(developmentRadioButton); group.add(gitRadioButton); } return jContentPane; }
private JPanel createContentPane() { JPanel panel = new JPanel(); combo1 = new JComboBox<>(numData); panel.add(combo1); combo2 = new JComboBox<>(dayData); combo2.setEditable(true); panel.add(combo2); panel.setSize(300, 200); popupMenu = new JPopupMenu(); JMenuItem item; for (int i = 0; i < dayData.length; i++) { item = popupMenu.add(new JMenuItem(dayData[i], mnDayData[i])); item.addActionListener(this); } panel.addMouseListener(new PopupListener(popupMenu)); JTextField field = new JTextField("CTRL+down for Popup"); // CTRL-down will show the popup. field .getInputMap() .put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, InputEvent.CTRL_MASK), "OPEN_POPUP"); field.getActionMap().put("OPEN_POPUP", new PopupHandler()); panel.add(field); return panel; }
public void createProgressScreen() { exportingProgressContainer = new JPanel(); exportingProgressContainer.setSize(new Dimension(this.getWidth(), this.getHeight())); exportingProgressContainer.setLayout(new BorderLayout()); exportingProgressContainer.setBackground(UIHelper.BG_COLOR); exportingProgressContainer.add( UIHelper.wrapComponentInPanel(new JLabel(creatingArchiveAnimation, JLabel.CENTER)), BorderLayout.CENTER); exportingProgressContainer.add( UIHelper.wrapComponentInPanel(archiveOutputUtil.getArchiveOutputStatus()), BorderLayout.SOUTH); }
public BorderedComponent(String text, JComponent comp, boolean collapsible) { super(null); this.comp = comp; // Only add border if text is not null if (text != null) { TitledBorder border; if (collapsible) { final JLabel textLabel = new JLabel(text); JPanel borderLabel = new JPanel(new FlowLayout(FlowLayout.LEFT, 2, 0)) { public int getBaseline(int w, int h) { Dimension dim = textLabel.getPreferredSize(); return textLabel.getBaseline(dim.width, dim.height) + textLabel.getY(); } }; borderLabel.add(textLabel); border = new LabeledBorder(borderLabel); textLabel.setForeground(border.getTitleColor()); if (IS_WIN) { collapseIcon = new ImageIcon(getImage("collapse-winlf")); expandIcon = new ImageIcon(getImage("expand-winlf")); } else { collapseIcon = new ArrowIcon(SOUTH, textLabel); expandIcon = new ArrowIcon(EAST, textLabel); } moreOrLessButton = new JButton(collapseIcon); moreOrLessButton.setContentAreaFilled(false); moreOrLessButton.setBorderPainted(false); moreOrLessButton.setMargin(new Insets(0, 0, 0, 0)); moreOrLessButton.addActionListener(this); String toolTip = Messages.BORDERED_COMPONENT_MORE_OR_LESS_BUTTON_TOOLTIP; moreOrLessButton.setToolTipText(toolTip); borderLabel.add(moreOrLessButton); borderLabel.setSize(borderLabel.getPreferredSize()); add(borderLabel); } else { border = new TitledBorder(text); } setBorder(new CompoundBorder(new FocusBorder(this), border)); } else { setBorder(new FocusBorder(this)); } if (comp != null) { add(comp); } }
/** * Constructor del juego que inicializa los valores. * * @param juga * @param jugadorActual */ public Juego(ArrayList<Jugador> juga, Jugador jugadorActual) { jugadores = new ArrayList<>(); this.jugadores = juga; this.jugador = jugadorActual; loader = Juego.class.getClassLoader(); utilidades = new Util(); claseTime = new Time(); ventana = new JFrame("Concéntrese - Juan S."); ventana.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); ventana.setSize(520, 475); ventana.setLayout(null); ventana.setResizable(false); contadorJugadas = 0; cartaPorDefecto = new ImageIcon(loader.getResource("recursos/carta8.gif")); panel = new JPanel(); panel.setSize(300, 450); panel.setLayout(new GridLayout(4, 4)); intentos = new JLabel("Intento : 0"); etiquetaTiempoPartida = new JLabel("Tiempo: "); tiempoPartida = new JLabel("00.00.000"); etiquetaTiempoPartida.setFont(etiquetaTiempoPartida.getFont().deriveFont(20.0f)); tiempoPartida.setFont(tiempoPartida.getFont().deriveFont(20.0f)); intentos.setFont(intentos.getFont().deriveFont(20.0f)); intentos.setBounds(320, 50, 200, 30); tiempoPartida.setBounds(420, 5, 200, 30); etiquetaTiempoPartida.setBounds(320, 5, 200, 30); ventana.add(tiempoPartida); ventana.add(etiquetaTiempoPartida); ventana.add(intentos); ventana.add(panel); crearMenuSuperior(); crearMatrizIconos(); crearArrayBotones(); crearTemporizador(); ventana.setLocationRelativeTo(null); ventana.setVisible(true); }
protected void layout1280() { // Resolution of the camera pictures divided by 2 // 320x240, Creative camera for layout1280 size_x = 320 / 2; size_y = 240 / 2; sizeCaptureWindow_x = size_x * 2; sizeCaptureWindow_y = size_y * 2; imagepanels = new WebcamCaptureAndFadeImagePanel[4]; imagepanels[0] = new WebcamCaptureAndFadeImagePanel(3, 8, size_x, size_y); imagepanels[1] = new WebcamCaptureAndFadeImagePanel(2, 3, size_x, size_y); imagepanels[2] = new WebcamCaptureAndFadeImagePanel(2, 3, size_x, size_y); imagepanels[3] = new WebcamCaptureAndFadeImagePanel(3, 8, size_x, size_y); setLayout(new BorderLayout()); setSize((4 + 2 + 4) * size_x, (6) * size_y); add(imagepanels[0], BorderLayout.WEST); JPanel middle = new JPanel(new BorderLayout()); middle.add(imagepanels[1], BorderLayout.NORTH); if ((comp = player.getVisualComponent()) != null) { middle.add(comp, BorderLayout.CENTER); } middle.add(imagepanels[2], BorderLayout.SOUTH); middle.setSize(new Dimension(4 * size_x, 2 * size_y)); add(middle, BorderLayout.CENTER); add(imagepanels[3], BorderLayout.EAST); enable_datetext = false; enable_forceNewImage = false; captureWindow = false; txt_location_x = txt_location_y = 0; txt_size_x = 18; txt_size_y = size_y; }
// Constructor connection receiving a socket number public ClientGUI(String host, int port, int udpPort) { super("Clash of Clans"); defaultPort = port; defaultUDPPort = udpPort; defaultHost = host; // the server name and the port number JPanel serverAndPort = new JPanel(new GridLayout(1, 5, 1, 3)); tfServer = new JTextField(host); tfPort = new JTextField("" + port); tfPort.setHorizontalAlignment(SwingConstants.RIGHT); // CHAT COMPONENTS chatStatus = new JLabel("Please login first", SwingConstants.LEFT); chatField = new JTextField(18); chatField.setBackground(Color.WHITE); JPanel chatControls = new JPanel(); chatControls.add(chatStatus); chatControls.add(chatField); chatControls.setBounds(0, 0, 200, 50); chatArea = new JTextArea("Welcome to the Chat room\n", 80, 80); chatArea.setEditable(false); JScrollPane jsp = new JScrollPane(chatArea); jsp.setBounds(0, 50, 200, 550); JPanel chatPanel = new JPanel(null); chatPanel.setSize(1000, 600); chatPanel.add(chatControls); chatPanel.add(jsp); // LOGIN COMPONENTS mainLogin = new MainPanel(); mainLogin.add(new JLabel("Main Login")); usernameField = new JTextField("user", 15); passwordField = new JTextField("password", 15); login = new CButton("Login"); login.addActionListener(this); sideLogin = new SidePanel(new FlowLayout(FlowLayout.LEFT)); sideLogin.add(usernameField); sideLogin.add(passwordField); sideLogin.add(login); // MAIN MENU COMPONENTS mainMenu = new MainPanel(); mmLabel = new JLabel("Main Menu"); timer = new javax.swing.Timer(1000, this); mainMenu.add(mmLabel); sideMenu = new SidePanel(new FlowLayout(FlowLayout.LEFT)); cmButton = new CButton("Customize Map"); tmButton = new CButton("Troop Movement"); gsButton = new CButton("Game Start"); logout = new CButton("Logout"); cmButton.addActionListener(this); tmButton.addActionListener(this); gsButton.addActionListener(this); logout.addActionListener(this); sideMenu.add(cmButton); // sideMenu.add(tmButton); sideMenu.add(gsButton); sideMenu.add(logout); // CM COMPONENTS mainCM = new MainPanel(new GridLayout(mapSize, mapSize)); tiles = new Tile[mapSize][mapSize]; int tileSize = mainCM.getWidth() / mapSize; for (int i = 0; i < mapSize; i++) { tiles[i] = new Tile[mapSize]; for (int j = 0; j < mapSize; j++) { tiles[i][j] = new Tile(i, j); tiles[i][j].setPreferredSize(new Dimension(tileSize, tileSize)); tiles[i][j].setSize(tileSize, tileSize); tiles[i][j].addActionListener(this); if ((i + j) % 2 == 0) tiles[i][j].setBackground(new Color(102, 255, 51)); else tiles[i][j].setBackground(new Color(51, 204, 51)); mainCM.add(tiles[i][j]); } } sideCM = new SidePanel(new FlowLayout(FlowLayout.LEFT)); cmBack = new CButton("Main Menu"); cmBack.setSize(150, 30); cmBack.setPreferredSize(new Dimension(150, 30)); cmBack.addActionListener(this); sideCM.add(cmBack); // TM COMPONENTS mainTM = new MainPanel(null); mapTM = new Map(600); mapTM.setPreferredSize(new Dimension(600, 600)); mapTM.setSize(600, 600); mapTM.setBounds(0, 0, 600, 600); mainTM.add(mapTM); sideTM = new SidePanel(new FlowLayout(FlowLayout.LEFT)); tmBack = new CButton("Main Menu"); tmBack.setSize(150, 30); tmBack.setPreferredSize(new Dimension(150, 30)); tmBack.addActionListener(this); sideTM.add(tmBack); JRadioButton button; ButtonGroup group; ub = new ArrayList<JRadioButton>(); group = new ButtonGroup(); button = new JRadioButton("Barbarian"); button.addActionListener(this); ub.add(button); sideTM.add(button); group.add(button); button = new JRadioButton("Archer"); button.addActionListener(this); ub.add(button); sideTM.add(button); group.add(button); createBuildings(); bb = new ArrayList<JRadioButton>(); group = new ButtonGroup(); JRadioButton removeButton = new JRadioButton("Remove Building"); bb.add(removeButton); sideCM.add(removeButton); group.add(removeButton); for (int i = 0; i < bList.size(); i++) { button = new JRadioButton(bList.get(i).getName() + '-' + bList.get(i).getQuantity()); bb.add(button); sideCM.add(button); group.add(button); } mainPanels = new MainPanel(new CardLayout()); mainPanels.add(mainLogin, "Login"); mainPanels.add(mainMenu, "Menu"); mainPanels.add(mainCM, "CM"); mainPanels.add(mainTM, "TM"); sidePanels = new SidePanel(new CardLayout()); sidePanels.add(sideLogin, "Login"); sidePanels.add(sideMenu, "Menu"); sidePanels.add(sideCM, "CM"); sidePanels.add(sideTM, "TM"); JPanel mainPanel = new JPanel(null); mainPanel.setSize(1000, 600); mainPanel.add(sidePanels); mainPanel.add(mainPanels); mainPanel.add(chatPanel); add(mainPanel, BorderLayout.CENTER); try { setIconImage(ImageIO.read(new File("images/logo.png"))); } catch (IOException exc) { exc.printStackTrace(); } setDefaultCloseOperation(EXIT_ON_CLOSE); setSize(1000, 600); setVisible(true); setResizable(false); chatField.requestFocus(); }
void setupGUI() { taDictionary = new TextArea(); taDictionary.setLocation(0, 0); taDictionary.setSize(106, 567); taDictionary.setBackground(new Color(-1)); taDictionary.setText(""); taDictionary.setRows(5); taDictionary.setColumns(1); getContentPane().add(taDictionary); tfSourc = new TextField(); tfSourc.setLocation(224, 90); tfSourc.setSize(266, 25); tfSourc.setBackground(new Color(-1)); tfSourc.setText(""); tfSourc.setColumns(10); getContentPane().add(tfSourc); lblSourc = new Label(); lblSourc.setLocation(106, 90); lblSourc.setSize(119, 25); lblSourc.setText("Source Word:"); getContentPane().add(lblSourc); /* lblDestinatio = new Label(); lblDestinatio.setLocation(106,97); lblDestinatio.setSize(119,25); lblDestinatio.setText("Destination Wor"); getContentPane().add(lblDestinatio); */ lblDestinatio = new Label(); lblDestinatio.setLocation(106, 120); lblDestinatio.setSize(119, 25); lblDestinatio.setText("Destination Word:"); getContentPane().add(lblDestinatio); lblWordSize = new Label(); lblWordSize.setLocation(106, 27); // 106,120 lblWordSize.setSize(119, 25); lblWordSize.setText("Word Size:"); getContentPane().add(lblWordSize); tfWordSize = new TextField(); tfWordSize.setLocation(224, 27); // 224,120 tfWordSize.setSize(263, 25); tfWordSize.setBackground(new Color(-1)); tfWordSize.setText("5"); tfWordSize.setColumns(10); getContentPane().add(tfWordSize); tfSourc_6 = new TextField(); tfSourc_6.setLocation(226, 120); tfSourc_6.setSize(263, 25); tfSourc_6.setBackground(new Color(-1)); tfSourc_6.setText(""); tfSourc_6.setColumns(10); getContentPane().add(tfSourc_6); lblFileNam = new Label(); lblFileNam.setLocation(104, 0); lblFileNam.setSize(119, 25); lblFileNam.setText("FilePath:"); getContentPane().add(lblFileNam); tfFilePat = new TextField(); tfFilePat.setLocation(224, 0); tfFilePat.setSize(266, 25); tfFilePat.setBackground(new Color(-1)); // OS Detection if (System.getProperty("os.name").startsWith("Windows")) { // includes: Windows 2000, Windows 95, Windows 98, Windows NT, Windows Vista, Windows XP tfFilePat.setText("c:\\ics340\\words.txt"); System.out.println("Detected Windows: " + System.getProperty("os.name")); } else { tfFilePat.setText("/Users/jasonedstrom/ics340/d1.txt"); System.out.println("Detected Mac OS X: " + System.getProperty("os.name")); } tfFilePat.setColumns(10); getContentPane().add(tfFilePat); btLoadTextFiel = new JButton(); btLoadTextFiel.setLocation(108, 50); // 108,27 btLoadTextFiel.setSize(198, 32); btLoadTextFiel.setText("Load Words from Text Field"); getContentPane().add(btLoadTextFiel); btLoadFil = new JButton(); btLoadFil.setLocation(306, 50); // 306,27 btLoadFil.setSize(183, 32); btLoadFil.setText("Load Words from File"); getContentPane().add(btLoadFil); btFindPat = new JButton(); btFindPat.setLocation(106, 160); btFindPat.setSize(384, 38); btFindPat.setText("Find Path"); getContentPane().add(btFindPat); lblDictCoun = new JLabel(); lblDictCoun.setLocation(108, 513); lblDictCoun.setSize(300, 27); lblDictCoun.setForeground(new Color(-65536)); lblDictCoun.setText("Words in Dictionary = 0 words"); getContentPane().add(lblDictCoun); lblIndexing1 = new JLabel(); lblIndexing1.setLocation(107, 454); lblIndexing1.setSize(130, 27); lblIndexing1.setForeground(new Color(-16777216)); lblIndexing1.setText(""); getContentPane().add(lblIndexing1); lblFindPat = new JLabel(); lblFindPat.setLocation(108, 540); lblFindPat.setSize(250, 27); lblFindPat.setForeground(new Color(-14646771)); lblFindPat.setText("Time to find Path: 0 milliseconds"); getContentPane().add(lblFindPat); lblCos = new JLabel(); lblCos.setLocation(360, 540); lblCos.setSize(175, 27); lblCos.setForeground(new Color(-16777216)); lblCos.setText("Cost of Path: 0.0"); getContentPane().add(lblCos); lblProgres = new JLabel(); lblProgres.setLocation(108, 484); lblProgres.setSize(371, 26); lblProgres.setForeground(new Color(-14646771)); lblProgres.setText("Time to Build Graph: 0 milliseconds"); getContentPane().add(lblProgres); testpanel = new JPanel(); testpanel.setLocation(106, 200); testpanel.setSize(350, 200); testpanel.setForeground(new Color(-14646771)); // testpanel.setText("Test Location"); getContentPane().add(testpanel); btClear = new JButton(); btClear.setLocation(355, 513); btClear.setSize(125, 25); btClear.setText("Clear Results"); getContentPane().add(btClear); // add actionlisteners to buttons btFindPat.addActionListener(this); btLoadTextFiel.addActionListener(this); btLoadFil.addActionListener(this); btClear.addActionListener(this); setTitle("WordLadderGUI"); setSize(500, 600); setVisible(true); setResizable(false); }
/** * Create the JPanel to allow users to save the mappings created to be used in a proceeding * mapping activity! * * @return JLayeredPane containing the gui to allow a user to save the mapping file! */ private JLayeredPane createSaveMappings() { JPanel saveMappingFilesCont = new JPanel(); saveMappingFilesCont.setSize(new Dimension(400, 300)); saveMappingFilesCont.setLayout(new BoxLayout(saveMappingFilesCont, BoxLayout.PAGE_AXIS)); saveMappingFilesCont.add( UIHelper.wrapComponentInPanel(new JLabel(saveMappingHelp, SwingConstants.CENTER))); saveMappingFilesCont.add(Box.createVerticalStrut(10)); saveMappingFilesCont.add( UIHelper.wrapComponentInPanel( UIHelper.createLabel( "" + "<html>" + "Please be aware, the mappings saved are saved on a field by field basis. " + "This means that regardless of what assay you selected to do this/these mappings," + " common fields amongst all assays automatically inherit the mapping information. This has a number" + " of benefits and a number of negative points. " + "<br/>" + "<p>The <strong>main benefit</strong> being that common field mappings are transportable regardless of assay types.<p>" + "<p>The <strong>main problem</strong> is that because fields are saved on a field name basis, duplicate fields like" + " <strong>Protocol REF</strong> columns are not saved. This mechanism for saving will be changed in the next release!</p>" + "<br/>" + "<br/>" + "<br/>" + "</html>", UIHelper.VER_11_PLAIN, UIHelper.GREY_COLOR))); // create selector for mapping files JFileChooser chooser = new JFileChooser(); chooser.setDialogTitle("Choose where and what to save the file as..."); chooser.setApproveButtonText("Select file"); chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); JPanel selectMappingPanel = new JPanel(); selectMappingPanel.setLayout(new BoxLayout(selectMappingPanel, BoxLayout.PAGE_AXIS)); selectMappingPanel.setOpaque(false); // need a jcheckbox to ask users if they wish to use a mapping JPanel useMappingContainer = new JPanel(new BorderLayout()); useMappingContainer.setOpaque(false); final JPanel savedMappingsPanel = new JPanel(); savedMappingsPanel.setLayout(new BoxLayout(savedMappingsPanel, BoxLayout.PAGE_AXIS)); savedMappingsPanel.setOpaque(false); savedMappingsPanel.setVisible(false); final JLabel saveStatusInfo = UIHelper.createLabel("", UIHelper.VER_11_BOLD, UIHelper.GREY_COLOR); final FileSelectionPanel savedMappingsFile = new FileSelectionPanel( "<html>select <strong>where</strong> to save file and <strong>it's name</strong>: </html>", chooser, FileSelectionPanel.SAVE); final JCheckBox useMapping = new JCheckBox("save mapping?"); UIHelper.renderComponent(useMapping, UIHelper.VER_11_BOLD, UIHelper.GREY_COLOR, false); useMapping.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { savedMappingsPanel.setVisible(useMapping.isSelected()); saveStatusInfo.setText(""); } }); useMappingContainer.add(useMapping, BorderLayout.WEST); selectMappingPanel.add(useMappingContainer); // add button to save mappings final JLabel saveMappingsButton = new JLabel(saveMappingsButtonIcon); saveMappingsButton.setVerticalAlignment(JLabel.BOTTOM); saveMappingsButton.addMouseListener( new MouseAdapter() { public void mouseEntered(MouseEvent mouseEvent) { saveMappingsButton.setIcon(saveMappingsButtonIconOver); } public void mouseExited(MouseEvent mouseEvent) { saveMappingsButton.setIcon(saveMappingsButtonIcon); } public void mousePressed(MouseEvent mouseEvent) { // save the mapping MappingXMLCreator mappingCreator = new MappingXMLCreator(); try { if (useMapping.isSelected()) { if (!savedMappingsFile.getSelectedFilePath().equals("")) { nextButton.setEnabled(false); backButton.setEnabled(false); mappingCreator.createXMLFile( savedMappingsFile.getSelectedFilePath(), mappingsToSave, assaysToBeDefined); saveStatusInfo.setText("mappings saved successfully..."); } else { saveStatusInfo.setText("please select a file..."); } } } catch (FileNotFoundException e) { e.printStackTrace(); saveStatusInfo.setText("mappings not saved..." + e.getMessage()); } finally { nextButton.setEnabled(true); backButton.setEnabled(true); } } }); final JLayeredPane finalPanel = getGeneralLayout(saveMappingsHeader, breadcrumb7, "", saveMappingFilesCont, getHeight()); final MouseListener[] listeners = new MouseListener[2]; listeners[0] = new MouseAdapter() { public void mouseEntered(MouseEvent mouseEvent) { backButton.setIcon(backOver); } public void mouseExited(MouseEvent mouseEvent) { backButton.setIcon(back); } public void mousePressed(MouseEvent mouseEvent) { backButton.setIcon(back); saveStatusInfo.setText(""); SwingUtilities.invokeLater( new Runnable() { public void run() { HistoryComponent hc = previousPage.pop(); setCurrentPage(hc.getDisplayComponent()); assignListenerToLabel(backButton, hc.getListeners()[0]); assignListenerToLabel(nextButton, hc.getListeners()[1]); } }); } }; assignListenerToLabel(backButton, listeners[0]); listeners[1] = new MouseAdapter() { public void mouseEntered(MouseEvent mouseEvent) { nextButton.setIcon(nextOver); } public void mouseExited(MouseEvent mouseEvent) { nextButton.setIcon(next); } public void mousePressed(MouseEvent mouseEvent) { nextButton.setIcon(next); Thread performMappingLogic = new Thread( new Runnable() { public void run() { investigation = MappingLogic.createInvestigation( definitions, assaySelections, dataEntryEnvironment); // now we need to construct the investigation from the defined table // reference objects and the ApplicationManager.assignDataEntryToISASection( investigation, new InvestigationDataEntry(investigation, dataEntryEnvironment)); investigation.setConfigurationCreateWith( ApplicationManager.getCurrentApplicationInstance() .getLoadedConfiguration()); investigation.setLastConfigurationUsed( ApplicationManager.getCurrentApplicationInstance() .getLoadedConfiguration()); dataEntryEnvironment.createGUIFromInvestigation(investigation); previousPage.push(new HistoryComponent(finalPanel, listeners)); ApplicationManager.getCurrentApplicationInstance().hideGlassPane(); ApplicationManager.getCurrentApplicationInstance() .setCurDataEntryPanel(dataEntryEnvironment); ApplicationManager.getCurrentApplicationInstance() .setCurrentPage(dataEntryEnvironment); } }); setCurrentPage(workingProgressScreen); performMappingLogic.start(); } }; JPanel saveMappingsSection = new JPanel(); saveMappingsSection.setLayout(new BoxLayout(saveMappingsSection, BoxLayout.LINE_AXIS)); saveMappingsSection.add(savedMappingsFile); saveMappingsSection.add(Box.createHorizontalStrut(10)); JPanel saveButtonContainer = new JPanel(new BorderLayout()); saveButtonContainer.add(saveMappingsButton, BorderLayout.SOUTH); saveMappingsSection.add(UIHelper.wrapComponentInPanel(saveButtonContainer)); savedMappingsPanel.add(saveMappingsSection); selectMappingPanel.add(savedMappingsPanel); saveMappingFilesCont.add(selectMappingPanel); saveMappingFilesCont.add(UIHelper.wrapComponentInPanel(saveStatusInfo)); assignListenerToLabel(nextButton, listeners[1]); return finalPanel; }
/** * Create a visualization of the mapping showing what columns the file had and what isatab fields * each of these columns have been mapped to * * @param sequence - sequence of assay processing. * @param nameOfFileBeingMapped - name to save the mapping visualization as. * @param mapping - Mappings for each isatab file to the incoming column name(s) and any literals. * @return JLayeredPane containing the GUI to display the mapping visualization. */ private JLayeredPane createMappingVisualization( final int sequence, final String nameOfFileBeingMapped, Map<MappingField, List<String>> mapping) { JPanel visContainer = new JPanel(); visContainer.setLayout(new BoxLayout(visContainer, BoxLayout.PAGE_AXIS)); visContainer.setSize( new Dimension((int) (menuPanels.getWidth() * 0.80), (int) (menuPanels.getHeight() * 0.90))); Tree t = null; GenerateMappingView gmv = new GenerateMappingView(nameOfFileBeingMapped, mapping); File treeFile = gmv.generateView(); try { t = (Tree) new TreeMLReader().readGraph(treeFile); } catch (Exception e) { e.printStackTrace(); } // create a new treemap final TreeView tview = new TreeView( t, new Dimension( (int) (menuPanels.getWidth() * 0.80), (int) (menuPanels.getHeight() * 0.90))); tview.setBackground(UIHelper.BG_COLOR); tview.setForeground(UIHelper.GREY_COLOR); visContainer.add(tview); JLabel help_section = new JLabel(mappingVisualisationHelp); visContainer.add(help_section); ImageIcon crumb = ((sequence - 1) == -1) ? breadcrumb4 : breadcrumb6; final JLayeredPane finalPanel = getGeneralLayout(mappingOverviewHeader, crumb, "", visContainer, getHeight()); final MouseListener[] listeners = new MouseListener[2]; listeners[0] = new MouseAdapter() { public void mouseEntered(MouseEvent mouseEvent) { backButton.setIcon(backOver); } public void mouseExited(MouseEvent mouseEvent) { backButton.setIcon(back); } public void mousePressed(MouseEvent mouseEvent) { backButton.setIcon(back); SwingUtilities.invokeLater( new Runnable() { public void run() { HistoryComponent hc = previousPage.pop(); setCurrentPage(hc.getDisplayComponent()); assignListenerToLabel(backButton, hc.getListeners()[0]); assignListenerToLabel(nextButton, hc.getListeners()[1]); } }); } }; assignListenerToLabel(backButton, listeners[0]); listeners[1] = new MouseAdapter() { public void mouseEntered(MouseEvent mouseEvent) { nextButton.setIcon(nextOver); } public void mouseExited(MouseEvent mouseEvent) { nextButton.setIcon(next); } public void mousePressed(MouseEvent mouseEvent) { nextButton.setIcon(next); Thread performMappingProcess = new Thread( new Runnable() { public void run() { try { if (sequence <= assaysToBeDefined.size() - 1) { AssaySelection aso = assaysToBeDefined.get(sequence); String nextMeasurement = aso.getMeasurement(); String nextTechnology = aso.getTechnology(); setCurrentPage( createMappings( sequence, getTableReferenceObject(nextTechnology, nextMeasurement), fileColumns, nameOfFileBeingMapped, reader)); } else { setCurrentPage(createSaveMappings()); } } catch (BiffException e) { setCurrentPage(lastPage); log.error(e.getMessage()); } catch (IOException e) { setCurrentPage(lastPage); log.error(e.getMessage()); } catch (NoAvailableLoaderException e) { setCurrentPage(lastPage); log.error(e.getMessage()); } } }); lastPage = currentPage; setCurrentPage(workingProgressScreen); performMappingProcess.start(); } }; assignListenerToLabel(nextButton, listeners[1]); return finalPanel; }
/** * Create JPanel asking users to select the file or directory containing files to be mapped and an * existing mapping file if they have one. * * @return JPanel containing elements! */ private JLayeredPane createSelectFilesPanel() { // create overall panel final JPanel selectFilesContainer = new JPanel(); selectFilesContainer.setSize(new Dimension(400, 100)); selectFilesContainer.setLayout(new BoxLayout(selectFilesContainer, BoxLayout.PAGE_AXIS)); // create selector for mapping files final FileSelectionPanel fileToMapFSP = new FileSelectionPanel( "<html>please select file(s) to be mapped (txt, csv or xls (Excel). Please ensure " + "that this file has <b>no empty columns</b> and if possible, please remove any special characters, e.g. μ</html>", fileChooser); selectFilesContainer.add(fileToMapFSP); JPanel selectMappingPanel = new JPanel(); selectMappingPanel.setLayout(new BoxLayout(selectMappingPanel, BoxLayout.PAGE_AXIS)); selectMappingPanel.setOpaque(false); // need a jcheckbox to ask users if they wish to use a mapping JPanel useMappingContainer = new JPanel(new BorderLayout()); useMappingContainer.setOpaque(false); // need a file selection panel to select the file. JFileChooser mappingFileChooser = new JFileChooser(); mappingFileChooser.setDialogTitle("Choose mapping file (XML)"); mappingFileChooser.setApproveButtonText("select file"); mappingFileChooser.setFont(UIHelper.VER_11_PLAIN); mappingFileChooser.setFileFilter(new CustomizableFileFilter("xml")); final FileSelectionPanel savedMappingsFile = new FileSelectionPanel( "<html>please select saved mapping file (xml): </html>", mappingFileChooser); savedMappingsFile.setVisible(false); final JCheckBox useMapping = new JCheckBox("use a previous mapping?"); UIHelper.renderComponent(useMapping, UIHelper.VER_11_BOLD, UIHelper.GREY_COLOR, false); useMapping.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { savedMappingsFile.setVisible(useMapping.isSelected()); } }); useMappingContainer.add(useMapping, BorderLayout.WEST); selectMappingPanel.add(useMappingContainer); selectMappingPanel.add(savedMappingsFile); selectFilesContainer.add(selectMappingPanel); final RoundedJTextField rowOffset = new RoundedJTextField(3); rowOffset.setEnabled(false); rowOffset.setSize(new Dimension(20, 20)); rowOffset.setText("1"); final JCheckBox overrideRowPosition = new JCheckBox("override row start position?"); UIHelper.renderComponent(overrideRowPosition, UIHelper.VER_11_BOLD, UIHelper.GREY_COLOR, false); overrideRowPosition.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { rowOffset.setEnabled(overrideRowPosition.isSelected()); } }); Box fileInputPanel = Box.createHorizontalBox(); fileInputPanel.setSize(new Dimension(100, 20)); fileInputPanel.add(overrideRowPosition); fileInputPanel.add(Box.createHorizontalStrut(5)); fileInputPanel.add(rowOffset); selectFilesContainer.add(fileInputPanel); selectFilesContainer.add(selectMappingPanel); final JCheckBox mapToBlankFieldsCheckbox = new JCheckBox("Do not remove blank fields?", false); UIHelper.renderComponent( mapToBlankFieldsCheckbox, UIHelper.VER_11_BOLD, UIHelper.GREY_COLOR, false); mapToBlankFieldsCheckbox.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { mapToBlankFields = mapToBlankFieldsCheckbox.isSelected(); } }); JPanel removeBlanksContainer = new JPanel(new BorderLayout()); removeBlanksContainer.setOpaque(false); removeBlanksContainer.add(mapToBlankFieldsCheckbox, BorderLayout.WEST); selectFilesContainer.add(removeBlanksContainer); JPanel statusPanel = new JPanel(new GridLayout(1, 1)); statusPanel.setPreferredSize(new Dimension(400, 30)); final JLabel statusLab = UIHelper.createLabel("", UIHelper.VER_11_BOLD, UIHelper.RED_COLOR); statusPanel.add(statusLab); selectFilesContainer.add(statusPanel); final JLayeredPane finalLayout = getGeneralLayout(selectFilesHeader, breadcrumb1, "", selectFilesContainer, getHeight()); final MouseListener[] listeners = new MouseListener[2]; listeners[0] = new MouseAdapter() { public void mouseEntered(MouseEvent mouseEvent) { backButton.setIcon(backOver); } public void mouseExited(MouseEvent mouseEvent) { backButton.setIcon(back); } public void mousePressed(MouseEvent mouseEvent) { backButton.setIcon(back); SwingUtilities.invokeLater( new Runnable() { public void run() { ApplicationManager.getCurrentApplicationInstance().setCurrentPage(menuPanels); ApplicationManager.getCurrentApplicationInstance() .setGlassPanelContents(menuPanels.getCreateISAMenuGUI()); menuPanels.startAnimation(); } }); } }; assignListenerToLabel(backButton, listeners[0]); listeners[1] = new MouseAdapter() { public void mouseEntered(MouseEvent mouseEvent) { nextButton.setIcon(nextOver); } public void mouseExited(MouseEvent mouseEvent) { nextButton.setIcon(next); } public void mousePressed(MouseEvent mouseEvent) { nextButton.setIcon(next); Thread loadFile = new Thread( new Runnable() { public void run() { ISAcreatorProperties.setProperty( "isacreator.rowOffset", rowOffset.isEnabled() ? rowOffset.getText() : "1"); if (useMapping.isSelected()) { if (!savedMappingsFile.getSelectedFilePath().trim().equals("")) { MappingXMLLoader loader = new MappingXMLLoader(savedMappingsFile.getSelectedFilePath()); try { preExistingMapping = loader.loadMappings(); } catch (XmlException e) { log.error(e.getMessage()); statusLab.setText( "<html>problem found in xml for saved mapping: " + e.getMessage() + " </html>"); setCurrentPage(lastPage); return; } catch (IOException e) { log.error(e.getMessage()); statusLab.setText( "<html>problem found when resolving file for saved mapping: " + e.getMessage() + " </html>"); setCurrentPage(lastPage); return; } } else { statusLab.setText( "<html>please select a file containing previous mappings...</html>"); setCurrentPage(lastPage); return; } } else { log.info("Mapping is not selected"); statusLab.setText(""); } if (fileToMapFSP.notEmpty()) { previousPage.push(new HistoryComponent(finalLayout, listeners)); statusLab.setText(""); SwingUtilities.invokeLater( new Runnable() { public void run() { setCurrentPage( createAssayUsedPanel(fileToMapFSP.getSelectedFilePath())); } }); } else { statusLab.setText( "<html>please <strong>select</strong> a file to map!</html>"); setCurrentPage(lastPage); } } }); if (fileToMapFSP.notEmpty() && fileToMapFSP.checkFileExtensionValid("xls", "csv", "txt")) { statusLab.setText(""); lastPage = currentPage; setCurrentPage(workingProgressScreen); loadFile.start(); } else { statusLab.setText( "<html>please select a file with the extension <strong>.xls</strong>, <strong>.csv</strong> or <strong>.txt</strong>...</html>"); } } }; assignListenerToLabel(nextButton, listeners[1]); return finalLayout; }
public void launchChess() { mainWindow = new JFrame("网络黑白棋 作者:张炀"); jpWest = new JPanel(); jpEast = new JPanel(); jpNorth = new JPanel(); jpSouth = new JPanel(); jpCenter = new JPanel(); turnLabel = new JLabel(); blackNumberLabel = new JLabel("黑棋:\n" + black + " "); whiteNumberLabel = new JLabel("白棋:\n" + white + " "); timeLabel = new JLabel("时间: " + time + " s"); noticeLabel = new JLabel(); noticeLabel = new JLabel("请选择:"); numberPane = new JPanel(); readyPane = new JPanel(); jt1 = new JTextField(18); // 发送信息框 jt2 = new JTextArea(3, 30); // 显示信息框 js = new JScrollPane(jt2); jt2.setLineWrap(true); jt2.setEditable(false); // jt1.setLineWrap(true); send = new JButton("发送"); cancel = new JButton("取消"); regret = new JButton("悔棋"); submit = new JButton("退出"); begin = new JButton("开始"); save = new JButton("存盘"); save.setEnabled(true); begin.setEnabled(true); fighter = new JRadioButton("下棋"); audience = new JRadioButton("观看"); group = new ButtonGroup(); group.add(audience); group.add(fighter); group.add(AIPlayer); submit.addActionListener(this); begin.addActionListener(this); save.addActionListener(this); send.addActionListener(this); cancel.addActionListener(this); regret.addActionListener(this); fighter.addActionListener(this); audience.addActionListener(this); jpNorth.setLayout(new BorderLayout()); jpNorth.add(turnLabel, BorderLayout.NORTH); jpNorth.add(jpCenter, BorderLayout.CENTER); jpSouth.add(js); jpSouth.add(jt1); jpSouth.add(send); jpSouth.add(cancel); jpEast.setLayout(new GridLayout(3, 1)); submit.setBackground(new Color(130, 251, 241)); panel x = new panel(); jpEast.add(x); jpEast.add(numberPane); jpEast.add(readyPane); numberPane.add(blackNumberLabel); numberPane.add(whiteNumberLabel); numberPane.add(timeLabel); numberPane.add(submit); numberPane.add(begin); numberPane.add(save); numberPane.add(regret); readyPane.add(noticeLabel); readyPane.add(fighter); readyPane.add(audience); // readyPane.add(save); // readyPane.add(regret); jpCenter.setSize(400, 400); jmb = new JMenuBar(); document = new JMenu("游戏 "); edit = new JMenu("设置 "); insert = new JMenu("棋盘 "); help = new JMenu("帮助 "); jmb.add(document); jmb.add(edit); jmb.add(insert); jmb.add(help); // mainWindow.setJMenuBar(jmb); mainWindow.setBounds(80, 80, 600, 600); mainWindow.setResizable(false); jsLeft = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, jpNorth, jpSouth); jsBase = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, jsLeft, jpEast); mainWindow.add(jsBase); mainWindow.setVisible(true); mainWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jsBase.setDividerLocation(0.7); jsLeft.setDividerLocation(0.78); jpCenter.setLayout(new GridLayout(8, 8, 0, 0)); ImageIcon key = new ImageIcon("chess1.jpg"); for (int i = 0; i < cell.length; i++) for (int j = 0; j < cell.length; j++) { cell[i][j] = new ChessBoard(i, j); cell[i][j].addMouseListener(this); jpCenter.add(cell[i][j]); } cell[3][3].state = cell[4][4].state = '黑'; cell[4][3].state = cell[3][4].state = '白'; cell[3][3].taken = cell[4][4].taken = true; cell[4][3].taken = cell[3][4].taken = true; RememberState(); new Thread(new TurnLabel(this)).start(); file = new File("D:/" + myRole); try { fout = new FileOutputStream(file); out = new ObjectOutputStream(fout); } catch (IOException e1) { e1.printStackTrace(); } Connect(); try { out99 = new ObjectOutputStream(socket99.getOutputStream()); in99 = new ObjectInputStream(socket99.getInputStream()); out66 = new ObjectOutputStream(socket66.getOutputStream()); in66 = new ObjectInputStream(socket66.getInputStream()); out88 = new DataOutputStream(socket88.getOutputStream()); } catch (IOException e) { e.printStackTrace(); } new Thread(new Client9999(this)).start(); new Thread(new Client6666(this)).start(); }