List of usage examples for javax.swing BorderFactory createLineBorder
public static Border createLineBorder(Color color, int thickness)
From source file:org.kchine.rpf.PoolUtils.java
public static String cacheJar(URL url, String location, int logInfo, boolean forced) throws Exception { final String jarName = url.toString().substring(url.toString().lastIndexOf("/") + 1); if (!location.endsWith("/") && !location.endsWith("\\")) location += "/"; String fileName = location + jarName; new File(location).mkdirs(); final JTextArea area = ((logInfo & LOG_PRGRESS_TO_DIALOG) != 0) ? new JTextArea() : null; final JProgressBar jpb = ((logInfo & LOG_PRGRESS_TO_DIALOG) != 0) ? new JProgressBar(0, 100) : null; final JFrame f = ((logInfo & LOG_PRGRESS_TO_DIALOG) != 0) ? new JFrame("copying " + jarName + " ...") : null;/*from w w w .jav a2s. c o m*/ try { ResponseCache.setDefault(null); URLConnection urlC = null; Exception connectionException = null; for (int i = 0; i < RECONNECTION_RETRIAL_NBR; ++i) { try { urlC = url.openConnection(); connectionException = null; break; } catch (Exception e) { connectionException = e; } } if (connectionException != null) throw connectionException; InputStream is = url.openStream(); File file = new File(fileName); long urlLastModified = urlC.getLastModified(); if (!forced) { boolean somethingToDo = !file.exists() || file.lastModified() < urlLastModified || (file.length() != urlC.getContentLength() && !isValidJar(fileName)); if (!somethingToDo) return fileName; } if ((logInfo & LOG_PRGRESS_TO_DIALOG) != 0) { Runnable runnable = new Runnable() { public void run() { try { f.setUndecorated(true); f.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); area.setEditable(false); area.setForeground(Color.white); area.setBackground(new Color(0x00, 0x80, 0x80)); jpb.setIndeterminate(true); jpb.setForeground(Color.white); jpb.setBackground(new Color(0x00, 0x80, 0x80)); JPanel p = new JPanel(new BorderLayout()); p.setBorder(BorderFactory.createLineBorder(Color.black, 3)); p.setBackground(new Color(0x00, 0x80, 0x80)); p.add(jpb, BorderLayout.SOUTH); p.add(area, BorderLayout.CENTER); f.add(p); f.pack(); f.setSize(300, 80); locateInScreenCenter(f); f.setVisible(true); System.out.println("here"); } catch (Exception e) { e.printStackTrace(); } } }; if (SwingUtilities.isEventDispatchThread()) runnable.run(); else { SwingUtilities.invokeLater(runnable); } } if ((logInfo & LOG_PRGRESS_TO_SYSTEM_OUT) != 0) { System.out.println("Downloading " + jarName + ":"); System.out.print("expected:==================================================\ndone :"); } if ((logInfo & LOG_PRGRESS_TO_LOGGER) != 0) { log.info("Downloading " + jarName + ":"); } int jarSize = urlC.getContentLength(); int currentPercentage = 0; FileOutputStream fos = null; fos = new FileOutputStream(fileName); int count = 0; int printcounter = 0; byte data[] = new byte[BUFFER_SIZE]; int co = 0; while ((co = is.read(data, 0, BUFFER_SIZE)) != -1) { fos.write(data, 0, co); count = count + co; int expected = (50 * count / jarSize); while (printcounter < expected) { if ((logInfo & LOG_PRGRESS_TO_SYSTEM_OUT) != 0) { System.out.print("="); } if ((logInfo & LOG_PRGRESS_TO_LOGGER) != 0) { log.info((int) (100 * count / jarSize) + "% done."); } ++printcounter; } if ((logInfo & LOG_PRGRESS_TO_DIALOG) != 0) { final int p = (int) (100 * count / jarSize); if (p > currentPercentage) { currentPercentage = p; final JTextArea fa = area; final JProgressBar fjpb = jpb; SwingUtilities.invokeLater(new Runnable() { public void run() { fjpb.setIndeterminate(false); fjpb.setValue(p); fa.setText("Copying " + jarName + " ..." + "\n" + p + "%" + " Done. "); } }); SwingUtilities.invokeLater(new Runnable() { public void run() { fa.setCaretPosition(fa.getText().length()); fa.repaint(); fjpb.repaint(); } }); } } } /* * while ((oneChar = is.read()) != -1) { fos.write(oneChar); * count++; * * final int p = (int) (100 * count / jarSize); if (p > * currentPercentage) { System.out.print(p+" % "); currentPercentage = * p; if (showProgress) { final JTextArea fa = area; final * JProgressBar fjpb = jpb; SwingUtilities.invokeLater(new * Runnable() { public void run() { fjpb.setIndeterminate(false); * fjpb.setValue(p); fa.setText("\n" + p + "%" + " Done "); } }); * * SwingUtilities.invokeLater(new Runnable() { public void run() { * fa.setCaretPosition(fa.getText().length()); fa.repaint(); * fjpb.repaint(); } }); } else { if (p%2==0) System.out.print("="); } } * } * */ is.close(); fos.close(); } catch (MalformedURLException e) { System.err.println(e.toString()); throw e; } catch (IOException e) { System.err.println(e.toString()); } finally { if ((logInfo & LOG_PRGRESS_TO_DIALOG) != 0) { f.dispose(); } if ((logInfo & LOG_PRGRESS_TO_SYSTEM_OUT) != 0) { System.out.println("\n 100% of " + jarName + " has been downloaded \n"); } if ((logInfo & LOG_PRGRESS_TO_LOGGER) != 0) { log.info(" 100% of " + jarName + " has been downloaded"); } } return fileName; }
From source file:Gui.MainGuiBuilder.java
private void NewPasswordBtnMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_NewPasswordBtnMouseClicked // TODO add your handling code here: String newPass = MonCompteNewPass.getText(); if (newPass.length() == 0 && newPass.length() < 4) { MonCompteNewPass.setBorder(BorderFactory.createLineBorder(Color.RED, 2)); msgChangePassword.setVisible(true); msgChangePassword.setText("le password doit tre de 4 caractres ou plus."); MonCompteNewPass.setText(""); msgChangePassword.setVisible(false); } else {//from ww w. j av a2s .c om appUser.setPassword(newPass); uService.updateUser(appUser); MonCompteNewPass.setText(""); logout(); } }
From source file:org.colombbus.tangara.EditorFrame.java
/** * This method initializes cmdButtonPanel * * @return javax.swing.JPanel// w w w. j a v a 2 s . com */ private JPanel getCmdButtonPanel() { if (cmdButtonPanel == null) { GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); gridBagConstraints1.insets = new Insets(4, 9, 18, 4); gridBagConstraints1.gridy = 1; gridBagConstraints1.ipadx = 60; gridBagConstraints1.ipady = -1; gridBagConstraints1.gridx = 0; GridBagConstraints gridBagConstraints = new GridBagConstraints(); gridBagConstraints.insets = new Insets(16, 9, 4, 4); gridBagConstraints.gridy = 0; gridBagConstraints.ipadx = 49; gridBagConstraints.ipady = -1; gridBagConstraints.gridx = 0; cmdButtonPanel = new JPanel(); cmdButtonPanel.setBackground(new Color(197, 214, 219));//Color(156, 199, 213)); cmdButtonPanel.setBorder(BorderFactory.createLineBorder(new Color(102, 102, 102), 1)); cmdButtonPanel.setPreferredSize(new Dimension(150, 140)); cmdButtonPanel.setLayout(new GridBagLayout()); cmdButtonPanel.add(getCmdRunButton(), gridBagConstraints); cmdButtonPanel.add(getRefreshButton(), gridBagConstraints1); } return cmdButtonPanel; }
From source file:Clavis.Windows.WShedule.java
public synchronized void create() { initComponents();// ww w.j a v a2 s . c o m this.setModal(true); this.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { close(); } }); this.setTitle(lingua.translate("Registos de emprstimo para o recurso") + ": " + lingua.translate(mat.getTypeOfMaterialName()).toLowerCase() + " " + lingua.translate(mat.getDescription())); KeyQuest.addtoPropertyListener(jPanelInicial, true); String dat = new TimeDate.Date().toString(); String[] auxiliar = prefs.get("datainicio", dat).split("/"); if (auxiliar[0].length() > 1) { if (auxiliar[0].charAt(0) == '0') { auxiliar[0] = auxiliar[0].replaceFirst("0", ""); } } if (auxiliar[1].length() > 1) { if (auxiliar[1].charAt(0) == '0') { auxiliar[1] = auxiliar[1].replaceFirst("0", ""); } } if (auxiliar[2].length() > 1) { if (auxiliar[2].charAt(0) == '0') { auxiliar[2] = auxiliar[2].replaceFirst("0", ""); } } inicio = new TimeDate.Date(Integer.valueOf(auxiliar[0]), Integer.valueOf(auxiliar[1]), Integer.valueOf(auxiliar[2])); auxiliar = prefs.get("datafim", dat).split("/"); if (auxiliar[0].length() > 1) { if (auxiliar[0].charAt(0) == '0') { auxiliar[0] = auxiliar[0].replaceFirst("0", ""); } } if (auxiliar[1].length() > 1) { if (auxiliar[1].charAt(0) == '0') { auxiliar[1] = auxiliar[1].replaceFirst("0", ""); } } if (auxiliar[2].length() > 1) { if (auxiliar[2].charAt(0) == '0') { auxiliar[2] = auxiliar[2].replaceFirst("0", ""); } } fim = new TimeDate.Date(Integer.valueOf(auxiliar[0]), Integer.valueOf(auxiliar[1]), Integer.valueOf(auxiliar[2])); SimpleDateFormat sdf = new SimpleDateFormat("dd/M/yyyy"); Date date; try { date = sdf.parse(fim.toString()); } catch (ParseException ex) { date = new Date(); } jXDatePickerFim.setDate(date); try { date = sdf.parse(inicio.toString()); } catch (ParseException ex) { date = new Date(); } jXDatePickerInicio.setDate(date); andamento = 0; if (DataBase.DataBase.testConnection(url)) { DataBase.DataBase db = new DataBase.DataBase(url); java.util.List<Keys.Request> requisicoes = Clavis.RequestList .simplifyRequests(db.getRequestsByMaterialByDateInterval(mat, inicio, fim)); db.close(); estado = lingua.translate("Todos"); DefaultTableModel modelo = (DefaultTableModel) jTable1.getModel(); if (requisicoes.size() > 0) { valores = new String[requisicoes.size()][4]; lista = new java.util.ArrayList<>(); requisicoes.stream().map((req) -> { if (mat.getMaterialTypeID() == 1) { valores[andamento][0] = req.getPerson().getName(); valores[andamento][1] = req.getTimeBegin().toString(0) + " - " + req.getTimeEnd().toString(0); valores[andamento][2] = req.getBeginDate().toString(); String[] multipla = req.getActivity().split(":::"); if (multipla.length > 1) { Components.PopUpMenu pop = new Components.PopUpMenu(multipla, lingua); pop.create(); jTable1.addMouseListener(new MouseAdapter() { int x = andamento; int y = 3; @Override public void mousePressed(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { int row = jTable1.rowAtPoint(e.getPoint()); int col = jTable1.columnAtPoint(e.getPoint()); if ((row == x) && (col == y)) { pop.show(e.getComponent(), e.getX(), e.getY()); } } } @Override public void mouseReleased(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { if (pop.isShowing()) { pop.setVisible(false); } } } }); valores[andamento][3] = lingua.translate(multipla[0]) + ""; } else { valores[andamento][3] = lingua.translate(req.getActivity()); } if (valores[andamento][3].equals("")) { valores[andamento][3] = lingua.translate("Sem descrio"); } Object[] ob = { req.getPerson().getName(), req.getTimeBegin().toString(0) + " - " + req.getTimeEnd().toString(0), req.getBeginDate().toString(), valores[andamento][3], req.getSubject().getName() }; modelo.addRow(ob); } else { valores[andamento][0] = req.getPerson().getName(); valores[andamento][1] = req.getBeginDate().toString(); valores[andamento][2] = req.getEndDate().toString(); String[] multipla = req.getActivity().split(":::"); if (multipla.length > 1) { Components.PopUpMenu pop = new Components.PopUpMenu(multipla, lingua); pop.create(); jTable1.addMouseListener(new MouseAdapter() { int x = andamento; int y = 3; @Override public void mousePressed(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { int row = jTable1.rowAtPoint(e.getPoint()); int col = jTable1.columnAtPoint(e.getPoint()); if ((row == x) && (col == y)) { pop.show(e.getComponent(), e.getX(), e.getY()); } } } @Override public void mouseReleased(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { if (pop.isShowing()) { pop.setVisible(false); } } } }); valores[andamento][3] = multipla[0]; } else { valores[andamento][3] = lingua.translate(req.getActivity()); } if (valores[andamento][3].equals("")) { valores[andamento][3] = lingua.translate("Sem descrio"); } Object[] ob = { req.getPerson().getName(), req.getBeginDate().toString(), req.getEndDate().toString(), valores[andamento][3] }; modelo.addRow(ob); } return req; }).map((req) -> { lista.add(req); return req; }).forEach((_item) -> { andamento++; }); } } jComboBoxEstado.setSelectedIndex(prefs.getInt("comboboxvalue", 0)); String[] opcoes = { lingua.translate("Ver detalhes da requisio"), lingua.translate("Ver requisices com a mesma data"), lingua.translate("Ver requisices com o mesmo estado") }; ActionListener[] eventos = new ActionListener[opcoes.length]; eventos[0] = (ActionEvent r) -> { Border border = BorderFactory.createCompoundBorder( BorderFactory.createCompoundBorder(new org.jdesktop.swingx.border.DropShadowBorder(Color.BLACK, 3, 0.5f, 6, false, false, true, true), BorderFactory.createLineBorder(Color.BLACK, 1)), BorderFactory.createEmptyBorder(0, 10, 0, 10)); int val = jTable1.getSelectedRow(); Keys.Request req = lista.get(val); javax.swing.JPanel pan = new javax.swing.JPanel(null); pan.setPreferredSize(new Dimension(500, 300)); pan.setBounds(0, 20, 500, 400); pan.setBackground(Components.MessagePane.BACKGROUND_COLOR); javax.swing.JLabel lrecurso1 = new javax.swing.JLabel(lingua.translate("Recurso") + ": "); lrecurso1.setBounds(10, 20, 120, 26); lrecurso1.setFocusable(true); lrecurso1.setHorizontalAlignment(javax.swing.JLabel.LEFT); pan.add(lrecurso1); javax.swing.JLabel lrecurso11 = new javax.swing.JLabel( lingua.translate(req.getMaterial().getTypeOfMaterialName()) + " " + lingua.translate(req.getMaterial().getDescription())); lrecurso11.setBounds(140, 20, 330, 26); lrecurso11.setBorder(border); pan.add(lrecurso11); javax.swing.JLabel lrecurso2 = new javax.swing.JLabel(lingua.translate("Utilizador") + ": "); lrecurso2.setBounds(10, 50, 120, 26); lrecurso2.setFocusable(true); lrecurso2.setHorizontalAlignment(javax.swing.JLabel.LEFT); pan.add(lrecurso2); javax.swing.JLabel lrecurso22 = new javax.swing.JLabel(req.getPerson().getName()); lrecurso22.setBounds(140, 50, 330, 26); lrecurso22.setBorder(border); pan.add(lrecurso22); javax.swing.JLabel lrecurso3 = new javax.swing.JLabel(lingua.translate("Data inicial") + ": "); lrecurso3.setBounds(10, 80, 120, 26); lrecurso3.setFocusable(true); lrecurso3.setHorizontalAlignment(javax.swing.JLabel.LEFT); pan.add(lrecurso3); javax.swing.JLabel lrecurso33 = new javax.swing.JLabel( req.getBeginDate().toStringWithMonthWord(lingua)); lrecurso33.setBounds(140, 80, 330, 26); lrecurso33.setBorder(border); pan.add(lrecurso33); javax.swing.JLabel lrecurso4 = new javax.swing.JLabel(lingua.translate("Data final") + ": "); lrecurso4.setBounds(10, 110, 120, 26); lrecurso4.setFocusable(true); lrecurso4.setHorizontalAlignment(javax.swing.JLabel.LEFT); pan.add(lrecurso4); javax.swing.JLabel lrecurso44 = new javax.swing.JLabel(req.getEndDate().toStringWithMonthWord(lingua)); lrecurso44.setBounds(140, 110, 330, 26); lrecurso44.setBorder(border); pan.add(lrecurso44); javax.swing.JLabel lrecurso5 = new javax.swing.JLabel(lingua.translate("Atividade") + ": "); lrecurso5.setBounds(10, 140, 120, 26); lrecurso5.setFocusable(true); lrecurso5.setHorizontalAlignment(javax.swing.JLabel.LEFT); pan.add(lrecurso5); javax.swing.JLabel lrecurso55; if (req.getActivity().equals("")) { lrecurso55 = new javax.swing.JLabel(lingua.translate("Sem descrio")); } else { String[] saux = req.getActivity().split(":::"); String atividade; boolean situacao = false; if (saux.length > 1) { situacao = true; atividade = saux[0]; } else { atividade = req.getActivity(); } if (req.getSubject().getId() > 0) { lrecurso55 = new javax.swing.JLabel( lingua.translate(atividade) + ": " + req.getSubject().getName()); } else { lrecurso55 = new javax.swing.JLabel(lingua.translate(atividade)); } if (situacao) { Components.PopUpMenu pop = new Components.PopUpMenu(saux, lingua); pop.create(); lrecurso55.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { pop.show(e.getComponent(), e.getX(), e.getY()); } @Override public void mouseExited(MouseEvent e) { pop.setVisible(false); } }); } } lrecurso55.setBounds(140, 140, 330, 26); lrecurso55.setBorder(border); pan.add(lrecurso55); int distancia = 170; if (req.getBeginDate().isBigger(req.getEndDate()) == 0) { javax.swing.JLabel lrecurso6 = new javax.swing.JLabel(lingua.translate("Horrio") + ": "); lrecurso6.setBounds(10, distancia, 120, 26); lrecurso6.setFocusable(true); lrecurso6.setHorizontalAlignment(javax.swing.JLabel.LEFT); pan.add(lrecurso6); javax.swing.JLabel lrecurso66 = new javax.swing.JLabel( req.getTimeBegin().toString(0) + " - " + req.getTimeEnd().toString(0)); lrecurso66.setBounds(140, distancia, 330, 26); lrecurso66.setBorder(border); pan.add(lrecurso66); distancia = 200; } if (req.getBeginDate().isBigger(req.getEndDate()) == 0) { javax.swing.JLabel lrecurso7 = new javax.swing.JLabel(lingua.translate("Dia da semana") + ": "); lrecurso7.setBounds(10, distancia, 120, 26); lrecurso7.setFocusable(true); lrecurso7.setHorizontalAlignment(javax.swing.JLabel.LEFT); pan.add(lrecurso7); javax.swing.JLabel lrecurso77 = new javax.swing.JLabel( lingua.translate(req.getWeekDay().perDayName())); lrecurso77.setBounds(140, distancia, 330, 26); lrecurso77.setBorder(border); pan.add(lrecurso77); if (distancia == 200) { distancia = 230; } else { distancia = 200; } } if (req.isTerminated() || req.isActive()) { javax.swing.JLabel lrecurso8 = new javax.swing.JLabel(lingua.translate("Levantamento") + ": "); lrecurso8.setBounds(10, distancia, 120, 26); lrecurso8.setFocusable(true); lrecurso8.setHorizontalAlignment(javax.swing.JLabel.LEFT); pan.add(lrecurso8); javax.swing.JLabel lrecurso88; if ((req.getLiftDate() != null) && (req.getLiftTime() != null)) { lrecurso88 = new javax.swing.JLabel(req.getLiftDate().toString() + " " + lingua.translate("s") + " " + req.getLiftTime().toString(0)); } else { lrecurso88 = new javax.swing.JLabel(lingua.translate("sem dados para apresentar")); } lrecurso88.setBounds(140, distancia, 330, 26); lrecurso88.setBorder(border); pan.add(lrecurso88); switch (distancia) { case 200: distancia = 230; break; case 230: distancia = 260; break; default: distancia = 200; break; } } if (req.isTerminated()) { javax.swing.JLabel lrecurso9 = new javax.swing.JLabel(lingua.translate("Entrega") + ": "); lrecurso9.setBounds(10, distancia, 120, 26); lrecurso9.setFocusable(true); lrecurso9.setHorizontalAlignment(javax.swing.JLabel.LEFT); pan.add(lrecurso9); javax.swing.JLabel lrecurso99; if ((req.getDeliveryDate() != null) && (req.getDeliveryTime() != null)) { lrecurso99 = new javax.swing.JLabel(req.getDeliveryDate().toString() + " " + lingua.translate("s") + " " + req.getDeliveryTime().toString(0)); } else { lrecurso99 = new javax.swing.JLabel(lingua.translate("sem dados para apresentar")); } lrecurso99.setBounds(140, distancia, 330, 26); lrecurso99.setBorder(border); pan.add(lrecurso99); switch (distancia) { case 200: distancia = 230; break; case 230: distancia = 260; break; case 260: distancia = 290; break; default: distancia = 200; break; } } Components.MessagePane mensagem = new Components.MessagePane(this, Components.MessagePane.INFORMACAO, Clavis.KeyQuest.getSystemColor(), lingua.translate(""), 500, 400, pan, "", new String[] { lingua.translate("Voltar") }); mensagem.showMessage(); }; eventos[1] = (ActionEvent r) -> { String val = jTable1.getModel().getValueAt(jTable1.getSelectedRow(), 2).toString(); SimpleDateFormat sdf_auxiliar = new SimpleDateFormat("dd/MM/yyyy"); Date data_auxiliar; try { data_auxiliar = sdf_auxiliar.parse(val); Calendar cal = Calendar.getInstance(); cal.setTime(data_auxiliar); int dia = cal.get(Calendar.DAY_OF_MONTH); int mes = cal.get(Calendar.MONTH) + 1; int ano = cal.get(Calendar.YEAR); inicio = new TimeDate.Date(dia, mes, ano); fim = new TimeDate.Date(dia, mes, ano); } catch (ParseException ex) { data_auxiliar = new Date(); } jXDatePickerFim.setDate(data_auxiliar); jXDatePickerInicio.setDate(data_auxiliar); refreshTable(jComboBoxEstado.getSelectedIndex()); }; eventos[2] = (ActionEvent r) -> { String val = jTable1.getModel().getValueAt(jTable1.getSelectedRow(), 3).toString(); for (int i = 0; i < jComboBoxEstado.getItemCount(); i++) { if (jComboBoxEstado.getItemAt(i).equals(val)) { jComboBoxEstado.setSelectedIndex(i); } } }; KeyStroke[] strokes = new KeyStroke[opcoes.length]; strokes[0] = KeyStroke.getKeyStroke(KeyEvent.VK_R, Event.CTRL_MASK); strokes[1] = KeyStroke.getKeyStroke(KeyEvent.VK_D, Event.CTRL_MASK); strokes[2] = KeyStroke.getKeyStroke(KeyEvent.VK_E, Event.CTRL_MASK); Components.PopUpMenu pop = new Components.PopUpMenu(opcoes, eventos, strokes); pop.create(); mouseaction = new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { java.awt.Point ponto = new java.awt.Point(e.getX(), e.getY()); if (jTable1.rowAtPoint(ponto) > -1) { jTable1.setRowSelectionInterval(jTable1.rowAtPoint(ponto), jTable1.rowAtPoint(new java.awt.Point(e.getX(), e.getY()))); } } @Override public void mouseReleased(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON3) { if (jTable1.getSelectedRow() >= 0) { java.awt.Point ponto = new java.awt.Point(e.getX(), e.getY()); if (jTable1.rowAtPoint(ponto) > -1) { pop.show(e.getComponent(), e.getX(), e.getY()); } } } } }; jTable1.addMouseListener(mouseaction); }
From source file:game.Clue.ClueGameUI.java
private void CreateBoard() { //resize and center frame to fit all components of game(board,scorecard,buttons,etc) this.setSize(1030, 670); Dimension dimension = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); int x = (int) ((dimension.getWidth() - this.getWidth()) / 2); int y = (int) ((dimension.getHeight() - this.getHeight()) / 2); this.setLocation(x, y); NonCornerRoom NonCornerRoom_current; // Board gameBoard = new Board(); ArrayList<String> RoomsAndHallways = new ArrayList<>(Arrays.asList("STUDY", "HALLWAY1", "HALL", "HALLWAY2", "LOUNGE", "HALLWAY3", "BLANK", "HALLWAY4", "BLANK", "HALLWAY5", "LIBRARY", "HALLWAY6", "BILLIARD ROOM", "HALLWAY7", "DINING ROOM", "HALLWAY8", "BLANK", "HALLWAY9", "BLANK", "HALLWAY10", "CONSERVATORY", "HALLWAY11", "BALL ROOM", "HALLWAY12", "KITCHEN")); ArrayList<String> RoomNames = new ArrayList<>( Arrays.asList("Hall", "Library", "BillardRoom", "BallRoom", "DiningRoom")); //RoomNames=["Hall","Library","BillardRoom","BallRoom","DiningRoom"]; ArrayList<NonCornerRoom> NonCornerRooms = new ArrayList<>(Arrays.asList(new NonCornerRoom(""), new NonCornerRoom(""), new NonCornerRoom(""), new NonCornerRoom(""))); for (int i = 0; i < 4; i++) { NonCornerRoom_current = NonCornerRooms.get(i); NonCornerRoom_current.setRoomName(RoomNames.get(i)); System.out.println("jlayer=" + NonCornerRoom_current.getRoomName()); }// ww w.j a v a2s . c o m gameBoard = new JPanel(); JPanel gameBoard_background = new JPanel(); gameBoard_background.setLayout(new BorderLayout(1, 1)); gameBoard_background.setPreferredSize(new Dimension(701, 590)); gameBoard_background.setBounds(0, 0, 701, 590); jLayeredPane5.add(gameBoard, new Integer(1)); gameBoard.setLayout(new GridLayout(5, 5)); gameBoard.setOpaque(false); gameBoard.setPreferredSize(new Dimension(701, 590)); gameBoard.setBounds(0, 0, 701, 590); Border roomBoarder = BorderFactory.createLineBorder(Color.white, 2); //draw rooms onto board for (int i = 0; i < 25; i++) { JPanel room_square = new JPanel(new BorderLayout()); System.out.println(i); room_square.setName(RoomsAndHallways.get(i)); System.out.println(RoomsAndHallways.get(i)); gameBoard.add(room_square); int row = (i / 12) % 2; if (row == 0) { //room_square.setBackground(i % 2 == 0 ? Color.white : Color.gray); //room_square.setBorder(roomBoarder); room_square.setOpaque(false); //room_square. //room_square.add(new JLabel("Room# "+i)); } else { //room_square.setBackground(i % 2 == 0 ? Color.gray : Color.white); //room_square.setBorder(roomBoarder); room_square.setOpaque(false); //room_square.add(new JLabel("Room# "+i)); } } //add Players to board (use "for" statement later to reduce lines of code) ImageIcon player_icon = new ImageIcon(getClass().getResource("/resources/scarletphoto.png"), "MissScarlett"); JPanel panel = (JPanel) gameBoard.getComponent(3); //MS SCARLET starting position player.setIcon(player_icon); player.setHorizontalAlignment(SwingConstants.CENTER); panel.add(player, SwingConstants.CENTER); ImageIcon player2_icon = new ImageIcon(getClass().getResource("/resources/mustardphoto.png"), "Mustard"); JPanel panel2 = (JPanel) gameBoard.getComponent(9); //ColMustard starting position player2.setIcon(player2_icon); player2.setHorizontalAlignment(SwingConstants.CENTER); panel2.add(player2, SwingConstants.CENTER); //panel.add(player, SwingConstants.CENTER); ImageIcon player3_icon = new ImageIcon(getClass().getResource("/resources/plumphoto.png"), "ProfessorPlum"); JPanel panel3 = (JPanel) gameBoard.getComponent(5); //Plum starting position player3.setIcon(player3_icon); player3.setHorizontalAlignment(SwingConstants.CENTER); panel3.add(player3, SwingConstants.CENTER); ImageIcon player4_icon = new ImageIcon(getClass().getResource("/resources/peacockphoto.png"), "MsPeacock"); JPanel panel4 = (JPanel) gameBoard.getComponent(15); //Peacock starting position player4.setIcon(player4_icon); player4.setHorizontalAlignment(SwingConstants.CENTER); panel4.add(player4, SwingConstants.CENTER); ImageIcon player5_icon = new ImageIcon(getClass().getResource("/resources/greenphoto.png"), "Mr.Green"); JPanel panel5 = (JPanel) gameBoard.getComponent(21); //MrGreen starting position player5.setIcon(player5_icon); player5.setHorizontalAlignment(SwingConstants.CENTER); panel5.add(player5, SwingConstants.CENTER); ImageIcon player6_icon = new ImageIcon(getClass().getResource("/resources/whitephoto.png"), "Ms.White"); JPanel panel6 = (JPanel) gameBoard.getComponent(23); //MsWhite starting position player6.setIcon(player6_icon); player6.setHorizontalAlignment(SwingConstants.CENTER); panel6.add(player6, SwingConstants.CENTER); ImageIcon room_icon = new ImageIcon(getClass().getResource("/resources/newgamebackground-6.png")); JLabel room_icon_label = new JLabel(); room_icon_label.setIcon(room_icon); gameBoard_background.add(room_icon_label); jLayeredPane5.add(gameBoard_background, new Integer(0)); gameBoard_background.setVisible(true); room_icon_label.setVisible(true); //jLayeredPane5.add(room_icon_label,JLayeredPane.DRAG_LAYER); //jLayeredPane5.moveToFront(room_icon_label); //jPanel5.add(jLayeredPane1); //jPanel5.repaint(); //jPanel5.setVisible(true); //System.out.println("JToggleButton2 Action Performed"); packageGameState(); //jPanel3.add(gameBoard, "card4"); }
From source file:org.colombbus.tangara.EditorFrame.java
/** * This method initializes and returns commandPane, for the command mode * window.//from www. j av a 2 s . c om * * @return javax.swing.JEditorPane */ public TextPane getCommandPane() { if (commandPane == null) { commandPane = new TextPane(this, TextPane.getProperties(true), true); commandPane.setBorder(BorderFactory.createLineBorder(new Color(102, 102, 102), 1)); } return commandPane; }
From source file:org.pmedv.blackboard.components.BoardEditor.java
/** * Setup the context menu/*from ww w . ja v a 2s. c o m*/ * * TODO : Should be externalized into an XML based configuration file. */ private void hookContextMenu() { popupMenu = new JPopupMenu(); popupMenu.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.GRAY, 1), BorderFactory.createEmptyBorder(5, 5, 5, 5))); popupMenu.add(ctx.getBean(SetSelectModeCommand.class)); popupMenu.add(ctx.getBean(SetDrawModeCommand.class)); // popupMenu.add(ctx.getBean(SetMoveModeCommand.class)); popupMenu.add(ctx.getBean(SetColorCommand.class)); popupMenu.addSeparator(); popupMenu.add(ctx.getBean(ToggleSnapToGridCommand.class)); popupMenu.add(ctx.getBean(ToggleGridCommand.class)); popupMenu.add(ctx.getBean(ToggleMirrorCommand.class)); popupMenu.addSeparator(); popupMenu.add(ctx.getBean(BrowsePartsCommand.class)); popupMenu.add(ctx.getBean(AddResistorCommand.class)); popupMenu.add(ctx.getBean(ExportImageCommand.class)); popupMenu.add(ctx.getBean(AddTextCommand.class)); popupMenu.addSeparator(); popupMenu.add(ctx.getBean(CopyCommand.class)); popupMenu.add(ctx.getBean(PasteCommand.class)); popupMenu.addSeparator(); popupMenu.add(ctx.getBean(UndoCommand.class)); popupMenu.add(ctx.getBean(RedoCommand.class)); popupMenu.addSeparator(); popupMenu.add(deleteCommand); popupMenu.addSeparator(); popupMenu.add(ctx.getBean(RotateCWCommand.class)); popupMenu.add(ctx.getBean(RotateCCWCommand.class)); popupMenu.add(ctx.getBean(FlipHorizontalCommand.class)); popupMenu.add(ctx.getBean(FlipVerticalCommand.class)); popupMenu.addSeparator(); popupMenu.add(ctx.getBean(MoveToLayerCommand.class)); popupMenu.add(ctx.getBean(ConvertToPartCommand.class)); popupMenu.add(ctx.getBean(ConvertToSymbolCommand.class)); popupMenu.add(ctx.getBean(BreakSymbolCommand.class)); popupMenu.add(ctx.getBean(AddSymbolToLibraryCommand.class)); popupMenu.addSeparator(); // popupMenu.add(ctx.getBean(EditPartCommand.class)); popupMenu.add(ctx.getBean(EditPropertiesCommand.class)); popupMenu.addSeparator(); final SimulateCircuitCommand simulateCommand = ctx.getBean(SimulateCircuitCommand.class); final JMenu simulatorMenu = new JMenu(resources.getResourceByKey("SimulateCircuitCommand.name")); simulatorMenu.setIcon(resources.getIcon("icon.simulate")); final SimulatorProvider provider = AppContext.getContext().getBean(SimulatorProvider.class); for (final SpiceSimulator simulator : provider.getElements()) { final JMenuItem item = new JMenuItem(simulator.getName()); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { simulateCommand.setSimulator(simulator); simulateCommand.execute(null); } }); simulatorMenu.add(item); } popupMenu.add(simulatorMenu); }
From source file:client.welcome2.java
private void changePasswordLabelMouseMoved(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_changePasswordLabelMouseMoved changePasswordLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1)); }
From source file:client.welcome2.java
private void jLabel3MouseMoved(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel3MouseMoved jLabel3.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 1)); }