List of usage examples for javax.swing BorderFactory createLineBorder
public static Border createLineBorder(Color color)
From source file:org.jdal.swing.form.SimpleBoxFormBuilder.java
/** * Builds the panel form./* w w w. j av a2 s. co m*/ * @return the form component */ public JComponent getForm() { // set sizes; int columnHeight = 0; for (int h : rowsHeight) columnHeight += h; // add space into components (fillers) columnHeight += (rows - 1) * defaultSpace; for (int i = 0; i < columns.size(); i++) { Box box = columns.get(i); int maxWidth = columnsWidth.get(i) == 0 ? Short.MAX_VALUE : columnsWidth.get(i); box.setMaximumSize(new Dimension(maxWidth, columnHeight)); if (maxWidth < Short.MAX_VALUE && columnHeight < Short.MAX_VALUE) { box.setMinimumSize(new Dimension(maxWidth, columnHeight)); box.setPreferredSize(new Dimension(maxWidth, columnHeight)); } } container.setFocusTraversalPolicy(focusTransversal); container.setFocusTraversalPolicyProvider(true); container.setSize(Short.MAX_VALUE, columnHeight); if (isFixedHeight()) { Dimension maxSize = new Dimension(Short.MAX_VALUE, columnHeight); if (container.isMaximumSizeSet()) { maxSize = container.getMaximumSize(); maxSize.height = columnHeight; } container.setMaximumSize(maxSize); } if (isDebug()) container.setBorder(BorderFactory.createLineBorder(Color.BLUE)); if (border != null) container.setBorder(border); return container; }
From source file:edu.ku.brc.af.ui.forms.SubViewBtn.java
/** * @param subviewDef//from w w w . ja va 2 s. c o m * @param isCollection * @param props */ public SubViewBtn(final MultiView mvParent, final FormCellSubViewIFace subviewDef, final ViewIFace view, final DATA_TYPE dataType, final int options, final Properties props, final Class<?> classToCreate, final AltViewIFace.CreationMode mode) { this.mvParent = mvParent; this.subviewDef = subviewDef; this.dataType = dataType; this.view = view; this.options = options; this.classToCreate = classToCreate; isEditing = mode == AltViewIFace.CreationMode.EDIT; // 02/12/08 - rods - Removing the "IS_NEW_OBJECT" of the parent object because it doesn't // matter to the popup form it creates. The form takes care of everything. this.options &= ~MultiView.IS_NEW_OBJECT; //log.debug("Editing "+MultiView.isOptionOn(options, MultiView.IS_EDITTING)); //log.debug("IsNew "+MultiView.isOptionOn(options, MultiView.IS_NEW_OBJECT)); cellName = subviewDef.getName(); frameTitle = props.getProperty("title"); String align = props.getProperty("align", "left"); String iconName = props.getProperty("icon", null); icon = null; baseLabel = props.getProperty("label"); if (baseLabel == null) { DBTableInfo tableInfo = DBTableIdMgr.getInstance() .getByClassName(classToCreate != null ? classToCreate.getName() : view.getClassName()); if (tableInfo != null) { baseLabel = tableInfo.getTitle(); String icNam = StringUtils.isNotEmpty(iconName) ? iconName : tableInfo.getName(); IconEntry entry = IconManager.getIconEntryByName(icNam); if (entry != null) { icon = IconManager.getIcon(icNam, entry.getSize() == IconSize.NonStd ? IconSize.NonStd : IconSize.Std24); } if (frameTitle == null) { frameTitle = baseLabel; } } } if (frameTitle == null) { DBTableInfo tableInfo = DBTableIdMgr.getInstance() .getByClassName(classToCreate != null ? classToCreate.getName() : view.getClassName()); if (tableInfo != null) { frameTitle = tableInfo.getTitle(); } } int x = 2; String colDef; if (align.equals("center")) { colDef = "f:p:g,p,2px,p,f:p:g"; } else if (align.equals("right")) { colDef = "f:p:g, p,2px,p"; } else // defaults to left { colDef = "p,2px,p,f:p:g"; x = 1; } subViewBtn = icon != null ? createButton(icon) : createButton(baseLabel); subViewBtn.addActionListener(new ActionListener() { //@Override public void actionPerformed(ActionEvent e) { showForm(); } }); //subViewBtn.setEnabled(false); label = createLabel(" "); label.setHorizontalAlignment(SwingConstants.CENTER); label.setOpaque(true); label.setBackground(Color.WHITE); label.setBorder(BorderFactory.createLineBorder(Color.GRAY)); PanelBuilder pb = new PanelBuilder(new FormLayout(colDef, "p"), this); CellConstraints cc = new CellConstraints(); pb.add(subViewBtn, cc.xy(x, 1)); pb.add(label, cc.xy(x + 2, 1)); try { classObj = Class.forName(view.getClassName()); } catch (ClassNotFoundException ex) { log.error(ex); FormDevHelper.showFormDevError(ex); } setOpaque(false); }
From source file:ome.formats.importer.gui.GuiCommonElements.java
/** * A version of addTextPane that lets you add a style and context * //from w w w. j av a2s. co m * @param container - parent container * @param text - text for new Text Pane * @param placement - TableLayout placement within the parent container * @param context - context for new text pane * @param style - style to apply to new text pane * @param debug - turn on/off red debug borders * @return new JTextPane */ public static synchronized JTextPane addTextPane(Container container, String text, String placement, StyleContext context, Style style, boolean debug) { StyledDocument document = new DefaultStyledDocument(context); try { document.insertString(document.getLength(), text, style); } catch (BadLocationException e) { log.error("BadLocationException inserting text to document."); } JTextPane textPane = new JTextPane(document); textPane.setOpaque(false); textPane.setEditable(false); textPane.setFocusable(false); container.add(textPane, placement); if (debug == true) textPane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.red), textPane.getBorder())); return textPane; }
From source file:org.notebook.gui.widget.LookAndFeelSelector.java
/** * Sets the look and feel.//from w ww. ja va2s .c o m * * @param theme * the new look and feel */ public void setLookAndFeel(String theme) { try { log.info("Updating skin '" + theme + "'"); if (skins.containsKey(theme)) { UIManager.setLookAndFeel(skins.get(theme)); } else { log.error("Not found skin '" + theme + "'"); return; } /** fix font bug start */ if (SwingUtilities.isEventDispatchThread()) { fixFontBug(); } else { SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { fixFontBug(); } }); } } catch (Exception e) { log.error(e.toString(), e); } /** * ?????? * tiptool */ if (!isDefaultLookAndFeel(theme)) { // Get border color try { Color c = SubstanceLookAndFeel.getCurrentSkin().getMainActiveColorScheme().getMidColor(); UIManager.put("ToolTip.border", BorderFactory.createLineBorder(c)); UIManager.put("ToolTip.background", new ColorUIResource(Color.WHITE)); UIManager.put("ToolTip.foreground", new ColorUIResource(Color.BLACK)); SubstanceSkin skin = SubstanceLookAndFeel.getCurrentSkin(); SubstanceColorScheme scheme = skin.getMainActiveColorScheme(); GuiUtils.putLookAndFeelColor("borderColor", scheme.getMidColor()); GuiUtils.putLookAndFeelColor("lightColor", scheme.getLightColor()); GuiUtils.putLookAndFeelColor("lightBackgroundFillColor", scheme.getLightBackgroundFillColor()); GuiUtils.putLookAndFeelColor("darkColor", scheme.getDarkColor()); GuiUtils.putLookAndFeelColor("backgroundFillColor", scheme.getBackgroundFillColor()); GuiUtils.putLookAndFeelColor("lineColor", scheme.getLineColor()); GuiUtils.putLookAndFeelColor("selectionForegroundColor", scheme.getSelectionForegroundColor()); GuiUtils.putLookAndFeelColor("selectionBackgroundColor", scheme.getSelectionBackgroundColor()); GuiUtils.putLookAndFeelColor("foregroundColor", scheme.getForegroundColor()); GuiUtils.putLookAndFeelColor("focusRingColor", scheme.getFocusRingColor()); } catch (Exception e) { log.info("This is not a SubstanceLookAndFeel skin."); } UIManager.put(LafWidget.ANIMATION_KIND, LafConstants.AnimationKind.NONE); UIManager.put(SubstanceLookAndFeel.TABBED_PANE_CONTENT_BORDER_KIND, SubstanceConstants.TabContentPaneBorderKind.SINGLE_FULL); JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); } }
From source file:forge.gui.CardDetailPanel.java
public final void setCard(final CardView card, final boolean mayView, final boolean isInAltState) { typeLabel.setVisible(true);/*from w ww .j ava 2 s .c om*/ powerToughnessLabel.setVisible(true); final CardStateView state = card == null ? null : card.getState(isInAltState); if (state == null) { nameCostLabel.setText(""); typeLabel.setText(""); powerToughnessLabel.setText(""); idLabel.setText(""); setInfoLabel.setText(""); setInfoLabel.setToolTipText(""); setInfoLabel.setOpaque(false); setInfoLabel.setBorder(null); cdArea.setText(""); updateBorder(null, false); return; } final String name = CardDetailUtil.formatCardName(card, mayView, isInAltState), nameCost; if (state.getManaCost().isNoCost() || !mayView) { nameCost = name; } else { final String manaCost; if (card.isSplitCard() && card.hasAlternateState() && card.getZone() != ZoneType.Stack) { //only display current state's mana cost when on stack manaCost = card.getCurrentState().getManaCost() + " // " + card.getAlternateState().getManaCost(); } else { manaCost = state.getManaCost().toString(); } nameCost = String.format("%s - %s", name, manaCost); } nameCostLabel.setText(FSkin.encodeSymbols(nameCost, false)); typeLabel.setText(CardDetailUtil.formatCardType(state, mayView)); final String set; final CardRarity rarity; if (mayView) { set = state.getSetCode(); rarity = state.getRarity(); } else { set = CardEdition.UNKNOWN.getCode(); rarity = CardRarity.Unknown; } setInfoLabel.setText(set); if (null != set && !set.isEmpty()) { if (mayView) { final CardEdition edition = FModel.getMagicDb().getEditions().get(set); final String setTooltip; if (null == edition) { setTooltip = rarity.name(); } else { setTooltip = String.format("%s (%s)", edition.getName(), rarity.name()); } setInfoLabel.setToolTipText(setTooltip); } setInfoLabel.setOpaque(true); final Color backColor = fromDetailColor(CardDetailUtil.getRarityColor(rarity)); setInfoLabel.setBackground(backColor); final Color foreColor = FSkin.getHighContrastColor(backColor); setInfoLabel.setForeground(foreColor); setInfoLabel.setBorder(BorderFactory.createLineBorder(foreColor)); } if (state.getState() == CardStateName.FaceDown) { updateBorder(state, false); // TODO: HACK! A temporary measure until the morphs still leaking color can be fixed properly. } else { updateBorder(state, mayView); } powerToughnessLabel.setText(CardDetailUtil.formatPowerToughness(state, mayView)); idLabel.setText(mayView ? CardDetailUtil.formatCardId(state) : ""); // fill the card text cdArea.setText(FSkin.encodeSymbols(CardDetailUtil.composeCardText(state, gameView, mayView), true)); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { scrArea.getVerticalScrollBar().setValue(scrArea.getVerticalScrollBar().getMinimum()); } }); }
From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.preenchedor_formulario.PanelPreenchedorFormulario.java
private void criaInterfaceVisualEscalavel() { miBtnSalvar = new JMenuItem(XHTML_Panel.BTN_SALVAR); painel = new JPanel(); textAreaSourceCode = new G_TextAreaSourceCode(); // frameSilvinha.setJMenuBar(this.criaMenuBar()); new OnChange(textAreaSourceCode, this); textAreaSourceCode.setTipoHTML();/*from w ww.jav a 2 s . c o m*/ textAreaSourceCode.setBorder(criaBorda(XHTML_Panel.COD_FONTE)); painel.setLayout(new GridLayout(2, 1)); setBackground(frameSilvinha.corDefault); Container contentPane = this; contentPane.setLayout(new GridLayout(1, 1)); painel.add(textAreaSourceCode); JPanel panelBtnTabela = new JPanel(); panelBtnTabela.setLayout(new BorderLayout()); /* * Barra de botes */ btnPanel = new JPanel(); btnPanel.setLayout(null); btn_salvar = new JButton(XHTML_Panel.BTN_SALVAR); btn_salvar.setToolTipText(XHTML_Panel.DICA_SALVAR); btn_salvar.setBounds(10, 0, 150, 25); btnPanel.add(btn_salvar); btn_abrir = new JButton(XHTML_Panel.BTN_ABRIR); btn_abrir.setToolTipText(XHTML_Panel.DICA_ABRIR); btn_abrir.setBounds(165, 0, 150, 25); btnPanel.add(btn_abrir); btn_salvarComo = new JButton(XHTML_Panel.BTN_SALVAR_COMO); btn_salvarComo.setToolTipText(XHTML_Panel.DICA_SALVAR_COMO); btn_salvarComo.setBounds(320, 0, 150, 25); btnPanel.add(btn_salvarComo); btn_cancelar = new JButton(XHTML_Panel.TELA_ANTERIOR); btn_cancelar.setToolTipText(XHTML_Panel.DICA_TELA_ANTERIOR); btn_cancelar.setBounds(480, 0, 150, 25); btnPanel.add(btn_cancelar); btnPanel.setPreferredSize(new Dimension(430, 30)); /* * Barra de correcao */ btnAplicar = new JButton(XHTML_Panel.BTN_APLICAR); btnAplicar.setToolTipText(XHTML_Panel.DICA_BTN_APLICAR); btnAplicar.setEnabled(false); texto = new JTextField(); texto.setBorder(BorderFactory.createLineBorder(Color.BLACK)); JPanel borda = new JPanel(new BorderLayout()); JLabel lbl_texto = new JLabel(XHTML_Panel.ROTULO_TEXTO); lbl_texto.setToolTipText(XHTML_Panel.DICA_ROTULO_TEXTO); borda.add(lbl_texto, BorderLayout.WEST); borda.add(texto, BorderLayout.CENTER); borda.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5)); borda.setOpaque(false); panelCorretor = new JPanel(new BorderLayout()); panelCorretor.add(borda, BorderLayout.CENTER); panelCorretor.add(btnAplicar, BorderLayout.EAST); //panelCorretor.add(btnPanel, BorderLayout.WEST); panelCorretor.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10)); panelCorretor.setOpaque(false); /* * Tabela de erros */ tabelaDeErros = new TabelaErros(); scrollPaneTabela = new JScrollPane(); scrollPaneTabela.setViewportView(tabelaDeErros); panelBtnTabela.add(panelCorretor, BorderLayout.NORTH); panelBtnTabela.add(scrollPaneTabela, BorderLayout.CENTER); panelBtnTabela.add(btnPanel, BorderLayout.SOUTH); scrollPaneTabela.setBorder(criaBorda(XHTML_Panel.LISTA_ERROS)); painel.add(panelBtnTabela); btnPanel.setBackground(frameSilvinha.corDefault); if (!original) { reverter = new JButton("Reverter"); reverter.setText(TradPainelRelatorio.REVERTER); reverter.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setVisible(false); TxtBuffer.setContent(TxtBuffer.getContentOriginal()); frameSilvinha.showPainelPreencheCampo(); setVisible(true); } }); //reverter.setActionCommand("Reverter"); reverter.setToolTipText(TradPainelRelatorio.DICA_REVERTER); reverter.getAccessibleContext().setAccessibleDescription(TradPainelRelatorio.DICA_REVERTER); reverter.getAccessibleContext().setAccessibleName(TradPainelRelatorio.DICA_REVERTER); reverter.setBounds(640, 0, 150, 25); btnPanel.add(reverter); } panelBtnTabela.setBackground(frameSilvinha.corDefault); painel.setBackground(frameSilvinha.corDefault); contentPane.setBackground(frameSilvinha.corDefault); scrollPaneTabela.setBackground(frameSilvinha.corDefault); textAreaSourceCode.setBackground(frameSilvinha.corDefault); miBtnSalvar.setEnabled(false); btn_salvar.setEnabled(false); salvaAlteracoes = TxtBuffer.getInstanciaSalvaAlteracoes(textAreaSourceCode.getTextPane(), btn_salvar, miBtnSalvar, frameSilvinha); contentPane.add(painel); // pack(); this.setVisible(true); }
From source file:org.colombbus.tangara.CommandSelection.java
/** * This method initializes this//from w ww . j a v a 2 s . c o m * */ private void initialize() { this.setSize(new Dimension(609, 427)); this.setContentPane(getMainPanel()); commandList.setCellRenderer(new MyCellRenderer()); commandList.setListData(Program.instance().getHistory()); switch (mode) { case MODE_TEXTFILE_CREATION: // file saving this.setTitle(Messages.getString("CommandSelection.fileCreation.title")); break; case MODE_PROGRAM_CREATION: // program saving this.setTitle(Messages.getString("CommandSelection.programCreation.title")); break; case MODE_COMMANDS_INSERTION: // command insertion in program mode this.setTitle(Messages.getString("CommandSelection.commandsInsertion.title")); break; } centralPanel.setBorder(BorderFactory.createLineBorder(new Color(127, 157, 185))); }
From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.corretor_eventos.PanelCorretorEventos.java
private void criaInterfaceVisualEscalavel() { miBtnSalvar = new JMenuItem(XHTML_Panel.BTN_SALVAR); painel = new JPanel(); frameSilvinha.setJMenuBar(this.criaMenuBar()); textAreaSourceCode.setTipoHTML();/* w ww . j a v a 2s . c o m*/ textAreaSourceCode.setBorder(criaBorda(XHTML_Panel.COD_FONTE)); frameSilvinha.setTitle(XHTML_Panel.TIT_CORR_EVT); painel.setLayout(new GridLayout(2, 1)); setBackground(frameSilvinha.corDefault); Container contentPane = this; contentPane.setLayout(new GridLayout(1, 1)); painel.add(textAreaSourceCode); JPanel panelBtnTabela = new JPanel(); panelBtnTabela.setLayout(new BorderLayout()); /* * Barra de botes */ btnPanel = new JPanel(); btnPanel.setLayout(null); btn_salvar = new JButton(XHTML_Panel.BTN_SALVAR); btn_salvar.setToolTipText(XHTML_Panel.DICA_SALVAR); btn_salvar.setBounds(10, 0, 150, 25); btnPanel.add(btn_salvar); btn_abrir = new JButton(XHTML_Panel.BTN_ABRIR); btn_abrir.setToolTipText(XHTML_Panel.DICA_ABRIR); btn_abrir.setBounds(165, 0, 150, 25); btnPanel.add(btn_abrir); btn_salvarComo = new JButton(XHTML_Panel.BTN_SALVAR_COMO); btn_salvarComo.setToolTipText(XHTML_Panel.DICA_SALVAR_COMO); btn_salvarComo.setBounds(320, 0, 150, 25); btnPanel.add(btn_salvarComo); btn_cancelar = new JButton(XHTML_Panel.TELA_ANTERIOR); btn_cancelar.setToolTipText(XHTML_Panel.DICA_TELA_ANTERIOR); btn_cancelar.setBounds(480, 0, 150, 25); btnPanel.add(btn_cancelar); btnPanel.setPreferredSize(new Dimension(430, 30)); /* * Barra de correcao */ btnAplicar = new JButton(XHTML_Panel.BTN_APLICAR); btnAplicar.setToolTipText(XHTML_Panel.DICA_BTN_APLICAR); btnAplicar.setEnabled(false); texto = new JTextField(); texto.setBorder(BorderFactory.createLineBorder(Color.BLACK)); JPanel borda = new JPanel(new BorderLayout()); lbl_texto = new JLabel("JavaScript: "); lbl_texto.setToolTipText(XHTML_Panel.DICA_JAVASCRIPT); borda.add(lbl_texto, BorderLayout.WEST); borda.add(texto, BorderLayout.CENTER); borda.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5)); borda.setOpaque(false); panelCorretor = new JPanel(new BorderLayout()); panelCorretor.add(borda, BorderLayout.CENTER); panelCorretor.add(btnAplicar, BorderLayout.EAST); // panelCorretor.add(btnPanel,BorderLayout.WEST); panelCorretor.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10)); panelCorretor.setOpaque(false); /* * Tabela de erros */ tabelaDeErros = new TabelaErros(); scrollPaneTabela = new JScrollPane(); scrollPaneTabela.setViewportView(tabelaDeErros); panelBtnTabela.add(panelCorretor, BorderLayout.NORTH); panelBtnTabela.add(scrollPaneTabela, BorderLayout.CENTER); panelBtnTabela.add(btnPanel, BorderLayout.SOUTH); scrollPaneTabela.setBorder(criaBorda(XHTML_Panel.LISTA_ERROS)); painel.add(panelBtnTabela); btnPanel.setBackground(frameSilvinha.corDefault); { reverter = new JButton("Reverter"); reverter.setText(TradPainelRelatorio.REVERTER); reverter.setToolTipText(TradPainelRelatorio.DICA_REVERTER); reverter.getAccessibleContext().setAccessibleDescription(TradPainelRelatorio.DICA_REVERTER); reverter.getAccessibleContext().setAccessibleName(TradPainelRelatorio.DICA_REVERTER); reverter.setBounds(480, 0, 150, 25); btnPanel.add(reverter); reverter = new JButton("Reverter"); reverter.setText(TradPainelRelatorio.REVERTER); reverter.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setVisible(false); TxtBuffer.setContent(TxtBuffer.getContentOriginal()); frameSilvinha.showPainelFerramentaEventoDependente(); setVisible(true); } }); reverter.setToolTipText(TradPainelRelatorio.DICA_REVERTER); reverter.getAccessibleContext().setAccessibleDescription(TradPainelRelatorio.DICA_REVERTER); reverter.getAccessibleContext().setAccessibleName(TradPainelRelatorio.DICA_REVERTER); reverter.setBounds(640, 0, 150, 25); btnPanel.add(reverter); } panelBtnTabela.setBackground(frameSilvinha.corDefault); painel.setBackground(frameSilvinha.corDefault); contentPane.setBackground(frameSilvinha.corDefault); scrollPaneTabela.setBackground(frameSilvinha.corDefault); textAreaSourceCode.setBackground(frameSilvinha.corDefault); miBtnSalvar.setEnabled(false); btn_salvar.setEnabled(false); salvaAlteracoes = TxtBuffer.getInstanciaSalvaAlteracoes(textAreaSourceCode.getTextPane(), btn_salvar, miBtnSalvar, frameSilvinha); String fil[] = { ".html", ".htm" }; salvaAlteracoes.setFiltro(fil); contentPane.add(painel); // pack(); this.setVisible(true); }
From source file:org.cloudml.ui.graph.Visu.java
public void createFrame() { final VisualizationViewer<Vertex, Edge> vv = v.getVisualisationViewer(); vv.getRenderContext().setVertexIconTransformer(new Transformer<Vertex, Icon>() { public Icon transform(final Vertex v) { return new Icon() { public int getIconHeight() { return 40; }/*from ww w . ja va 2s.c o m*/ public int getIconWidth() { return 40; } public void paintIcon(java.awt.Component c, Graphics g, int x, int y) { ImageIcon img; if (v.getType() == "node") { img = new ImageIcon(this.getClass().getResource("/server.png")); } else if (v.getType() == "platform") { img = new ImageIcon(this.getClass().getResource("/dbms.png")); } else { img = new ImageIcon(this.getClass().getResource("/soft.png")); } ImageObserver io = new ImageObserver() { public boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height) { // TODO Auto-generated method stub return false; } }; g.drawImage(img.getImage(), x, y, getIconHeight(), getIconWidth(), io); if (!vv.getPickedVertexState().isPicked(v)) { g.setColor(Color.black); } else { g.setColor(Color.red); properties.setModel(new CPIMTable(v)); runtimeProperties.setModel(new CPSMTable(v)); } g.drawString(v.getName(), x - 10, y + 50); } }; } }); // create a frame to hold the graph final JFrame frame = new JFrame(); Container content = frame.getContentPane(); final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); content.add(panel, BorderLayout.CENTER); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final ModalGraphMouse gm = new DefaultModalGraphMouse<Integer, Number>(); vv.setGraphMouse(gm); final ScalingControl scaler = new CrossoverScalingControl(); JButton plus = new JButton("+"); plus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1.1f, vv.getCenter()); } }); JButton save = new JButton("save"); save.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser fc = new JFileChooser(); int returnVal = fc.showDialog(frame, "save"); File result = fc.getSelectedFile(); JsonCodec codec = new JsonCodec(); OutputStream streamResult; try { streamResult = new FileOutputStream(result); codec.save(dmodel, streamResult); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } }); JButton saveImage = new JButton("save as image"); saveImage.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser fc = new JFileChooser(); int returnVal = fc.showDialog(frame, "save"); File result = fc.getSelectedFile(); JsonCodec codec = new JsonCodec(); v.writeJPEGImage(result); } }); //WE NEED TO UPDATE THE FACADE AND THE GUI JButton load = new JButton("load"); load.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser fc = new JFileChooser(); int returnVal = fc.showDialog(frame, "load"); File result = fc.getSelectedFile(); JsonCodec codec = new JsonCodec(); try { InputStream stream = new FileInputStream(result); Deployment model = (Deployment) codec.load(stream); dmodel = model; v.setDeploymentModel(dmodel); ArrayList<Vertex> V = v.drawFromDeploymentModel(); nodeTypes.removeAll(); nodeTypes.setModel(fillList()); properties.setModel(new CPIMTable(V.get(0))); runtimeProperties.setModel(new CPSMTable(V.get(0))); CommandFactory fcommand = new CommandFactory(); CloudMlCommand load = fcommand.loadDeployment(result.getPath()); cml.fireAndWait(load); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } }); JButton minus = new JButton("-"); minus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1 / 1.1f, vv.getCenter()); } }); JButton deploy = new JButton("Deploy!"); deploy.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { //cad.deploy(dmodel); System.out.println("deploy"); CommandFactory fcommand = new CommandFactory(); CloudMlCommand deploy = fcommand.deploy(); cml.fireAndWait(deploy); } }); //right panel JPanel intermediary = new JPanel(); intermediary.setLayout(new BoxLayout(intermediary, BoxLayout.PAGE_AXIS)); intermediary.setBorder(BorderFactory.createLineBorder(Color.black)); JLabel jlCPIM = new JLabel(); jlCPIM.setText("CPIM"); JLabel jlCPSM = new JLabel(); jlCPSM.setText("CPSM"); properties = new JTable(null); //properties.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); JTableHeader h = properties.getTableHeader(); JPanel props = new JPanel(); props.setLayout(new BorderLayout()); props.add(new JScrollPane(properties), BorderLayout.CENTER); props.add(h, BorderLayout.NORTH); runtimeProperties = new JTable(null); //runtimeProperties.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); JTableHeader h2 = runtimeProperties.getTableHeader(); JPanel runProps = new JPanel(); runProps.setLayout(new BorderLayout()); runProps.add(h2, BorderLayout.NORTH); runProps.add(new JScrollPane(runtimeProperties), BorderLayout.CENTER); intermediary.add(jlCPIM); intermediary.add(props); intermediary.add(jlCPSM); intermediary.add(runProps); content.add(intermediary, BorderLayout.EAST); //Left panel JPanel selection = new JPanel(); JLabel nodes = new JLabel(); nodes.setText("Types"); selection.setLayout(new BoxLayout(selection, BoxLayout.PAGE_AXIS)); nodeTypes = new JList(fillList()); nodeTypes.setLayoutOrientation(JList.VERTICAL); nodeTypes.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); nodeTypes.setVisibleRowCount(10); JScrollPane types = new JScrollPane(nodeTypes); types.setPreferredSize(new Dimension(150, 80)); selection.add(nodes); selection.add(types); content.add(selection, BorderLayout.WEST); ((DefaultModalGraphMouse<Integer, Number>) gm) .add(new MyEditingGraphMousePlugin(0, vv, v.getGraph(), nodeTypes, dmodel)); JPanel controls = new JPanel(); controls.add(plus); controls.add(minus); controls.add(save); controls.add(saveImage); controls.add(load); controls.add(deploy); controls.add(((DefaultModalGraphMouse<Integer, Number>) gm).getModeComboBox()); content.add(controls, BorderLayout.SOUTH); frame.pack(); frame.setVisible(true); }
From source file:com.mirth.connect.client.ui.components.rsta.FindReplaceDialog.java
private void initComponents() { setLayout(new MigLayout("insets 11, novisualpadding, hidemode 3, fill, gap 6")); setBackground(UIConstants.COMBO_BOX_BACKGROUND); getContentPane().setBackground(getBackground()); findPanel = new JPanel(new MigLayout("insets 0, novisualpadding, hidemode 3, fill, gap 6")); findPanel.setBackground(getBackground()); ActionListener findActionListener = new ActionListener() { @Override// www . j a v a 2 s .co m public void actionPerformed(ActionEvent evt) { find(); } }; findLabel = new JLabel("Find text:"); findComboBox = new JComboBox<String>(); findComboBox.setEditable(true); findComboBox.setBackground(UIConstants.BACKGROUND_COLOR); findComboBox.getEditor().getEditorComponent().addKeyListener(new KeyAdapter() { @Override public void keyReleased(final KeyEvent evt) { if (evt.getKeyCode() == KeyEvent.VK_ENTER && evt.getModifiers() == 0) { find(); } } }); ActionListener replaceActionListener = new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { replace(); } }; replaceLabel = new JLabel("Replace with:"); replaceComboBox = new JComboBox<String>(); replaceComboBox.setEditable(true); replaceComboBox.setBackground(UIConstants.BACKGROUND_COLOR); directionPanel = new JPanel(new MigLayout("insets 8, novisualpadding, hidemode 3, fill, gap 6")); directionPanel.setBackground(getBackground()); directionPanel.setBorder(BorderFactory.createTitledBorder( BorderFactory.createLineBorder(new Color(150, 150, 150)), "Direction", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Tahoma", 1, 11))); ButtonGroup directionButtonGroup = new ButtonGroup(); directionForwardRadio = new JRadioButton("Forward"); directionForwardRadio.setBackground(directionPanel.getBackground()); directionButtonGroup.add(directionForwardRadio); directionBackwardRadio = new JRadioButton("Backward"); directionBackwardRadio.setBackground(directionPanel.getBackground()); directionButtonGroup.add(directionBackwardRadio); optionsPanel = new JPanel(new MigLayout("insets 8, novisualpadding, hidemode 3, fill, gap 6")); optionsPanel.setBackground(getBackground()); optionsPanel.setBorder(BorderFactory.createTitledBorder( BorderFactory.createLineBorder(new Color(150, 150, 150)), "Options", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Tahoma", 1, 11))); wrapSearchCheckBox = new JCheckBox("Wrap Search"); matchCaseCheckBox = new JCheckBox("Match Case"); regularExpressionCheckBox = new JCheckBox("Regular Expression"); wholeWordCheckBox = new JCheckBox("Whole Word"); findButton = new JButton("Find"); findButton.addActionListener(findActionListener); replaceButton = new JButton("Replace"); replaceButton.addActionListener(replaceActionListener); replaceAllButton = new JButton("Replace All"); replaceAllButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { replaceAll(); } }); warningLabel = new JLabel(); closeButton = new JButton("Close"); closeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { dispose(); } }); }