javax.swing.JScrollPane Java Examples

The following examples show how to use javax.swing.JScrollPane. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XTextAreaPeer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void uninstallDefaults(JScrollPane c) {
    super.uninstallDefaults(c);

    JScrollBar vsb = scrollpane.getVerticalScrollBar();
    if (vsb != null) {
        if (vsb.getBorder() == vsbBorder) {
            vsb.setBorder(null);
        }
        vsbBorder = null;
    }

    JScrollBar hsb = scrollpane.getHorizontalScrollBar();
    if (hsb != null) {
        if (hsb.getBorder() == hsbBorder) {
            hsb.setBorder(null);
        }
        hsbBorder = null;
    }
}
 
Example #2
Source File: ChatAreaSendField.java    From Spark with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new IconTextField with Icon.
 *
 * @param text the text to use on the button.
 */
public ChatAreaSendField(String text) {
    setLayout(new GridBagLayout());
    setBackground((Color)UIManager.get("TextPane.background"));
    textField = new ChatInputEditor();
    textField.setBorder(null);
    setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.lightGray));
    button = new JButton();
    
    if (Spark.isMac()) {
        button.setContentAreaFilled(false);
    }

    ResourceUtils.resButton(button, text);

    add(button, new GridBagConstraints(1, 0, 1, 1, 0.0, 1.0, GridBagConstraints.EAST, GridBagConstraints.VERTICAL, new Insets(2, 2, 2, 2), 0, 0));

    button.setVisible(false);
    
    final JScrollPane pane = new JScrollPane(textField);
    pane.setBorder(null);
    add(pane, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));
    button.setEnabled(false);
}
 
Example #3
Source File: TableExample2.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public TableExample2(String URL, String driver, String user,
        String passwd, String query) {
    JFrame frame = new JFrame("Table");
    frame.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });
    JDBCAdapter dt = new JDBCAdapter(URL, driver, user, passwd);
    dt.executeQuery(query);

    // Create the table
    JTable tableView = new JTable(dt);

    JScrollPane scrollpane = new JScrollPane(tableView);
    scrollpane.setPreferredSize(new Dimension(700, 300));

    frame.getContentPane().add(scrollpane);
    frame.pack();
    frame.setVisible(true);
}
 
Example #4
Source File: MainFrameComponentFactory.java    From spotbugs with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Creates the source code panel, but does not put anything in it.
 */
JPanel createSourceCodePanel() {
    Font sourceFont = new Font("Monospaced", Font.PLAIN, (int) Driver.getFontSize());
    mainFrame.getSourceCodeTextPane().setFont(sourceFont);
    mainFrame.getSourceCodeTextPane().setEditable(false);
    mainFrame.getSourceCodeTextPane().getCaret().setSelectionVisible(true);
    mainFrame.getSourceCodeTextPane().setDocument(SourceCodeDisplay.SOURCE_NOT_RELEVANT);
    JScrollPane sourceCodeScrollPane = new JScrollPane(mainFrame.getSourceCodeTextPane());
    sourceCodeScrollPane.getVerticalScrollBar().setUnitIncrement(20);

    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    panel.add(sourceCodeScrollPane, BorderLayout.CENTER);

    panel.revalidate();
    if (MainFrame.GUI2_DEBUG) {
        System.out.println("Created source code panel");
    }
    return panel;
}
 
