List of usage examples for javax.swing JSplitPane HORIZONTAL_SPLIT
int HORIZONTAL_SPLIT
To view the source code for javax.swing JSplitPane HORIZONTAL_SPLIT.
Click Source Link
Component
s are split along the x axis. From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.script.PainelScript.java
private void initComponentsEscalavel(ArrayList<FerramentaDescricaoModel> erros) { Ferramenta_Scripts.carregaTexto(TokenLang.LANG); JPanel regraFonteBtn = new JPanel(); regraFonteBtn.setLayout(new BorderLayout()); textAreaSourceCode = new G_TextAreaSourceCode(); textAreaSourceCode.setTipoHTML();// w w w .j av a 2 s . co m new OnChange(textAreaSourceCode, this); tableLinCod = new TabelaDescricao(erros); arTextPainelCorrecao = new ArTextPainelCorrecao(); salvar = new JButton(); abrir = new JButton(); cancelar = new JButton(); strConteudoalt = new String(); btnSalvar = new JMenuItem("Salvar"); salvar.setEnabled(false); salvaAlteracoes = TxtBuffer.getInstanciaSalvaAlteracoes(textAreaSourceCode.getTextPane(), salvar, new JMenuItem(), parentFrame); pnRegra = new JPanel(); lbRegras1 = new JLabel(); lbRegras2 = new JLabel(); pnSetaDescricao = new JPanel(); new JScrollPane(); tArParticipRotulo = new TArParticipRotulo(); conteudoDoAlt = new JTextArea(); pnListaErros = new JPanel(); scrollPanetabLinCod = new JScrollPane(); pnBotoes = new JPanel(); new JButton(); aplicar = new JButton(); conteudoParticRotulo = new ArrayList<String>(); setBackground(CoresDefault.getCorPaineis()); Container contentPane = this;// ?? contentPane.setLayout(new GridLayout(2, 1)); { pnRegra.setBorder(criaBorda(Ferramenta_Scripts.TITULO_REGRA)); pnRegra.setLayout(new GridLayout(2, 1)); pnRegra.add(lbRegras1); lbRegras1.setText(Ferramenta_Scripts.REGRAP1); lbRegras2.setText(Ferramenta_Scripts.REGRAP2); lbRegras1.setHorizontalAlignment(SwingConstants.CENTER); lbRegras2.setHorizontalAlignment(SwingConstants.CENTER); pnRegra.add(lbRegras1); pnRegra.add(lbRegras2); pnRegra.setPreferredSize(new Dimension(700, 60)); } // ---- Salvar ---- salvar.setText(Ferramenta_Scripts.BTN_SALVAR); salvar.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { salvarActionPerformed(e); } }); salvar.setToolTipText(Ferramenta_Scripts.DICA_SALVAR); salvar.getAccessibleContext().setAccessibleDescription(Ferramenta_Scripts.DICA_SALVAR); salvar.getAccessibleContext().setAccessibleName(Ferramenta_Scripts.DICA_SALVAR); salvar.setBounds(10, 0, 150, 25); abrir.setText(Ferramenta_Scripts.BTN_ABRIR); abrir.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AbrirActionPerformed(e); } }); abrir.setToolTipText(Ferramenta_Scripts.DICA_ABRIR); abrir.getAccessibleContext().setAccessibleDescription(Ferramenta_Scripts.DICA_ABRIR_HTML); abrir.getAccessibleContext().setAccessibleName(Ferramenta_Scripts.DICA_ABRIR_HTML); abrir.setBounds(165, 0, 150, 25); cancelar.setText(Ferramenta_Imagens.TELA_ANTERIOR); cancelar.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { CancelarActionPerformed(e); } }); cancelar.setToolTipText(Ferramenta_Imagens.DICA_TELA_ANTERIOR); cancelar.getAccessibleContext().setAccessibleDescription(Ferramenta_Imagens.DICA_TELA_ANTERIOR); cancelar.getAccessibleContext().setAccessibleName(Ferramenta_Imagens.DICA_TELA_ANTERIOR); cancelar.setBounds(320, 0, 150, 25); GridBagConstraints cons = new GridBagConstraints(); cons.fill = GridBagConstraints.BOTH; cons.weighty = 1; pnSetaDescricao.setLayout(new BorderLayout()); cons.anchor = GridBagConstraints.WEST; cons.insets = new Insets(0, 0, 0, 0); JScrollPane sp = new JScrollPane(); sp.setBorder(criaBorda(Ferramenta_Scripts.CONTEUDO_ALTER)); sp.setViewportView(conteudoDoAlt); sp.setPreferredSize(new Dimension(500, 300)); pnSetaDescricao.setPreferredSize(new Dimension(400, 60)); pnListaErros.setBorder(criaBorda(Ferramenta_Scripts.LISTA_ERROS)); pnListaErros.setLayout(new BorderLayout()); scrollPanetabLinCod.setViewportView(tableLinCod); pnListaErros.add(scrollPanetabLinCod, BorderLayout.CENTER); { pnBotoes.setLayout(null); aplicar.setEnabled(false); aplicar.setText(Ferramenta_Scripts.BTN_APLICAR); aplicar.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { aplicarRotuloActionPerformed(e); } }); aplicar.setToolTipText(Ferramenta_Scripts.DICA_APLICAR); aplicar.getAccessibleContext().setAccessibleDescription(Ferramenta_Scripts.DICA_APLICAR); aplicar.getAccessibleContext().setAccessibleName(Ferramenta_Scripts.DICA_APLICAR); aplicar.setBounds(3, 3, 120, 30); pnBotoes.add(aplicar); } /* * Colocar os controles */ pnRegra.setBackground(CoresDefault.getCorPaineis()); regraFonteBtn.add(pnRegra, BorderLayout.NORTH); textAreaSourceCode.setBorder(criaBorda("")); textAreaSourceCode.setBackground(CoresDefault.getCorPaineis()); JSplitPane splitPane = null; Dimension minimumSize = new Dimension(0, 0); sp.setMinimumSize(minimumSize); sp.setPreferredSize(new Dimension(150, 90)); splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, sp, textAreaSourceCode); splitPane.setOneTouchExpandable(true); int w = parentFrame.getWidth(); int s = w / 4; splitPane.setDividerLocation(s); regraFonteBtn.add(splitPane, BorderLayout.CENTER); pnBotoes.setPreferredSize(new Dimension(600, 35)); pnBotoes.setBackground(CoresDefault.getCorPaineis()); regraFonteBtn.setBackground(CoresDefault.getCorPaineis()); contentPane.add(regraFonteBtn); JPanel textoErrosBtn = new JPanel(); textoErrosBtn.setLayout(new BorderLayout()); pnSetaDescricao.setBackground(CoresDefault.getCorPaineis()); pnSetaDescricao.add(pnBotoes, BorderLayout.WEST); textoErrosBtn.add(pnSetaDescricao, BorderLayout.NORTH); textoErrosBtn.add(pnListaErros, BorderLayout.CENTER); JPanel pnSalvarCancelar = new JPanel(); pnSalvarCancelar.setLayout(null); pnSalvarCancelar.setPreferredSize(new Dimension(600, 35)); pnSalvarCancelar.add(salvar); pnSalvarCancelar.add(abrir); pnSalvarCancelar.add(cancelar); 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()); parentFrame.showPainelFerramentaScriptPArq(TxtBuffer.getContentOriginal()); setVisible(true); } }); reverter.setToolTipText(TradPainelRelatorio.DICA_REVERTER); reverter.getAccessibleContext().setAccessibleDescription(TradPainelRelatorio.DICA_REVERTER); reverter.getAccessibleContext().setAccessibleName(TradPainelRelatorio.DICA_REVERTER); reverter.setBounds(485, 0, 150, 25); pnSalvarCancelar.add(reverter); } pnSalvarCancelar.setBackground(CoresDefault.getCorPaineis()); textoErrosBtn.add(pnSalvarCancelar, BorderLayout.SOUTH); pnListaErros.setBackground(CoresDefault.getCorPaineis()); if (tableLinCod.getRowCount() == 0) tableLinCod.addLinha(0, 0, GERAL.DOC_SEM_ERROS); contentPane.setBackground(CoresDefault.getCorPaineis()); contentPane.add(textoErrosBtn); this.setVisible(true); }
From source file:edu.gmu.cs.sim.util.media.chart.ChartGenerator.java
/** Generates a new ChartGenerator with a blank chart. Before anything else, buildChart() is called. */ public ChartGenerator() { // create the chart buildChart();/*from w w w . ja v a 2 s . c o m*/ chart.getPlot().setBackgroundPaint(Color.WHITE); chart.setAntiAlias(true); JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true); split.setBorder(new EmptyBorder(0, 0, 0, 0)); JScrollPane scroll = new JScrollPane(); JPanel b = new JPanel(); b.setLayout(new BorderLayout()); b.add(seriesAttributes, BorderLayout.NORTH); b.add(new JPanel(), BorderLayout.CENTER); scroll.getViewport().setView(b); scroll.setBackground(getBackground()); scroll.getViewport().setBackground(getBackground()); JPanel p = new JPanel(); p.setLayout(new BorderLayout()); LabelledList list = new LabelledList("Chart Properties"); DisclosurePanel pan1 = new DisclosurePanel("Chart Properties", list); globalAttributes.add(pan1); JLabel j = new JLabel("Right-Click or Control-Click"); j.setFont(j.getFont().deriveFont(10.0f).deriveFont(java.awt.Font.ITALIC)); list.add(j); j = new JLabel("on Chart for More Options"); j.setFont(j.getFont().deriveFont(10.0f).deriveFont(java.awt.Font.ITALIC)); list.add(j); titleField = new PropertyField() { public String newValue(String newValue) { setTitle(newValue); getChartPanel().repaint(); return newValue; } }; titleField.setValue(chart.getTitle().getText()); list.add(new JLabel("Title"), titleField); buildGlobalAttributes(list); final JCheckBox legendCheck = new JCheckBox(); ItemListener il = new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { LegendTitle title = new LegendTitle(chart.getPlot()); title.setLegendItemGraphicPadding(new org.jfree.ui.RectangleInsets(0, 8, 0, 4)); chart.addLegend(title); } else { chart.removeLegend(); } } }; legendCheck.addItemListener(il); list.add(new JLabel("Legend"), legendCheck); legendCheck.setSelected(true); /* final JCheckBox aliasCheck = new JCheckBox(); aliasCheck.setSelected(chart.getAntiAlias()); il = new ItemListener() { public void itemStateChanged(ItemEvent e) { chart.setAntiAlias( e.getStateChange() == ItemEvent.SELECTED ); } }; aliasCheck.addItemListener(il); list.add(new JLabel("Antialias"), aliasCheck); */ JPanel pdfButtonPanel = new JPanel(); pdfButtonPanel.setBorder(new javax.swing.border.TitledBorder("Chart Output")); DisclosurePanel pan2 = new DisclosurePanel("Chart Output", pdfButtonPanel); pdfButtonPanel.setLayout(new BorderLayout()); Box pdfbox = new Box(BoxLayout.Y_AXIS); pdfButtonPanel.add(pdfbox, BorderLayout.WEST); JButton pdfButton = new JButton("Save as PDF"); pdfbox.add(pdfButton); pdfButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { FileDialog fd = new FileDialog(frame, "Choose PDF file...", FileDialog.SAVE); fd.setFile(chart.getTitle().getText() + ".pdf"); fd.setVisible(true); String fileName = fd.getFile(); if (fileName != null) { Dimension dim = chartPanel.getPreferredSize(); PDFEncoder.generatePDF(chart, dim.width, dim.height, new File(fd.getDirectory(), Utilities.ensureFileEndsWith(fd.getFile(), ".pdf"))); } } }); movieButton = new JButton("Create a Movie"); pdfbox.add(movieButton); pdfbox.add(Box.createGlue()); movieButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (movieMaker == null) { startMovie(); } else { stopMovie(); } } }); globalAttributes.add(pan2); // we add into an outer box so we can later on add more global seriesAttributes // as the user instructs and still have glue be last Box outerAttributes = Box.createVerticalBox(); outerAttributes.add(globalAttributes); outerAttributes.add(Box.createGlue()); p.add(outerAttributes, BorderLayout.NORTH); p.add(scroll, BorderLayout.CENTER); p.setMinimumSize(new Dimension(0, 0)); p.setPreferredSize(new Dimension(200, 0)); split.setLeftComponent(p); // Add scale and proportion fields Box header = Box.createHorizontalBox(); final double MAXIMUM_SCALE = 8; fixBox = new JCheckBox("Fill"); fixBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setFixed(fixBox.isSelected()); } }); header.add(fixBox); fixBox.setSelected(true); // add the scale field scaleField = new NumberTextField(" Scale: ", 1.0, true) { public double newValue(double newValue) { if (newValue <= 0.0) { newValue = currentValue; } if (newValue > MAXIMUM_SCALE) { newValue = currentValue; } scale = newValue; resizeChart(); return newValue; } }; scaleField.setToolTipText("Zoom in and out"); scaleField.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2)); scaleField.setEnabled(false); scaleField.setText(""); header.add(scaleField); // add the proportion field proportionField = new NumberTextField(" Proportion: ", 1.5, true) { public double newValue(double newValue) { if (newValue <= 0.0) { newValue = currentValue; } proportion = newValue; resizeChart(); return newValue; } }; proportionField.setToolTipText("Change the chart proportions (ratio of width to height)"); proportionField.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2)); header.add(proportionField); chartHolder.setMinimumSize(new Dimension(0, 0)); chartHolder.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); chartHolder.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); chartHolder.getViewport().setBackground(Color.gray); JPanel p2 = new JPanel(); p2.setLayout(new BorderLayout()); p2.add(chartHolder, BorderLayout.CENTER); p2.add(header, BorderLayout.NORTH); split.setRightComponent(p2); setLayout(new BorderLayout()); add(split, BorderLayout.CENTER); // set the default to be white, which looks good when printed chart.setBackgroundPaint(Color.WHITE); // JFreeChart has a hillariously broken way of handling font scaling. // It allows fonts to scale independently in X and Y. We hack a workaround here. chartPanel.setMinimumDrawHeight((int) DEFAULT_CHART_HEIGHT); chartPanel.setMaximumDrawHeight((int) DEFAULT_CHART_HEIGHT); chartPanel.setMinimumDrawWidth((int) (DEFAULT_CHART_HEIGHT * proportion)); chartPanel.setMaximumDrawWidth((int) (DEFAULT_CHART_HEIGHT * proportion)); chartPanel.setPreferredSize(new java.awt.Dimension((int) (DEFAULT_CHART_HEIGHT * DEFAULT_CHART_PROPORTION), (int) (DEFAULT_CHART_HEIGHT))); }
From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.objeto.PainelObjeto.java
private void initComponentsEscalavel( ArrayList<FerramentaDescricaoModel> erros) { Ferramenta_Objetos.carregaTexto(TokenLang.LANG); JPanel regraFonteBtn = new JPanel(); regraFonteBtn.setLayout(new BorderLayout()); scrollPaneDescricao = new G_TextAreaSourceCode(); scrollPaneDescricao.setTipoHTML();/*from www. j a v a2 s . c o m*/ new OnChange(scrollPaneDescricao, this); //parentFrame.setJMenuBar(this.criaMenuBar()); // parentFrame.setTitle("Associador de rtulos"); tableLinCod = new TabelaDescricao(erros); arTextPainelCorrecao = new ArTextPainelCorrecao(); // scrollPaneCorrecaoLabel = new ConteudoCorrecaoLabel(); salvar = new JButton(); abrir = new JButton(); cancelar = new JButton(); strConteudoalt = new String(); // panelLegenda = new JPanel(); pnRegra = new JPanel(); lbRegras1 = new JLabel(); lbRegras2 = new JLabel(); pnSetaDescricao = new JPanel(); pnSetaDescricao.setLayout(new BorderLayout()); spTextoDescricao = new JScrollPane(); tArParticipRotulo = new TArParticipRotulo(); conteudoDoAlt = new JTextArea(); pnListaErros = new JPanel(); scrollPanetabLinCod = new JScrollPane(); lbTemp = new JLabel(); pnBotoes = new JPanel(); btnSalvar = new JMenuItem(GERAL.BTN_SALVAR); adicionar = new JButton(); conteudoParticRotulo = new ArrayList<String>(); // setJMenuBar(this.criaMenuBar()); // ======== this ======== // setTitle("Associe explicitamente os r\u00f3tulos aos respectivos // controles:"); salvar.setEnabled(false); salvaAlteracoes = TxtBuffer.getInstanciaSalvaAlteracoes(scrollPaneDescricao.getTextPane(), salvar, new JMenuItem(), parentFrame); setBackground(CoresDefault.getCorPaineis()); Container contentPane = this;// ?? contentPane.setLayout(new GridLayout(2, 1)); // ======== pnRegra ======== { pnRegra.setBorder(criaBorda(Ferramenta_Objetos.TITULO_REGRA)); pnRegra.setLayout(new GridLayout(2, 1)); pnRegra.add(lbRegras1); lbRegras1.setText(Ferramenta_Objetos.REGRAP1); lbRegras2.setText(Ferramenta_Objetos.REGRAP2); lbRegras1.setHorizontalAlignment(SwingConstants.CENTER); lbRegras2.setHorizontalAlignment(SwingConstants.CENTER); pnRegra.add(lbRegras1); pnRegra.add(lbRegras2); pnRegra.setPreferredSize(new Dimension(700, 60)); } // G_URLIcon.setIcon(lbTemp, // "http://pitecos.blogs.sapo.pt/arquivo/pai%20natal%20o5.%20jpg.jpg"); // ======== pnDescricao ======== // ---- Salvar ---- salvar.setText(Ferramenta_Objetos.BTN_SALVAR); salvar.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { salvarActionPerformed(e); } }); salvar.setToolTipText(Ferramenta_Objetos.DICA_SALVAR); salvar.getAccessibleContext().setAccessibleDescription(Ferramenta_Objetos.DICA_SALVAR); salvar.getAccessibleContext().setAccessibleName(Ferramenta_Objetos.DICA_SALVAR); salvar.setBounds(10, 0, 150, 25); abrir.setText(Ferramenta_Objetos.BTN_ABRIR); abrir.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AbrirActionPerformed(e); } }); abrir.setToolTipText(Ferramenta_Objetos.DICA_ABRIR); abrir.getAccessibleContext().setAccessibleDescription(Ferramenta_Objetos.DICA_ABRIR_HTML); abrir.getAccessibleContext().setAccessibleName(Ferramenta_Objetos.DICA_ABRIR_HTML); abrir.setBounds(165, 0, 150, 25); cancelar.setText(Ferramenta_Objetos.TELA_ANTERIOR); cancelar.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { CancelarActionPerformed(e); } }); cancelar.setToolTipText(Ferramenta_Objetos.DICA_TELA_ANTERIOR); cancelar.getAccessibleContext().setAccessibleDescription(Ferramenta_Objetos.DICA_TELA_ANTERIOR); cancelar.getAccessibleContext().setAccessibleName(Ferramenta_Objetos.DICA_TELA_ANTERIOR); cancelar.setBounds(320, 0, 150, 25); // ======== pnParticRotulo ======== // pnSetaDescricao.setBorder(criaBorda(Ferramenta_Imagens.TITULO_DIGITE_O_ALT)); // ======== spParticRotulo ======== { // spTextoDescricao.setViewportView(conteudoDoAlt); } // lbRegras1.setText(Reparo_Imagens.REGRAP2); // lbRegras1.setHorizontalAlignment(SwingConstants.CENTER); // pnRegra.add(lbRegras1); JScrollPane sp = new JScrollPane(); sp.setViewportView(conteudoDoAlt); sp.setPreferredSize(new Dimension(500, 300)); sp.setBorder(criaBorda(Ferramenta_Objetos.CONTEUDO_ALTER)); // pnSetaDescricao.add(spTextoDescricao,cons); pnSetaDescricao.setPreferredSize(new Dimension(400, 60)); // ======== pnListaErros ======== { pnListaErros.setBorder(criaBorda(Ferramenta_Objetos.LISTA_ERROS)); pnListaErros.setLayout(new BorderLayout()); // ======== scrollPanetabLinCod ======== { scrollPanetabLinCod.setViewportView(tableLinCod); } pnListaErros.add(scrollPanetabLinCod, BorderLayout.CENTER); } // ======== pnBotoes ======== { // pnBotoes.setBorder(criaBorda("")); pnBotoes.setLayout(null); // ---- adicionar ---- adicionar.setText(Ferramenta_Objetos.BTN_ADICIONAR); adicionar.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { adicionarActionPerformed(e); } }); } /* * Colocar os controles */ pnRegra.setBackground(CoresDefault.getCorPaineis()); regraFonteBtn.add(pnRegra, BorderLayout.NORTH); scrollPaneDescricao.setBorder(criaBorda("")); scrollPaneDescricao.setBackground(CoresDefault.getCorPaineis()); JSplitPane splitPane = null; Dimension minimumSize = new Dimension(0, 0); // JScrollPane ajudaScrollPane = new // JScrollPane(ajuda,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); sp.setMinimumSize(minimumSize); sp.setPreferredSize(new Dimension(150, 90)); splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, sp, scrollPaneDescricao); splitPane.setOneTouchExpandable(true); // splitPane.set // splitPane.setDividerLocation(0.95); int w = parentFrame.getWidth(); int s = w / 4; splitPane.setDividerLocation(s); // regraFonteBtn.add(scrollPaneCorrecaoLabel, BorderLayout.CENTER); regraFonteBtn.add(splitPane, BorderLayout.CENTER); pnBotoes.setPreferredSize(new Dimension(600, 35)); pnBotoes.setBackground(CoresDefault.getCorPaineis()); // regraFonteBtn.add(pnBotoes, BorderLayout.SOUTH); regraFonteBtn.setBackground(CoresDefault.getCorPaineis()); contentPane.add(regraFonteBtn); JPanel textoErrosBtn = new JPanel(); textoErrosBtn.setLayout(new BorderLayout()); pnSetaDescricao.setBackground(CoresDefault.getCorPaineis()); pnSetaDescricao.add(pnBotoes); aplicar = new JButton(); aplicar.setBounds(3, 3, 120, 30); pnBotoes.add(aplicar); // ---- aplicarRotulo ---- aplicar.setEnabled(false); aplicar.setText(Ferramenta_Objetos.BTN_APLICAR); aplicar.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { aplicarRotuloActionPerformed(e); } }); aplicar.setToolTipText(Ferramenta_Objetos.DICA_APLICAR); aplicar.getAccessibleContext().setAccessibleDescription(Ferramenta_Objetos.DICA_APLICAR); aplicar.getAccessibleContext().setAccessibleName(Ferramenta_Objetos.DICA_APLICAR); textoErrosBtn.add(pnSetaDescricao, BorderLayout.NORTH); textoErrosBtn.add(pnListaErros, BorderLayout.CENTER); JPanel pnSalvarCancelar = new JPanel(); pnSalvarCancelar.setLayout(null); pnSalvarCancelar.setPreferredSize(new Dimension(600, 35)); pnSalvarCancelar.add(salvar); pnSalvarCancelar.add(abrir); pnSalvarCancelar.add(cancelar); if (!original) { reverter = new JButton("Reverter"); reverter.setText(TradPainelRelatorio.REVERTER); reverter.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub setVisible(false); TxtBuffer.setContent(TxtBuffer.getContentOriginal()); parentFrame.showPainelFerramentaDescricaoObjetosPArq(TxtBuffer.getContentOriginal()); setVisible(true); } }); //reverter.setActionCommand("Reverter"); reverter.setToolTipText(TradPainelRelatorio.DICA_REVERTER); reverter.getAccessibleContext().setAccessibleDescription(TradPainelRelatorio.DICA_REVERTER); reverter.getAccessibleContext().setAccessibleName(TradPainelRelatorio.DICA_REVERTER); reverter.setBounds(485, 0, 150, 25); pnSalvarCancelar.add(reverter); } pnSalvarCancelar.setBackground(CoresDefault.getCorPaineis()); textoErrosBtn.add(pnSalvarCancelar, BorderLayout.SOUTH); pnListaErros.setBackground(CoresDefault.getCorPaineis()); textoErrosBtn.add(pnListaErros, BorderLayout.CENTER); contentPane.setBackground(CoresDefault.getCorPaineis()); contentPane.add(textoErrosBtn); if (tableLinCod.getRowCount() == 0) tableLinCod.addLinha(0, 0, GERAL.DOC_SEM_ERROS); this.setVisible(true); }
From source file:edu.brown.gui.CatalogViewer.java
/** * /*from w ww .j a v a 2s. c om*/ */ protected void viewerInit() { // ---------------------------------------------- // MENU // ---------------------------------------------- JMenu menu; JMenuItem menuItem; // // File Menu // menu = new JMenu("File"); menu.getPopupMenu().setLightWeightPopupEnabled(false); menu.setMnemonic(KeyEvent.VK_F); menu.getAccessibleContext().setAccessibleDescription("File Menu"); menuBar.add(menu); menuItem = new JMenuItem("Open Catalog From File"); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK)); menuItem.getAccessibleContext().setAccessibleDescription("Open Catalog From File"); menuItem.addActionListener(this.menuHandler); menuItem.putClientProperty(MenuHandler.MENU_ID, MenuOptions.CATALOG_OPEN_FILE); menu.add(menuItem); menuItem = new JMenuItem("Open Catalog From Jar"); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK)); menuItem.getAccessibleContext().setAccessibleDescription("Open Catalog From Project Jar"); menuItem.addActionListener(this.menuHandler); menuItem.putClientProperty(MenuHandler.MENU_ID, MenuOptions.CATALOG_OPEN_JAR); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem("Quit", KeyEvent.VK_Q); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.CTRL_MASK)); menuItem.getAccessibleContext().setAccessibleDescription("Quit Program"); menuItem.addActionListener(this.menuHandler); menuItem.putClientProperty(MenuHandler.MENU_ID, MenuOptions.QUIT); menu.add(menuItem); // ---------------------------------------------- // CATALOG TREE PANEL // ---------------------------------------------- this.catalogTree = new JTree(); this.catalogTree.setEditable(false); this.catalogTree.setCellRenderer(new CatalogViewer.CatalogTreeRenderer()); this.catalogTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); this.catalogTree.addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) CatalogViewer.this.catalogTree .getLastSelectedPathComponent(); if (node == null) return; Object user_obj = node.getUserObject(); String new_text = ""; // <html>"; boolean text_mode = true; if (user_obj instanceof WrapperNode) { CatalogType catalog_obj = ((WrapperNode) user_obj).getCatalogType(); new_text += CatalogViewer.this.getAttributesText(catalog_obj); } else if (user_obj instanceof AttributesNode) { AttributesNode wrapper = (AttributesNode) user_obj; new_text += wrapper.getAttributes(); } else if (user_obj instanceof PlanTreeCatalogNode) { final PlanTreeCatalogNode wrapper = (PlanTreeCatalogNode) user_obj; text_mode = false; CatalogViewer.this.mainPanel.remove(0); CatalogViewer.this.mainPanel.add(wrapper.getPanel(), BorderLayout.CENTER); CatalogViewer.this.mainPanel.validate(); CatalogViewer.this.mainPanel.repaint(); if (SwingUtilities.isEventDispatchThread() == false) { SwingUtilities.invokeLater(new Runnable() { public void run() { wrapper.centerOnRoot(); } }); } else { wrapper.centerOnRoot(); } } else { new_text += CatalogViewer.this.getSummaryText(); } // Text Mode if (text_mode) { if (CatalogViewer.this.text_mode == false) { CatalogViewer.this.mainPanel.remove(0); CatalogViewer.this.mainPanel.add(CatalogViewer.this.textInfoPanel); } CatalogViewer.this.textInfoTextArea.setText(new_text); // Scroll to top CatalogViewer.this.textInfoTextArea.grabFocus(); } CatalogViewer.this.text_mode = text_mode; } }); this.generateCatalogTree(this.catalog, this.catalog_file_path.getName()); // // Text Information Panel // this.textInfoPanel = new JPanel(); this.textInfoPanel.setLayout(new BorderLayout()); this.textInfoTextArea = new JTextArea(); this.textInfoTextArea.setEditable(false); this.textInfoTextArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12)); this.textInfoTextArea.setText(this.getSummaryText()); this.textInfoTextArea.addFocusListener(new FocusListener() { @Override public void focusLost(FocusEvent e) { // TODO Auto-generated method stub } @Override public void focusGained(FocusEvent e) { CatalogViewer.this.scrollTextInfoToTop(); } }); this.textInfoScroller = new JScrollPane(this.textInfoTextArea); this.textInfoPanel.add(this.textInfoScroller, BorderLayout.CENTER); this.mainPanel = new JPanel(new BorderLayout()); this.mainPanel.add(textInfoPanel, BorderLayout.CENTER); // // Search Toolbar // JPanel searchPanel = new JPanel(); searchPanel.setLayout(new BorderLayout()); JPanel innerSearchPanel = new JPanel(); innerSearchPanel.setLayout(new BoxLayout(innerSearchPanel, BoxLayout.X_AXIS)); innerSearchPanel.add(new JLabel("Search: ")); this.searchField = new JTextField(30); innerSearchPanel.add(this.searchField); searchPanel.add(innerSearchPanel, BorderLayout.EAST); this.searchField.addKeyListener(new KeyListener() { private String last = null; @Override public void keyReleased(KeyEvent e) { String value = CatalogViewer.this.searchField.getText().toLowerCase().trim(); if (!value.isEmpty() && (this.last == null || !this.last.equals(value))) { CatalogViewer.this.search(value); } this.last = value; } @Override public void keyTyped(KeyEvent e) { // Do nothing... } @Override public void keyPressed(KeyEvent e) { // Do nothing... } }); // Putting it all together JScrollPane scrollPane = new JScrollPane(this.catalogTree); JPanel topPanel = new JPanel(); topPanel.setLayout(new BorderLayout()); topPanel.add(searchPanel, BorderLayout.NORTH); topPanel.add(scrollPane, BorderLayout.CENTER); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, topPanel, this.mainPanel); splitPane.setDividerLocation(400); this.add(splitPane, BorderLayout.CENTER); }
From source file:com.rapidminer.gui.graphs.GraphViewer.java
public GraphViewer(final GraphCreator<V, E> graphCreator) { try {//from w w w . j av a2 s . c o m if (!RapidMiner.getExecutionMode().isHeadless()) { graphMouse = new DefaultModalGraphMouse(1 / 1.1f, 1.1f); } } catch (HeadlessException e) { } this.graphCreator = graphCreator; setLayout(new BorderLayout()); Graph<V, E> graph = graphCreator.createGraph(); this.layoutSelection = new LayoutSelection<>(this, graph); this.layout = new ISOMLayout<>(graph); vv = new VisualizationViewer<V, E>(layout) { private static final long serialVersionUID = 8247229781249216143L; private boolean initialized = false; /** * Necessary in order to re-change layout after first painting (starting position and * size). */ @Override public void paint(Graphics g) { super.paint(g); if (!initialized) { initialized = true; updateLayout(); if (objectViewerSplitPane != null) { objectViewerSplitPane.setDividerLocation(0.9); } } } }; vv.setBorder(BorderFactory.createEmptyBorder()); vv.setBackground(Color.white); // === design === // ## edge layout ## // EDGE SHAPE int edgeShapeType = graphCreator.getEdgeShape(); switch (edgeShapeType) { case GraphCreator.EDGE_SHAPE_LINE: vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line<V, E>()); break; case GraphCreator.EDGE_SHAPE_QUAD_CURVE: vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.QuadCurve<V, E>()); break; case GraphCreator.EDGE_SHAPE_CUBIC_CURVE: vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.CubicCurve<V, E>()); break; case GraphCreator.EDGE_SHAPE_BENT_LINE: vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.BentLine<V, E>()); break; case GraphCreator.EDGE_SHAPE_WEDGE: vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Wedge<V, E>(5)); break; default: vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line<V, E>()); break; } // EDGE FONT vv.getRenderContext().setEdgeFontTransformer(new Transformer<E, Font>() { @Override public Font transform(E arg0) { return EDGE_FONT; } }); // EDGE COLORS vv.getRenderContext().setEdgeDrawPaintTransformer(new Transformer<E, Paint>() { @Override public Paint transform(E edge) { double edgeStrength = graphCreator.getEdgeStrength(edge); int value = (int) Math.max(140, Math.min(230, 230 - edgeStrength * 90)); return new Color(value, value, value); } }); vv.getRenderContext().setArrowDrawPaintTransformer(new Transformer<E, Paint>() { @Override public Paint transform(E edge) { double edgeStrength = graphCreator.getEdgeStrength(edge); int value = (int) Math.max(140, Math.min(230, 230 - edgeStrength * 90)); return new Color(value, value, value).darker(); } }); vv.getRenderContext().setArrowFillPaintTransformer(new Transformer<E, Paint>() { @Override public Paint transform(E edge) { double edgeStrength = graphCreator.getEdgeStrength(edge); int value = (int) Math.max(140, Math.min(230, 230 - edgeStrength * 90)); return new Color(value, value, value); } }); // EDGE LABEL POSITION vv.getRenderContext() .setEdgeLabelClosenessTransformer(new ConstantDirectionalEdgeValueTransformer<V, E>(0.5d, 0.5d)); int labelOffset = graphCreator.getLabelOffset(); if (labelOffset >= 0) { vv.getRenderContext().setLabelOffset(labelOffset); } // EDGE LABELS vv.getRenderContext().setEdgeLabelTransformer(new Transformer<E, String>() { @Override public String transform(E object) { return graphCreator.getEdgeName(object); } }); // EDGE LABEL RENDERER Renderer.EdgeLabel<V, E> edgeLabelRenderer = graphCreator.getEdgeLabelRenderer(); if (edgeLabelRenderer != null) { vv.getRenderer().setEdgeLabelRenderer(edgeLabelRenderer); // renderer... } vv.getRenderContext().setEdgeLabelRenderer(new EdgeLabelRenderer() { // ...context! private JLabel renderer = new JLabel(); @Override public <T> Component getEdgeLabelRendererComponent(JComponent parent, Object value, Font font, boolean isSelected, T edge) { this.renderer.setFont(font); if (graphCreator.isEdgeLabelDecorating()) { this.renderer.setOpaque(true); renderer.setBackground(Color.WHITE); // use this for a more fancy look and feel // renderer.setBackground(SwingTools.TRANSPARENT_YELLOW); // this.renderer.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(SwingTools.DARK_BLUE), // BorderFactory.createEmptyBorder(1,1,1,1))); } this.renderer.setText(value.toString()); return this.renderer; } /** Let the graph model decide. */ @Override public boolean isRotateEdgeLabels() { return graphCreator.isRotatingEdgeLabels(); } /** Does nothing. */ @Override public void setRotateEdgeLabels(boolean rotate) { } }); // ## vertex layout ## // VERTEX FONT vv.getRenderContext().setVertexFontTransformer(new Transformer<V, Font>() { @Override public Font transform(V vertex) { if (graphCreator.isBold(vertex)) { return VERTEX_BOLD_FONT; } else { return VERTEX_PLAIN_FONT; } } }); // VERTEX NAME vv.getRenderContext().setVertexLabelTransformer(new Transformer<V, String>() { @Override public String transform(V object) { return graphCreator.getVertexName(object); } }); // VERTEX FILL PAINT Transformer<V, Paint> paintTransformer = graphCreator.getVertexPaintTransformer(vv); if (paintTransformer == null) { paintTransformer = new Transformer<V, Paint>() { @Override public Paint transform(V vertex) { if (vv.getPickedVertexState().isPicked(vertex)) { return SwingTools.LIGHT_YELLOW; } else { return SwingTools.LIGHT_BLUE; } } }; } vv.getRenderContext().setVertexFillPaintTransformer(paintTransformer); // VERTEX DRAW PAINT vv.getRenderContext().setVertexDrawPaintTransformer(new Transformer<V, Paint>() { @Override public Paint transform(V vertex) { if (vv.getPickedVertexState().isPicked(vertex)) { return SwingTools.DARKEST_YELLOW.darker(); } else { return SwingTools.DARKEST_BLUE.darker(); } } }); // VERTEX TOOL TIP this.vv.setVertexToolTipTransformer(new Transformer<V, String>() { @Override public String transform(V vertex) { return graphCreator.getVertexToolTip(vertex); } }); // VERTEX SHAPE vv.getRenderContext().setVertexShapeTransformer(new ExtendedVertexShapeTransformer<>(graphCreator)); // VERTEX RENDERER Renderer.Vertex<V, E> vertexRenderer = graphCreator.getVertexRenderer(); if (vertexRenderer != null) { vv.getRenderer().setVertexRenderer(vertexRenderer); } // VERTEX LABEL RENDERER setDefaultLabelPosition(); // custom renderer? Renderer.VertexLabel<V, E> customVertexLabelRenderer = graphCreator.getVertexLabelRenderer(); if (customVertexLabelRenderer != null) { vv.getRenderer().setVertexLabelRenderer(customVertexLabelRenderer); } // context vv.getRenderContext().setVertexLabelRenderer(new VertexLabelRenderer() { private JLabel label = new JLabel(); @Override public <T> Component getVertexLabelRendererComponent(JComponent parent, Object object, Font font, boolean isSelection, T vertex) { label.setFont(font); if (object != null) { label.setText(object.toString()); } else { label.setText(""); } return label; } }); // === end of design === // === main panel === if (graphCreator.getObjectViewer() == null) { add(vv, BorderLayout.CENTER); } else { JComponent viewer = graphCreator.getObjectViewer().getViewerComponent(); if (viewer != null) { viewer.setBorder(null); objectViewerSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); objectViewerSplitPane.setResizeWeight(1); objectViewerSplitPane.add(vv, 0); objectViewerSplitPane.add(viewer, 1); add(objectViewerSplitPane, BorderLayout.CENTER); } else { add(vv, BorderLayout.CENTER); } } // === control panel === Component controlPanel = createControlPanel(); add(new ExtendedJScrollPane(controlPanel), BorderLayout.WEST); this.showEdgeLabels = !graphCreator.showEdgeLabelsDefault(); togglePaintEdgeLabels(); this.showVertexLabels = !graphCreator.showVertexLabelsDefault(); togglePaintVertexLabels(); this.layoutSelection.setLayout(); }
From source file:de.codesourcery.eve.skills.ui.components.impl.planning.CreateProductionTemplateComponent.java
@Override protected JPanel createPanel() { tree.setRootVisible(true);//from w ww.j av a 2 s . c om tree.setCellRenderer(renderer); tree.setModel(this.treeBuilder.getTreeModel()); final PopupMenuBuilder menuBuilder = new PopupMenuBuilder().addItem("Produce", new CreateSubPlanAction()) .addItem("Buy on market", new DeleteSubPlanAction()) .addItem("Buy on market", new DeleteInventionJobAction()) .addItem("Invent from T1 blueprint", new CreateInventionJobAction()); menuBuilder.attach(tree); tree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent e) { final TreePath selectedPath = e.getPath(); if (selectedPath == null || selectedPath.getPathCount() == 0) { selectedNodeChanged(null); } else { selectedNodeChanged((ITreeNode) selectedPath.getLastPathComponent()); } } }); final JScrollPane treePane = new JScrollPane(tree); // add editor panel editorPanel.setLayout(new GridBagLayout()); editorPanel.setBorder(BorderFactory.createLineBorder(Color.black)); // cost statement panel final JPanel costPanel = costStatement.getPanel(); final JPanel combinedPanel = new JPanel(); combinedPanel.setLayout(new GridBagLayout()); combinedPanel.add(costPanel, constraints(0, 0).resizeBoth().useRemainingWidth().end()); combinedPanel.add(editorPanel, constraints(0, 1).resizeBoth().useRemainingSpace().end()); final JPanel result = new JPanel(); result.setLayout(new GridBagLayout()); final JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, treePane, combinedPanel); result.add(splitPane, constraints().resizeBoth().end()); costStatement.refresh(); return result; }
From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.imagem.PanelDescricaoImagens.java
private void initComponentsEscalavel(ArrayList<FerramentaDescricaoModel> erros) { Ferramenta_Imagens.carregaTexto(TokenLang.LANG); JPanel regraFonteBtn = new JPanel(); regraFonteBtn.setLayout(new BorderLayout()); textAreaSourceCode = new G_TextAreaSourceCode(); textAreaSourceCode.setTipoHTML();//from ww w . j a v a2 s . com new OnChange(textAreaSourceCode, this); // parentFrame.setTitle("Associador de rtulos"); tableLinCod = new TabelaDescricao(this, erros); arTextPainelCorrecao = new ArTextPainelCorrecao(this); // scrollPaneCorrecaoLabel = new ConteudoCorrecaoLabel(); analiseSistematica = new JButton(); salvar = new JButton(); abrir = new JButton(); cancelar = new JButton(); strConteudoalt = new String(); // panelLegenda = new JPanel(); btnSalvar = new JMenuItem(GERAL.BTN_SALVAR); pnRegra = new JPanel(); lbRegras1 = new JLabel(); lbRegras2 = new JLabel(); pnSetaDescricao = new JPanel(); spTextoDescricao = new JScrollPane(); tArParticipRotulo = new TArParticipRotulo(this); conteudoDoAlt = new JTextArea(); pnListaErros = new JPanel(); scrollPanetabLinCod = new JScrollPane(); /** * Mostra pro usurio a imagem que est sem descrio */ imagemSemDesc = new XHTMLPanel(); pnBotoes = new JPanel(); salvar.setEnabled(false); salvaAlteracoes = TxtBuffer.getInstanciaSalvaAlteracoes(textAreaSourceCode.getTextPane(), salvar, new JMenuItem(), parentFrame); adicionar = new JButton(); aplicar = new JButton(); conteudoParticRotulo = new ArrayList<String>(); analiseSistematica.setEnabled(false); // setJMenuBar(this.criaMenuBar()); // ======== this ======== // setTitle("Associe explicitamente os r\u00f3tulos aos respectivos // controles:"); setBackground(CoresDefault.getCorPaineis()); Container contentPane = this;// ?? contentPane.setLayout(new GridLayout(2, 1)); // ======== pnRegra ======== { pnRegra.setBorder(criaBorda(Ferramenta_Imagens.TITULO_REGRA)); pnRegra.setLayout(new GridLayout(2, 1)); pnRegra.add(lbRegras1); lbRegras1.setText(Ferramenta_Imagens.REGRAP1); lbRegras2.setText(Ferramenta_Imagens.REGRAP2); lbRegras1.setHorizontalAlignment(SwingConstants.CENTER); lbRegras2.setHorizontalAlignment(SwingConstants.CENTER); pnRegra.add(lbRegras1); pnRegra.add(lbRegras2); pnRegra.setPreferredSize(new Dimension(700, 60)); } // G_URLIcon.setIcon(lbTemp, // "http://pitecos.blogs.sapo.pt/arquivo/pai%20natal%20o5.%20jpg.jpg"); JScrollPane sp = new JScrollPane(); sp.setViewportView(imagemSemDesc); sp.setPreferredSize(new Dimension(500, 300)); // ======== pnDescricao ======== // ---- Salvar ---- salvar.setText(Ferramenta_Imagens.BTN_SALVAR); salvar.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { salvarActionPerformed(e); } }); salvar.setToolTipText(Ferramenta_Imagens.DICA_SALVAR); salvar.getAccessibleContext().setAccessibleDescription(Ferramenta_Imagens.DICA_SALVAR); salvar.getAccessibleContext().setAccessibleName(Ferramenta_Imagens.DICA_SALVAR); salvar.setBounds(10, 0, 150, 25); abrir.setText(Ferramenta_Imagens.BTN_ABRIR); abrir.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AbrirActionPerformed(e); } }); abrir.setToolTipText(Ferramenta_Imagens.DICA_ABRIR_HTML); abrir.getAccessibleContext().setAccessibleDescription(Ferramenta_Imagens.DICA_ABRIR_HTML); abrir.getAccessibleContext().setAccessibleName(Ferramenta_Imagens.DICA_ABRIR_HTML); abrir.setBounds(165, 0, 150, 25); cancelar.setText(Ferramenta_Imagens.TELA_ANTERIOR); cancelar.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { CancelarActionPerformed(e); } }); cancelar.setToolTipText(Ferramenta_Imagens.DICA_TELA_ANTERIOR); cancelar.getAccessibleContext().setAccessibleDescription(Ferramenta_Imagens.DICA_TELA_ANTERIOR); cancelar.getAccessibleContext().setAccessibleName(Ferramenta_Imagens.TELA_ANTERIOR); cancelar.setBounds(320, 0, 150, 25); analiseSistematica.setText(GERAL.ANALISE_SISTEMATICA); analiseSistematica.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { buttonAction = e; Thread t = new Thread(new Runnable() { public void run() { PainelStatusBar.showProgTarReq(); parentFrame.setCursor(new Cursor(Cursor.WAIT_CURSOR)); analiseSistematicaActionPerformed(buttonAction); parentFrame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); PainelStatusBar.hideProgTarReq(); } }); t.setPriority(9); t.start(); } }); analiseSistematica.setToolTipText(GERAL.DICA_ANALISE_SISTEMATICA); analiseSistematica.getAccessibleContext().setAccessibleDescription(GERAL.DICA_ANALISE_SISTEMATICA); analiseSistematica.getAccessibleContext().setAccessibleName(GERAL.DICA_ANALISE_SISTEMATICA); analiseSistematica.setBounds(480, 0, 150, 25); // ======== pnParticRotulo ======== pnSetaDescricao.setBorder(criaBorda(Ferramenta_Imagens.TITULO_DIGITE_O_ALT)); GridBagConstraints cons = new GridBagConstraints(); GridBagLayout layout = new GridBagLayout(); cons.fill = GridBagConstraints.BOTH; cons.weighty = 1; cons.weightx = 0.80; pnSetaDescricao.setLayout(layout); cons.anchor = GridBagConstraints.SOUTHEAST; cons.insets = new Insets(0, 0, 0, 10); conteudoDoAlt.addKeyListener(new KeyListener() { public void keyPressed(KeyEvent arg0) { } public void keyTyped(KeyEvent arg0) { } public void keyReleased(KeyEvent arg0) { if (conteudoDoAlt.getText().length() == 0) { System.out.println("conteudo vazio"); aplicar.setEnabled(false); } else if (tableLinCod.getSelectedRow() != -1) { System.out.println("com conteudo"); aplicar.setEnabled(true); } } }); // ======== spParticRotulo ======== { spTextoDescricao.setViewportView(conteudoDoAlt); } // lbRegras1.setText(Reparo_Imagens.REGRAP2); // lbRegras1.setHorizontalAlignment(SwingConstants.CENTER); // pnRegra.add(lbRegras1); pnSetaDescricao.add(spTextoDescricao, cons); cons.weightx = 0.20; pnSetaDescricao.setPreferredSize(new Dimension(400, 60)); // ======== pnListaErros ======== { pnListaErros.setBorder(criaBorda(Ferramenta_Imagens.LISTA_ERROS)); pnListaErros.setLayout(new BorderLayout()); // ======== scrollPanetabLinCod ======== { scrollPanetabLinCod.setViewportView(tableLinCod); } pnListaErros.add(scrollPanetabLinCod, BorderLayout.CENTER); } // ======== pnBotoes ======== { // pnBotoes.setBorder(criaBorda("")); pnBotoes.setLayout(null); // ---- adicionar ---- adicionar.setText(Ferramenta_Imagens.BTN_ADICIONAR); adicionar.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { adicionarActionPerformed(e); } }); adicionar.setToolTipText(Ferramenta_Imagens.DICA_ADICIONAR); adicionar.getAccessibleContext().setAccessibleDescription(Ferramenta_Imagens.DICA_ADICIONAR); adicionar.getAccessibleContext().setAccessibleName(Ferramenta_Imagens.DICA_ADICIONAR); adicionar.setBounds(10, 5, 150, 25); // pnBotoes.add(adicionar); // ---- aplicarRotulo ---- aplicar.setEnabled(false); aplicar.setText(Ferramenta_Imagens.BTN_APLICAR); aplicar.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { aplicarRotuloActionPerformed(e); } }); aplicar.setToolTipText(Ferramenta_Imagens.DICA_APLICAR); aplicar.getAccessibleContext().setAccessibleDescription(Ferramenta_Imagens.DICA_APLICAR); aplicar.getAccessibleContext().setAccessibleName(Ferramenta_Imagens.DICA_APLICAR); aplicar.setBounds(10, 5, 150, 25); pnBotoes.add(aplicar); } /* * Colocar os controles */ pnRegra.setBackground(CoresDefault.getCorPaineis()); regraFonteBtn.add(pnRegra, BorderLayout.NORTH); textAreaSourceCode.setBorder(criaBorda("")); textAreaSourceCode.setBackground(CoresDefault.getCorPaineis()); JSplitPane splitPane = null; Dimension minimumSize = new Dimension(0, 0); // JScrollPane ajudaScrollPane = new // JScrollPane(ajuda,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); sp.setMinimumSize(minimumSize); sp.setPreferredSize(new Dimension(150, 90)); splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, sp, textAreaSourceCode); splitPane.setOneTouchExpandable(true); // splitPane.set // splitPane.setDividerLocation(0.95); int w = parentFrame.getWidth(); int s = w / 4; splitPane.setDividerLocation(s); // regraFonteBtn.add(scrollPaneCorrecaoLabel, BorderLayout.CENTER); regraFonteBtn.add(splitPane, BorderLayout.CENTER); pnBotoes.setPreferredSize(new Dimension(600, 35)); pnBotoes.setBackground(CoresDefault.getCorPaineis()); // regraFonteBtn.add(pnBotoes, BorderLayout.SOUTH); regraFonteBtn.setBackground(CoresDefault.getCorPaineis()); contentPane.add(regraFonteBtn); JPanel textoErrosBtn = new JPanel(); textoErrosBtn.setLayout(new BorderLayout()); pnSetaDescricao.setBackground(CoresDefault.getCorPaineis()); pnSetaDescricao.add(pnBotoes, cons); textoErrosBtn.add(pnSetaDescricao, BorderLayout.NORTH); textoErrosBtn.add(pnListaErros, BorderLayout.CENTER); JPanel pnSalvarCancelar = new JPanel(); pnSalvarCancelar.setLayout(null); pnSalvarCancelar.setPreferredSize(new Dimension(600, 35)); pnSalvarCancelar.add(salvar); pnSalvarCancelar.add(abrir); pnSalvarCancelar.add(cancelar); if (!original) { reverter = new JButton("Reverter"); reverter.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setVisible(false); TxtBuffer.setContent(TxtBuffer.getContentOriginal()); parentFrame.showPainelFerramentaImgPArq(TxtBuffer.getContentOriginal(), enderecoPagina); setVisible(true); } }); //reverter.setActionCommand("Reverter"); reverter.setText(TradPainelRelatorio.REVERTER); reverter.setToolTipText(TradPainelRelatorio.DICA_REVERTER); reverter.getAccessibleContext().setAccessibleDescription(TradPainelRelatorio.DICA_REVERTER); reverter.getAccessibleContext().setAccessibleName(TradPainelRelatorio.DICA_REVERTER); if (EstadoSilvinha.conteudoEmPainelResumo) { reverter.setBounds(640, 0, 150, 25); } else { reverter.setBounds(480, 0, 150, 25); } pnSalvarCancelar.add(reverter); } if (EstadoSilvinha.conteudoEmPainelResumo) { pnSalvarCancelar.add(analiseSistematica); } pnSalvarCancelar.setBackground(CoresDefault.getCorPaineis()); textoErrosBtn.add(pnSalvarCancelar, BorderLayout.SOUTH); pnListaErros.setBackground(CoresDefault.getCorPaineis()); textoErrosBtn.add(pnListaErros, BorderLayout.CENTER); if (tableLinCod.getRowCount() == 0) tableLinCod.addLinha(0, 0, GERAL.DOC_SEM_ERROS); contentPane.setBackground(CoresDefault.getCorPaineis()); contentPane.add(textoErrosBtn); this.setVisible(true); }
From source file:com.lp.client.frame.component.PanelDokumentenablage.java
private void jbInit() throws Throwable { if (LPMain.getInstance().getDesktop() .darfAnwenderAufZusatzfunktionZugreifen(MandantFac.ZUSATZFUNKTION_DOKUMENTENABLAGE)) { if (!(new HeliumDocPath()).equals(fullDocPath)) { bHatDokumentenablage = true; }/*from w w w. jav a2 s . c o m*/ } if (bShowExitButton) { String[] aWhichButtonIUse = new String[] { PanelBasis.ACTION_NEW, PanelBasis.ACTION_UPDATE, PanelBasis.ACTION_SAVE, PanelBasis.ACTION_DISCARD }; enableToolsPanelButtons(aWhichButtonIUse); createAndSaveAndShowButton("/com/lp/client/res/scanner.png", "TWAIN-Import", BUTTON_SCAN, null); } dropArea.setCenterText(LPMain.getTextRespectUISPr("lp.datei.draganddrop.ablegen")); dropArea.setBackground(Color.LIGHT_GRAY); dropArea.setSupportFiles(true); dropArea.addDropListener(this); dropArea.setMinimumSize(new Dimension(200, 100)); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); JPanel leftPane = new JPanel(); JPanel rightPane = new JPanel(); JLayeredPane rightLayered = new JLayeredPane(); rightLayered.setLayout(new GridBagLayout()); rightLayered.add(rightPane, new GridBagConstraints(1, 1, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); // rightLayered.setLayer(rightPane, 0, 1); if (bShowExitButton && bHatDokumentenablage) rightLayered.add(dropArea, new GridBagConstraints(1, 2, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); // rightLayered.setLayer(dropArea, 1, 1); rightPane.setLayout(new GridBagLayout()); tree = new WrapperJTree(treeModel); tree.setEditable(false); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); tree.setShowsRootHandles(true); tree.setRowHeight(0); tree.setCellRenderer(new ToolTipCellRenderer()); ToolTipManager.sharedInstance().registerComponent(tree); tree.addTreeSelectionListener(this); refresh(); personalDto = DelegateFactory.getInstance().getPersonalDelegate() .personalFindByPrimaryKey(LPMain.getTheClient().getIDPersonal()); dokumentbelegartDto = DelegateFactory.getInstance().getJCRDocDelegate() .dokumentbelegartfindbyMandant(LPMain.getTheClient().getMandant()); for (int i = 0; i < dokumentbelegartDto.length; i++) { if (!JCRDocFac.DEFAULT_ARCHIV_BELEGART.equals(dokumentbelegartDto[i].getCNr())) wcbBelegart.addItem(dokumentbelegartDto[i].getCNr()); } dokumentgruppierungDto = DelegateFactory.getInstance().getJCRDocDelegate() .dokumentgruppierungfindbyMandant(LPMain.getTheClient().getMandant()); for (int i = 0; i < dokumentgruppierungDto.length; i++) { if (!JCRDocFac.DEFAULT_ARCHIV_GRUPPE.equals(dokumentgruppierungDto[i].getCNr()) || !JCRDocFac.DEFAULT_KOPIE_GRUPPE.equals(dokumentgruppierungDto[i].getCNr()) || !JCRDocFac.DEFAULT_VERSANDAUFTRAG_GRUPPE.equals(dokumentgruppierungDto[i].getCNr())) { wcbGruppierung.addItem(dokumentgruppierungDto[i].getCNr()); } } // Listen for when the selection changes. tree.addTreeExpansionListener(this); wcbVersteckteAnzeigen.setEnabled(true); wcbVersteckteAnzeigen.addActionListener(actionListener); wtfSuche.setEditable(true); wbuSuche.setEnabled(true); wbuSuche.addActionListener(actionListener); wbuPartner = new WrapperButton(); wbuPartner.setText(LPMain.getTextRespectUISPr("button.partner")); wbuPartner.setToolTipText(LPMain.getTextRespectUISPr("button.partner.tooltip")); wbuPartner.setActionCommand(ACTION_SPECIAL_PARTNER); wbuPartner.addActionListener(this); wbuChooseDoc.setActionCommand(ACTION_SPECIAL_CHOOSE); wbuChooseDoc.addActionListener(this); wbuShowDoc.setActionCommand(ACTION_SPECIAL_SHOW); wbuShowDoc.addActionListener(this); wbuSaveDoc.setActionCommand(ACTION_SPECIAL_SAVE); wbuSaveDoc.addActionListener(this); wtfPartner = new WrapperTextField(); wtfPartner.setColumnsMax(Facade.MAX_UNBESCHRAENKT); wtfPartner.setActivatable(false); wtfAnleger.setActivatable(false); wdfZeitpunkt.setActivatable(false); wtfBelegnummer.setActivatable(false); wtfTable.setActivatable(false); wtfRow.setActivatable(false); wtfFilename.setActivatable(false); wtfFilename.setColumnsMax(100); wtfMIME.setActivatable(false); wcbVersteckt.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { wtfSchlagworte.setMandatoryField(!wcbVersteckt.isSelected()); } }); if (bHatStufe0) { wcbSicherheitsstufe.addItem(JCRDocFac.SECURITY_NONE); } if (bHatStufe1) { wcbSicherheitsstufe.addItem(JCRDocFac.SECURITY_LOW); } if (bHatStufe2) { wcbSicherheitsstufe.addItem(JCRDocFac.SECURITY_MEDIUM); } if (bHatStufe3) { wcbSicherheitsstufe.addItem(JCRDocFac.SECURITY_HIGH); } if (bHatStufe99) { wcbSicherheitsstufe.addItem(JCRDocFac.SECURITY_ARCHIV); } wtfTable.setMandatoryField(true); wtfName.setMandatoryField(true); wtfName.setColumnsMax(200); wtfBelegnummer.setMandatoryField(true); wtfRow.setMandatoryField(true); wtfFilename.setMandatoryField(true); wtfMIME.setMandatoryField(true); wtfAnleger.setMandatoryField(true); wtfSchlagworte.setMandatoryField(true); wtfSchlagworte.setColumnsMax(300); wdfZeitpunkt.setMandatoryField(true); wtfPartner.setMandatoryField(true); treeView = new JScrollPane(tree); treeView.setMinimumSize(new Dimension(200, 10)); treeView.setPreferredSize(new Dimension(200, 10)); iZeile = 0; if (!bShowExitButton) { jpaWorkingOn.add(wtfSuche, new GridBagConstraints(0, iZeile, 1, 1, 0.2, 0.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); jpaWorkingOn.add(wbuSuche, new GridBagConstraints(1, iZeile, 1, 1, 0.1, 0.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); iZeile++; } jpaWorkingOn.add(wcbVersteckteAnzeigen, new GridBagConstraints(0, iZeile, 1, 1, 1, 0.0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); iZeile++; leftPane.add(treeView); jpaWorkingOn.add(splitPane, new GridBagConstraints(0, iZeile, 3, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); iZeile = 0; rightPane.add(wlaName, new GridBagConstraints(0, iZeile, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); rightPane.add(wtfName, new GridBagConstraints(1, iZeile, 3, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); rightPane.add(wlaTable, new GridBagConstraints(4, iZeile, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); rightPane.add(wtfTable, new GridBagConstraints(5, iZeile, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); iZeile++; rightPane.add(wlaSchlagworte, new GridBagConstraints(0, iZeile, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); rightPane.add(wtfSchlagworte, new GridBagConstraints(1, iZeile, 6, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); iZeile++; rightPane.add(wlaZeitpunkt, new GridBagConstraints(0, iZeile, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); rightPane.add(wdfZeitpunkt, new GridBagConstraints(1, iZeile, 3, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); rightPane.add(wlaSicherheitsstufe, new GridBagConstraints(4, iZeile, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); rightPane.add(wcbSicherheitsstufe, new GridBagConstraints(5, iZeile, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); rightPane.add(wcbVersteckt, new GridBagConstraints(6, iZeile, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); iZeile++; rightPane.add(wlaBelegnummer, new GridBagConstraints(0, iZeile, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); rightPane.add(wtfBelegnummer, new GridBagConstraints(1, iZeile, 3, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); rightPane.add(wlaRow, new GridBagConstraints(4, iZeile, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); rightPane.add(wtfRow, new GridBagConstraints(5, iZeile, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); iZeile++; rightPane.add(wlaFilename, new GridBagConstraints(0, iZeile, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); rightPane.add(wtfFilename, new GridBagConstraints(1, iZeile, 3, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); rightPane.add(wlaMIME, new GridBagConstraints(4, iZeile, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); rightPane.add(wtfMIME, new GridBagConstraints(5, iZeile, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); iZeile++; rightPane.add(wlaBelegart, new GridBagConstraints(0, iZeile, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); rightPane.add(wcbBelegart, new GridBagConstraints(1, iZeile, 3, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); rightPane.add(wlaGruppierung, new GridBagConstraints(4, iZeile, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); rightPane.add(wcbGruppierung, new GridBagConstraints(5, iZeile, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); iZeile++; rightPane.add(wbuPartner, new GridBagConstraints(0, iZeile, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); rightPane.add(wtfPartner, new GridBagConstraints(1, iZeile, 3, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); rightPane.add(wlaAnleger, new GridBagConstraints(4, iZeile, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); rightPane.add(wtfAnleger, new GridBagConstraints(5, iZeile, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); iZeile++; rightPane.add(wbuChooseDoc, new GridBagConstraints(0, iZeile, 3, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); rightPane.add(wbuShowDoc, new GridBagConstraints(3, iZeile, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); rightPane.add(wbuSaveDoc, new GridBagConstraints(5, iZeile, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); iZeile++; rightPane.add(wlaVorschau, new GridBagConstraints(0, iZeile, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); iZeile++; rightPane.add(wmcMedia, new GridBagConstraints(0, iZeile, 7, 4, 1.0, 0.5, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); splitPane.setLeftComponent(treeView); splitPane.setRightComponent(rightLayered); }
From source file:ca.phon.app.project.ProjectWindow.java
private void init() { /* Layout *///from www . ja v a2 s . co m setLayout(new BorderLayout()); final ProjectDataTransferHandler transferHandler = new ProjectDataTransferHandler(this); /* Create components */ newCorpusButton = createNewCorpusButton(); createCorpusButton = createCorpusButton(); corpusList = new JList<String>(); corpusModel = new CorpusListModel(getProject()); corpusList.setModel(corpusModel); corpusList.setCellRenderer(new CorpusListCellRenderer()); corpusList.setVisibleRowCount(20); corpusList.addListSelectionListener(e -> { if (getSelectedCorpus() != null) { String corpus = getSelectedCorpus(); sessionModel.setCorpus(corpus); sessionList.clearSelection(); corpusDetails.setCorpus(corpus); if (getProject().getCorpusSessions(corpus).size() == 0) { onSwapNewAndCreateSession(newSessionButton); } else { onSwapNewAndCreateSession(createSessionButton); } } }); corpusList.addMouseListener(new MouseInputAdapter() { @Override public void mousePressed(MouseEvent e) { doPopup(e); } @Override public void mouseReleased(MouseEvent e) { doPopup(e); } public void doPopup(MouseEvent e) { if (e.isPopupTrigger()) { int clickedIdx = corpusList.locationToIndex(e.getPoint()); if (clickedIdx >= 0 && Arrays.binarySearch(corpusList.getSelectedIndices(), clickedIdx) < 0) { corpusList.setSelectedIndex(clickedIdx); } showCorpusListContextMenu(e.getPoint()); } } }); final DragSource corpusDragSource = new DragSource(); corpusDragSource.createDefaultDragGestureRecognizer(corpusList, DnDConstants.ACTION_COPY, (event) -> { final List<ProjectPath> paths = new ArrayList<>(); for (String corpus : getSelectedCorpora()) { final ProjectPath corpusPath = new ProjectPath(getProject(), corpus, null); paths.add(corpusPath); } final ProjectPathTransferable transferable = new ProjectPathTransferable(paths); event.startDrag(DragSource.DefaultCopyDrop, transferable); }); corpusList.setDragEnabled(true); corpusList.setTransferHandler(transferHandler); corpusDetails = new CorpusDetailsPane(getProject()); corpusDetails.setWrapStyleWord(true); corpusDetails.setRows(6); corpusDetails.setLineWrap(true); corpusDetails.setBackground(Color.white); corpusDetails.setOpaque(true); JScrollPane corpusDetailsScroller = new JScrollPane(corpusDetails); sessionList = new JList<String>(); newSessionButton = createNewSessionButton(); createSessionButton = createSessionButton(); sessionModel = new SessionListModel(getProject()); sessionList.setModel(sessionModel); sessionList.setCellRenderer(new SessionListCellRenderer()); sessionList.setVisibleRowCount(20); sessionList.addListSelectionListener(e -> { if (sessionList.getSelectedValue() != null && !e.getValueIsAdjusting()) { String corpus = getSelectedCorpus(); String session = getSelectedSessionName(); sessionDetails.setSession(corpus, session); } }); sessionList.addMouseListener(new MouseInputAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2 && e.getButton() == 1) { // get the clicked item int clickedItem = sessionList.locationToIndex(e.getPoint()); if (sessionList.getModel().getElementAt(clickedItem) == null) return; final String session = sessionList.getModel().getElementAt(clickedItem).toString(); final String corpus = ((SessionListModel) sessionList.getModel()).getCorpus(); msgPanel.reset(); msgPanel.setMessageLabel("Opening '" + corpus + "." + session + "'"); msgPanel.setIndeterminate(true); msgPanel.repaint(); SwingUtilities.invokeLater(() -> { final ActionEvent ae = new ActionEvent(sessionList, -1, "openSession"); (new OpenSessionAction(ProjectWindow.this, corpus, session)).actionPerformed(ae); msgPanel.setIndeterminate(false); }); } } @Override public void mousePressed(MouseEvent e) { doPopup(e); } @Override public void mouseReleased(MouseEvent e) { doPopup(e); } public void doPopup(MouseEvent e) { if (e.isPopupTrigger()) { int clickedIdx = sessionList.locationToIndex(e.getPoint()); if (clickedIdx >= 0 && Arrays.binarySearch(sessionList.getSelectedIndices(), clickedIdx) < 0) { sessionList.setSelectedIndex(clickedIdx); } showSessionListContextMenu(e.getPoint()); } } }); sessionList.setDragEnabled(true); sessionList.setTransferHandler(transferHandler); final DragSource sessionDragSource = new DragSource(); sessionDragSource.createDefaultDragGestureRecognizer(sessionList, DnDConstants.ACTION_COPY, (event) -> { final List<ProjectPath> paths = new ArrayList<>(); final String corpus = getSelectedCorpus(); if (corpus == null) return; for (String session : getSelectedSessionNames()) { final ProjectPath sessionPath = new ProjectPath(getProject(), corpus, session); paths.add(sessionPath); } final ProjectPathTransferable transferable = new ProjectPathTransferable(paths); event.startDrag(DragSource.DefaultCopyDrop, transferable); }); sessionDetails = new SessionDetailsPane(getProject()); sessionDetails.setLineWrap(true); sessionDetails.setRows(6); sessionDetails.setWrapStyleWord(true); sessionDetails.setBackground(Color.white); sessionDetails.setOpaque(true); JScrollPane sessionDetailsScroller = new JScrollPane(sessionDetails); JScrollPane corpusScroller = new JScrollPane(corpusList); JScrollPane sessionScroller = new JScrollPane(sessionList); blindModeBox = new JCheckBox("Blind transcription"); blindModeBox.setSelected(false); msgPanel = new StatusPanel(); corpusPanel = new JPanel(new BorderLayout()); corpusPanel.add(newCorpusButton, BorderLayout.NORTH); corpusPanel.add(corpusScroller, BorderLayout.CENTER); corpusPanel.add(corpusDetailsScroller, BorderLayout.SOUTH); sessionPanel = new JPanel(new BorderLayout()); sessionPanel.add(newSessionButton, BorderLayout.NORTH); sessionPanel.add(sessionScroller, BorderLayout.CENTER); sessionPanel.add(sessionDetailsScroller, BorderLayout.SOUTH); final JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); splitPane.setLeftComponent(corpusPanel); splitPane.setRightComponent(sessionPanel); splitPane.setResizeWeight(0.5); // invoke later SwingUtilities.invokeLater(() -> { splitPane.setDividerLocation(0.5); }); // the frame layout String projectName = null; projectName = getProject().getName(); DialogHeader header = new DialogHeader(projectName, StringUtils.abbreviate(projectLoadPath, 80)); add(header, BorderLayout.NORTH); CellConstraints cc = new CellConstraints(); final JPanel topPanel = new JPanel(new FormLayout("pref, fill:pref:grow, right:pref", "pref")); topPanel.add(msgPanel, cc.xy(1, 1)); topPanel.add(blindModeBox, cc.xy(3, 1)); add(splitPane, BorderLayout.CENTER); add(topPanel, BorderLayout.SOUTH); // if no corpora are currently available, 'prompt' the user to create a new one if (getProject().getCorpora().size() == 0) { SwingUtilities.invokeLater(() -> { onSwapNewAndCreateCorpus(newCorpusButton); }); } else { SwingUtilities.invokeLater(() -> { corpusList.setSelectedIndex(0); }); } }
From source file:org.angnysa.yaba.swing.BudgetFrame.java
private void layoutComponents() { setLayout(new BorderLayout()); JSplitPane subSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, new JScrollPane(transactionTable), new JScrollPane(reconciliationTable)); subSplitPane.setPreferredSize(new Dimension(400, 600)); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, subSplitPane, simulationPanel); splitPane.setPreferredSize(new Dimension(1000, 600)); add(splitPane, BorderLayout.CENTER); pack();//w w w. j a v a 2 s.co m subSplitPane.setDividerLocation(0.5); splitPane.setDividerLocation(0.4); }