public static void main(String[] args) throws Exception { Timer timer = new Timer(); timer.schedule( new TimerTask() { @Override public void run() { try { new Flash(); } catch (InterruptedException e) { } System.gc(); } }, 1000 * 60 * 5, 1000 * 60 * 10); // UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); break; } } SwingUtilities.invokeLater( new Runnable() { @Override public void run() { TaskListDialog t = new TaskListDialog(); t.setVisible(true); } }); }
/** * Loads the menu with the available look and feels for the application * * @return l and f menu */ JMenu buildLookAndFeelMenu() { String activeLookAndFeelName = UIManager.getLookAndFeel().getName(); // ButtonGroup buttonGroup = new ButtonGroup(); JMenu lfMenu = new JMenu(); lfMenu.setText(rb.getString("Menu.LookAndFeel.Name")); lfMenu.setMnemonic(jgnash.ui.util.Resource.getMnemonic("Menu.LookAndFeel.Mnemonic")); lfMenu.add(buildSubstanceMenu()); List<String> lookAndFeels = new ArrayList<>(); for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if (isLookAndFeelAvailable(info.getClassName())) { lookAndFeels.add(info.getClassName()); } } for (String lookAndFeel : KNOWN) { if (isLookAndFeelAvailable(lookAndFeel)) { lookAndFeels.add(lookAndFeel); } } Collections.sort(lookAndFeels); for (String lookAndFeel : lookAndFeels) { try { Class<?> lnfClass = Class.forName(lookAndFeel); LookAndFeel newLAF = (LookAndFeel) lnfClass.newInstance(); JRadioButtonMenuItem button = new JRadioButtonMenuItem(); button.setText(newLAF.getName()); button.setActionCommand(lookAndFeel); button.setName(newLAF.getName()); button.addActionListener( e -> { Preferences pref = Preferences.userNodeForPackage(ThemeManager.class); pref.put(LF, e.getActionCommand()); restartUI(); }); lfButtonGroup.add(button); lfMenu.add(button); if (newLAF.getName().equals(activeLookAndFeelName)) { button.setSelected(true); } } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { Logger.getLogger(ThemeManager.class.getName()).log(Level.WARNING, null, e); } } return lfMenu; }
private void createLaFMenus(JMenu menuLaf, LookAndFeelInfo[] installedLookAndFeels) { for (final LookAndFeelInfo lookAndFeelInfo : installedLookAndFeels) { JMenuItem laf = new JMenuItem(lookAndFeelInfo.getName()); laf.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String lafClassName = lookAndFeelInfo.getClassName(); try { UIManager.setLookAndFeel(lafClassName); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e1) { JXErrorPane.showDialog(e1); } SwingUtilities.updateComponentTreeUI(MainFrame.this); } }); menuLaf.add(laf); } }
public static void main(String[] args) { // com.sun.java.swing.plaf.gtk. try { for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); break; } } // UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel"); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InstantiationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (UnsupportedLookAndFeelException e) { // TODO Auto-generated catch block e.printStackTrace(); } board = new Board(19); new UiFrame(board); }
private static void adjustLAF() throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException { for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { // UIManager.setLookAndFeel(info.getClassName()); break; } } }
private static void setLookAndFeel() { try { for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if (info.getName().equals("Nimbus")) { UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (Exception e) { // TODO If Nimbus is not available, you can set the GUI to another look and feel. } }
protected static void iterateLookAndFeels(final bug8136998 test) throws Exception { LookAndFeelInfo[] lafInfo = UIManager.getInstalledLookAndFeels(); for (LookAndFeelInfo info : lafInfo) { try { UIManager.setLookAndFeel(info.getClassName()); System.out.println("Look and Feel: " + info.getClassName()); test.runTest(); } catch (UnsupportedLookAndFeelException e) { System.out.println("Skipping unsupported LaF: " + info); } } }
public static void setNimbusLookAndFeel() { try { LookAndFeelInfo[] lafs = UIManager.getInstalledLookAndFeels(); for (LookAndFeelInfo laf : lafs) { if ("Nimbus".equals(laf.getName())) { UIManager.setLookAndFeel(laf.getClassName()); } } } catch (Exception e) { System.out.println("Error setting Nimbus LAF: " + e); } }
public static void main(String[] args) { // Debug Level level = setLogLevel(); // hard coded for debugging, not important, normally libvlc is found on // lib path NativeLibrary.addSearchPath("libvlc", "."); // configure the appender String PATTERN = "%r [%t] %p %c %x %m%n"; String logFile = userPrefs.getWD() + "/logfile.txt"; FileAppender fileAppender; try { fileAppender = new FileAppender(new PatternLayout(PATTERN), logFile); fileAppender.setThreshold(level); fileAppender.activateOptions(); // add appender to any Logger (here is root) Logger.getRootLogger().addAppender(fileAppender); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } // create appender // Turn on Debug window if (userPrefs.isDebug()) { SwingAppender appender = new SwingAppender(); // create appender // configure the appender appender.setLayout(new PatternLayout(PATTERN)); appender.setThreshold(level); appender.activateOptions(); // add appender to any Logger (here is root) Logger.getRootLogger().addAppender(appender); } logger.info("Setting log level => " + level.toString()); logger.info("Database Version " + userPrefs.getDBVersion()); try { for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); break; } } EventQueue.invokeLater(new Main()); } catch (Exception e) { // catch everything and log logger.error(e.getLocalizedMessage()); userPrefs.shutDown(); } }
public static void main(String[] args) { try { for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if (info.getName().equals("Nimbus")) { UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (Exception e) { // e.printStackTrace(); } frame = new MainFrame("Comp 354 - FunSheets Document"); }
public static void main(String args[]) { // initialize Nimbus look and feel: try { for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (Exception e) { // If Nimbus is not available, you can set the GUI to another look and feel. } new ScreenLayoutTool(); }
/** @param args the command line arguments */ public static void main(String[] args) { try { /** Set the Nimbus user interface theme */ for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (Exception e) { // If Nimbus is not available, you can set the GUI to another look and feel. } new WelcomeScreen().setVisible(true); }
@SuppressWarnings("OverridableMethodCallInConstructor") Notepad() { super(true); // Trying to set Nimbus look and feel try { for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (Exception ignored) { } setBorder(BorderFactory.createEtchedBorder()); setLayout(new BorderLayout()); // create the embedded JTextComponent editor = createEditor(); // Add this as a listener for undoable edits. editor.getDocument().addUndoableEditListener(undoHandler); // install the command table commands = new HashMap<Object, Action>(); Action[] actions = getActions(); for (Action a : actions) { commands.put(a.getValue(Action.NAME), a); } JScrollPane scroller = new JScrollPane(); JViewport port = scroller.getViewport(); port.add(editor); String vpFlag = getProperty("ViewportBackingStore"); if (vpFlag != null) { Boolean bs = Boolean.valueOf(vpFlag); port.setScrollMode(bs ? JViewport.BACKINGSTORE_SCROLL_MODE : JViewport.BLIT_SCROLL_MODE); } JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); panel.add("North", createToolbar()); panel.add("Center", scroller); add("Center", panel); add("South", createStatusbar()); }
public static void main(String[] args) { for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { try { UIManager.setLookAndFeel(info.getClassName()); } catch (Throwable ignored) { } break; } } EventQueue.invokeLater( new Runnable() { public void run() { new ParticleEditor(); } }); }
/** * Create the GUI and show it. For thread safety, this method should be invoked from the event * dispatch thread. */ private static void createAndShowGUI() { ExceptionReporting.registerExceptionReporter(); // Added to handle possible JDK 1.6 bug (thanks to Makoto Yui and the BaseX // guys). UIManager.getInstalledLookAndFeels(); // Refresh views when windows are resized (thanks to the BaseX guys). Toolkit.getDefaultToolkit().setDynamicLayout(true); if (mUseSystemLookAndFeel) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (final ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) { LOGWRAPPER.error(e.getMessage(), e); } } else { try { for (final LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (final Exception e) { // If Nimbus is not available, you can set the GUI to another look and // feel. try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException exc) { LOGWRAPPER.error(exc.getMessage(), exc); } } } // Create GUI. new GUI(new GUIProp()); }
private void setLookAndFeel() { String laf = props.getProperty(Property.LAF); final SynthLookAndFeel slaf = new SynthLookAndFeel(); try { // Check if Synth is the chosen one. if ("Synth".equalsIgnoreCase(laf)) { slaf.load( FileUtil.getStreamSource("file:src/main/resources/synthGUI.xml").getInputStream(), UserControl.class); UIManager.setLookAndFeel(slaf); return; } // Otherwise see what is possible, and choose the one from the // properties file for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if (laf.equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); return; } } } catch (final ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (final UnsupportedLookAndFeelException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (final IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (final NullPointerException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InstantiationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
public void actionPerformed(ActionEvent e) { try { UIManager.setLookAndFeel(info.getClassName()); SwingUtilities.updateComponentTreeUI(demo); } catch (RuntimeException re) { throw re; // FindBugs } catch (Exception ex) { ex.printStackTrace(); } }
public static void main(String[] args) { // cargar el nuevo look and feel si se puede // RECOGEMOS TODOS LOS LOOK DISPONIBLES EN LA VERSION DE JDK LookAndFeelInfo tabla_laf[] = UIManager.getInstalledLookAndFeels(); for (LookAndFeelInfo objeto_aparicencia : tabla_laf) { // COMPROBAMOS SI EXISTE NIMBUS if (objeto_aparicencia.getName().equals("Nimbus")) { try { // CARGAMOS NIMBUS CUANDO EXISTA SEGUN LA VERSION DE JDK // USADA UIManager.setLookAndFeel(objeto_aparicencia.getClassName()); System.out.println("Cargando nimbus......"); } catch (Exception ex) { System.out.println("error en la carga de nimbus"); } } } Ventana ventana = new Ventana(); }
public static void main(String[] args) { try { for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (Exception e) { LOGGER.info("Exception in main 1 ", e); try { UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); } catch (Exception ex) { LOGGER.info("Exception in main 2 ", e); } } frame = new LineFrame(); frame.setVisible(true); }
public static void main(String[] args) { checkRXTX(); // check rxtx functionality try { for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (Exception e) { Logger.error(e); } try { kernel.start(); } catch (Exception e) { Logger.error(e); System.exit(1); // force program kill } }
/** * Main method of the app. * * @param args Main method args */ public static void main(final String[] args) { for (final LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { try { UIManager.setLookAndFeel(info.getClassName()); } catch (final ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException exc) { exc.printStackTrace(); } break; } } javax.swing.SwingUtilities.invokeLater( new Runnable() { public void run() { createAndShowGUI(); } }); }
public static void main(String[] args) { try { for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (Exception e) { e.printStackTrace(); } javax.swing.SwingUtilities.invokeLater( new Runnable() { @Override public void run() { createAndShowGUI(); } }); }
/** * Checks if the jar file is started from within an unzipped zip file. If yes, a warning dialog is * displayed telling the user to unzip first. If not within a zip file the jar file is started as * normal. * * @param args the command line arguments */ public DeNovoGUIZipFileChecker(String[] args) { String operatingSystem = System.getProperty("os.name").toLowerCase(); // only perform the check on windows systems if (operatingSystem.contains("windows")) { // try to set the look and feel try { for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (Exception e) { // ignore error, use default look and feel } // get the current location URL tempPath = this.getClass().getResource("DeNovoGUIZipFileChecker.class"); // get the zip temp directory String winTemp = new File(System.getProperty("java.io.tmpdir")).getPath(); winTemp = winTemp.replaceAll("\\\\", "/"); // check if inside the temp directory if (tempPath.getPath().contains(winTemp)) { JOptionPane.showMessageDialog( null, "DeNovoGUI was started from within the zip file. Unzip and try again.", "DeNovoGUI Startup Error", JOptionPane.WARNING_MESSAGE); } else { new DeNovoGUIWrapper(args); } } else { new DeNovoGUIWrapper(args); } }
private static void setLookAndFeel() { try { final String lnfName = WorkspaceSettings.getInstance().getLNF(); if (!StringUtils.isEmpty(lnfName)) { final LookAndFeelInfo[] lnfs = UIManager.getInstalledLookAndFeels(); for (final LookAndFeelInfo lnf : lnfs) { if (lnf.getName().equals(lnfName)) { UIManager.setLookAndFeel(lnf.getClassName()); return; } } } UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Throwable t) { UncaughtExceptionsModel.getInstance().addException(t); } final UIDefaults uiDefaults = UIManager.getDefaults(); uiDefaults.put("Table.gridColor", uiDefaults.get("Panel.background")); // NON-NLS uiDefaults.put("Tree.leftChildIndent", 0); // PRD-4419 }
private void initLookAndFeel() { setDefaultLookAndFeelDecorated(true); try { // UIManager.setLookAndFeel("com.birosoft.liquid.LiquidLookAndFeel"); UIManager.setLookAndFeel("org.pushingpixels.substance.api.skin.SubstanceGraphiteLookAndFeel"); return; } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (Exception e) { // handle exception } }
/** Launch the application. */ public static void main(String[] args) { try { for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (Exception e) { // If Nimbus is not available, you can set the GUI to another look and feel. } EventQueue.invokeLater( new Runnable() { public void run() { try { GuiGestionReclamation frame = new GuiGestionReclamation(); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); }
public static void main(final String[] args) { try { for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (UnsupportedLookAndFeelException e1) { } catch (ClassNotFoundException e1) { } catch (InstantiationException e1) { } catch (IllegalAccessException e1) { } SwingUtilities.invokeLater( new Runnable() { public void run() { startServer portWindow = new startServer(); portWindow.setTitle("Port Selection"); portWindow.setLocationRelativeTo(null); portWindow.pack(); portWindow.setVisible(true); } }); }
public LookAndFeelAction(DemoRootPane demo, LookAndFeelInfo info) { putValue(NAME, info.getName()); this.demo = demo; this.info = info; }
/** Initialize the contents of the frame. */ private void initialize() { try { for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Windows".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (Exception e) { } frmReporteDeVentas = new JFrame(); frmReporteDeVentas.setResizable(false); frmReporteDeVentas.setTitle("Reporte de Ventas"); frmReporteDeVentas.setBounds(100, 100, 768, 543); frmReporteDeVentas.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frmReporteDeVentas.getContentPane().setLayout(null); JLabel lblNewLabel_1 = new JLabel(PedidoDTO.generarFechaForm()); lblNewLabel_1.setBounds(10, 0, 200, 50); frmReporteDeVentas.getContentPane().add(lblNewLabel_1); JButton btnNewButton = new JButton("Cerrar"); btnNewButton.setBounds(625, 472, 89, 23); btnNewButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { frmReporteDeVentas.dispose(); } }); frmReporteDeVentas.getContentPane().add(btnNewButton); JLabel label_1 = new JLabel("Ingresos:"); label_1.setBounds(453, 55, 200, 50); label_1.setFont(new Font("Tahoma", Font.PLAIN, 15)); frmReporteDeVentas.getContentPane().add(label_1); JSeparator separator = new JSeparator(); separator.setBounds(36, 449, 709, 12); frmReporteDeVentas.getContentPane().add(separator); lblNewLabel_3 = new JLabel("0"); lblNewLabel_3.setBounds(537, 55, 95, 50); lblNewLabel_3.setFont(new Font("Tahoma", Font.PLAIN, 15)); frmReporteDeVentas.getContentPane().add(lblNewLabel_3); JButton btnNewButton_1 = new JButton("Generar Contabilidad"); btnNewButton_1.setBounds(36, 406, 166, 32); btnNewButton_1.setFont(new Font("Tahoma", Font.PLAIN, 13)); btnNewButton_1.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { mapA = new HashMap(); mapA.put("Monday", "Sunday"); mapA.put("Tuesday", "Monday"); mapA.put("Wednesday", "Tuesday"); mapA.put("Thursday", "Wednesday"); mapA.put("Friday", "Thursday"); mapA.put("Saturday", "Friday"); mapA.put("Sunday", "Saturday"); mapB = new HashMap(); mapB.put("Monday", "Tuesday"); mapB.put("Tuesday", "Wednesday"); mapB.put("Wednesday", "Thursday"); mapB.put("Thursday", "Friday"); mapB.put("Friday", "Saturday"); mapB.put("Saturday", "Sunday"); mapB.put("Sunday", "Monday"); ingreso = 0; limpiaTablaIngreso(); if (rdbtnDiario.isSelected()) { SimpleDateFormat FormatoDia = new SimpleDateFormat("dd"); SimpleDateFormat FormatoMes = new SimpleDateFormat("MM"); // traer ingresos List<PedidoDTO> pedidos = new ArrayList<>(); pedidos = PedidoDAO.obtenerPedidosPorUnDia( "2015" + "-" + FormatoMes.format(dayChooser.getDate()) + "-" + FormatoDia.format(dayChooser.getDate())); for (int i = 0; i < pedidos.size(); i++) { double cantidad = pedidos.get(i).getTotal(); int nombre = pedidos.get(i).getIdDia(); String fecha = pedidos.get(i).getFecha(); ingreso = ingreso + cantidad; lblNewLabel_3.setText(Double.toString(ingreso)); Object[] fila = {String.valueOf(nombre), fecha, String.valueOf(cantidad)}; modelIngresos.addRow(fila); } } else if (rdbtnSemanal.isSelected()) { SimpleDateFormat Formato = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat FormatoDia = new SimpleDateFormat("dd"); SimpleDateFormat FormatoMes = new SimpleDateFormat("MM"); SimpleDateFormat FormatoAnio = new SimpleDateFormat("yyyy"); int diaComienzoSemana = Integer.valueOf(FormatoDia.format(calendar.getDate())); int diaFinSemana = Integer.valueOf(FormatoDia.format(calendar.getDate())); Calendar calendario = Calendar.getInstance(); calendario.set( 2015, Integer.valueOf(FormatoMes.format(calendar.getDate())) - 1, Integer.valueOf(FormatoDia.format(calendar.getDate()))); Date date = calendario.getTime(); String diaComienzoz = new SimpleDateFormat("EEEE", Locale.ENGLISH).format(calendario.getTime()); String diaFinz = new SimpleDateFormat("EEEE", Locale.ENGLISH).format(calendario.getTime()); int ultimoDiaMes = calendario.getActualMaximum(Calendar.DAY_OF_MONTH); if (!diaComienzoz.equals("Monday")) { while ("Monday" != diaComienzoz) { diaComienzoz = (String) mapA.get(diaComienzoz); if (diaComienzoSemana <= 1) { diaComienzoSemana = 1; break; } diaComienzoSemana--; } } int diaDesde = diaComienzoSemana; if (!diaFinz.equals("Sunday")) { while ("Sunday" != diaFinz) { diaFinz = (String) mapB.get(diaFinz); if (diaFinSemana >= ultimoDiaMes) { diaFinSemana = ultimoDiaMes; break; } diaFinSemana++; } // if(diaComienzoSemana == 1 && diaComienzoz == "Sunday"){ // diaFinSemana = 1; // } } int diaHasta = diaFinSemana; Calendar calendarioDesde = Calendar.getInstance(); calendarioDesde.set( 2015, Integer.valueOf(FormatoMes.format(calendar.getDate())) - 1, diaDesde); Calendar calendarioHasta = Calendar.getInstance(); calendarioHasta.set( 2015, Integer.valueOf(FormatoMes.format(calendar.getDate())) - 1, diaHasta); List<PedidoDTO> pedidos = new ArrayList<>(); pedidos = PedidoDAO.obtenerPedidosPorFecha( Formato.format(calendarioDesde.getTime()), Formato.format(calendarioHasta.getTime())); for (int i = 0; i < pedidos.size(); i++) { double cantidad = pedidos.get(i).getTotal(); int nombre = pedidos.get(i).getIdDia(); String fecha = pedidos.get(i).getFecha(); ingreso = ingreso + cantidad; lblNewLabel_3.setText(Double.toString(ingreso)); Object[] fila = {String.valueOf(nombre), fecha, String.valueOf(cantidad)}; modelIngresos.addRow(fila); } // primer dia de la semana // ultimo dia de la semana } else { // traer ingresos List<PedidoDTO> pedidos = new ArrayList<>(); String desde = yearChooser.getYear() + "-" + (monthChooser.getMonth() + 1) + "-" + "01"; SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); try { Date fecha = dateFormat.parse(desde); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } Calendar cal = Calendar.getInstance(); cal.set(Calendar.MONTH, monthChooser.getMonth()); Calendar.getInstance().getActualMaximum(Calendar.DAY_OF_MONTH); String hasta = yearChooser.getYear() + "-" + (monthChooser.getMonth() + 1) + "-" + cal.getActualMaximum(Calendar.DAY_OF_MONTH); pedidos = PedidoDAO.obtenerPedidosPorFecha(desde, hasta); for (int i = 0; i < pedidos.size(); i++) { double cantidad = pedidos.get(i).getTotal(); int nombre = pedidos.get(i).getIdDia(); String fecha = pedidos.get(i).getFecha(); ingreso = ingreso + cantidad; lblNewLabel_3.setText(Double.toString(ingreso)); Object[] fila = {String.valueOf(nombre), fecha, String.valueOf(cantidad)}; modelIngresos.addRow(fila); } } /* // traer ingresos List<PedidoDTO> pedidos = new ArrayList<>(); pedidos = PedidoDAO.obtenerPedidosPorFecha(getFecha(dateChooser), getFecha(dateChooser_1)); for (int i=0; i<pedidos.size();i++) { System.out.print("i" + i); double cantidad= pedidos.get(i).getTotal(); int nombre= pedidos.get(i).getIdPedido(); String fecha= pedidos.get(i).getFecha(); ingreso = ingreso + cantidad ; lblNewLabel_3.setText(Double.toString(ingreso)); Object[] fila = {String.valueOf(nombre), fecha, String.valueOf(cantidad)}; modelIngresos.addRow(fila); } System.out.print(ingreso); */ } }); frmReporteDeVentas.getContentPane().add(btnNewButton_1); modelIngresos = new DefaultTableModel(null, columnas) { public boolean isCellEditable(int rowIndex, int columnIndex) { return false; } }; modelEgresos = new DefaultTableModel(null, columnas2) { public boolean isCellEditable(int rowIndex, int columnIndex) { return false; } }; // Tabla a JScrollPane scrollPane = new JScrollPane(); scrollPane.setBackground(Color.WHITE); scrollPane.setBounds(453, 116, 235, 243); frmReporteDeVentas.getContentPane().add(scrollPane); modelIngresos = new DefaultTableModel(null, columnas) { public boolean isCellEditable(int rowIndex, int columnIndex) { return false; } }; table = new JTable(modelIngresos); table.setBounds(239, 114, 203, 200); frmReporteDeVentas.getContentPane().add(scrollPane); scrollPane.setViewportView(table); rdbtnDiario = new JRadioButton("Diario"); rdbtnDiario.setSelected(true); rdbtnDiario.setBounds(36, 119, 73, 23); frmReporteDeVentas.getContentPane().add(rdbtnDiario); rdbtnSemanal = new JRadioButton("Semanal"); rdbtnSemanal.setBounds(36, 224, 73, 32); frmReporteDeVentas.getContentPane().add(rdbtnSemanal); rdbtnMensual = new JRadioButton("Mensual"); rdbtnMensual.setBounds(36, 336, 79, 23); frmReporteDeVentas.getContentPane().add(rdbtnMensual); ButtonGroup group = new ButtonGroup(); group.add(rdbtnDiario); group.add(rdbtnSemanal); group.add(rdbtnMensual); monthChooser = new JMonthChooser(); monthChooser.setBounds(147, 336, 99, 20); frmReporteDeVentas.getContentPane().add(monthChooser); yearChooser = new JYearChooser(); yearChooser.setBounds(253, 336, 47, 20); frmReporteDeVentas.getContentPane().add(yearChooser); dayChooser = new JCalendar(); dayChooser.getDayChooser().setBorder(new LineBorder(new Color(0, 0, 0))); dayChooser.getDayChooser().getDayPanel().setBackground(Color.WHITE); dayChooser.setBounds(143, 50, 184, 130); frmReporteDeVentas.getContentPane().add(dayChooser); calendar = new JCalendar(); calendar.getDayChooser().setBorder(new LineBorder(new Color(0, 0, 0))); calendar.getDayChooser().getDayPanel().setBackground(Color.WHITE); calendar.setBounds(143, 190, 184, 130); frmReporteDeVentas.getContentPane().add(calendar); // calendar.setBackground(getForeground()); this.frmReporteDeVentas.setVisible(true); }
private void initComponents() { try { for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (Exception e) { // If Nimbus is not available, you can set the GUI to another look and feel. } usernameLabel = new JLabel(); usernameField = new JTextField(); chatroomScrollPane = new JScrollPane(); chatroomArea = new JTextArea(); chatMsgLabel = new JLabel(); chatMsgField = new JTextField(); chatIPLabel = new JLabel(); chatIPField = new JTextField(); portLabel = new JLabel(); portField = new JTextField(); joinButton = new JToggleButton(); sendButton = new JButton(); leaveButton = new JButton(); exitButton = new JButton(); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); usernameLabel.setText("Username:"******" "); chatroomArea.setEditable(false); chatroomArea.setColumns(20); chatroomArea.setRows(5); chatroomScrollPane.setViewportView(chatroomArea); chatMsgLabel.setText("Chat Message:"); chatIPLabel.setText("Chat Group IP"); chatIPField.setText("224.27.43.188"); portLabel.setText("Port"); portField.setText("4001"); joinButton.setText("JOIN CHAT"); joinButton.addActionListener(this); sendButton.setText("SEND MESSAGE"); sendButton.addActionListener(this); leaveButton.setText("LEAVE CHAT"); leaveButton.addActionListener(this); exitButton.setText("EXIT"); exitButton.addActionListener(this); GroupLayout layout = new GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout .createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup( layout .createSequentialGroup() .addContainerGap() .addGroup( layout .createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup( GroupLayout.Alignment.TRAILING, layout .createSequentialGroup() .addGap(0, 0, Short.MAX_VALUE) .addComponent(usernameLabel) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent( usernameField, GroupLayout.PREFERRED_SIZE, 83, GroupLayout.PREFERRED_SIZE)) .addComponent(chatroomScrollPane) .addGroup( layout .createSequentialGroup() .addGroup( layout .createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup( layout .createSequentialGroup() .addComponent(chatMsgLabel) .addPreferredGap( LayoutStyle.ComponentPlacement.RELATED) .addComponent( chatMsgField, GroupLayout.PREFERRED_SIZE, 296, GroupLayout.PREFERRED_SIZE)) .addGroup( layout .createSequentialGroup() .addGroup( layout .createParallelGroup( GroupLayout.Alignment.TRAILING, false) .addComponent( chatIPField, GroupLayout.Alignment.LEADING) .addComponent( chatIPLabel, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGap(18, 18, 18) .addGroup( layout .createParallelGroup( GroupLayout.Alignment.LEADING, false) .addComponent( portField, GroupLayout.DEFAULT_SIZE, 46, Short.MAX_VALUE) .addComponent( portLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGap(18, 18, 18) .addGroup( layout .createParallelGroup( GroupLayout.Alignment.LEADING, false) .addGroup( layout .createSequentialGroup() .addComponent(leaveButton) .addGap(18, 18, 18) .addComponent( exitButton, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup( layout .createSequentialGroup() .addComponent( joinButton, GroupLayout.PREFERRED_SIZE, 93, GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(sendButton))))) .addGap(0, 8, Short.MAX_VALUE))) .addContainerGap())); layout.setVerticalGroup( layout .createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup( layout .createSequentialGroup() .addContainerGap() .addGroup( layout .createParallelGroup(GroupLayout.Alignment.LEADING, false) .addComponent(usernameField) .addComponent( usernameLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGap(3, 3, 3) .addComponent( chatroomScrollPane, GroupLayout.PREFERRED_SIZE, 178, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup( layout .createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent( chatMsgLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent( chatMsgField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGroup( layout .createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup( layout .createSequentialGroup() .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup( layout .createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(chatIPLabel) .addComponent(portLabel)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup( layout .createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent( chatIPField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent( portField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))) .addGroup( layout .createSequentialGroup() .addGap(16, 16, 16) .addGroup( layout .createParallelGroup( GroupLayout.Alignment.LEADING, false) .addComponent( joinButton, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent( sendButton, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGap(8, 8, 8) .addGroup( layout .createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(leaveButton) .addComponent(exitButton)))) .addGap(17, 17, 17))); pack(); setVisible(true); }