Example #5
Source File: PortMapperView.java    From portmapper with GNU General Public License v3.0 6 votes vote down vote up
private JComponent getPresetPanel() {
    final ActionMap actionMap = this.getContext().getActionMap(this.getClass(), this);

    final JPanel presetPanel = new JPanel(new MigLayout("", "[grow, fill][]", ""));
    presetPanel.setBorder(BorderFactory
            .createTitledBorder(app.getResourceMap().getString("mainFrame.port_mapping_presets.title")));

    portMappingPresets = new JList<>(new PresetListModel(app.getSettings()));
    portMappingPresets.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    portMappingPresets.setLayoutOrientation(JList.VERTICAL);

    portMappingPresets.addListSelectionListener(e -> {
        logger.trace("Selection of preset list has changed: {}", isPresetMappingSelected());
        firePropertyChange(PROPERTY_PRESET_MAPPING_SELECTED, false, isPresetMappingSelected());
    });

    presetPanel.add(new JScrollPane(portMappingPresets), "spany 4, grow");

    presetPanel.add(new JButton(actionMap.get(ACTION_CREATE_PRESET_MAPPING)), "wrap, sizegroup preset_buttons");
    presetPanel.add(new JButton(actionMap.get(ACTION_EDIT_PRESET_MAPPING)), "wrap, sizegroup preset_buttons");
    presetPanel.add(new JButton(actionMap.get(ACTION_REMOVE_PRESET_MAPPING)), "wrap, sizegroup preset_buttons");
    presetPanel.add(new JButton(actionMap.get(ACTION_USE_PRESET_MAPPING)), "wrap, sizegroup preset_buttons");

    return presetPanel;
}
 
Example #6
Source File: TreePosTest.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/** Scroll a text area to display a given position near the middle of the visible area. */
private void scroll(final JTextArea t, final int pos) {
    // Using invokeLater appears to give text a chance to sort itself out
    // before the scroll happens; otherwise scrollRectToVisible doesn't work.
    // Maybe there's a better way to sync with the text...
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                Rectangle r = t.modelToView(pos);
                JScrollPane p = (JScrollPane) SwingUtilities.getAncestorOfClass(JScrollPane.class, t);
                r.y = Math.max(0, r.y - p.getHeight() * 2 / 5);
                r.height += p.getHeight() * 4 / 5;
                t.scrollRectToVisible(r);
            } catch (BadLocationException ignore) {
            }
        }
    });
}
 
Example #7
Source File: XTextAreaPeer.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
private PropertyChangeListener createPropertyChangeHandler() {
    return new PropertyChangeListener() {
            @Override
            public void propertyChange(PropertyChangeEvent e) {
                String propertyName = e.getPropertyName();

                if (propertyName.equals("componentOrientation")) {
                    JScrollPane pane = (JScrollPane)e.getSource();
                    JScrollBar vsb = pane.getVerticalScrollBar();
                    if (vsb != null) {
                        if (isLeftToRight(pane)) {
                            vsbBorder = new CompoundBorder(new EmptyBorder(0, 4, 0, -4),
                                                           vsb.getBorder());
                        } else {
                            vsbBorder = new CompoundBorder(new EmptyBorder(0, -4, 0, 4),
                                                           vsb.getBorder());
                        }
                        vsb.setBorder(vsbBorder);
                    }
                }
            }};
}
 
Example #8
Source File: ZoomManager.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void actionPerformed(ActionEvent e) {
    Scene scene = manager.getScene();
    JScrollPane pane = (JScrollPane) SwingUtilities.getAncestorOfClass(
            JScrollPane.class, scene.getView());
    if (pane == null) {
        // Unlikely, but we cannot assume it exists.
        return;
    }
    JViewport viewport = pane.getViewport();
    Rectangle visRect = viewport.getViewRect();
    Rectangle compRect = scene.getPreferredBounds();
    int zoomX = visRect.width * 100 / compRect.width;
    int zoomY = visRect.height * 100 / compRect.height;
    int zoom = Math.min(zoomX, zoomY);
    manager.setZoom(zoom);
}
 
Example #9
Source File: UIRes.java    From RipplePower with Apache License 2.0 6 votes vote down vote up
public static void addStyle(JScrollPane jScrollPane, String labelName, boolean bottom) {
	Border line = BorderFactory.createLineBorder(Color.LIGHT_GRAY);
	TitledBorder titled = BorderFactory.createTitledBorder(line, labelName);
	titled.setTitleFont(GraphicsUtils.getFont("Verdana", 0, 13));
	titled.setTitleColor(fontColorTitle);
	Border empty = null;
	if (bottom) {
		empty = new EmptyBorder(5, 8, 5, 8);
	} else {
		empty = new EmptyBorder(5, 8, 0, 8);
	}
	CompoundBorder border = new CompoundBorder(titled, empty);
	jScrollPane.setBorder(border);
	jScrollPane.setForeground(fontColor);
	jScrollPane.setBackground(Color.WHITE);
	jScrollPane.setFont(GraphicsUtils.getFont("Monospaced", 0, 13));
	jScrollPane.setHorizontalScrollBar(null);
}
 
