How to fine tune your GUI?
Hello!
I am pretty new at Java and i have search for information about how to fine tune your GUI but have not found anything.
Last time when i wrote a program with a GUI I manually placed out all the widgets. This time I was thinking to give the layotmanager another go. But when I do I cant seem to easly place things exactly where I whant.
For instance in this code, all my buttons are to the left in the boarder layout north part.
I whant to learn:
How do I move all the buttons to the right, little further down, etcetera to my specifications
Please if someone could provide me a link to a website, tip on what I need to search for. So I can learn how to do this when you mix diffrent layoutmanager in one GUI.
Example of my code:
//Import java library
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionListener;
public class View_Inlupp2 {
//*****GUI Components
//Menu File Items
private JMenuItem New = new JMenuItem("New");
private JMenuItem Open = new JMenuItem("Open");
private JMenuItem Save = new JMenuItem("Save");
private JMenuItem Save_As = new JMenuItem("Save as");
//Menu Operations Items
private JMenuItem Find_Route = new JMenuItem("Find Route");
private JMenuItem Show_Connections = new JMenuItem("Show Connections");
private JMenuItem New_Place = new JMenuItem("New Place");
private JMenuItem New_Connection = new JMenuItem("New Connection");
private JMenuItem Change_Connection = new JMenuItem("Change Connection");
//Top field
private JButton Find_RouteBtn = new JButton("Find Route");
private JButton Show_ConnectionsBtn = new JButton("Show Connections");
private JButton New_PlaceBtn = new JButton("New Place");
private JButton New_ConnectionBtn = new JButton("New Connection");
private JButton Change_ConnectionBtn = new JButton("Change Connection");
//Left side
//Center
public View_Inlupp2() {
//Create and show the GUI.
createAndShowGUI();
//**********GUI Structure
private JPanel createContentPane() {
//Create the JPanel where we will put everything on
JPanel totalGUI = new JPanel();
//Set totalGui to have a BorderLayout with a horizontal
//gap of 10 and a vertical gap of 10 between each widget
totalGUI.setLayout(new BorderLayout(10, 10));
//*****Top Field
//Create a holder for the buttons with a BoxLayout.LINE_AXIS
JPanel top = new JPanel();
top.setLayout(new BoxLayout(top, BoxLayout.LINE_AXIS));
top.add(Find_RouteBtn);
top.add(Show_ConnectionsBtn);
top.add(New_PlaceBtn);
top.add(New_ConnectionBtn);
top.add(Change_ConnectionBtn);
//*****Put our GUI together and add all the widgets to our totalGUI
totalGUI.add(top, BorderLayout.NORTH);
totalGUI.setOpaque(true);
return totalGUI;
private JMenuBar createMenuBar() {
//Create a menuBar
JMenuBar menuBar = new JMenuBar();
//Create menus
JMenu File = new JMenu("File");
JMenu Operations = new JMenu("Operations");
//Add menus to menuBar
menuBar.add(File);
menuBar.add(Operations);
//Add menuItems to the File menu
File.add(New);
File.add(Open);
File.add(Save);
File.add(Save_As);
//Add menuItems to the Operations menu
Operations.add(Find_Route);
Operations.add(Show_Connections);
Operations.add(New_Place);
Operations.add(New_Connection);
Operations.add(Change_Connection);
return menuBar;
//**********Create the window frame
//Create the frame and add the created content pane.
private void createAndShowGUI() {
JFrame.setDefaultLookAndFeelDecorated(true); //The program look the same on Windows, Mac and Linux
JFrame frame = new JFrame("Inlupp2");
//Set the ContentPane, menuBar, and the settings for our window
frame.setContentPane(createContentPane());
frame.setJMenuBar(createMenuBar());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(1024, 640);
//frame.setResizable(false);
frame.setVisible(true);
//**********Interaction
//Add the ActionListener passed by the Controller to each of the buttons
public void buttonActionListeners(ActionListener al) {
}//End buttonActionListener
}//End class
First of all, learn and use proper Java naming conventions. All text books, tutorial and code examples on the forums use these naming conventions. So don't make up your own. Variable names should NOT start with an upper case character.
By default a JPanel uses a FlowLayout. Read the API to learn how to change the default left alignment to center or right.
If you want extra space around a panel you can use an EmptyBorder.
Both of these topics are covered in the Swing tutorial and you've been given the link to the tutorial in the past.
Also, the code you posted is not executable so we can't see the problems you attempt to descripe.
If you need further help then you need to create a [Short, Self Contained, Compilable and Executable, Example Program (SSCCE)|http://sscce.org], that demonstrates the incorrect behaviour.
Similar Messages
-
Hi,
I am having below two queries. 2nd query is taking more time & it gives time out error. Can anybody tell how to fine tune below query. Thanks.
1st Query.
SELECT EKETEBELN EKETEBELP EKETETENR EKETEINDT
EKETMENGE EKETWEMNG
INTO TABLE I_EKET
FROM EKET
WHERE EKETMENGE <> EKETWEMNG
AND
EKET~EINDT IN S_EINDT.
DESCRIBE TABLE I_EKET LINES V_ZLINES.
IF V_ZLINES > 0.
2nd Query.
SELECT EKKOEBELN EKKOAEDAT EKKOLIFNR EKPOEBELP EKPO~MATNR
EKPO~WERKS
EKPOLOEKZ EKPOELIKZ EKPOTXZ01 EKPONETPR LFA1~NAME1
INTO TABLE I_PODEL
FROM EKKO
INNER JOIN EKPO ON EKKOEBELN = EKPOEBELN
INNER JOIN LFA1 ON EKKOLIFNR = LFA1LIFNR
FOR ALL ENTRIES IN I_EKET
WHERE EKKO~EBELN = I_EKET-EBELN AND
EKPO~EBELP = I_EKET-EBELP AND
EKPO~MATNR IN S_MATNR AND
EKPO~WERKS IN S_WERKS AND
EKPO~WERKS NE 'W001' AND
EKKO~EKORG = P_EKORG AND
EKKO~LIFNR IN S_LIFNR AND
EKKO~LOEKZ NE 'X' AND
EKPO~LOEKZ NE 'S' AND
EKPO~ELIKZ NE 'X' AND
EKPO~LOEKZ NE 'L' AND
EKKO~AEDAT IN S_AEDAT.
ELSE.
WRITE 'No POs found for the selection criteria!'.
ENDIF.Not the right forum to ask this question.
VJ -
How to fine tune a software instrument
Can anyone tell me how to fine-tune a software instrument that's a little sharp for my audio track? Is there an easy way to do that?
Which instrument? Here it is for the EXS24 II.
-
How to fine tune ROIs of LEDs of a camera image?
Hi,
I use NI Smart Camera and NI Vision Builder 2012 for measuring HUE values of the LEDs. I can manually adjust the ROI of each LED. Sometimes mechanics move a bit and my ROIs are then tilted/off from LED and measurement results are staring to fail. I am wondering how to set vision builder/camera to automatically fine tune ROIs when needed? I attach a sample picture of LEDs. There is also situation where I manually fine tune LED D79's ROI.
BR,
Jick
Attachments:
LEDs.png 37 KBThanks for the example. There is still one open question: how do I detect if one LED is OFF? For example if one LED is missing Detect Objects 1 step finds one object less but how can I know which LED is missing/off? How about creating Detect Object step for each LED separately and if there is no LED on measure colors step just fails? I attach my suggestion here.
BR,
Jick
Attachments:
Adjust_ROIs.vbai 114 KB
camera_simulation_image2.png 26 KB -
Nw2004s Java - IBM SDK - How to fine tune
Hello,
Can you anyone let me know about tunning IBM SDK parameters on Linux using configtool ?
We have already set some parameters as per SAP Note for IBM SDK.
Still not sure, how to set the following in the configtool
1. HeapDumppath
2. HeapDumpon CtrlBreak
If I XX:HeapDumpPath=/usr/sap/dumps , JVM is not starting. The same setting Sun JAVA JDK on Solaris is working fine.
I believe the syntax is different for IBM SDK than Sun JDK.
Thanks in Advance for your help !
kandyHi,
Please check the following SAP Notes:
Note 1004255 - How to create a full HPROF heap dump of J2EE Engine 6.40/7.0
Note 1053495 - Settings to get a heapdump with IBM JVM on AIX
Note 710146 - How to change J2EE Engine JVM Settings
Hope That helps.
Regards,
Siddhesh -
How to fine-tune KM Navgation iView
Hi Experts,
We have 6-7 KM navigation iviews on the homepage, all rendering xml news from different folders of KM.
Now we have discovered that the maximum time of page loading is occupied by these navigation iviews(If we make these navigation iviews invisible, then the loading time is almost half).
Please suggest some ways to tune these Navigation iviews so that the load time of homepage should be less.
Thanks,
AnkitHi Ankit
This is a classic issue - the performance for the KM Navigation Iview is very poor, and I would never suggest you to put more 2-3 KM Nav Iviews on the same page. And I would not recommend you to put any KM Nav Iviews on a frontpage or any other important or content-heavy page.
You have the following options:
1) Limit the number of KM Nav Iviews on the page in question.
2) Set Cache Level to Shared (server side caching) even though this feature is not working consistently in the SAP Portal.
3) Configure the search iview (search component set and search options set) according to the Last10Documents scenario: http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/45bcc1c0-0d01-0010-1094-fe7993416ea6
4) Contact a developer and let him code a servlet used to render pure html according to your needs. Show him this introduction: http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/3059b588-e19b-2910-7d8f-9b689a066e3c
Best regards,
Martin Søgaard -
How to fine tune the performnce of Adobe - WebDynpro Java
Hi Experts,
Upon deploying an Adobe - WebDynpr Java application on my local NWDW machine having 2 GB RAM, it takes around 10 minutes by watch before the PDF form appears on the screen with the populated data.
This is really depressing as the client will surely not accept this.
Any tips on fine tuning the performance of Adobe online applications?
Regards,
Shobhithi,
when the J2EE engine is running...
goto task manager....
see performance.
if the memory usage is more than the memory you have installed,
that means you are using virtual memory...(ie. hard disk as RAM)
try shutting down any excess processes which you are not using.
(CAUTION: shut down only those processes which you know)
Summary is:-
check if you are on virtual memory.
because if you are using virtual memory....
you are falling short of RAM.
our server also has 2 GB RAM, but it works fine(including Interactive forms)
regards,
-ag -
Hi DBA,
i am new to this field.
i can see from EM some sql are taking 8%- 95% of Db . i get the SQL_ID from the Em how to fine tune this?
also can you please help me out with some standard recommendations to run the DB in best manner.
Thanks in advance.As a generic recommendation for slow sql queries, read the following thread ,
When your query takes too long ...
HTH
Aman.... -
How do you get your purchased items on apple tv to you i tunes on your computer
How do you get your purchased items on apple tv to you i tunes on your computer
Download them.
Store > Check for Available downloads. -
How do you get your apps from the i tunes library onto your mac?
how do you get your apps from i tunes library onto your mac
You don't. Apps from iTunes are for iOS devices. Apps for the Mac come from the Mac app store. Click the apple >> app store.
-
How can you change your security question for I tunes?
How can you change your security question for I tunes?
If you have a rescue email address (which is not the same thing as an alternate email address) set up on your account then the steps half-way down this page give you a reset link on your account : http://support.apple.com/kb/HT5312
If you don't have a rescue email address (you won't be able to add one until you can answer 2 of your questions) then you will need to contact iTunes Support / Apple to get the questions reset.
Contacting Apple about account security : http://support.apple.com/kb/HT5699
When they've been reset (and if you don't already have a rescue email address) you can then use the steps half-way down the HT5312 link above to add a rescue email address for potential future use -
How can I fine tune the performance of my IMS5.1 mailserver?
I installed the IMS5.1 on Solaris 8 with default parameters, without IDA. It is used as a mail relay. It seems to have/keep about 700 msgs in the tcp_local channel but none in the process channel. It uses the cpu very much, in my opinion too much (100% is no exception. It uses the swap file for only 30%. How can I tune the performance of my system. Don't laugh: the "server" is only a SUN Ultra 5 workstation.
I've been working with this MTA since '95. Unfortunately there is no easy answer. The number of msgs in queue is not an indication of performance, it can be, but it can also be that the hosts your system is trying to reach are not available. You can use tools like imsimta qtop to see top subjects or top domains. Poke around and see just why you have 700 msgs in your queues.
Channels like process or say conversion channel are internal while channnels like tcp_local deal with external systems. If you had mail backing up in the conversion channel then you'd have a good sign of local performance problems. Mail backing up in tcp_local is not necessarily a sign of performance problems on your end.
I don't see a problem with the software using all available CPU. What is wrong with that?
If you've made any changes to the configuration it could be that you have introduced something that is causing say a mapping process to loop and thus eat more CPU that would otherwise be normal.
What process is using all of this CPU? Knowing this would help to determine what part of the MTA might be using lots of CPU. -
How do you get your tunes and voice recordings from your iPod Touch into iTunes on a new computer if you don't have Mobile Me?
iTunes on tmy new computer shows none of my data and I fear if I sync my iPod with the computer all will be deleted on the iPod.
I still have everything in iTunes on the old computer.Just move your iTunes library to you new computer. You can transfer iTunes purchases to you new computer from your iPod by:
iTunes Store: Transferring purchases from your iPhone, iPad, or iPod to a computer
iTunes: How to move your music to a new computer
http://support.apple.com/kb/HT1848Make sure you also move the backup. You an find where the the backup is located here:
iPhone and iPod touch: About backups
You can move other items by:
Best iPod to PC
After you move you stuff to the new computer, restore the iPod from backup. -
How do you fine tune an effect in Captivate 6
I'm trying to scale and move a video using the effects timeline and I want it to wind up in an exact location on the stage. Is there any way to fine tune it by entering in exact coordinates rather than by bouncing back & forth between Live Preview and Edit View? I'm used to being able to entering in exact numbers when tweening an object in Flash and this seems like a pretty bad way of moving things around on the screen. Am I missing something here?
ThanksAs a temporary workaround, this is my work flow:
I create a 'crosshair' in the exact location, using two line shapes that can be positioned exactly using the Transform accordion.
The motion path end points have a circle that you'll have to drag over the crosshair. Motion paths use the center point of an object, contrary to resizing, moving that is from the upper left corner of the bounding box. I used the described work flow in the first movie here: http://blog.lilybiri.com/reset-effects
Lilybiri -
How can you authorise your windows vista computer to play stuff you downloaded from itunes??? I cannot get this drop down menu shown on your support pages whatever I do. I have been trying for ages. This is not a good first impression.
Authorize a Mac or PC
Review the following before you authorize a computer:
You can authorize up to five computers with your Apple ID.
You must authorize your computer to download past purchases, use Home Sharing, or use the Automatic Downloads setting.
You can play unprotected music that's in the AAC file format without authorizing your computer. This includes iTunes Plus tracks and content from sources other than the iTunes Store, like your audio CDs.
To authorize a computer, follow these steps:
Open iTunes.
Choose Store > Authorize This Computer from the menu bar.
You may need to show the menu bar to see this option in Windows. In earlier versions of iTunes, you can access this option from the Advanced menu.
Enter your Apple ID and click Authorize.
If your Apple ID uses an expired MobileMe account, you can still authorize your computer.
In some cases, iTunes may ask you to authorize the computer again. iTunes should use the same authorization as before if the computer is in your list of authorized computers.
Learn what to do if iTunes repeatedly asks you to authorize when you try to play your content.
http://support.apple.com/kb/ht1420
Note : If you are Unable to see the Store Tab on your iTunes then click anywhere on your iTunes and press
Ctrl + B key on your keyboard once and you should be able to see the Store tab in your iTunes.
Maybe you are looking for
-
Printing problem with Photoshop CS 6 extended and HP printer
Hi all, long time browser, first time poster. This is a weird issue, it should be noted from the first that I only have weird computer issues. I work at a technical High School where we have the whole Adobe CS6 Extended suite installed. We are runnin
-
I had to replace my iMac due to HDD and Logicboard failure, so I want to reinstall Windows 7 on Boot Camp partition. Will there be a problem reactivating Windows 7 Home Premium?
-
Why won't 110 min video not fit DVD when using Compressor Best 120 min
I have a standard DV video lasting 110 minutes. I have exported it as a DV clip and imported that clip as an asset in DVD Studio Pro 4. Build fails with a not enough room on the output media message. I have also exported from FCP using Compressor set
-
Number of folder sub-levels and characters
Does anyone know: a) how many levels of folders are permissible in Mac OS X b) how many characters are allowed for file or folder names? I have recently switched over to the Mac system from Windows where the I believe the maximum number of "folders w
-
Why does safari reload page from beginning when going back in history
This behavior in safari is driving me nuts, i'm using mountain lion 10.8.1 and everytime i swipe two fingers to the left after having left a page to checksomething, safari goes back to the page and starts me in a different place (usually very beginni