Making JTextFields look "good"

sup, I cant seem to get my JTextFields to be displayed at the right height(as tall as the characters) in ANY window size.... what layout should I use?
thanks
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Calculator extends JFrame implements ActionListener {
private static final int WIDTH = 300;
private static final int HEIGHT = 200;
private static final int CHAR_PER_LINE = 10;
private JTextField text1, text2, result;
public static void main(String[] args) {
Calculator demo = new Calculator();
demo.setVisible(true);
public Calculator() {
setSize(WIDTH, HEIGHT);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setTitle("Calculator");
Container content = getContentPane();
content.setLayout(new GridLayout(3, 1));
JPanel row1 = new JPanel();
row1.setLayout(new BoxLayout(row1, BoxLayout.X_AXIS));
JLabel label1 = new JLabel("Number 1:");
row1.add(label1);
text1 = new JTextField(CHAR_PER_LINE);
row1.add(text1);
content.add(row1);
JPanel row2 = new JPanel();
row2.setLayout(new BoxLayout(row2, BoxLayout.X_AXIS));
JLabel label2 = new JLabel("Number 2:");
row2.add(label2);
text2 = new JTextField(CHAR_PER_LINE);
row2.add(text2);
content.add(row2);
JPanel row3 = new JPanel();
row3.setLayout(new BoxLayout(row3, BoxLayout.X_AXIS));
JLabel label3 = new JLabel("Result:");
row3.add(label3);
result = new JTextField(CHAR_PER_LINE);
row3.add(result);
content.add(row3);
JMenu operMenu = new JMenu("Oper");
JMenuItem m;
m = new JMenuItem("Add");
m.addActionListener(this);
operMenu.add(m);
m = new JMenuItem("Sub");
m.addActionListener(this);
operMenu.add(m);
JMenuBar mBar = new JMenuBar();
mBar.add(operMenu);
setJMenuBar(mBar);
public void actionPerformed(ActionEvent e) {
String command = e.getActionCommand();
int number1 = Integer.parseInt(text1.getText().trim());
int number2 = Integer.parseInt(text2.getText().trim());
if (command.equalsIgnoreCase("Add"))
result.setText(Integer.toString(number1 + number2));
else if (command.equalsIgnoreCase("Sub"))
result.setText(Integer.toString(number1 - number2));
else
result.setText("Error in GUI");
}

BoxLayout is a good choice, but insert glue before and after your items like
row1.add(Box.createHorizontalGlue());
This will eat up any space beyond the controls preferred width.
or if it's the height thats a problem, change the content's layout to BoxLayout, and insert
content.add(Box.createVerticalGlue());
to eat up extra vertical space beyond the control's preferred height.
i find that a combination of Border and Box layouts will get you what you want 99% of the time.

Similar Messages

  • Having trouble making a Facebook "Like Us" plugin look good.

    Hello.
    I'm having troulble getting a Facebook "Like Us" link to look good on a site I built. It seems that no matter where I insert the code for the plugin it just doesn't fit or look right.
    Here's the site: http://friendsoflafayette.org/index.html
    If I put the plugin in the rightside div it extends past the box. If I put in in the footer it isn't centered. As you can tell, I'm not a master with code and aren't sure how to make this fit properly. Ideally I'd like to put it in the rightside div but is there a way to line-break the text "American Friends of Lafayette" or somehow shorten the width to make it fit the div box? Alternately, how can I center the plugin in the footer so at least it looks presentable?
    Any suggestions welcome.
    Best Regards,
    John

    In code view, try changing this:
    <div class="fb-like-box fb_iframe_widget" data-href="http://www.facebook.com/pages/The-American-Friends-of-Lafayette/168772073195787" data-width="292" data-height="200" data-show-faces="false" data-stream="false" data-header="false">
    to this with an inline style noted in red:
    <div class="fb-like-box fb_iframe_widget" style="margin-left: 35%" data-href="http://www.facebook.com/pages/The-American-Friends-of-Lafayette/168772073195787" data-width="292" data-height="200" data-show-faces="false" data-stream="false" data-header="false">
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists 
    http://alt-web.com/
    http://twitter.com/altweb

  • Hello, I am interested in buying this week of a mac mini 2011 with intel graphics HD3000 but I'm not sure it looks good with my Samsung SyncMaster933HD monitor. How would it look better with the hdmi-dvi connection or a built-in display adapter port-vga

    Hello, I am interested in buying this week of a mac mini 2011 withintel graphics HD3000 but I'm not sure it looks good with my Samsung SyncMaster 933HD monitor. How would it look better.... with the hdmi-dvi connection built in, buying a HDMI 1.3 cable and HDMI-making or buying an adapter hdmi display port - vga and connected through the port thunderbolt
    Thanks

    I originally set up my mini with the included HDMI -> DVI adaptor to connect to a Sycmaster monitor. The graphics were very good.

  • How can I make my images look good when exporting to PDF document?

    Hello! I'm struggling here with a PDF Brochure that I need to create (intended for web only, not print).
    There are two images that look horrible and pixelated when I create my PDF file. I have tried everything, making the images bigger and smaller, using 72 dpi images and 300 dpi ones. Everything results the same way... It looks perfect in my InDesign file, but in the PDF it looks all damaged. Here are two screen shots, one of how it looks in the PDF and one of how it looks in InDesign.
    Could you please tell me what I need to do to guarantee that the image looks good quality in the PDF? (My document is 40cmx20cm, I don't not if using cm is affecting the document).
    To export to PDF I'm using the option: Adobe PDF pressets --> Smallest file size.
    If you can help me I would really appreciate it!
    Thank you,
    Nataly.

    beer and no prepress schrieb:
    If it's for the web, why not export to JPEG?  Why PDF?
    Terrible idea. In a JPG the text will not be alive, you loose all interactivity.
    And making JPGs with InDesign is not what the program is meant to make.

  • Why can't my HD to SD SHORT film look good? Best Encode?

    I have a 12 minute short film on HDV. I imported it to FCP5 and then DVDSP4 and created an HD-DVD and it looked GREAT. Then I found out my computer is pretty much the only DVD player that can play the HD-DVD I had created. Thus began my journey to make a decent SD-DVD, and so far I am not even close...
    HERE'S WHAT I'M DOING:
    1. I used FCP to downconvert from HDV to DV (I don't have access to the camera to use it downconvert option). I'm sure this step is where the quality drops at least 4 generations!
    2. DVDSP5 > Preferences > Mode: Two Pass VBR, Bit Rate: 5.5, Max Bit Rate: 8.5, Motion Est: Best
    IMAGE PROBLEM:
    Lots of pixelation in darker areas of the screen. Places i could see in HD are now just black and pixelated black at that.
    TWO QUESTION:
    1. My main annoyance is this: When I burn the DVD, it only burns about 20% of the DVD (HD-DVD would use 60%). I have the space on my DVD-R, why can't I utilize this space and burn 90% of this space with data to make my film look good?
    2. iDVD did a better job of making the SD DVD look good. So I know there is something i could do. I've never used Compressor. How can I encode my HDV for use in SD DVD environement in DVDSP5?
    Any help will be much appreciated... I hope answers to these questions helps others as well...
    Best,
    AJ

    AJ -
    Thanks for your reply -I hope i can clarify below.
    Yes i have been editing the sequences using native HDV 1080i.
    When comparing the output of the converted formats here is what i did.
    I have a Sony a HC1 HDV Camcorder. I captured and edited all clips with native HDV. Then i recorded back the HDV material back into the camera (HUGE issues with doing this in FCP - but ill leave that to another thread)
    From there i did two things
    1) I sent the native HDV Final Cut sequence to compressor and set it to DVD, 90Min, Best quality, 2pass VBR. I burned a DVD with DVDSP4 with this encoded sequence
    2) i played back the HDV Sequence from my sony camcorder back into the television directly - but using the composite video output (not using the high definition component output).
    3) I set my Sony HDV cam to output via firewire as standard DV (eg - i let the camera do its own HDV to DV downconvert). from there i recaptured back into FCP, compressed with the same compressor settings, and sent to DVDSP4
    I compared side by side the content from all three options. Hands down Options 2 and 3 looked MUCH better than option 1.
    Here is what i noticed
    1) A lot of motion artifacts with option 1. This especially when the camera pans and moves. I think this has to do with the way interlacing during downconversion happens. If i run the FCP sequence through a de-interlace filter it actually does come out better - though not as smooth since you are loosing 1/2 the frames.
    2) A lot of digital artifacts. pixellation and such like. It looks almost like one of those old VCDs in terms of image quality.
    I had searched the forums and found that many other people are having the same problems - so i know that i am not alone on this one (unfortunately). I do find it frustrating that a very expensive >$1000 application suite which claims to support HD has so many issues with editing in HD (this is just one of the issues.. others are that you cannot reliably export HDV back to tape, there are issues with editing multi-cam with HDV with more than 3 sequences... etc..).

  • KDE fonts under Gnome doesn't look good

    Ok, most people complains about GTK fonts under KDE. I have the inverse problem, my kde apps doesn't look good into gnome.
    If I run kde, the fonts are displayed properly with small size, but if I run gnome and the run a kde app, the fonts are very big.
    When i run a gtk app under kde, the fonts are showed properly but it doesn't use my gnome theme.
    Anyone have a solution on making kde apps looking good under gnome?

    Even though it's the inverse problem, it's likely still the same solution.  Gnome has a Gconf setting for DPI.  Otherwise you change it as an option to X.  Where you do so depends on how you start up X though (startx, xdm, kdm, gdm, etc).  I'll post back once I'm in Gnome and tell you where you can change the DPI.

  • When I first am looking at my newly uploaded photos in "Library", a box appears near the bottom of the photo that says "loading" (the photo looks good to me), then it is more "faded" and does not look as good.  Is there some setting on that I am not aware

    When I am first looking at my newly uploaded photos in "Library," a box appears near the bottom of the photo that says "Loading".  While it is loading, I usually think the photo looks "good".  After the photo is done loading, it looks more washed out.  Is there some sort of setting that I might have on (or that I need to turn on) so that this does not happen.  I have Lr4.  Thanks.

    Hi Tracy,
    There used to be a way to see if poster was new to the forum.., anyway - welcome to the forum.
    As I was alluding to, biggest differences in initial display are due to:
    * Camera calibration profile.
    * Auto-exposure/contrast settings (for which compensations have been auto-applied in camera, but not in Lightroom).
    So, choose a matching camera calibration profile (whether that's an option or not depends on your camera model - they're available for many but not all models) if you prefer one of them over "Adobe Standard" (the factory default profile).
    Also, your camera covers for underexposure due to non-optimal auto-exposure/contrast setting, Lightroom doesn't, so your options are:
    * turn it off in camera.
    * learn to compensate manually (or automatically via a plugin) in Lightroom.
    Of course, in addition to preferred defaults (alt-click big "reset" button in dev module), come up with some presets which are appropriate for your druthers and type of photography.. e.g. these will compensate Nikon ADL settings:
    http://www.robcole.com/LrForumSupport/ADL%20Compensations%20%282012%29.zip
    Cheers,
    Rob

  • We are trying to do a Quick payment from payment workbench and getting 'FRM-41830: List of values contains no entries' error for payment document column/field. Payment document setup looks good. Not sure what the issue is.

    We are trying to do a Quick payment from payment workbench and getting 'FRM-41830: List of values contains no entries' error for payment document column/field. Payment document setup looks good. Not sure what the issue is.

    Already gone through following three notes but didn't found resolution.
    APXPAWKB: FRM-41830 When Clicking on Payment Document LOV (Doc ID 1081305.1)
    R12: APXPAWKB: Payment Document Lov Is Empty When Entering A Payment (Doc ID 857587.1)
    R12: Payment Workbench Error: FRM-41830 List Of Values Contains No Entries (APXPAWKB.FMB) (Doc ID 1323875.1)

  • I've been giving HD videos in MTS format and convert the for editing in FCE.  Looks good in the program, but when I export the finished film, quality had been noticeable diminished.  Is there any way to prevent FCE from lowering the output quality?

    Hello -
    I've been sent HD footage in MTS format and converted it to Mp4 for editing in FCE.  It looks good in FCE but when I export the movie, the quality is noticably diminished.   Is there any way I can prevent FCE from lowering the quality on export?
    Thanks.

    >I use Foxreal video converter for Mac to convert the MTS using the Apple intermediate codec setting and the problem is that I don't get image, just audio
    My thought would be to NOT use Foxreal video converter.
    Use MPEG Streamclip or Clipwrap.
    -DH

  • High quality only looks good when in full screen

    I have a "15 MacBookPro using AE CC 2014.2..
    So I typed some text within AE and dragged in a high resolution photo to make a simple video. My composition size was 1920x1080.  But the photo and text always look weird, sorta pixelated, unless they are full screen.  It's like the AE video can't handle being resized whether I'm watching it on quicktime or youtube, or even while working in AE.  However the high res photo looks great at any size when I view just as a photo, using the Preview application.
    This has happened before on other videos I've made but it really bothered me because it just ruins the photo on this one.  if I make my video 720 it comes out not as noticeable but then if you try to watch the video full screen it gets blurry in the expected pixelated fashion, so that doesn't truly solve anything....I am just confused as to why after effects is not letting me make high quality videos that look good in a smaller video window (eg: the youtube video player if you don't click full screen)
    below I attached a screen shot of what is happening.  This particular screen shot is from when I uploaded it on youtube and watched it.  But if I watch it in a small window using quicktime or even in AE, it looks the same...until you blow it up to full screen then it looks alright!
    But I want people who just happen upon the video to be drawn into the photograph and bold text on screen not see some pixelated **** 

    Your thin outlines on the fonts are going to fall apart when you have the media player scaled down. Here's why. Say those thin lines are 2 pixels wide. Say the Media player is set to 600 pixels wide instead of 1920. Divide 600 by 1920 and you get .3125 (or 31.25%) Multiply 2 pixels by .3125 and you get .625 and since there is no such thing as a fraction of a pixel the media player is going to make it's best guess where those white pixels should be and adjust the color to approximate what six tenths of a pixel would look like. The result is poor quality.
    You can improve the quality by first, not using very thin lines in your design, and second, not putting high value pixels (white, red, blue, green at 255 for example) next to black ones (0). Learning how pixels behave is as important to a motion graphics designer as learning how a brush responds to the canvas for a painter working with oils. Video is limited to whole pixel brushes so you need to learn how to paint with them.

  • Trying to get Photoshop CS4 functional with Mavericks and an Epson 3880 printer. CS4 fails to send a file to the print queue. Have reinstalled the Epson 3880 driver for Mavericks. All looks good but no file is sent.

    rying to get Photoshop CS4 functional with Mavericks and an Epson 3880 printer. CS4 fails to send a file to the print queue. Have reinstalled the Epson 3880 driver for Mavericks. All looks good but no file is sent.
    Does anyone know how to fix this?

    What EXACT version of Photoshop CS4 are you running?  You should be on Photoshop CS4 v 11.0.2.
    Also run Apple's software update to see whether it offers you the latest Epson update:
    Printer Driver v9.33
    Epson Stylus Pro 3880, Drivers & Downloads - Technical Support - Epson America, Inc.
    MOST IMPORTANTLY:  have Photoshop re-create its own Preferences:
    To re-create the preferences files for Photoshop, start the application while holding down Ctrl+Alt+Shift (Windows) or Command+Option+Shift (Mac OS). Then, click Yes to the message, "Delete the Adobe Photoshop Settings file?"
    Note: If this process doesn't work for you while you're using a wireless (Bluetooth) keyboard, attach a wired keyboard and retry.
    Important: If you re-create the preferences by manually deleting the Adobe Photoshop CS6 Settings file, make sure that you only delete that file. If you delete the entire settings folder, you also delete any unsaved actions or presets.
    Reinstalling Photoshop does not remove the preferences file. Before reinstalling Photoshop, re-create your preferences.
    NEW Video! Julieanne Kost created a video that takes you through two ways of resetting your Photoshop preferences. The manual preference file removal method is between 0:00 - 5:05. The keyboard shortcut method is between 5:05 - 8:18. The video is located here:
    How to Reset Photoshop CS6’s Preferences File | The Complete Picture with Julieanne Kost | Adobe TV
    Mac OS
    Important: Apple made the user library folder hidden by default with the release of Mac OS X 10.7. If  you require access to files in the hidden library folder to perform Adobe-related troubleshooting, see How to access hidden user library files.

  • TS3048 I am usng a bluetooth keyboard with my Mac and some of the keys are not working.  They are the numbers 1 through  9.  I have gone through the troubleshooting for mouse and keyboard and everything looks good. How can I get them to work again?

    Hi,  I am using a Mac computer that my husband set up.  I have worked on it recently with no problems.  Today, I am having problems with the bluetooth keyboard not  working properly.  The numbers 1 through 9 do not work.  I have gone through troubleshooting wireless mouse and keyboard issues and everything looks good.  Except, when I check the keys on the keyboard viewer, these keys still do not work.  The webpage guides me through and at this point I do not know what to do next, because the keyboard is still not working properly.  I sure hope there are some experienced people in the community to help me.  What should I do?

    Hi:
    I wish my suggestion had gotten you further.
    I do suggest you try to connect the keyboard again.  The request for a number is a step in it trying to pair.  If it gets by the number, it sometimes takes a little while to get connected.  If you are unable to get it connected and want a new one, I have been using Apple Bluetooth keyboards for years - and I like them. The one I have (the newest model) only uses two batteries and is very thin. 
    Speaking of batteries, if you are not already doing so, you might consider rechargeables.  I have a drawer full of them and use a 15 minute charger.  I go tired of buying batteries and rechargeables are environmentally friendly to boot. At the moment, I use 2450 mAh Energizers and a 15 minute Energizer charger (all purchased new on eBay at a very reasonable price).
    I am far from an iPad "expert," although I have one.  If my suggestion below does not help, post your question in a separate thread in the iPad forum.
    I had a terrible time syncing my iCal on my Mac with my iPad iCal (confusing - hopefully it makes sense).  I quit using iCloud as that added to the confusion. There is a facility to one-time sync items.  When you connect your computer to your iPad, iTunes opens.  The system begins a process (automatic backup and so on). After it finishes, you can click on "info."  At the bottom of the screen, there is an advanced section.  You can select any of the items and then force it to sync. The iCal information from your computer would be deposited on the iPad. 
    After all that, I do not use a Google calendar so the information may be worthless to you.
    If you want to reset the iPad to factory settings, you can do that when it is connected to iTunes (one of the options).  Me being me, I try never to erase anything. 
    Barry
    Message was edited by: Barry Hemphill

  • Exported Movie looks good in Quicktime, but not in any other Player?

    I Have noticed that the text that I have exported from After Effects were looking jagged in windows media and Kmplayer. At first I thought it was my render settings that were making it look low quality, but then I found that when played in Quicktime the movie look high rez. only problem is that quick time is extremely laggy when I open up my movies. Why is this happening?

    Huh? That's simply hardware scaling. Your movie is not being viewed at 100% size.
    Mylenium

  • My subs look good in dvdsp but when I burn an example the subs are too high in the frame.All my offsets are 0 and the alignment button is bottom.

    My subs look good in dvdsp but when I burn an example the subs are too high in the frame.All my offsets are 0 and the alignment button is bottom.
    Any thoughts

    Try creating a new project, and bring in a short clip and one or 2 subtitles and see if you see the same behavior.  If you don't,  something's probably wonky in the project.  If the sample behavior has the same problem, if you want to send it to me with the associated media, I'll take a quick look.
    My email is [email protected]

  • HDCam 1080i to ???? for PC and still look good compressed?

    Client has asked for 1280x720 compressed in a codec that a PC can read via After Effects. Eventually they want to go to Flash. Their source is HDCam 1080i.
    I've captured via FCP 6/AJA Kona LHe in Apple 10bit 4:2:2 Uncompressed, then let Compressor 3.0.1 turn it into Animation codec and H.264 in order to give them a file size they can work with. The H.264 and the Animation file look like the field order is messed up. But Compressor's frame control is set to Automatic and when it isn't it wants to deinterlace and take 2 hours or more to render a 5 second clip. I've got almost twenty minutes of material to process so that isn't a real world workflow.
    They've come to me as a service bureau to give them a file they can work with. I just can't figure out what kind of file would work. I'm wondering if there is something wrong with the compression I've used or is this just state of the art for Compressor?
    Look at some screen grabs of the original and the resultant H.264 (the animation codec has the same jaggy/zipper/comb effect on the edges. Look at the edge of the car and their clothes, etc.)
    http://www.countdownvideoproductions.com/jaggies.html
    What's the best way to get from the Apple Codec into a PC they can use and have the file not be so large, yet look good (unlike Compressor's output to H.264 and Animation)?
    Graeme where are you?

    Cinephile8 wrote:
    ... I'm licensing images from a company that offers two sizes: 200 and 800 KB. ...
    kB doesn'r measure the 'size' of a picture in terms of 'looking good', if you don't know resolution, bit-depth, codec etc.
    a jpg, showing plain blue rectangle of 3000x5000 pixel with <20kB could look much better than a 16bit.tiff of 480x360 pixel...........
    Brad told you about res of HDef video.
    if you don't plan to add massive Ken Burns Effects, this res is enough.
    a less compressed pic (same res, but more kBs) will finally deliver better quality, forinstance less probs with 'banding'.
    I would purchase the same picture in BOTH 'sizes' and make a test, including final delivery (YouTube, DVD, web, Vimeo, projection, whatever) .... and judge with your own eyes, what fullfills YOUR criteria of 'quality'.

Maybe you are looking for

  • How to enable Dynamic Time Series?

    Hi expert, I tried to enabled Dynamic Time Series for an application, by go to Dimension Library, right click, select "Dynamic Time Series", then selected both YTD and QTD for generation 2 and 3 respectively, then refresh database. But found seems th

  • Could not open LSMW conversion file for Material Master uplo

    Hi, When i am uploading Material Master data the error says Could not open the file proj_subproj_obj.lsmw.conv file. I could read the conversion data in LSMW but there is a problem with session creation. I have created a Job and assigned a variant to

  • Will I be able to cut a micro sim to a nano sim?

    Replies will be great :)

  • Can i back up a phone that hasnt ever been backed up

    i am trying to back up a phone that hasnt ever been backed up. it will only let me restore from a backup but not let me just back up what is on the phone. help

  • An odd choice

    Hello to all! I am looking to run FCS1 or FCE4 on a new machine. Unusually my options are to buy a new 20" Imac for £800 (apologies to dollar users) or an (obviously) second hand MDD G4 1.25GHz for £125. I have worked extensively on PCs with Avid but