Example #10
Source File: BulbPanel.java    From ThingML-Tradfri with Apache License 2.0 6 votes vote down vote up
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    
    try {
        //JOptionPane pane = new JOptionPane();
        //pane.setMessageType(JOptionPane.INFORMATION_MESSAGE);
        JDialog dialog = new JDialog((Frame)null, "Result of COAP GET for bulb " + bulb.getName(), false);
        JTextArea msg = new JTextArea(bulb.getJsonObject().toString(4) + "\n");
        msg.setFont(new Font("monospaced", Font.PLAIN, 10));
        msg.setLineWrap(true);
        msg.setWrapStyleWord(true);
        JScrollPane scrollPane = new JScrollPane(msg);
        
        dialog.getContentPane().add(scrollPane);
        dialog.setSize(350, 350);
        //dialog.pack();
        dialog.setVisible(true);
        
        
    } catch (JSONException ex) {
        Logger.getLogger(BulbPanel.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
Example #11
Source File: PreviewView.java    From ramus with GNU General Public License v3.0 6 votes vote down vote up
public PreviewView(ReportEditorView reportEditorView) {
    this.reportEditorView = reportEditorView;
    JScrollPane pane = new JScrollPane(editorPane);
    HTMLEditorKit kit = new HTMLEditorKit() {
        /**
         *
         */
        private static final long serialVersionUID = -8040272164224951314L;

        @Override
        public Document createDefaultDocument() {
            Document document = super.createDefaultDocument();
            document.putProperty("IgnoreCharsetDirective", true);
            return document;
        }
    };

    editorPane.setEditorKit(kit);
    editorPane.setEditable(false);
    this.add(pane, BorderLayout.CENTER);
}
 
Example #12
Source File: PruebaCorrelacionIdiomas.java    From chuidiang-ejemplos with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
    * A�ade el textArea para mostrar los resultados y el texto generado.
    * @param contenedor Contendor al que a�adir.
    * @param constraints Se ignora
    */
private void anhadeTextAreaParaResultados(Container contenedor )
{
	areaResultados = new JTextArea();
       areaResultados.setLineWrap(true);
       areaResultados.setWrapStyleWord(true);
       areaResultados.setEditable(false);
       areaResultados.setColumns(40);
       areaResultados.invalidate();

       JScrollPane scrollLista = new JScrollPane(areaResultados);
       scrollLista.setBorder(new TitledBorder("Resultados"));
       GridBagConstraints constraints = new GridBagConstraints();
       constraints.gridx = 0;
       constraints.gridy = 2;
       constraints.gridwidth = 4;
       constraints.gridheight = 1;
       constraints.weightx = 1.0;
       constraints.weighty = 1.0;
       constraints.fill = GridBagConstraints.BOTH;
       contenedor.add(scrollLista, constraints);
}
 
Example #13
Source File: HighlighterPanel.java    From zap-extensions with Apache License 2.0 6 votes vote down vote up
private void initUi() {
    // This
    this.setLayout(new BorderLayout());
    this.setName("Highlighter");

    // mainPanel
    mainPanel = new JPanel(new BorderLayout());
    this.add(mainPanel);

    // 0: button panel
    initButtonPanel();
    mainPanel.add(buttonPanel, BorderLayout.PAGE_START);

    // 1: userPanel
    userPanel = new JPanel(new BorderLayout());
    reinit();
    mainPanel.add(new JScrollPane(userPanel));
}
 
Example #14
Source File: AnalysisControllerUI.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void initComponents(URL ruleBase, String htmlDescription) {
    setLayout(new BorderLayout());
    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    HTMLTextArea descriptionArea = new HTMLTextArea();
    HTMLDocument hdoc = (HTMLDocument) descriptionArea.getDocument();
    descriptionArea.setText(htmlDescription);
    descriptionArea.setCaretPosition(0);
    hdoc.setBase(ruleBase);

    JScrollPane descriptionAreaScrollPane = new JScrollPane(descriptionArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                                                            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    descriptionAreaScrollPane.setPreferredSize(new Dimension(375, 220));

    add(descriptionAreaScrollPane, BorderLayout.CENTER);
}
 
Example #15
Source File: XTextAreaPeer.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void uninstallDefaults(JScrollPane c) {
    super.uninstallDefaults(c);

    JScrollBar vsb = scrollpane.getVerticalScrollBar();
    if (vsb != null) {
        if (vsb.getBorder() == vsbBorder) {
            vsb.setBorder(null);
        }
        vsbBorder = null;
    }

    JScrollBar hsb = scrollpane.getHorizontalScrollBar();
    if (hsb != null) {
        if (hsb.getBorder() == hsbBorder) {
            hsb.setBorder(null);
        }
        hsbBorder = null;
    }
}
 
Example #16
Source File: ReportEditorTest.java    From ramus with GNU General Public License v3.0 6 votes vote down vote up
public ReportEditorTest() {
    setSize(1200, 800);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setLocationRelativeTo(null);
    JPanel panel = new JPanel(new BorderLayout());

    XMLDiagram diagram = new XMLDiagram();
    ReportEditor editor = new ReportEditor(diagram);

    setContentPane(panel);
    JScrollPane pane = new JScrollPane(editor);

    panel.add(pane, BorderLayout.CENTER);
    JToolBar bar = new JToolBar();
    panel.add(bar, BorderLayout.NORTH);
    for (Action action : editor.getActions()) {
        JButton button = bar.add(action);
        button.setText((String) action.getValue(Action.ACTION_COMMAND_KEY));
    }

}
 
Example #17
Source File: Outline.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
@Override
public Insets getAutoscrollInsets() {
    int         margin     = Scale.get(this).scale(AUTO_SCROLL_MARGIN);
    JScrollPane scrollPane = UIUtilities.getAncestorOfType(this, JScrollPane.class);
    if (scrollPane != null) {
        Rectangle bounds = scrollPane.getViewport().getViewRect();
        return new Insets(bounds.y + margin, bounds.x + margin, getHeight() - (bounds.y + bounds.height) + margin, getWidth() - (bounds.x + bounds.width) + margin);
    }
    return new Insets(margin, margin, margin, margin);
}
 
Example #18
Source File: MultipleAlignmentJmolDisplay.java    From biojava with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Creates a new Frame with the String output representation of the
 * {@link MultipleAlignment}.
 *
 * @param multAln
 * @param result String output
 */
public static void showAlignmentImage(MultipleAlignment multAln,
		String result) {

	JFrame frame = new JFrame();

	String title = multAln.getEnsemble().getAlgorithmName() +
			" V."+multAln.getEnsemble().getVersion();
	frame.setTitle(title);
	frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

	AlignmentTextPanel txtPanel = new AlignmentTextPanel();
	txtPanel.setText(result);

	JMenuBar menu = MenuCreator.getAlignmentTextMenu(
			frame,txtPanel,null,multAln);

	frame.setJMenuBar(menu);
	JScrollPane js = new JScrollPane();
	js.getViewport().add(txtPanel);
	js.getViewport().setBorder(null);

	frame.getContentPane().add(js);
	frame.pack();
	frame.setVisible(true);
}
 
Example #19
Source File: QueryClientGui.java    From fosstrak-epcis with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Sets up the window used to show the debug output.
 */
private void drawDebugWindow() {
    debugWindow = new JFrame("Debug output");
    debugWindow.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
    debugWindow.addWindowListener(this);
    debugWindow.setLocation(500, 100);
    debugWindow.setSize(500, 300);

    dwOutputTextArea = new JTextArea();
    dwOutputScrollPane = new JScrollPane(dwOutputTextArea);
    debugWindow.add(dwOutputScrollPane);

    dwButtonPanel = new JPanel();
    debugWindow.add(dwButtonPanel, BorderLayout.AFTER_LAST_LINE);

    dwClearButton = new JButton("Clear");
    dwClearButton.addActionListener(this);
    dwButtonPanel.add(dwClearButton);
}
 
Example #20
Source File: AbegoTreeLayoutForNetbeansDemo.java    From treelayout with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static void showScene(TreeScene scene, String title) {
	JScrollPane panel = new JScrollPane(scene.createView());
	JDialog dialog = new JDialog();
	dialog.setModal(true);
	dialog.setTitle(title);
	dialog.add(panel, BorderLayout.CENTER);
	dialog.setSize(800, 600);
	dialog.setVisible(true);
	dialog.dispose();
}
 
Example #21
Source File: UISupport.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates preformatted instance of ScrollableContainer to be used in Options
 * dialog. All insets are already initialized to defaults, the client components
 * should have zero outer insets.
 * 
 * @param contents component to be displayed
 * @return preformatted instance of ScrollableContainer
 */
public static ScrollableContainer createScrollableContainer(JComponent contents) {
    ScrollableContainer container = new ScrollableContainer(contents,
                                    JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                                    JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    container.setViewportBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
    container.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 5));
    return container;
}
 
Example #22
Source File: LegendPanel.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
/** Instantiates a new legend panel. */
public LegendPanel() {
    setLayout(new BorderLayout(0, 0));

    scrollPane = new JScrollPane(legendImagePanel);
    scrollPane.setAutoscrolls(true);
    scrollPane.setPreferredSize(new Dimension(SCROLL_PANE_WIDTH, SCROLL_PANE_HEIGHT));
    add(scrollPane, BorderLayout.CENTER);
}
 
Example #23
Source File: BloomDemo.java    From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private JComponent buildBloomViewer() {
    viewer = new BloomViewer("/images/screen.png");
    scroller = new JScrollPane(viewer);
    scroller.setBorder(null);
    scroller.getViewport().setBackground(Color.BLACK);
    return scroller;
}
 
Example #24
Source File: MenuDemo.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public Container createContentPane() {
    // Create the content-pane-to-be.
    JPanel contentPane = new JPanel(new BorderLayout());
    contentPane.setOpaque(true);

    // Create a scrolled text area.
    output = new JTextArea(5, 30);
    output.setEditable(false);
    scrollPane = new JScrollPane(output);

    // Add the text area to the content pane.
    contentPane.add(scrollPane, BorderLayout.CENTER);

    return contentPane;
}
 
Example #25
Source File: PainelSelecaoCor.java    From brModelo with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void buildChooser() {
    setLayout(new BorderLayout());// GridLayout(0, 1));

    if (!itens.isEmpty()) {
        JScrollPane jsp = new javax.swing.JScrollPane();
        lst = new JList(itens.toArray(new Legenda.ItemDeLegenda[]{}));
        add(jsp, BorderLayout.EAST);
        jsp.add(lst);
        jsp.setViewportView(lst);
        lst.setModel(new javax.swing.AbstractListModel() {

            @Override
            public int getSize() {
                return itens.size();
            }

            @Override
            public Object getElementAt(int i) {
                return itens.get(i);
            }
        });
        lst.addListSelectionListener( e -> {
            if (e == null || lst.getSelectedIndex() < 0) {
                return;
            }
            
            Legenda.ItemDeLegenda r = itens.get(lst.getSelectedIndex());
            
            getColorSelectionModel().setSelectedColor(r.getCor());
        });
        lst.setCellRenderer(new JListItemParaItemLegenda(false));
    }
}
 
Example #26
Source File: ProfilerOptionsContainer.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private JScrollPane createPanelScroll(ProfilerOptionsPanel panel) {
    enlargeBorder(panel, 0, 0, 0, 5);
    JScrollPane scroll = new JScrollPane(panel);
    scroll.setBorder(BorderFactory.createEmptyBorder());
    scroll.setViewportBorder(BorderFactory.createEmptyBorder());
    scroll.getVerticalScrollBar().setUnitIncrement(scrollIncrement);
    scroll.getVerticalScrollBar().setBlockIncrement((int)(content.getHeight() * 0.8d));
    scroll.getHorizontalScrollBar().setUnitIncrement(scrollIncrement);
    scroll.getHorizontalScrollBar().setBlockIncrement((int)(content.getWidth() * 0.8d));
    return scroll;
}
 
Example #27
Source File: CBreakpointPanel.java    From binnavi with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new breakpoint panel.
 *
 * @param parent Parent window used for dialogs.
 * @param debuggerProvider Provides the debuggers where breakpoints can be set.
 * @param graph Graph that is shown in the window the panel belongs to.
 * @param viewContainer View container of the graph.
 */
public CBreakpointPanel(final JFrame parent, final BackEndDebuggerProvider debuggerProvider,
    final ZyGraph graph, final IViewContainer viewContainer) {
  super(new BorderLayout());

  Preconditions.checkNotNull(parent, "IE01331: Parent argument can not be null");
  Preconditions.checkNotNull(
      debuggerProvider, "IE01332: Debugger provider argument can not be null");
  Preconditions.checkNotNull(graph, "IE01333: Graph argument can not be null");

  m_breakpointTable = new CBreakpointTable(debuggerProvider, graph, viewContainer);

  add(new CBreakpointToolbar(parent, debuggerProvider, graph.getRawView()), BorderLayout.NORTH);
  add(new JScrollPane(m_breakpointTable), BorderLayout.CENTER);
}
 
Example #28
Source File: BurpEditorWrapper.java    From cstc with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Component getComponent() {
	if (fallbackMode) {
		JScrollPane inputScrollPane = new JScrollPane(fallbackArea);
		return inputScrollPane;
	}
	return burpEditor.getComponent();
}
 
Example #29
Source File: ScoreTable.java    From rcrs-server with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public JComponent getGUIComponent() {
    JTable table = new JTable(model.table);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    JScrollPane scroll = new JScrollPane(table);
    JList rowHeader = new JList(model.list);
    rowHeader.setFixedCellHeight(table.getRowHeight());
    rowHeader.setCellRenderer(new RowHeaderRenderer(table));
    rowHeader.setBackground(table.getBackground());
    rowHeader.setOpaque(true);
    scroll.setRowHeaderView(rowHeader);
    return scroll;
}
 
Example #30
Source File: DesignerTablePanel.java    From nextreports-designer with Apache License 2.0 5 votes vote down vote up
public void actionPerformed(ActionEvent e) {
            String expression = expressionColumn.getName();
//            String result = (String) JOptionPane.showInputDialog(Globals.getMainFrame(), null, "Expression",
//                    JOptionPane.QUESTION_MESSAGE, null, null, expression);

            final JTextArea textArea = new JTextArea(expression, 10, 30);
            textArea.setLineWrap(true);
            textArea.setWrapStyleWord(true);
            textArea.setEditable(true);

            Object msg[] = {"", new JScrollPane(textArea)};
//
            int option = JOptionPane.showOptionDialog(Globals.getMainFrame(),
                    msg, I18NSupport.getString("designer.expression"),
                    JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);

            if (option == JOptionPane.YES_OPTION) {
                String result = textArea.getText();
                if (expressionColumn instanceof ExpressionColumn) {
                    ((ExpressionColumn) expressionColumn).setExpression(result);
                } else if (expressionColumn instanceof GroupByFunctionColumn) {
                    ((GroupByFunctionColumn) expressionColumn).setExpression(result);
                }
                okPressed = true;
            }

            table.packAll();
        }