private void selFolder() { // selects a single folder, then makes table uneditable other than launch, sel res folder and // cancel, gui table different, just shows folder final JFileChooser fc = new JFileChooser(currentPath); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int result = fc.showOpenDialog(FrontEnd.this); dir = fc.getSelectedFile(); switch (result) { case JFileChooser.APPROVE_OPTION: dirImp = dir.toString(); dtm.getDataVector().removeAllElements(); dtm.fireTableDataChanged(); curRow = 0; addRow(); dtm.setValueAt( "You have chosen the folder '" + dirImp.substring(67) + "' and all of its subfolders.", 0, 0); dtm.setValueAt(dirImp.substring(67), 0, 1); if (table.getRowCount() > 0) { openF.setEnabled(false); openFo.setEnabled(false); selFo.setEnabled(false); canF.setEnabled(true); } selFoFl = 1; case JFileChooser.CANCEL_OPTION: break; } }
public static void refreshCalendar(int month, int year) { // instantiation String[] months = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; int numoday, startom; // Number Of Days, Start Of Month // Allow/disallow buttons prev.setEnabled(true); next.setEnabled(true); if (month == 0 && year <= ryear) { prev.setEnabled(false); } // Cannot set an appointment back in time if (month == 11 && year >= ryear + 50) { next.setEnabled(false); } // Too early to set an appointment lmonth.setText(months[month]); // Refresh the month label (at the top) lmonth.setBounds( 160 - lmonth.getPreferredSize().width / 2, 25, 180, 25); // Re-align label with calendar cyear.setSelectedItem(String.valueOf(year)); // Select the correct year in the combo box // deletes current table for (int i = 0; i < 6; i++) { for (int j = 0; j < 7; j++) { mcal.setValueAt(null, i, j); } } // Get first day of month and number of days GregorianCalendar cal = new GregorianCalendar(year, month, 1); numoday = cal.getActualMaximum(GregorianCalendar.DAY_OF_MONTH); startom = cal.get(GregorianCalendar.DAY_OF_WEEK); // Create calendar for (int i = 1; i <= numoday; i++) { int row = new Integer((i + startom - 2) / 7); int column = (i + startom - 2) % 7; mcal.setValueAt(i, row, column); } // Apply renderers Cal.setDefaultRenderer(Cal.getColumnClass(0), new tblCalendarRenderer()); }
@SuppressWarnings("unchecked") @Override public int loop() { synchronized (lock) { try { if (!ui.isVisible()) handler.stopMod(getName()); World world = minecraft.getWorld(); JTable list = ui.getList(); DefaultTableModel model = (DefaultTableModel) list.getModel(); TableRowSorter<TableModel> sorter = (TableRowSorter<TableModel>) list.getRowSorter(); if (world != null) { Player currentPlayer = minecraft.getPlayer(); int playerX = (int) java.lang.Math.round(currentPlayer.getX()); int playerY = (int) java.lang.Math.round(currentPlayer.getY()); int playerZ = (int) java.lang.Math.round(currentPlayer.getZ()); ArrayList<Block> blocks = new ArrayList<Block>(); for (int x = playerX - radius; x < playerX + radius; x++) for (int y = playerY - radius; y < playerY + radius; y++) for (int z = playerZ - radius; z < playerZ + radius; z++) if (world.getBlockIDAt(x, y, z) == blockID) blocks.add(new Block(x, y, z)); label: for (int row = 0; row < model.getRowCount(); row++) { int x = (Integer) model.getValueAt(row, 1); int y = (Integer) model.getValueAt(row, 2); int z = (Integer) model.getValueAt(row, 3); for (Block block : blocks) { if (x == block.getX() && y == block.getY() && z == block.getZ()) { model.setValueAt(getDistanceTo(x, y, z, currentPlayer), row, 0); continue label; } } model.removeRow(row); } label: for (Block block : blocks) { for (int row = 0; row < model.getRowCount(); row++) { int x = (Integer) model.getValueAt(row, 1); int y = (Integer) model.getValueAt(row, 2); int z = (Integer) model.getValueAt(row, 3); if (x == block.getX() && y == block.getY() && z == block.getZ()) continue label; } model.addRow( new Object[] { getDistanceTo(block.getX(), block.getY(), block.getZ(), minecraft.getPlayer()), block.getX(), block.getY(), block.getZ() }); } sorter.sort(); list.repaint(); } else { for (int i = model.getRowCount() - 1; i >= 0; i--) model.removeRow(i); } } catch (Exception exception) { } } return 500; }
private void openFile() { // opens a single file chooser (can select multiple), does not traverse folders. this.copyList = new ArrayList(); final JFileChooser fc = new JFileChooser(currentPath); fc.setMultiSelectionEnabled(true); fc.setFileSelectionMode(JFileChooser.FILES_ONLY); FileNameExtensionFilter filterhtml = new FileNameExtensionFilter("HTML File (.html)", "html"); fc.addChoosableFileFilter(filterhtml); fc.setFileFilter(filterhtml); int result = fc.showOpenDialog(FrontEnd.this); dir = fc.getCurrentDirectory(); dirImp = dir.toString(); switch (result) { case JFileChooser.APPROVE_OPTION: for (File file1 : fc.getSelectedFiles()) { fileImp = file1.toString(); boolean exists = false; for (int i = 0; i < table.getRowCount(); i++) { dir = fc.getCurrentDirectory(); dirImp = dir.toString(); String copyC = dtm.getValueAt(i, 0).toString(); if (duplC.isSelected()) { if (fileImp.endsWith(copyC)) { exists = true; break; } } } if (!exists) { addRow(); dtm.setValueAt(fileImp.substring(67), curRow, 0); dtm.setValueAt(dirImp.substring(67), curRow, 1); curRow++; if (headC == 1) { if (fileImp.substring(67).endsWith(dirImp.substring(67) + ".html")) { curRow--; dtm.removeRow(curRow); } } } } case JFileChooser.CANCEL_OPTION: break; } }
private void openFolder() { // opens all htmls in a folder other than the one with same name as folder final JFileChooser fc = new JFileChooser(currentPath); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int result = fc.showOpenDialog(FrontEnd.this); file = fc.getSelectedFiles(); dir = fc.getSelectedFile(); switch (result) { case JFileChooser.APPROVE_OPTION: dirImp = dir.toString(); File[] filesInDirectory = dir.listFiles(); for (File file1 : filesInDirectory) { String fileS = file1.toString(); fileS.substring(fileS.lastIndexOf('.') + 1); if (fileS.contains("html")) { fileImp = file1.toString(); boolean exists = false; for (int i = 0; i < table.getRowCount(); i++) { String copyC = dtm.getValueAt(i, 0).toString(); if (duplC.isSelected()) { if (fileImp.contains(copyC)) { exists = true; break; } } } if (!exists) { addRow(); dtm.setValueAt(fileImp.substring(67), curRow, 0); dtm.setValueAt(dirImp.substring(67), curRow, 1); curRow++; if (headC == 1) { if (fileImp.substring(67).endsWith(dirImp.substring(67) + ".html")) { curRow--; dtm.removeRow(curRow); } } } } } case JFileChooser.CANCEL_OPTION: break; } }
public void setValueAt(Object obj, int row, int col) { if (obj instanceof Education) super.setValueAt(new Education((Education) obj, EmployeeAttribute.CODE), row, col); else if (obj instanceof JobTitle) super.setValueAt(new JobTitle((JobTitle) obj, EmployeeAttribute.DESCRIPTION), row, col); else if (obj instanceof Organization) super.setValueAt( new Organization((Organization) obj, EmployeeAttribute.DESCRIPTION), row, col); else if (obj instanceof Unit) super.setValueAt(new Unit((Unit) obj, Unit.CODE_DESCRIPTION), row, col); else if (obj instanceof WorkAgreement) super.setValueAt( new WorkAgreement((WorkAgreement) obj, EmployeeAttribute.DESCRIPTION), row, col); else if (obj instanceof SexType) super.setValueAt(new SexType((SexType) obj, EmployeeAttribute.DESCRIPTION), row, col); else if (obj instanceof Qualification) super.setValueAt(new Qualification((Qualification) obj, EmployeeAttribute.CODE), row, col); else super.setValueAt(obj, row, col); }