Getting objects on panel to expand proportionatel

Hey there.
I was wondering what I have to do in order to get the various components on my panel to expand in similar proportions when maximised or dragged to a larger frame size.
Thanks
Dane

I seem to have had that problem as well, and I also seem to have sorted it using a variety of layouts, but the problem is that I don't know how exactly I sorted it out. It is very confusing as I would like to know . Here is my code if anyone can possibly decipher it!
public class OcrGUI extends JFrame implements ActionListener {
    // declaration of various instance variables
    private JTextArea area;
    private JLabel label;
    private JEditorPane URLpane;
    private JButton browseButton, generateButton;
    private JTextField fileField;
    private JLabel inputFileLabel;
    private JScrollPane scrollPane1, scrollPane2;
    private JMenuBar menuBar;
    private JMenu menuFile;
    private JMenuItem open,quitProg;
    private JFileChooser Chooser;
    private String inputType = null;
    public void actionPerformed(ActionEvent ae) {
        if (ae.getSource() == open) {
            this.browseFile();
        if (ae.getSource() == browseButton) {
            this.browseFile();
        if (ae.getSource() == quitProg) {
            this.quitProgram();
    private void quitProgram() {
        String s1 = "Yes";
        String s2 = "Cancel";
        Object[] options1 =
        { s1, s2};
        int n = JOptionPane.showOptionDialog(this,
        "Are you sure you want to quit?", "Quit",
        JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null,
        options1, s2);
        if (n == JOptionPane.YES_OPTION) {
            System.exit(0);
    private void browseFile() {
        Chooser = new JFileChooser();
        if (Chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
            File inF = Chooser.getSelectedFile();
            try {
                int x =1;
            catch (Exception e) {
                e.printStackTrace();
                JOptionPane.showMessageDialog(this, "Invalid file format",
                "Error", JOptionPane.ERROR_MESSAGE);
    public void insertImage() throws MalformedURLException {
        URL url = new URL("http://taxonomy.zoology.gla.ac.uk/~rdmp1c/teaching/Msc_IT/big.gif");
        JLabel label = new JLabel(new ImageIcon(url));
    public OcrGUI() {
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        this.myLayout();
        this.initLayout();
    private void myLayout() {
        menuBar = new javax.swing.JMenuBar();
        menuFile = new javax.swing.JMenu();
        menuFile.setText("File");
        menuBar.add(menuFile);
        open = new JMenuItem("Open");
        quitProg = new JMenuItem("Quit");
        open.addActionListener(this);
        quitProg.addActionListener(this);
        menuFile.add(open);
        menuFile.addSeparator();
        menuFile.add(quitProg);
        setJMenuBar(menuBar);
        Container pane = this.getContentPane();
        this.getContentPane().setLayout(new BorderLayout());
        //top
        JPanel one = new JPanel();
        one.setLayout(new BorderLayout());
//        label = new JLabel("                                                                                                                                                                                                      ");
        try {
            URL url = new URL("http://taxonomy.zoology.gla.ac.uk/~rdmp1c/teaching/Msc_IT/big.gif");
            label = new JLabel(new ImageIcon(url));
        } catch (Throwable t)
        {t.printStackTrace();}       
        scrollPane1 = new JScrollPane(label);
        scrollPane1.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
        scrollPane1. setVerticalScrollBarPolicy(javax.swing.JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
        one.add(scrollPane1);
        pane.add(one, "Center");
        //middle
        JPanel two = new JPanel();
        two.setLayout(new GridLayout(2,1));
        JPanel filler2 = new JPanel();
        FlowLayout inputPanelLayout = new java.awt.FlowLayout();
        filler2.setLayout(inputPanelLayout);
        inputPanelLayout.setHgap(50);
        inputPanelLayout.setVgap(10);
        inputFileLabel = new JLabel("Input File:", JLabel.LEFT);
        fileField = new JTextField();
        fileField.setColumns(30);
        browseButton = new JButton("Browse");
        browseButton.addActionListener(this);
        fileField.setToolTipText("Let's you input a file");
        browseButton.setToolTipText("Browse here");
        Border loweredetched;
        loweredetched = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
        TitledBorder border = BorderFactory.createTitledBorder(loweredetched, "Input File Selection");
        border.setTitleJustification(TitledBorder.LEFT);
        border.setTitlePosition(TitledBorder.DEFAULT_POSITION);
        filler2.setBorder(border);
        filler2.add(inputFileLabel);
        filler2.add(fileField);
        filler2.add(browseButton);
        //bottom
        JPanel filler3 = new JPanel();
        filler3.setLayout(new java.awt.FlowLayout());
        generateButton = new JButton("Generate");
        generateButton.setToolTipText("Generates Output");
        filler3.add(generateButton);
        two.add(filler2);
        two.add(filler3);
        pane.add(two, "South");
    private void initLayout() {
        this.setTitle("OCR");
        this.setSize(700, 500);

Similar Messages

  • Having trouble getting objects on panel

    i am just attempting to build a simple gui frame and am having some trouble getting my labels to appear. here is what I have for the panel that the labels and buttons will be on. everything shows up no problem except clearButton and welcome2. Any suggestions would be greatly appreciated...thanks in advance
    class CountClicks2Panel extends JPanel
    constructs a count-clicks-1 panel instance
    public CountClicks2Panel()
    // button has not been clicked yet
    this.numClicks = 0;
    // create the labels and buttons for this panel
    JLabel welcome = new JLabel("Button-Click Counter");
    welcome.setForeground(Color.BLUE);
    JLabel welcome2 = new JLabel("Jared Letendre");
    welcome2.setForeground(Color.RED);
    JButton clickMe = new JButton("Click Me");
    clickMe.setForeground(Color.BLUE);
    clickMe.setBackground(Color.RED);
    JButton clearButton = new JButton("Clear Count");
    clearButton.setForeground(Color.BLUE);
    clearButton.setBackground(Color.RED);
    showNumClicks = new JLabel("# of clicks: " +
    this.numClicks);
    // add labels and button to this panel
    this.add(welcome);
    this.add(clickMe);
    this.add(showNumClicks);
    this.add(welcome2);
    this.add(clearButton);
    // create button action (so clicks will be counted),
    // and associate that action with clickMe button
    CountClicks2Action countAction = new CountClicks2Action();
    CountClicks2Action clearAction = new CountClicks2Action();
    clearButton.addActionListener(clearAction);
    clickMe.addActionListener(countAction);
    } // end CountClicks2Panel

    Sorry about that...i put it in code blocks originally but it didnt show when i previewed it...anyway here is the complete code. thanks for helping out
    import  java.awt.*;
    import  java.awt.event.*;
    import  javax.swing.*;
       A GUI application with a button for which the number
       of clicks is kept track of and displayed
       @author Sharon Tuttle
       @version 09-10-07
    public class CountClicks2Test
           creates a CountClicks1 frame
           @param args not used here
        public static void main(String args[])
            CountClicks2Frame mainFrame = new CountClicks2Frame();
            mainFrame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );   
            mainFrame.setVisible(true);   
       A frame with a panel containing two labels and a button
    class CountClicks2Frame extends JFrame
           constructs a count-clicks-1 frame instance
        public CountClicks2Frame()
            this.setTitle("Button-click Counter");
            this.setSize(this.DEFAULT_WIDTH, this.DEFAULT_HEIGHT);
            // add count-clicks-1 panel to frame
            CountClicks1Panel panel = new CountClicks1Panel();
            this.add(panel);
        // data fields
        private final static int DEFAULT_WIDTH = 150;
        private final static int DEFAULT_HEIGHT = 200;
       A panel with two labels and a button, that displays how many times
       the button has been clicked
    class CountClicks2Panel extends JPanel
           constructs a count-clicks-1 panel instance
        public CountClicks2Panel()
            // button has not been clicked yet
            this.numClicks = 0;
            // create the labels and buttons for this panel
            JLabel welcome = new JLabel("Button-Click Counter");
            welcome.setForeground(Color.BLUE);
            JLabel welcome2 = new JLabel("Jared Letendre");
            welcome2.setForeground(Color.RED);
            JButton clickMe = new JButton("Click Me");
            clickMe.setForeground(Color.BLUE);
            clickMe.setBackground(Color.RED);
            JButton clearButton = new JButton("Clear Count");
            clearButton.setForeground(Color.BLUE);
            clearButton.setBackground(Color.RED);
            showNumClicks = new JLabel("# of clicks: " +
                                       this.numClicks);
            // add labels and button to this panel
            this.add(welcome);
            this.add(clickMe);
            this.add(showNumClicks);
            this.add(welcome2);
            this.add(clearButton);
            // create button action (so clicks will be counted),
            //    and associate that action with clickMe button
            CountClicks2Action countAction = new CountClicks2Action();
            CountClicks2Action clearAction = new CountClicks2Action();
            clearButton.addActionListener(clearAction);
            clickMe.addActionListener(countAction);
        } // end CountClicks2Panel constructor 
           An action listener that counts the number of times the
           clickMe button has been clicked
        private class CountClicks2Action implements ActionListener
            // default constructor will suffice, in this case
               increases and displays the number of clicks of this
               button
            public void actionPerformed(ActionEvent event)
                CountClicks2Panel.this.numClicks++;
                CountClicks2Panel.this.showNumClicks.setText(
                    "# of clicks: "
                    + CountClicks2Panel.this.numClicks);
            public void actionPerformed2(ActionEvent event2)
                 CountClicks2Panel.this.numClicks = 0;
                 CountClicks2Panel.this.showNumClicks.setText(
                    "# of clicks: "
                    + CountClicks2Panel.this.numClicks);
        // data fields for CountClicks1Panel
        private int numClicks;
        private JLabel showNumClicks;
    } // end of class CountClicks1Panel

  • Get Count of Panels in Sliding Panels

    Is there a way to get the # of panels of a sidling panels
    widget?
    I'd like to add left and right arrows and gray out an arrow
    if they're at the end of the list of panels.
    The only way to do this is to find out if currentPanel =
    totalPanels (assuming this exists).
    Is there an API for this?
    Thanks!
    Chris

    hi Chris,
    Try calling the getContentPanelsCount() method on the sliding
    panels object.
    var panelCount = sp.getContentPanelsCount();
    You can also get the index of the current panel like this:
    var curPanelIndex =
    sp.getContentPanelIndex(sp.getCurrentPanel());
    I have the addition of observers to widgets on my list of
    things to do.
    --== Kin ==--

  • Trying to install reader on windows 7 pc, get object already exists

    trying to install adobe reader on windows 7 pc and keep getting object already exist. Checked my control panel programs, no adobe reader programs installed

    Try running the Acrobat Cleaner http://labs.adobe.com/downloads/acrobatcleaner.html
    then download and run the installer from http://get.adobe.com/reader/enterprise/

  • Nulls from HashMap.get(Object)

    I understand that I get the nulls because the Object is not in the map. But is there some elegant way to have it default to the empty String?
    Right now, after I grab all my data into variable with HashMap.get(Object), I go and check each once for null, and assign it the empty String instead. This is a lot of lines of code for something that is so basic.
    I know i could initialize them all to the empty string, and then for each variable, check the HashMap with containsKey(Object) before assigning with HashMap.get(Object). Now, would I be correct in assuming the compiler would optimize this for me and not actually check the HashMap twice for the same Object? And... even if that is the case, its still just as many lines of code.
    Is there perhaps some more elegant way?
    String exchange = parameterMap.get("exchange");
    String messageType = parameterMap.get("messagetype");
    String traderTimeStamp = parameterMap.get("traderTimeStamp");
    String exchangeTimeStamp = parameterMap.get("exchangeTimeStamp");
    String sequence = parameterMap.get("sequence");
    String product = parameterMap.get("product");
    String quantity = parameterMap.get("quantity");
    String price = parameterMap.get("price");
    if (exchange == null)
    exchange = "";
    if (messageType == null)
    messageType = "";
    if (traderTimeStamp == null)
    traderTimeStamp = "";
    if (exchangeTimeStamp == null)
    exchangeTimeStamp = "";
    if (sequence == null)
    sequence = "";
    if (product == null)
    product = "";
    if (quantity == null)
    quantity = "";
    if (price == null)
    price = "";

    You could first put "" for all potential keys.
    Or you could create a helper method
    public String nonNull(String s) {
      return (s != null) ? s : "";
    String exchange = nonNull(parameterMap.get("exchange"));

  • HT4759 i downloaded the icloud to my pc it says to login with apple id and it says it is a valid apple id but not cloud but i cannot get the control panel for icloud to come up to set it up on my pc which runs windows 8

    i downloaded the icloud to my pc it says to login with apple id and it says it is a valid apple id but not cloud but i cannot get the control panel for icloud to come up to set it up on my pc which runs windows 8

    An update.
    From iCloud Control Panel 2.1.1 for Windows
    "iCloud Control Panel 2.1 and later includes support for Windows 8"
    but you still need to set it up on a Mac or iOS device, "Note: To create an iCloud account you need an iPhone, iPad, or iPod touch with iOS 5 or later, or a Mac with OS X Lion v10.7.5 or later."

  • How to get object key before load data into form?

    I need to get object key (e.g. ItemCode in Item Master Data From ,docEntry in A/R Invoice From) to calculate and do something  before data is loaded into this form .
    I try to use SAPbouiCOM.BusinessObjectInfo.objectKey as in this code.
    Private Sub oApp_FormDataEvent(ByRef pVal As SAPbouiCOM.BusinessObjectInfo, ByRef BubbleEvent As Boolean) Handles oApp.FormDataEvent
           If pVal.FormTypeEx = "672" And pVal.BeforeAction = True And pVal.EventType = SAPbouiCOM.BoEventTypes.et_FORM_DATA_LOAD Then
                   oApp.MessageBox(pVal.ObjectKey)
           End If
    End Sub
    But this fields doesn't valid under this condition (form DI help file).
    - The property returns an empty value in the before notification of the Load action (et_FORM_DATA_LOAD) triggered by a Find operation.
    How can I get this value(key)?

    Janos
    I can't do a calculation after data is loaded because what I'm going to do is that if the opening entry match my condition , the system will not let that user see that entry (bubbleEvent = False).
    I think when formDataEvent is triggered B1 know which entry are going to load because before this event is triggered we did one of following ways
    1. choose from "choose from list windows"
    2. enter docEntry or itemCode or cardCode  and then press Find Button
    3. press "next/previous record button"
    4. press linked button (orange arrow)
    Choice 3 and 4 can be done by retrieve data from BusinessObjectInfo.objectKey (I've tested and it return entry key that is going to open correctly).
    but 1 and 2 can't (it return empty as I mention before).
    thanks
    Edited by: daron tancharoen on Aug 5, 2008 2:34 PM

  • I got locked out of Mac os 9 and now I can't get into OS 9 or OS X.  All I see is the Macintosh SE and a finder face and text that says "mac os 9.2 welcome to mac os".  I can't get into COntrol Panel to reset the password to allow me to get in.

    I got locked out of Mac os 9 and now I can't get into OS 9 or OS X.  All I see is the Macintosh SE and a finder face and text that says "mac os 9.2 welcome to mac os".  I can't get into COntrol Panel to reset the password to allow me to get in.

    Do you have OS X and OS 9 installed on your Mac? If so, startup with the Option key depressed. This will open the Startup Manager window. Select the OS you want to start from & click the right arrow.
     Cheers, Tom

  • Can I get the kuler panel in illustrator cs6?

    I Cant get the kuler panel to work in illustrator cs6.

    everyone here is right, dreamweaver is better and you will need to understand html for this to work. HOWEVER, you can make a functional website using just illustrator and notepad (or text edit if you're on a mac).
    Design your site in illy, slice it up with the slice tool. http://s23.postimg.org/mv311kpp7/test_illy.jpg 
    Save for web and select html and images, you'll get an html file and an images folder. Open the HTML file in your text editing program and it will look like this: http://s10.postimg.org/f32nf6r2h/html_stuff.jpg   you'll have to know HTML codes but you can find tutorials online for most stuff, you'll just have to figure it out. In my fake site, i linked a button to google so i had to add <a href> tags to the code. http://s22.postimg.org/5avpadhch/a_href.jpg  save the html file and open it in your web browser, hopefully not IE. You can't tell in the picture but the middle button actually does link to google. http://s21.postimg.org/qd77slqmf/firefox.jpg

  • Object States panel not working in CS6, please help!

    I have InDesign CS6 installed (same license) on my work computer and home computer. The Object States panel works just fine at home. But at work the panel shows up, but it is always blank even though I have an object selected that has a State applied to it.
    I am thinking I need to uninstall/reinstall and hopefully it will work again.
    On a side note, when I save the file down to CS5 from CS6 and open in CS5, the Object States is now visible. I attached a photo. Top two images are screen grabs from file opened in CS6. Bottom two photos are same file opened in CS5. See how the Object States are visible in CS5 and not in CS6.

    Thjnis sort of problem is usually fixed by trashing the prefs. See Replace Your Preferences

  • How to get Object Name

    hi
    i make a widget in flex for Captivate5.5, now i want to get my Object Name(widget->Animation->ObjectName) in flex , how can i get that name
    how can i get Object Name in Flex Dynamically....

    thnx Jim Leichliter for ur replay
    i'm using  http://blogs.adobe.com/captivate/2010/10/flex-based-widgets.html classes,

  • How do i get the password panel to come up??

    the only help i get drom apple is tro go to a dealer and pay for a new hard drive

    That's kind of nuts.  
    Apple menu -> System Preferences -> Accounts  or Users & Groups
    Turn off the auto-login feature.  This will allow you to get the password panel on startup.

  • How do I get the basic panel in the develop module to reappear in Lightroom 5?

    Hello! I was editing a photo in Lightroom 5 the other day, and I thought I hit something, but all of a sudden the basic panel was missing. I went online to see how I can fix it, and what was suggested was to right click on one of the panels and it should have an option that says basic, in order to get the basic panel back. That is what I did, but what it does is just opens and closes the panels. I don't know how to get my basic panel back, I hope I can get some advice.
    Thank You!

    The trick is to right-click on one of the other panel headers, e.g. Tone Curve, and you'll see a context menu allowing you ro reselect the Basic Panel.
    Alternatively, when in the Develop Module simply do Ctrl+1 (Cmd+1 on a Mac), or in the menu bar go to Window>Panels>Basic Panel.

  • Browser.download.useToolkitUI to true on the about:config to get old download panel Does NOT work. How do I get it back?

    Firefox 26:
    The fix turning browser.download.useToolkitUI to true on the about:config does not work. How do I get rid of the library crap and get my download panel back?

    Mozilla, if a large number of people use a feature to the point that they are digging in to the configuration to re-enable it when you turn it off my default, please don't remove the feature altogether. It disrupts users' browsing experience and upsets them.

  • How do I safely get the side panels of the printer off

    How do I safely get the side panels off the printer. I am attempting a repair and do not want to break them

    The thin strip is called the encoder strip.  It has very fine lines that are used to keep track of where the carriage is as it moves across the paper.  You should not need to remove the sides to replace this, but it can be a bit tricky.  The post here may help.  Be sure the encoder strip is properly threaded through the sensor at the back of the carriage.
    Bob Headrick,  HP Expert
    I am not an employee of HP, I am a volunteer posting here on my own time.
    If your problem is solved please click the "Accept as Solution" button ------------V
    If my answer was helpful please click the "Thumbs Up" to say "Thank You"--V

Maybe you are looking for

  • My macbook is extremely hot and the fan is worryingly loud, what is wrong with it and how do i stop this from happening?

    For soem reason if I actually dare to use my macbook the fan kicks in and is so loud that I am unable to use skype or other voice programs without a headset because of its volume, also it gets very hot very fast, so hot that if I rest it on my knees

  • Mail issues with Apple's Mail

    I was using Outlook Express to send & receive mail.  And then (because Outlook Express has been giving me fits with errors and needing to put my password in every time I wanted to use it)  I switched to Mail (the one that came on my Mac). And now, wi

  • Flash Player seems to install, but will not function

    Flash Player installs but does not work.  When I go to the troubleshooting website (http://helpx.adobe.com/flash-player.html), the box does not fill with information.  If I right click where the box should be however, the menu shows the version and a

  • How to connect MBAir to home media player?

    Hi, I have a Western Digital home media player linked to my router, I'm trying to connect it to my MBAir via wifi so I can stream movies. http://www.wdc.com/en/products/products.aspx?id=330 However, I can't find out how to set up the connection on th

  • Count is too slow?Any alternatives?

    Query is taking forever.The data is against 11 million records.And encountered an error about metadata entry. Any idea? Message was edited by: JAUS