Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Page 2 of 2 FirstFirst 12
Results 26 to 28 of 28

Thread: Evil JScrollBars

  1. #26
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Default Re: Evil JScrollBars

    How do you add a scroll thing to a JOptionPane?

  2. #27
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Smile Re: Evil JScrollBars

    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
     
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
     
    import java.util.*;
    import java.io.*;
     
    import java.awt.event.WindowEvent;
    import java.awt.Window;
    import javax.swing.JScrollPane;
    import java.awt.Component;
    import javax.swing.JMenu;
    import javax.swing.JMenuItem;
    import javax.swing.JScrollBar;
    import javax.swing.JComboBox;
    import javax.swing.JInternalFrame;
    import javax.swing.JDesktopPane;
    import java.awt.Color;
     
    public class OpenANewWindow {
    	public static void main(String[] args) {
    		MainWindow frame = new MainWindow();
    		frame.showGUI();
    	}
    }
     
    class MainWindow extends JFrame {
    	JButton button;
    	JPanel panel;
    	NewWindow newWindow = new NewWindow();
     
    	public MainWindow() {
    		panel = new JPanel();
    		newWindow = new NewWindow();
    		button = new JButton("New Window");
     
    		button.addActionListener(new ActionListener() {
    			public void actionPerformed(ActionEvent e) {
    				newWindow.setVisible(true);
    			}
    		});
     
    		panel.add(button);
     
    		getContentPane().add(panel);
    	}
     
    	public void showGUI() {
    		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		setSize(300,300);
    		setLocation(100,100);
    		setVisible(true);
    	}
    }
     
    class NewWindow extends JFrame {
    JScrollbar bar, bar2;
    JPanel panel2;
    	public NewWindow() {
    panel2 = new JPanel();
    bar = new JScrollBar(JScrollBar.VERTICAL, 30, 20, 0, 200);
    bar.setBlockIncrement(1);
    		bar.setUnitIncrement(2);
    bar.setVisible(true);
    bar2 = new JScrollBar(JScrollBar.HORIZONTAL, 30, 40, 0, 200);
    		bar2.setBlockIncrement(1);
    		bar2.setUnitIncrement(2);
                    bar2.setVisible(true);
    panel2.add(bar);
    panel2.add(bar2);
     
     
    }
    public void showGUI2()
    {
    		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		setSize(200,200);
    		setLocation(300,300);
    		setVisible(false);
    	}
    }

  3. #28
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Default JScrollBar

    I updated it on the other thread. It now shows a much smaller program like you wanted.

Page 2 of 2 FirstFirst 12