/** Initializes contained components. */ private void initComponents() { final SimpleDateFormat format = new SimpleDateFormat("mm:ss"); final Calendar c = Calendar.getInstance(); final JLabel counter = new JLabel(); counter.setForeground(Color.red); counter.setFont(counter.getFont().deriveFont((float) (counter.getFont().getSize() + 5))); setLayout(new GridBagLayout()); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); GridBagConstraints constraints = new GridBagConstraints(); JLabel messageLabel = new JLabel( GuiActivator.getResources().getI18NString("service.gui.security.SECURITY_ALERT")); messageLabel.setForeground(Color.WHITE); constraints.anchor = GridBagConstraints.CENTER; constraints.fill = GridBagConstraints.NONE; constraints.gridx = 0; constraints.gridy = 0; add(messageLabel, constraints); constraints.anchor = GridBagConstraints.CENTER; constraints.fill = GridBagConstraints.NONE; constraints.gridx = 0; constraints.gridy = 1; add(counter, constraints); ZrtpControl zrtpControl = null; if (securityControl instanceof ZrtpControl) zrtpControl = (ZrtpControl) securityControl; long initialSeconds = 0; if (zrtpControl != null) initialSeconds = zrtpControl.getTimeoutValue(); c.setTimeInMillis(initialSeconds); counter.setText(format.format(c.getTime())); if (initialSeconds > 0) timer.schedule( new TimerTask() { @Override public void run() { if (c.getTimeInMillis() - 1000 > 0) { c.add(Calendar.SECOND, -1); counter.setText(format.format(c.getTime())); } } }, 1000, 1000); }
/* public void addMiniChart(Plugin p){ components.add(p); rebuild(); } public void removeMiniChart(Plugin p){ components.remove(p); rebuild(); } */ public void rebuild() { // remove everything from main panel mainpanel.removeAll(); GridBagLayout gbl = new GridBagLayout(); GridBagConstraints gbc = new GridBagConstraints(); mainpanel.setLayout(gbl); gbc.anchor = gbc.NORTHWEST; gbc.fill = gbc.BOTH; gbc.weightx = 1; gbc.gridx = 0; int i = 0; // add chart gbc.weighty = 1; gbc.gridy = i; gbl.setConstraints(chartPanel, gbc); mainpanel.add(chartPanel); // add all other plugins/components validate(); }
public ChartWindow(String title) { this.symbol = title; thisp = this; // initialize the main layout setTitle(title); mainpanel = new JPanel(); GridBagLayout gbl = new GridBagLayout(); GridBagConstraints gbc = new GridBagConstraints(); mainpanel.setLayout(gbl); // build a toolbar // add a plain status bar this.statusLine = new JLabel("Done"); this.getContentPane().add(statusLine, BorderLayout.SOUTH); statusLine.setBackground(new Color(0, 0, 0)); statusLine.setForeground(new Color(255, 255, 255)); statusLine.setOpaque(true); // x1 = new TimeSeries("symbol", FixedMillisecond.class); dataset1.addSeries(x1); System.out.println("Populated."); // chart = createChart(dataset1); System.out.println("constr."); // chart.getXYPlot().setOrientation(PlotOrientation.VERTICAL); chart.setAntiAlias(false); chartPanel = new ChartPanel(chart); // int i = 0; gbc.anchor = gbc.NORTHWEST; gbc.fill = gbc.BOTH; gbc.weightx = 1; gbc.gridx = 0; gbc.weighty = 1; gbc.gridy = i; gbl.setConstraints(chartPanel, gbc); mainpanel.add(chartPanel); // System.out.println("add"); setVisible(true); setSize(new Dimension(400, 300)); // chartPanel.setPopupMenu(buildPopupMenu()); chartPanel.setMouseZoomable(true); chartPanel.setHorizontalAxisTrace(true); chartPanel.setVerticalAxisTrace(true); chartPanel.setHorizontalZoom(true); chartPanel.setOpaque(true); chartPanel.setBackground(new Color(0, 0, 0)); this.getContentPane().add(mainpanel, BorderLayout.CENTER); this.setSize(600, 400); this.toFront(); this.show(); }
public void setup() { setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); title = new JLabel(SHTML + TITLE + elem.title + EHTML); gbc.fill = GridBagConstraints.NONE; gbc.anchor = GridBagConstraints.WEST; gbc.gridy = 4; gbc.gridx = 0; gbc.gridwidth = 2; gbc.gridheight = 1; gbc.weighty = 1.0; add(title, gbc); donor = new JLabel(SHTML + DONOR + elem.donor + EHTML); gbc.gridy = 5; add(donor, gbc); subDate = new JLabel(SHTML + SUB_DATE + elem.subDate.toString() + EHTML); gbc.gridy = 6; add(subDate, gbc); objDate = new JLabel(SHTML + OBJ_DATE + elem.objDate.toString() + EHTML); gbc.gridy = 7; add(objDate, gbc); medium = new JLabel(SHTML + MEDIUM + elem.medium + EHTML); gbc.gridy = 8; add(medium, gbc); accNum = new JLabel(SHTML + ACC_NUM + elem.accNum + EHTML); gbc.gridy = 9; add(accNum, gbc); desc = new JLabel(SHTML + DESC + EHTML); // gbc.anchor = GridBagConstraints.PAGE_START; gbc.insets = new Insets(0, 50, 0, 0); gbc.gridy = 4; gbc.gridx = 2; add(desc, gbc); descView = new JTextArea(); descView.setLineWrap(true); descView.setWrapStyleWord(true); descView.setEditable(false); descView.setText(elem.desc); descView.setFont(new Font("Times New Roman", Font.PLAIN, 13)); JScrollPane scrollPane = new JScrollPane(descView); scrollPane.setPreferredSize(new Dimension(225, 100)); // scrollPane.setBorder(null); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); descView.setCaretPosition(0); gbc.gridy = 5; gbc.gridheight = 4; gbc.gridx = 2; add(scrollPane, gbc); gbc.insets = null; gbc.gridy = 0; gbc.gridx = 0; gbc.gridwidth = 4; gbc.gridheight = 4; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(0, 0, 10, 0); vpan = new V3DPanel(elem, provider); vpan.setPreferredSize(new Dimension(500, 300)); setBackground(BACKGROUND); add(vpan, gbc); validate(); }
ShutdownFrame(CryoBay cb) { super("CryoBay Monitor"); cryoB = cb; cmdClose = new JButton("Close") { public JToolTip createToolTip() { return new JToolTip(); } }; cmdClose.setToolTipText("Close program"); cmdClose.addActionListener(this); addWindowListener(this); GridBagConstraints gbc = new GridBagConstraints(); Border loweredbevel = BorderFactory.createLoweredBevelBorder(); lblBStatus = new JLabel("Status: "); lblBHeater = new JLabel("Heater: "); lblBTemp = new JLabel(" Temp: "); lblBCli = new JLabel(" CLI: "); lblStatus = new JTextField(17); lblStatus.setEditable(false); lblStatus.setOpaque(true); lblStatus.setBorder(loweredbevel); lblHeater = new JTextField(17); lblHeater.setEditable(false); lblHeater.setOpaque(true); lblHeater.setBorder(loweredbevel); lblTemp = new JTextField(17); lblTemp.setEditable(false); lblTemp.setOpaque(true); lblTemp.setBorder(loweredbevel); lblCli = new JTextField(17); lblCli.setEditable(false); lblCli.setOpaque(true); lblCli.setBorder(loweredbevel); JPanel lblPanel = new JPanel(); lblPanel.setLayout(new GridBagLayout()); gbc.insets = new Insets(2, 5, 2, 5); setGbc(gbc, 0, 0, 1, 1); lblPanel.add(lblBStatus, gbc); setGbc(gbc, 0, 1, 1, 1); lblPanel.add(lblBHeater, gbc); setGbc(gbc, 0, 2, 1, 1); lblPanel.add(lblBTemp, gbc); setGbc(gbc, 0, 3, 1, 1); lblPanel.add(lblBCli, gbc); JPanel valPanel = new JPanel(); valPanel.setLayout(new GridBagLayout()); gbc.insets = new Insets(2, 5, 2, 5); setGbc(gbc, 0, 0, 1, 1); valPanel.add(lblStatus, gbc); setGbc(gbc, 0, 1, 1, 1); valPanel.add(lblHeater, gbc); setGbc(gbc, 0, 2, 1, 1); valPanel.add(lblTemp, gbc); setGbc(gbc, 0, 3, 1, 1); valPanel.add(lblCli, gbc); JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new GridBagLayout()); gbc.anchor = GridBagConstraints.CENTER; setGbc(gbc, 0, 5, 1, 1); buttonPanel.add(cmdClose, gbc); // finally, add the panels to the content pane getContentPane().setLayout(new GridBagLayout()); gbc.insets = new Insets(10, 10, 10, 10); gbc.anchor = GridBagConstraints.CENTER; setGbc(gbc, 0, 0, 1, 4); getContentPane().add(lblPanel, gbc); setGbc(gbc, 1, 0, 1, 4); getContentPane().add(valPanel, gbc); setGbc(gbc, 0, 5, 0, 0); getContentPane().add(buttonPanel, gbc); setSize(300, 220); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); setLocation(screenSize.width / 2 - 300, screenSize.height / 2 - 220); setResizable(true); }