List of usage examples for javax.swing JPanel setOpaque
@BeanProperty(expert = true, description = "The component's opacity") public void setOpaque(boolean isOpaque)
From source file:Converter.java
ConversionPanel(Converter myController, String myTitle, Unit[] myUnits, ConverterRangeModel myModel) { if (MULTICOLORED) { setOpaque(true);/*from ww w.j a v a2 s . co m*/ setBackground(new Color(0, 255, 255)); } setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(myTitle), BorderFactory.createEmptyBorder(5, 5, 5, 5))); // Save arguments in instance variables. controller = myController; units = myUnits; title = myTitle; sliderModel = myModel; // Create the text field format, and then the text field. numberFormat = NumberFormat.getNumberInstance(); numberFormat.setMaximumFractionDigits(2); NumberFormatter formatter = new NumberFormatter(numberFormat); formatter.setAllowsInvalid(false); formatter.setCommitsOnValidEdit(true);// seems to be a no-op -- // aha -- it changes the value property but doesn't cause the result to // be parsed (that happens on focus loss/return, I think). // textField = new JFormattedTextField(formatter); textField.setColumns(10); textField.setValue(new Double(sliderModel.getDoubleValue())); textField.addPropertyChangeListener(this); // Add the combo box. unitChooser = new JComboBox(); for (int i = 0; i < units.length; i++) { // Populate it. unitChooser.addItem(units[i].description); } unitChooser.setSelectedIndex(0); sliderModel.setMultiplier(units[0].multiplier); unitChooser.addActionListener(this); // Add the slider. slider = new JSlider(sliderModel); sliderModel.addChangeListener(this); // Make the text field/slider group a fixed size // to make stacked ConversionPanels nicely aligned. JPanel unitGroup = new JPanel() { public Dimension getMinimumSize() { return getPreferredSize(); } public Dimension getPreferredSize() { return new Dimension(150, super.getPreferredSize().height); } public Dimension getMaximumSize() { return getPreferredSize(); } }; unitGroup.setLayout(new BoxLayout(unitGroup, BoxLayout.PAGE_AXIS)); if (MULTICOLORED) { unitGroup.setOpaque(true); unitGroup.setBackground(new Color(0, 0, 255)); } unitGroup.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5)); unitGroup.add(textField); unitGroup.add(slider); // Create a subpanel so the combo box isn't too tall // and is sufficiently wide. JPanel chooserPanel = new JPanel(); chooserPanel.setLayout(new BoxLayout(chooserPanel, BoxLayout.PAGE_AXIS)); if (MULTICOLORED) { chooserPanel.setOpaque(true); chooserPanel.setBackground(new Color(255, 0, 255)); } chooserPanel.add(unitChooser); chooserPanel.add(Box.createHorizontalStrut(100)); // Put everything together. setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS)); add(unitGroup); add(chooserPanel); unitGroup.setAlignmentY(TOP_ALIGNMENT); chooserPanel.setAlignmentY(TOP_ALIGNMENT); }
From source file:es.emergya.ui.plugins.admin.aux1.SummaryAction.java
private JPanel getBotonesSalir(final SaveOrUpdateAction guardar, final JFrame d, int width) { JPanel botones = new JPanel(new FlowLayout(FlowLayout.TRAILING)); botones.setPreferredSize(new Dimension(width, 40)); botones.setOpaque(false); botones.add(getGuardarBtn(guardar)); botones.add(getCancelBtn(d));//w w w .j a va2s. co m return botones; }
From source file:UI.SecurityDashboard.java
private void performMetric4(MainViewPanel mvp) { Metric4 metric4 = new Metric4(); JPanel graphPanel4 = new JPanel(); graphPanel4.setLayout(new BorderLayout()); metric4.run();/* ww w. jav a 2 s .co m*/ graphPanel4.add(mvp.getPanel4(metric4), BorderLayout.CENTER); MalwarePanel.setLayout(new BorderLayout()); JTextArea header = new JTextArea( "\nThe Malware detection will scan for viruses, trojans, and worms that may have affected a device.\n"); header.setLineWrap(true); header.setWrapStyleWord(true); header.setEditable(false); MalwarePanel.add(header, BorderLayout.NORTH); if (metric4.getTotalCount() == 0) { Font noMalwareFont = new Font("Calibri", Font.BOLD, 40); JLabel noMalwareLabel = new JLabel( " No Malware Detected"); noMalwareLabel.setFont(noMalwareFont); noMalwareLabel.setPreferredSize(new Dimension(WIDTH, 100)); graphPanel4.add(noMalwareLabel, BorderLayout.NORTH); JPanel emptyPanel = new JPanel(); emptyPanel.setPreferredSize(new Dimension(50, 200)); emptyPanel.setOpaque(true); graphPanel4.add(emptyPanel, BorderLayout.SOUTH); } MalwarePanel.add(graphPanel4, BorderLayout.CENTER); ChartPanel fourthPanel = mvp.getPanel4(metric4); fourthPanel.addChartMouseListener(new ChartMouseListener() { @Override public void chartMouseClicked(ChartMouseEvent cme) { dashboardTabs.setSelectedIndex(4); } @Override public void chartMouseMoved(ChartMouseEvent cme) { } }); Metric4Panel.setLayout(new BorderLayout()); Font titleFont = new Font("Calibri", Font.BOLD, 27); JLabel malwareTitleLabel = new JLabel(" Malware Detection"); malwareTitleLabel.setFont(titleFont); Metric4Panel.add(malwareTitleLabel, BorderLayout.PAGE_START); Metric4Panel.add(fourthPanel, BorderLayout.CENTER); if (metric4.getTotalCount() == 0) { Font noMalwareFont = new Font("Calibri", Font.BOLD, 20); JLabel noMalwareLabel = new JLabel(" No Malware Detected"); noMalwareLabel.setFont(noMalwareFont); Metric4Panel.add(noMalwareLabel, BorderLayout.SOUTH); } Metric4Panel.setBackground(Color.white); }
From source file:es.emergya.ui.plugins.admin.aux1.SummaryAction.java
private JPanel buildCentralUrl(final String centered_label, final Object[] left_items, final Object[] right_items, final String left_label, final String right_label, final int textfieldSize, final Dimension dimensionList, final Dimension dimensionPanel, final Dimension dimensionButtonPanel, final Dimension dimensionFilterLateral, JPanel cabecera) { JPanel central = buildCenter(centered_label); GridBagConstraints gbc = new GridBagConstraints(); buildJList(dimensionList, left_items, left, false); JScrollPane scrollleft = addScrollPane(dimensionList, left); buildJList(dimensionList, right_items, right, false); JScrollPane scrollright = addScrollPane(dimensionList, right); gbc.gridx = 0;//from ww w. ja v a2 s.c om gbc.gridy = 1; gbc.insets = new Insets(10, 10, 10, 10); gbc.gridwidth = 5; central.add(cabecera, gbc); gbc.gridwidth = 1; gbc.gridy++; JPanel leftPanel = null; if (left_items != null) { leftPanel = buildLateral(left_label, dimensionPanel, dimensionFilterLateral, scrollleft, left, true); leftItems.clear(); for (Object o : ((DefaultListModel) left.getModel()).toArray()) { leftItems.add(o); } central.add(leftPanel, gbc); gbc.gridx++; JPanel botones = buildBotones(dimensionButtonPanel, left, right); central.add(botones, gbc); gbc.gridx++; right.setEnabled(true); comboTipoCapa.setEnabled(true); habilitado.setEnabled(true); } else { right.setEnabled(false); } JPanel rightPanel = buildLateral(right_label, dimensionPanel, dimensionFilterLateral, scrollright, right, false); rightItems.clear(); for (Object o : ((DefaultListModel) right.getModel()).toArray()) { rightItems.add(o); } central.add(rightPanel, gbc); if (left_items != null) { final JButton up = new JButton(LogicConstants.getIcon("button_up")); up.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { reorder(0, right.getModel().getSize() - 1); } }); up.setBorderPainted(false); up.setOpaque(false); up.setContentAreaFilled(false); final JButton down = new JButton(LogicConstants.getIcon("button_down")); down.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { reorder(right.getModel().getSize() - 1, 0); } }); down.setBorderPainted(false); down.setOpaque(false); down.setContentAreaFilled(false); JPanel upDown = new JPanel(new FlowLayout()); upDown.setOpaque(false); upDown.add(up); upDown.add(down); upDown.setPreferredSize(new Dimension(SummaryAction.BUTTON_WIDTH, 100)); gbc.gridx++; central.add(upDown, gbc); } JPanel resultado = new JPanel(new BorderLayout(10, 5)); final TitledBorder titledBorder = new TitledBorder(centered_label); resultado.setBorder(titledBorder); resultado.setOpaque(false); resultado.add(central, BorderLayout.CENTER); JPanel res = new JPanel(new BorderLayout()); res.setOpaque(false); res.setBorder(new EmptyBorder(0, 15, 0, 15)); res.add(resultado); return res; }
From source file:ca.phon.app.project.ProjectWindow.java
private MultiActionButton createCorpusButton() { MultiActionButton retVal = new MultiActionButton(); ImageIcon newIcn = IconManager.getInstance().getIcon("places/folder", IconSize.SMALL); String s1 = "Corpus"; String s2 = "Enter corpus name and press enter. Press escape to cancel."; retVal.getTopLabel().setText(WorkspaceTextStyler.toHeaderText(s1)); retVal.getTopLabel().setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0)); retVal.getTopLabel().setFont(FontPreferences.getTitleFont()); retVal.getTopLabel().setIcon(newIcn); retVal.setAlwaysDisplayActions(true); retVal.setOpaque(false);/*from w ww . j a va2s. c o m*/ ImageIcon cancelIcn = IconManager.getInstance().getIcon("actions/button_cancel", IconSize.SMALL); ImageIcon cancelIcnL = cancelIcn; PhonUIAction btnSwapAct = new PhonUIAction(this, "onSwapNewAndCreateCorpus", retVal); btnSwapAct.putValue(Action.ACTION_COMMAND_KEY, "CANCEL_CREATE_ITEM"); btnSwapAct.putValue(Action.NAME, "Cancel create"); btnSwapAct.putValue(Action.SHORT_DESCRIPTION, "Cancel create"); btnSwapAct.putValue(Action.SMALL_ICON, cancelIcn); btnSwapAct.putValue(Action.LARGE_ICON_KEY, cancelIcnL); retVal.addAction(btnSwapAct); JPanel corpusNamePanel = new JPanel(new BorderLayout()); corpusNamePanel.setOpaque(false); final JTextField corpusNameField = new JTextField(); corpusNameField.setDocument(new NameDocument()); corpusNameField.setText("Corpus Name"); corpusNamePanel.add(corpusNameField, BorderLayout.CENTER); ActionMap actionMap = retVal.getActionMap(); actionMap.put(btnSwapAct.getValue(Action.ACTION_COMMAND_KEY), btnSwapAct); InputMap inputMap = retVal.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false); inputMap.put(ks, btnSwapAct.getValue(Action.ACTION_COMMAND_KEY)); retVal.setActionMap(actionMap); retVal.setInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, inputMap); PhonUIAction createNewCorpusAct = new PhonUIAction(this, "onCreateCorpus", corpusNameField); createNewCorpusAct.putValue(Action.SHORT_DESCRIPTION, "Create new corpus folder"); createNewCorpusAct.putValue(Action.SMALL_ICON, IconManager.getInstance().getIcon("actions/list-add", IconSize.SMALL)); JButton createBtn = new JButton(createNewCorpusAct); corpusNamePanel.add(createBtn, BorderLayout.EAST); corpusNameField.setAction(createNewCorpusAct); // swap bottom component in new project button retVal.setBottomLabelText(WorkspaceTextStyler.toDescText(s2)); retVal.add(corpusNamePanel, BorderLayout.CENTER); retVal.addFocusListener(new FocusListener() { @Override public void focusLost(FocusEvent e) { } @Override public void focusGained(FocusEvent e) { corpusNameField.requestFocus(); } }); return retVal; }
From source file:com.igormaznitsa.sciareto.ui.MainFrame.java
public MainFrame(@Nonnull @MustNotContainNull final String... args) { super();//w ww. j av a2 s.com initComponents(); this.stackPanel = new JPanel(); this.stackPanel.setFocusable(false); this.stackPanel.setOpaque(false); this.stackPanel.setBorder(BorderFactory.createEmptyBorder(32, 32, 16, 32)); this.stackPanel.setLayout(new BoxLayout(this.stackPanel, BoxLayout.Y_AXIS)); final JPanel glassPanel = (JPanel) this.getGlassPane(); glassPanel.setOpaque(false); this.setGlassPane(glassPanel); glassPanel.setLayout(new BorderLayout(8, 8)); glassPanel.add(Box.createGlue(), BorderLayout.CENTER); final JPanel ppanel = new JPanel(new BorderLayout(0, 0)); ppanel.setFocusable(false); ppanel.setOpaque(false); ppanel.setCursor(null); ppanel.add(this.stackPanel, BorderLayout.SOUTH); glassPanel.add(ppanel, BorderLayout.EAST); this.stackPanel.add(Box.createGlue()); glassPanel.setVisible(false); this.setTitle("Scia Reto"); setIconImage(UiUtils.loadImage("logo256x256.png")); this.stateless = args.length > 0; final MainFrame theInstance = this; this.addWindowListener(new WindowAdapter() { @Override public void windowClosing(@Nonnull final WindowEvent e) { if (doClosing()) { dispose(); } } }); this.tabPane = new EditorTabPane(this); this.explorerTree = new ExplorerTree(this); final JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); splitPane.setOneTouchExpandable(true); splitPane.setDividerLocation(250); splitPane.setResizeWeight(0.0d); splitPane.setLeftComponent(this.explorerTree); splitPane.setRightComponent(this.tabPane); add(splitPane, BorderLayout.CENTER); this.menuOpenRecentProject.addMenuListener(new MenuListener() { @Override public void menuSelected(MenuEvent e) { final File[] lastOpenedProjects = FileHistoryManager.getInstance().getLastOpenedProjects(); if (lastOpenedProjects.length > 0) { for (final File folder : lastOpenedProjects) { final JMenuItem item = new JMenuItem(folder.getName()); item.setToolTipText(folder.getAbsolutePath()); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openProject(folder, false); } }); menuOpenRecentProject.add(item); } } } @Override public void menuDeselected(MenuEvent e) { menuOpenRecentProject.removeAll(); } @Override public void menuCanceled(MenuEvent e) { } }); this.menuOpenRecentFile.addMenuListener(new MenuListener() { @Override public void menuSelected(MenuEvent e) { final File[] lastOpenedFiles = FileHistoryManager.getInstance().getLastOpenedFiles(); if (lastOpenedFiles.length > 0) { for (final File file : lastOpenedFiles) { final JMenuItem item = new JMenuItem(file.getName()); item.setToolTipText(file.getAbsolutePath()); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openFileAsTab(file); } }); menuOpenRecentFile.add(item); } } } @Override public void menuDeselected(MenuEvent e) { menuOpenRecentFile.removeAll(); } @Override public void menuCanceled(MenuEvent e) { } }); if (!this.stateless) { restoreState(); } else { boolean openedProject = false; for (final String filePath : args) { final File file = new File(filePath); if (file.isDirectory()) { openedProject = true; openProject(file, true); } else if (file.isFile()) { openFileAsTab(file); } } if (!openedProject) { //TODO try to hide project panel! } } final LookAndFeel current = UIManager.getLookAndFeel(); final ButtonGroup lfGroup = new ButtonGroup(); final String currentLFClassName = current.getClass().getName(); for (final UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { final JRadioButtonMenuItem menuItem = new JRadioButtonMenuItem(info.getName()); lfGroup.add(menuItem); if (currentLFClassName.equals(info.getClassName())) { menuItem.setSelected(true); } menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(@Nonnull final ActionEvent e) { try { UIManager.setLookAndFeel(info.getClassName()); SwingUtilities.updateComponentTreeUI(theInstance); PreferencesManager.getInstance().getPreferences().put(Main.PROPERTY_LOOKANDFEEL, info.getClassName()); PreferencesManager.getInstance().flush(); } catch (Exception ex) { LOGGER.error("Can't change LF", ex); } } }); this.menuLookAndFeel.add(menuItem); } }
From source file:ca.phon.app.project.ProjectWindow.java
private MultiActionButton createSessionButton() { MultiActionButton retVal = new MultiActionButton(); ImageIcon newIcn = IconManager.getInstance().getIcon("mimetypes/text-xml", IconSize.SMALL); String s1 = "Session"; String s2 = "Enter session name and press enter. Press escape to cancel."; retVal.getTopLabel().setText(WorkspaceTextStyler.toHeaderText(s1)); retVal.getTopLabel().setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0)); retVal.getTopLabel().setFont(FontPreferences.getTitleFont()); retVal.getTopLabel().setIcon(newIcn); retVal.setAlwaysDisplayActions(true); retVal.setOpaque(false);/* w w w .java 2 s. c o m*/ ImageIcon cancelIcn = IconManager.getInstance().getIcon("actions/button_cancel", IconSize.SMALL); ImageIcon cancelIcnL = cancelIcn; PhonUIAction btnSwapAct = new PhonUIAction(this, "onSwapNewAndCreateSession", retVal); btnSwapAct.putValue(Action.ACTION_COMMAND_KEY, "CANCEL_CREATE_ITEM"); btnSwapAct.putValue(Action.NAME, "Cancel create"); btnSwapAct.putValue(Action.SHORT_DESCRIPTION, "Cancel create"); btnSwapAct.putValue(Action.SMALL_ICON, cancelIcn); btnSwapAct.putValue(Action.LARGE_ICON_KEY, cancelIcnL); retVal.addAction(btnSwapAct); JPanel sessionNamePanel = new JPanel(new BorderLayout()); sessionNamePanel.setOpaque(false); final JTextField sessionNameField = new JTextField(); sessionNameField.setDocument(new NameDocument()); sessionNameField.setText("Session Name"); sessionNamePanel.add(sessionNameField, BorderLayout.CENTER); ActionMap actionMap = retVal.getActionMap(); actionMap.put(btnSwapAct.getValue(Action.ACTION_COMMAND_KEY), btnSwapAct); InputMap inputMap = retVal.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false); inputMap.put(ks, btnSwapAct.getValue(Action.ACTION_COMMAND_KEY)); retVal.setActionMap(actionMap); retVal.setInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, inputMap); PhonUIAction createNewSessionAct = new PhonUIAction(this, "onCreateSession", sessionNameField); createNewSessionAct.putValue(Action.SHORT_DESCRIPTION, "Create new session in selected corpus"); createNewSessionAct.putValue(Action.SMALL_ICON, IconManager.getInstance().getIcon("actions/list-add", IconSize.SMALL)); JButton createBtn = new JButton(createNewSessionAct); sessionNamePanel.add(createBtn, BorderLayout.EAST); sessionNameField.setAction(createNewSessionAct); // swap bottom component in new project button retVal.setBottomLabelText(WorkspaceTextStyler.toDescText(s2)); retVal.add(sessionNamePanel, BorderLayout.CENTER); retVal.addFocusListener(new FocusListener() { @Override public void focusLost(FocusEvent e) { } @Override public void focusGained(FocusEvent e) { sessionNameField.requestFocus(); } }); return retVal; }
From source file:es.emergya.ui.plugins.admin.aux1.SummaryAction.java
@SuppressWarnings("unchecked") private JPanel buildSimpleCentral(final String labelPie, final SaveOrUpdateAction guardar, final JFrame d) { JPanel central = new JPanel(new GridBagLayout()); central.setOpaque(false); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0;/*from ww w . ja v a2 s. c om*/ gbc.gridy = 0; gbc.insets = new Insets(2, 1, 2, 1); gbc.gridwidth = 1; central.add(Box.createVerticalStrut(10), gbc); gbc.gridy++; gbc.gridx = 0; gbc.anchor = GridBagConstraints.LINE_END; JLabel nombreLbl = new JLabel("Nombre:", SwingConstants.RIGHT); central.add(nombreLbl, gbc); gbc.gridx++; gbc.gridwidth = 3; gbc.anchor = GridBagConstraints.LINE_START; central.add(nombre, gbc); gbc.gridy++; gbc.gridx = 0; gbc.gridwidth = 1; gbc.anchor = GridBagConstraints.LINE_END; JLabel apellidosLbl = new JLabel("Apellidos: ", SwingConstants.RIGHT); central.add(apellidosLbl, gbc); gbc.gridx++; gbc.gridwidth = 3; gbc.anchor = GridBagConstraints.LINE_START; central.add(apellidos, gbc); gbc.anchor = GridBagConstraints.LINE_END; JLabel rolLbl = new JLabel("Rol:", SwingConstants.RIGHT); gbc.gridy++; gbc.gridx = 0; gbc.gridwidth = 1; central.add(rolLbl, gbc); gbc.gridx++; gbc.gridwidth = 3; gbc.anchor = GridBagConstraints.LINE_START; central.add(rol, gbc); gbc.gridwidth = 1; gbc.anchor = GridBagConstraints.LINE_END; JLabel contrasenyaLbl = new JLabel("Contrasea:", SwingConstants.RIGHT); gbc.gridy++; gbc.gridx = 0; central.add(contrasenyaLbl, gbc); gbc.gridx++; gbc.anchor = GridBagConstraints.LINE_START; central.add(contrasenya, gbc); gbc.anchor = GridBagConstraints.LINE_END; JLabel contrasenya2Lbl = new JLabel("Repetir Contrasea:", SwingConstants.RIGHT); gbc.gridx++; central.add(contrasenya2Lbl, gbc); gbc.gridx++; gbc.anchor = GridBagConstraints.LINE_START; central.add(repetir, gbc); gbc.anchor = GridBagConstraints.LINE_END; JLabel administradorLbl = new JLabel("Administrador:", SwingConstants.RIGHT); gbc.gridy++; gbc.gridx = 0; central.add(administradorLbl, gbc); gbc.gridx++; gbc.anchor = GridBagConstraints.LINE_START; central.add(administrador, gbc); administrador.setOpaque(false); gbc.anchor = GridBagConstraints.LINE_END; JLabel habilitadoLbl = new JLabel("Habilitado", SwingConstants.RIGHT); gbc.gridx++; central.add(habilitadoLbl, gbc); gbc.gridx++; gbc.anchor = GridBagConstraints.LINE_START; central.add(habilitado, gbc); habilitado.setOpaque(false); gbc.gridx = 0; gbc.gridy++; gbc.anchor = GridBagConstraints.LINE_END; JLabel labl_pie = new JLabel(labelPie, JLabel.LEFT); central.add(labl_pie, gbc); textfieldPie.setColumns(textfieldSize); labl_pie.setLabelFor(textfieldPie); gbc.gridx++; gbc.gridwidth = 4; gbc.anchor = GridBagConstraints.LINE_START; central.add(textfieldPie, gbc); gbc.gridy++; gbc.gridx = 0; central.add(Box.createVerticalStrut(10), gbc); gbc.gridwidth = 2; gbc.gridy++; gbc.gridx = 1; JPanel botones = getBotonesSalir(guardar, d, 250); central.add(botones, gbc); ((DefaultComboBoxModel) rol.getModel()).removeAllElements(); for (String r : RolConsultas.getAllNames()) { ((DefaultComboBoxModel) rol.getModel()).addElement(r); } return central; }
From source file:it.illinois.adsc.ema.softgrid.monitoring.ui.SPMainFrame.java
private void setupGUI() throws Exception { this.getContentPane().setLayout(new GridBagLayout()); chartPanel = getChartPanel();//from w ww . ja v a2s . c o m this.setPreferredSize(new Dimension(800, 700)); alertPanel.setPreferredSize(new Dimension(200, 700)); alertPanel.setMinimumSize(new Dimension(200, 700)); alertPanel.setMaximumSize(new Dimension(200, 700)); transientPanel.setPreferredSize(new Dimension(200, 700)); transientPanel.setMinimumSize(new Dimension(200, 700)); transientPanel.setMaximumSize(new Dimension(200, 700)); queryTextArea.setPreferredSize(new Dimension(300, 100)); queryTextArea.setMinimumSize(new Dimension(300, 100)); queryTextArea.setMaximumSize(new Dimension(300, 100)); monitorButton.setPreferredSize(new Dimension(30, 30)); monitorButton.setMinimumSize(new Dimension(30, 30)); monitorButton.setMaximumSize(new Dimension(30, 30)); monitorButton.setToolTipText("Execute and Monitor"); exitButton.setPreferredSize(new Dimension(30, 30)); exitButton.setMinimumSize(new Dimension(30, 30)); exitButton.setMaximumSize(new Dimension(30, 30)); exitButton.setToolTipText("Close and Exit"); clearButton.setPreferredSize(new Dimension(30, 30)); clearButton.setMinimumSize(new Dimension(30, 30)); clearButton.setMaximumSize(new Dimension(30, 30)); clearButton.setToolTipText("Reset"); runButton.setPreferredSize(new Dimension(30, 30)); runButton.setMinimumSize(new Dimension(30, 30)); runButton.setMaximumSize(new Dimension(30, 30)); runButton.setToolTipText("Initialize the server...!"); alertPanel.setLayout(new VerticalFlowLayout()); transientPanel.setLayout(new BorderLayout()); // System.out.println("new File(\"../MonitorEngine/Images/execute-xxl.png\").exists() = " + new File("../MonitorEngine/Images/execute-xxl.png").exists()); // System.out.println("execute-xxl.png = " + new File("execute-xxl.png").exists()); // System.out.println("new File().getAbsolutePath() = " + new File("openmuc.jar").getAbsolutePath()); Image img = new ImageIcon(ImageIO.read(getClass().getClassLoader().getResourceAsStream("execute-xxl.png"))) .getImage(); Image newimg = img.getScaledInstance(30, 30, java.awt.Image.SCALE_SMOOTH); ImageIcon icon = new ImageIcon(newimg); monitorButton.setIcon(icon); img = new ImageIcon(ImageIO.read(getClass().getClassLoader().getResourceAsStream("stop-xxl.png"))) .getImage(); newimg = img.getScaledInstance(30, 30, java.awt.Image.SCALE_SMOOTH); icon = new ImageIcon(newimg); exitButton.setIcon(icon); img = new ImageIcon(ImageIO.read(getClass().getClassLoader().getResourceAsStream("reset-xxl.png"))) .getImage(); newimg = img.getScaledInstance(30, 30, java.awt.Image.SCALE_SMOOTH); icon = new ImageIcon(newimg); clearButton.setIcon(icon); img = new ImageIcon(ImageIO.read(getClass().getClassLoader().getResourceAsStream("start-xxl.png"))) .getImage(); newimg = img.getScaledInstance(30, 30, java.awt.Image.SCALE_SMOOTH); icon = new ImageIcon(newimg); runButton.setIcon(icon); altertScrolPane.getViewport().add(alertPanel, null); altertScrolPane.setBorder(BorderFactory.createEtchedBorder()); logAreaScrollPane.getViewport().add(logTextArea, null); logAreaScrollPane.setBorder(BorderFactory.createEtchedBorder()); JPanel tempQueryPanel = new JPanel(); JPanel buttonPanel = new JPanel(); // tempQueryPanel.setBorder(BorderFactory.createTitledBorder("Monitor Query")); tempQueryPanel.setLayout(new GridBagLayout()); buttonPanel.setLayout(new GridBagLayout()); buttonPanel.setBorder(BorderFactory.createEtchedBorder()); buttonPanel.setOpaque(true); buttonPanel.setBackground(Color.gray); buttonPanel.add(runButton, new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(6, 12, 3, 12), 0, 0)); buttonPanel.add(monitorButton, new GridBagConstraints(0, 2, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(3, 12, 3, 12), 0, 0)); buttonPanel.add(clearButton, new GridBagConstraints(0, 3, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(3, 12, 3, 12), 0, 0)); buttonPanel.add(exitButton, new GridBagConstraints(0, 4, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(3, 12, 3, 12), 0, 0)); // tempQueryPanel.add(splitPane, new GridBagConstraints(0, 0, 1, 6, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); tempQueryPanel.add(buttonPanel, new GridBagConstraints(0, 0, 1, 1, 0, 1, GridBagConstraints.CENTER, GridBagConstraints.VERTICAL, new Insets(0, 0, 0, 0), 0, 0)); tempQueryPanel.add(queryScrolPane, new GridBagConstraints(1, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); mainTabbedPane.add(splitPane, "Controller"); mainTabbedPane.add(ConfigPanel.getInstance(), "Configuration"); splitPane.setTopComponent(tempQueryPanel); splitPane.setDividerLocation(152); splitPane.setBottomComponent(resultTabbedPane); splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); this.getContentPane().add(mainTabbedPane, new GridBagConstraints(0, 0, 1, 2, 0.75, 0.25, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(12, 12, 12, 0), 0, 0)); // this.getContentPane().add(alertTitile, new GridBagConstraints(1, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(12, 0, 0, 12), 0, 0)); // this.getContentPane().add(altertScrolPane, new GridBagConstraints(1, 1, 1, 2, 0, 1, GridBagConstraints.CENTER, GridBagConstraints.VERTICAL, new Insets(0, 0, 12, 12), 0, 0)); // tempQueryPanel.add(queryScrolPane, new GridBagConstraints(0, 0, 1, 5, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); // this.getContentPane().add(logAreaScrollPane, new GridBagConstraints(0, 2, 1, 1, 0.75, 0.75, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(12, 12, 12, 0), 0, 0)); exitButton.addActionListener(this); monitorButton.addActionListener(this); clearButton.addActionListener(this); clearButton.setEnabled(false); clearButton.setVisible(false); monitorButton.setEnabled(true); runButton.addActionListener(this); queryTextArea.setContentType("text/html"); queryTextArea.setText("select overloadrank from virtual"); messageHandler = new MessageUIHandler(logTextArea, logAreaScrollPane); ConfigPanel.getInstance().setupConfigPanel(); }
From source file:es.emergya.ui.gis.popups.ConsultaHistoricos.java
private JPanel getElementos() { JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEADING)); panel.setOpaque(false); panel.setBorder(new TitledBorder("Elementos a Consultar")); JLabel jLabel = new JLabel("Recursos", SwingConstants.RIGHT); jLabel.setPreferredSize(ConsultaHistoricos.DIMENSION_LABEL); panel.add(jLabel);//from w w w.ja v a2 s . co m recursos = new JList(new DefaultListModel()); recursos.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.CTRL_MASK), "selectAll"); recursos.getActionMap().put("selectAll", new AbstractAction() { private static final long serialVersionUID = -5515338515763292526L; @Override public void actionPerformed(ActionEvent e) { recursos.setSelectionInterval(0, recursos.getModel().getSize() - 1); } }); recursos.addListSelectionListener(listSelectionListener); final JScrollPane jScrollPaneR = new JScrollPane(recursos, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); jScrollPaneR.getViewport().setPreferredSize(DIMENSION_JLIST); panel.add(jScrollPaneR); jLabel = new JLabel("Incidencias", SwingConstants.RIGHT); jLabel.setPreferredSize(ConsultaHistoricos.DIMENSION_LABEL); panel.add(jLabel); incidencias = new JList(new DefaultListModel()); incidencias.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.CTRL_MASK), "selectAll"); incidencias.getActionMap().put("selectAll", new AbstractAction() { private static final long serialVersionUID = -5515338515763292526L; @Override public void actionPerformed(ActionEvent e) { incidencias.setSelectionInterval(0, incidencias.getModel().getSize() - 1); } }); incidencias.addListSelectionListener(listSelectionListener); final JScrollPane jScrollPaneI = new JScrollPane(incidencias, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); jScrollPaneI.getViewport().setPreferredSize(DIMENSION_JLIST); panel.setPreferredSize(DIMENSION_2JLIST); panel.add(jScrollPaneI); return panel; }