public void dispatchEvent(XEvent xev) { if (eventLog.isLoggable(Level.FINEST)) eventLog.finest(xev.toString()); int type = xev.get_type(); if (isDisposed()) { return; } switch (type) { case VisibilityNotify: handleVisibilityEvent(xev); break; case ClientMessage: handleClientMessage(xev); break; case Expose: case GraphicsExpose: handleExposeEvent(xev); break; case ButtonPress: case ButtonRelease: handleButtonPressRelease(xev); break; case MotionNotify: handleMotionNotify(xev); break; case KeyPress: handleKeyPress(xev); break; case KeyRelease: handleKeyRelease(xev); break; case EnterNotify: case LeaveNotify: handleXCrossingEvent(xev); break; case ConfigureNotify: handleConfigureNotifyEvent(xev); break; case MapNotify: handleMapNotifyEvent(xev); break; case UnmapNotify: handleUnmapNotifyEvent(xev); break; case ReparentNotify: handleReparentNotifyEvent(xev); break; case PropertyNotify: handlePropertyNotify(xev); break; case DestroyNotify: handleDestroyNotify(xev); break; case CreateNotify: handleCreateNotify(xev); break; } }
public LoginPanel(Image img, ActionListener listener) { super(null); this.listener = listener; if (img == null) { InputStream inData = getClass().getResourceAsStream("/resources/background.gif"); BufferedImage back = null; if (inData != null) try { back = ImageIO.read(inData); } catch (IOException e) { loger.finest("LoginPanel class can't get the background image"); } this.background = back; } setLayout(null); JPanel logingPanel = new JPanel(); loginTitle = new JLabel("Autentificare"); logingPanel.setSize(250, 150); logingPanel.setBorder(new javax.swing.border.LineBorder(Color.black, 2)); logingPanel.setLayout(null); loginTitle.setBounds(3, 0, logingPanel.getWidth(), 20); logingPanel.add(loginTitle); JLabel loginUser = new JLabel("Utilizator"); loginUser.setBounds( 80 - loginUser.getPreferredSize().width, 40, loginUser.getPreferredSize().width, loginUser.getPreferredSize().height); logingPanel.add(loginUser); user = new JTextField(10); user.setBounds(85, 40, user.getPreferredSize().width, user.getPreferredSize().height); // user.setText("test"); // loginUser.setLabelFor(user); logingPanel.add(user); JLabel loginPass = new JLabel("Parola"); loginPass.setBounds( 80 - loginPass.getPreferredSize().width, 80, loginPass.getPreferredSize().width, loginPass.getPreferredSize().height); logingPanel.add(loginPass); // JTextField pass = new JTextField(10); pass = new JPasswordField(10); pass.setBounds(85, 80, pass.getPreferredSize().width, pass.getPreferredSize().height); pass.addKeyListener(this); // pass.setText("test"); // loginUser.setLabelFor(user); logingPanel.add(pass); JButton loginButton = new JButton("Start"); loginButton.setActionCommand("LOGIN"); loginButton.setBounds( 60, 110, loginButton.getPreferredSize().width, loginButton.getPreferredSize().height); // loginButton.setOpaque(false); loginButton.setFocusPainted(false); // loginButton.setContentAreaFilled(false); // loginButton.setBorderPainted(false); loginButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); loginButton.addActionListener(listener); logingPanel.add(loginButton); add(logingPanel); }
/** * Initialises the class and internal logger. Uses the supplied arguments to receive data from the * application and add data to the charts dynamically. * * @param title The title of the charts on display. Whether the displayed data is for <code>new * </code> or <code>old</code> links. That is whether the data is for newly discovered links * or existing (old) links already stored within the database. * @param parent The instance of <code>COMPortClient</code> that acts as the data source for the * charts. */ public LinkChart(String title, COMPortClient parent) { super("Charts", true, true, true, true); super.setLayer(1); identifier = title.toLowerCase(); // Obtain an instance of Logger for the class log = LoggerFactory.getLogger(className); owner = parent; // Setup a hashtable to hold the values for up, down and unknown link states Hashtable<String, Integer> linkStats = new Hashtable<String, Integer>(); if (identifier.equals("old")) { this.setTitle("Recognised Link Status on " + owner.getPortName() + ":"); // Get the current figures from the link table linkStats = ((LinkTable) owner.getLinkTable().getModel()).getInitialFigures(); } else if (identifier.equals("new")) { this.setTitle("Discovered Link Status on " + owner.getPortName() + ":"); linkStats = ((LinkTable) owner.getNewLinkTable().getModel()).getInitialFigures(); } else { // If the identifier was set to something other than old or new then it's not right. log.warning("An instance of LinkChart has been created for an unknown purpose."); return; } // Initialise the dataset for the pie chart dpdCurrentData = new DefaultPieDataset(); dpdCurrentData.insertValue(0, "Link Down", linkStats.get("down")); dpdCurrentData.insertValue(1, "Link Up", linkStats.get("up")); dpdCurrentData.insertValue(2, "Link State Unknown", linkStats.get("unknown")); // Initialise the dataset for the line chart dcdPreviousData = new DefaultCategoryDataset(); dcdPreviousData.addValue( linkStats.get("down"), "Link Down", Calendar.getInstance().getTime().toString()); dcdPreviousData.addValue( linkStats.get("up"), "Link Up", Calendar.getInstance().getTime().toString()); dcdPreviousData.addValue( linkStats.get("unknown"), "Link State Unknown", Calendar.getInstance().getTime().toString()); // Set the variables we need for holding the charts JFreeChart jfcCurrentStatus; // This will be displayed as a pie chart JFreeChart jfcPreviousStatus; // This will be displayed as a line chart ChartPanel cpCurrent; // Chartpanels hold the JFreeChart ChartPanel cpPrevious; // Use the factory to create the charts jfcCurrentStatus = ChartFactory.createPieChart("Current Status", dpdCurrentData, true, true, false); jfcPreviousStatus = ChartFactory.createLineChart( "Previous Status", "Time received", "Number of Links", dcdPreviousData, PlotOrientation.VERTICAL, true, true, false); // Add them to the chart panels cpCurrent = new ChartPanel(jfcCurrentStatus); cpPrevious = new ChartPanel(jfcPreviousStatus); // Add the chart panels to the content pane this.add(cpCurrent, BorderLayout.EAST); this.add(cpPrevious, BorderLayout.WEST); // Change the layout to show them next to each other this.setLayout(new GridLayout(1, 2)); // Add a listener to the window this.addInternalFrameListener(new CloseLinkChart(this)); log.finest("Adding frame to the desktop"); // Set the window properties and display it Client.getJNWindow().addToDesktop(this); this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); this.setSize(650, 400); this.setVisible(true); owner.addChartWindow(title, this); }