Java Code Examples for javax.swing.JScrollPane#setAutoscrolls()
The following examples show how to use
javax.swing.JScrollPane#setAutoscrolls() .
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: InlineGMLPreviewPanel.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * Creates the UI. * * @param noOfRows the no of rows */ private void createUI(int noOfRows) { setLayout(new BorderLayout()); int xPos = 0; int width = BasePanel.FIELD_PANEL_WIDTH - xPos - 20; int height = BasePanel.WIDGET_HEIGHT * (noOfRows - 1); this.setBounds(0, 0, width, height); textField = new JTextArea(); textField.setBounds(xPos, BasePanel.WIDGET_HEIGHT, width, height); Font font = textField.getFont(); // Create a new, smaller font from the current font Font updatedFont = new Font(font.getFontName(), font.getStyle(), FONT_SIZE); // Set the new font in the editing area textField.setFont(updatedFont); textField.setEditable(true); // Wrap the text field with a scroll pane JScrollPane scroll = new JScrollPane(textField); scroll.setAutoscrolls(true); add(scroll, BorderLayout.CENTER); }
Example 2
Source File: MainPanel.java From javagame with MIT License | 6 votes |
/** * GUI������������ */ private void initGUI() { setLayout(new BorderLayout()); // ���b�Z�[�W����\���G���A dialogueArea = new JTextArea(); dialogueArea.setEditable(false); dialogueArea.setLineWrap(true); dialogueArea.append("�l�H���]�v���g�^�C�v\n\n"); // ���b�Z�[�W���̓t�B�[���h inputField = new JTextField("���b�Z�[�W����͂��Ă�������"); inputField.selectAll(); // �p�l���ɒlj� JScrollPane scrollPane = new JScrollPane(dialogueArea); scrollPane.setAutoscrolls(true); add(scrollPane, BorderLayout.CENTER); add(inputField, BorderLayout.SOUTH); inputField.addActionListener(this); }
Example 3
Source File: MainPanel.java From javagame with MIT License | 6 votes |
/** * GUI������������ */ private void initGUI() { setLayout(new BorderLayout()); // ���b�Z�[�W����\���G���A dialogueArea = new JTextArea(); dialogueArea.setEditable(false); dialogueArea.setLineWrap(true); dialogueArea.append("�l�H���]�v���g�^�C�v\n\n"); // ���b�Z�[�W���̓t�B�[���h inputField = new JTextField("���b�Z�[�W����͂��Ă�������"); inputField.selectAll(); // �p�l���ɒlj� JScrollPane scrollPane = new JScrollPane(dialogueArea); scrollPane.setAutoscrolls(true); add(scrollPane, BorderLayout.CENTER); add(inputField, BorderLayout.SOUTH); inputField.addActionListener(this); }
Example 4
Source File: GroupWindow.java From egdownloader with GNU General Public License v2.0 | 6 votes |
public GroupWindow(List<File> groups, final EgDownloaderWindow mainWindow){ super(Version.NAME + "任务组列表"); this.mainWindow = mainWindow; this.setSize(300, 400); this.setResizable(false); this.setIconImage(IconManager.getIcon("group").getImage()); this.setLocationRelativeTo(null); this.getContentPane().setLayout(null); this.setDefaultCloseOperation(mainWindow == null ? EXIT_ON_CLOSE : DISPOSE_ON_CLOSE); JLabel tipLabel = new AJLabel("双击选择任务组", new Color(67,44,1), 15, 15, 100, 30); JButton addGroupBtn = new AJButton("新建", IconManager.getIcon("add"), new OperaBtnMouseListener(this, MouseAction.CLICK, new IListenerTask() { public void doWork(Window window, MouseEvent e) { new AddGroupDialog((GroupWindow) window, mainWindow); } }) , 215, 15, 62, 30); addGroupBtn.setUI(AJButton.blueBtnUi); JList list = new GroupList(groups, this, mainWindow); list.setSelectedIndex(0); JScrollPane listPane = new JScrollPane(list); listPane.setBounds(new Rectangle(10, 50, 270, 300)); listPane.setAutoscrolls(true); listPane.getViewport().setBackground(new Color(254,254,254)); ComponentUtil.addComponents(this.getContentPane(), tipLabel, addGroupBtn, listPane); this.setVisible(true); }
Example 5
Source File: Frame.java From blog-codes with Apache License 2.0 | 5 votes |
/** * */ public Frame() { super("mxGraph"); // Creates graph with model mxGraph graph = new mxGraph(); Object parent = graph.getDefaultParent(); graph.getModel().beginUpdate(); try { Object v1 = graph.insertVertex(parent, null, "Hello", 20, 20, 80, 30); mxCell v2 = (mxCell) graph.insertVertex(parent, null, "World!", 240, 150, 80, 30); Object e1 = graph.insertEdge(parent, null, "e1", v1, v2); mxCell v3 = (mxCell) graph.insertVertex(e1, null, "v3", -0.5, 0, 40, 40, "shape=triangle"); v3.getGeometry().setRelative(true); v3.getGeometry().setOffset(new mxPoint(-20, -20)); } finally { graph.getModel().endUpdate(); } // Creates a control in a scrollpane graphControl = new GraphControl(graph); JScrollPane scrollPane = new JScrollPane(graphControl); scrollPane.setAutoscrolls(true); // Puts the control into the frame getContentPane().setLayout(new BorderLayout()); getContentPane().add(scrollPane, BorderLayout.CENTER); setSize(new Dimension(320, 200)); }
Example 6
Source File: LegendPanel.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** 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 7
Source File: GameOptionsDialog.java From megamek with GNU General Public License v2.0 | 5 votes |
private JPanel addGroup(IOptionGroup group) { JPanel groupPanel = new JPanel(); JScrollPane scrOptions = new JScrollPane(groupPanel); groupPanel.setLayout(new BoxLayout(groupPanel, BoxLayout.Y_AXIS)); scrOptions.setAutoscrolls(true); scrOptions.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); scrOptions.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); panOptions.addTab(group.getDisplayableName(), scrOptions); return groupPanel; }
Example 8
Source File: PreviewComponent.java From otroslogviewer with Apache License 2.0 | 5 votes |
public PreviewComponent() { super(new MigLayout()); titleLabel = new JLabel(Messages.getMessage("preview.label")); nameLabel = new JLabel(); contentArea = new JTextArea(); contentArea.setEditable(false); border = BorderFactory.createTitledBorder(Messages.getMessage("preview.fileContent")); contentArea.setBorder(border); contentArea.setAutoscrolls(false); contentArea.setFont(new Font("Courier New", Font.PLAIN, contentArea.getFont().getSize())); contentScrollPane = new JScrollPane(contentArea); contentScrollPane.setAutoscrolls(false); progressBar = new JProgressBar(); progressBar.setStringPainted(true); progressBar.setMaximum(1); enabledCheckBox = new JCheckBox(Messages.getMessage("preview.enable"), true); enabledCheckBox.setMnemonic(Messages.getMessage("preview.enable.mnemonic").charAt(0)); enabledCheckBox.setRolloverEnabled(true); enabledCheckBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { boolean enabled = enabledCheckBox.isSelected(); progressBar.setEnabled(enabled); contentScrollPane.setEnabled(enabled); contentArea.setEnabled(enabled); nameLabel.setEnabled(enabled); titleLabel.setEnabled(enabled); } }); add(titleLabel, "dock north, gap 5 5 5 5, center"); add(nameLabel, "dock north, gap 5 5 5 5"); add(contentScrollPane, "dock center, gap 5 5 5 5"); add(enabledCheckBox, "dock south, gap 0 5 5 5"); add(progressBar, "dock south, gap 5 5 5 5"); }
Example 9
Source File: WhiteRabbitMain.java From WhiteRabbit with Apache License 2.0 | 5 votes |
private JComponent createConsolePanel() { JTextArea consoleArea = new JTextArea(); consoleArea.setToolTipText("General progress information"); consoleArea.setEditable(false); Console console = new Console(); console.setTextArea(consoleArea); System.setOut(new PrintStream(console)); System.setErr(new PrintStream(console)); JScrollPane consoleScrollPane = new JScrollPane(consoleArea); consoleScrollPane.setBorder(BorderFactory.createTitledBorder("Console")); consoleScrollPane.setPreferredSize(new Dimension(800, 200)); consoleScrollPane.setAutoscrolls(true); ObjectExchange.console = console; return consoleScrollPane; }
Example 10
Source File: MultipleAlignmentJmolDisplay.java From biojava with GNU Lesser General Public License v2.1 | 5 votes |
/** * Creates a new Frame with the MultipleAlignment Sequence Panel. * The panel can communicate with the Jmol 3D visualization by * selecting the aligned residues of every structure. * * @param multAln * @param jmol * @throws StructureException */ public static void showMultipleAligmentPanel(MultipleAlignment multAln, AbstractAlignmentJmol jmol) throws StructureException { MultipleAligPanel me = new MultipleAligPanel(multAln, jmol); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.setTitle(jmol.getTitle()); me.setPreferredSize(new Dimension( me.getCoordManager().getPreferredWidth() , me.getCoordManager().getPreferredHeight())); JMenuBar menu = MenuCreator.getAlignmentPanelMenu( frame,me,null, multAln); frame.setJMenuBar(menu); JScrollPane scroll = new JScrollPane(me); scroll.setAutoscrolls(true); MultipleStatusDisplay status = new MultipleStatusDisplay(me); me.addAlignmentPositionListener(status); Box vBox = Box.createVerticalBox(); vBox.add(scroll); vBox.add(status); frame.getContentPane().add(vBox); frame.pack(); frame.setVisible(true); frame.addWindowListener(me); frame.addWindowListener(status); }
Example 11
Source File: DisplayAFP.java From biojava with GNU Lesser General Public License v2.1 | 5 votes |
public static void showAlignmentPanel(AFPChain afpChain, Atom[] ca1, Atom[] ca2, AbstractAlignmentJmol jmol) throws StructureException { AligPanel me = new AligPanel(); me.setAlignmentJmol(jmol); me.setAFPChain(afpChain); me.setCa1(ca1); me.setCa2(ca2); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.setTitle(afpChain.getName1() + " vs. " + afpChain.getName2() + " | " + afpChain.getAlgorithmName() + " V. " + afpChain.getVersion()); me.setPreferredSize(new Dimension(me.getCoordManager().getPreferredWidth() , me.getCoordManager().getPreferredHeight())); JMenuBar menu = MenuCreator.getAlignmentPanelMenu(frame,me,afpChain,null); frame.setJMenuBar(menu); JScrollPane scroll = new JScrollPane(me); scroll.setAutoscrolls(true); StatusDisplay status = new StatusDisplay(); status.setAfpChain(afpChain); status.setCa1(ca1); status.setCa2(ca2); me.addAlignmentPositionListener(status); Box vBox = Box.createVerticalBox(); vBox.add(scroll); vBox.add(status); frame.getContentPane().add(vBox); frame.pack(); frame.setVisible(true); // make sure they get cleaned up correctly: frame.addWindowListener(me); frame.addWindowListener(status); }
Example 12
Source File: Layout.java From blog-codes with Apache License 2.0 | 4 votes |
public Layout() { super("mxGraph"); // Creates graph with model mxGraph graph = new mxGraph(); Object parent = graph.getDefaultParent(); graph.getModel().beginUpdate(); try { int nodeCount = 100; int edgeCount = 100; Object[] nodes = new Object[nodeCount]; Object[] edges = new Object[edgeCount]; for (int i = 0; i < nodeCount; i++) { nodes[i] = graph.insertVertex(parent, null, "N" + i, 0, 0, 30, 30); } for (int i = 0; i < edgeCount; i++) { int r1 = (int) (Math.random() * nodeCount); int r2 = (int) (Math.random() * nodeCount); edges[i] = graph.insertEdge(parent, null, r1 + "-" + r2, nodes[r1], nodes[r2]); } mxIGraphLayout layout = new mxFastOrganicLayout(graph); layout.execute(parent); } finally { graph.getModel().endUpdate(); } graph.getView().setScale(0.2); // Creates a control in a scrollpane graphControl = new GraphControl(graph); JScrollPane scrollPane = new JScrollPane(graphControl); scrollPane.setAutoscrolls(true); // Puts the control into the frame getContentPane().setLayout(new BorderLayout()); getContentPane().add(scrollPane, BorderLayout.CENTER); setSize(new Dimension(320, 200)); }
Example 13
Source File: Solver.java From algorithms-nutshell-2ed with MIT License | 4 votes |
public static void main(String[] args) throws Exception { // solution found. Create GUI. final JFrame frame = new JFrame(); frame.setAlwaysOnTop(true); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.addWindowListener(new WindowAdapter() { /** Once opened: load up the images. */ public void windowOpened(WindowEvent e) { System.out.println("Loading card images..."); cardImages = CardImagesLoader.getDeck(e.getWindow()); } }); frame.setSize(808,350); JList<IMove> list = new JList<IMove>(); // add widgets at proper location frame.setLayout(null); // top row: JPanel topLeft = new JPanel(); topLeft.setBounds(0, 0, 400, 40); topLeft.add(new JLabel("Select Game:")); final JTextField jtf = new JTextField (7); topLeft.add(jtf); frame.add(topLeft); JPanel topRight = new JPanel(); topRight.setBounds(400, 0, 400, 40); String instructions = "Select moves from below list to see game state at that moment."; topRight.add(new JLabel(instructions)); frame.add(topRight); // bottom row FreeCellDrawing drawer = new FreeCellDrawing(); drawer.setBounds (0, 40, 400, 275); drawer.setBackground(new java.awt.Color (0,128,0)); frame.add(drawer); // Create the GUI and put it in the window with scrollbars. JScrollPane scrollingPane = new JScrollPane(list); scrollingPane.setAutoscrolls(true); scrollingPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollingPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); scrollingPane.setBounds(400, 40, 400, 275); frame.add(scrollingPane); // set up listeners and show everything jtf.addActionListener(new DealController(frame, drawer, list)); frame.setVisible(true); }
Example 14
Source File: ReadMeDialog.java From importer-exporter with Apache License 2.0 | 4 votes |
private void initGUI() { setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); JButton button = new JButton(Language.I18N.getString("common.button.ok")); setLayout(new GridBagLayout()); { JPanel main = new JPanel(); add(main, GuiUtil.setConstraints(0,0,1.0,1.0,GridBagConstraints.BOTH,5,5,5,5)); main.setLayout(new GridBagLayout()); { JLabel readMeHeader = new JLabel(Language.I18N.getString("menu.help.readMe.information")); main.add(readMeHeader, GuiUtil.setConstraints(0,0,1.0,0.0,GridBagConstraints.HORIZONTAL,10,2,2,5)); JTextArea readMe = new JTextArea(); readMe.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); readMe.setEditable(false); readMe.setBackground(Color.WHITE); readMe.setFont(new Font(Font.MONOSPACED, 0, 11)); try { BufferedReader in = new BufferedReader( new InputStreamReader(this.getClass().getResourceAsStream("/META-INF/README.txt"), StandardCharsets.UTF_8)); // read address template StringBuilder builder = new StringBuilder(); String line = null; while ((line = in.readLine()) != null) { builder.append(line); builder.append("\n"); } readMe.setText(builder.toString()); } catch (Exception e) { readMe.setText("The README.txt file could not be found.\n\n" + "" + "Please refer to the README.txt file provided with the installation package.\n\n"); } readMe.setCaretPosition(0); PopupMenuDecorator.getInstance().decorate(readMe); JScrollPane scroll = new JScrollPane(readMe); scroll.setAutoscrolls(true); scroll.setBorder(BorderFactory.createEtchedBorder()); main.add(scroll, GuiUtil.setConstraints(0,1,1.0,1.0,GridBagConstraints.BOTH,2,0,0,0)); } button.setMargin(new Insets(button.getMargin().top, 25, button.getMargin().bottom, 25)); add(button, GuiUtil.setConstraints(0,3,0.0,0.0,GridBagConstraints.NONE,5,5,5,5)); } setPreferredSize(new Dimension(600, 400)); setResizable(true); pack(); button.addActionListener(l -> dispose()); }