Box layout error
getting error
cannot resovle symbol createRigidArea location class Box
same thing is there in java tutorials pls help me.
pAnswer.add(Box.createRigidArea(new Dimension(0,5)));
Here is the code which is working Fine i am working on it It's Tested Ok Injoy dear
& after Compiling this code u can able to get correct layout Then u have to chack your
PATH variable ehere u set your java PATH OK Dear Bye
import javax.swing.*;
import java.awt.*;
public class bookdata
JFrame frame;
JPanel panel , panel2 , panel3;
JButton but1,but2,but3,but4,but5,but6;
Color cc;
BoxLayout bak;
ImageIcon icon;
FlowLayout flo;
public bookdata()
icon = new ImageIcon("book/book.jpg");
frame = new JFrame("Book Database");
frame.setResizable(false);
frame.setIconImage(new ImageIcon("book/logo.gif").getImage());
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
int x = (d.width - 550)/2;
int y = (d.height - 500)/2;
frame.setBounds(x,y,400,300);
public void main1()
JLabel label = new JLabel(icon);
flo = new FlowLayout();
panel3 = new JPanel();
but1 = new JButton("NEW BOOK");
but2 = new JButton("EDIT");
but3 = new JButton("DELET");
but4 = new JButton("SHOW");
but5 = new JButton("LONE");
but6 = new JButton();
panel = new JPanel();
bak = new BoxLayout(panel,BoxLayout.Y_AXIS); // BOX Layout
panel.setLayout(bak);
// 1st 220 is for R
// 2nd 177 is for G
// 3rd 162 is for B
// 4th 255 is for Alpha
cc = new Color(51,51,255);
panel2 = new JPanel();
panel2.setLayout(flo);
panel2.setBackground(cc);
panel2.add(label);
JSeparator hh = new JSeparator(SwingConstants.VERTICAL);
SpringLayout layout = new SpringLayout();
panel3.setLayout(layout);
panel3.add(but1); // pp1
panel3.add(but2); // pp2
panel3.add(but3); // pp3
panel3.add(but4); // pp4
panel3.add(but5); // pp5
panel3.add(hh);
layout.putConstraint(SpringLayout.WEST, but1, 15,SpringLayout.WEST, panel3); // pp1
layout.putConstraint(SpringLayout.NORTH, but1, 25,SpringLayout.NORTH, panel3);
layout.putConstraint(SpringLayout.WEST, but2, 15,SpringLayout.WEST, panel3); // pp2
layout.putConstraint(SpringLayout.NORTH, but2, 55,SpringLayout.NORTH, panel3);
layout.putConstraint(SpringLayout.WEST, but3, 15,SpringLayout.WEST, panel3); // pp3
layout.putConstraint(SpringLayout.NORTH, but3, 85,SpringLayout.NORTH, panel3);
layout.putConstraint(SpringLayout.WEST, but4, 15,SpringLayout.WEST, panel3); // pp4
layout.putConstraint(SpringLayout.NORTH, but4, 115,SpringLayout.NORTH, panel3);
layout.putConstraint(SpringLayout.WEST, but5, 15,SpringLayout.WEST, panel3); // pp5
layout.putConstraint(SpringLayout.NORTH, but5, 145,SpringLayout.NORTH, panel3);
layout.putConstraint(SpringLayout.WEST, hh, 100,SpringLayout.WEST, panel3);
layout.putConstraint(SpringLayout.NORTH, hh, 500,SpringLayout.NORTH, panel3);
frame.getContentPane().add(panel);
panel.add(panel2);
panel.add(panel3);
frame.setSize(600,500);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
Similar Messages
-
i know how to use a box layout on panels but i am having a problem applying box layout on jframe,
what i do basicaly is extends jframe first and then in the constructor i put setLayout(new BoxLayout(this,BoxLayout.X_AXIS));
it gives an error that box layout cant be shared...this method works with all other layouts...
please help me and please dont tell me to go read the sun online tutorials...To speak truely. All the j2se default layout manager will be replaced by the default layoutmanager in NetBeans ---group layout manager.
I suggest you download a NetBeans IDE and start working with the new layout manager. -
Layout error - ergonomic violation
Hi,
I have designed a screen of type: modal dialog box. This consists of a box and a custom control within it. The functionality of this screen is working perfectly.
But in the screen, I am getting a layout error saying "Frame encloses ALL fields of template"
I am unable to remove this error. Please help me.Hi Tiyasha,
maybe the statement to item 1 in SAP Note [941424|https://service.sap.com/sap/support/notes/941424] can be helpful with regards to that error message.
Best regards,
Andreas -
How to have a box layout on a JDialog, with an image set as background
Hi,
I need to have a JDialog in which there is a background image set (I already did this part, but only with the default layout). I further need to add text to the lower part of the JDialog. (For this, I guess I need to have a box layout.). I am not able to do so, because if I do so, I wont be able to set image background to the entire JDialog. Please help me out with how to solve this issue?
Thanks,
JobyHi jduprez,
Thanks for the reply. I checked Rob Camick's blog. It gives a nice way to add an image to a panel (*master panel*) and to use it.
I still have my problem open. The above solution gives panel that I can add to my JDialog. But on the bottom half of the image (as you said, BorderLayout.South), I need to add another structured set of components using a Border Layout again.!, ie, one more panel with a BorderLayout. So when I add
this panel, to the master panel containing the image, then the image gets cut off, at that point. I tried using component.setOpaque(false) on my sub-panel, still it does not work. Any idea, how to achieve this...?
Following is the code I have adapted.
public class BackgroundPanel extends JPanel
public static final int SCALED = 0;
public static final int TILED = 1;
public static final int ACTUAL = 2;
private Paint painter;
private Image image;
private int style = SCALED;
private float alignmentX = 0.5f;
private float alignmentY = 0.5f;
private boolean isTransparentAdd = true;
public static void main(String[] args) {
Image img = getImage("D:/imgs/Snowdrop.jpg");
BackgroundPanel panel = new BackgroundPanel(img);
JDialog dlg = new JDialog();
dlg.setLayout(new BorderLayout());
dlg.add(panel);
panel.setTransparentAdd(true);
Panel nPanel = new Panel();
nPanel.setLayout(new BorderLayout());
JLabel label = new JLabel();
//label.set
label.setText("<html>HI<br>This is another line<br><br><br><br><br><br><br><br><br><br></html>");
nPanel.add(label, BorderLayout.NORTH);
panel.add(nPanel/*label*/,BorderLayout.SOUTH);
dlg.setSize(600, 500);
dlg.setVisible(true);
private static Image getImage(String fileName){
File file = new File(fileName);
Image image = null;
try{
image = ImageIO.read(file);
catch(IOException ioe){
/*JOptionPane.showMessageDialog(dlg, "Error in loading image file",
"Error", JOptionPane.ERROR_MESSAGE, null);*/
return image;
* Set image as the background with the SCALED style
public BackgroundPanel(Image image)
this(image, SCALED);
* Set image as the background with the specified style
public BackgroundPanel(Image image, int style)
this(image,style,-1,-1);
* Set image as the backround with the specified style and alignment
public BackgroundPanel(Image image, int style, float alignmentX, float alignmentY)
setImage( image );
setStyle( style );
if (alignmentX > 0){
setImageAlignmentX( alignmentX );
if (alignmentY > 0){
setImageAlignmentY( alignmentY );
setLayout( new BorderLayout() );
* Use the Paint interface to paint a background
public BackgroundPanel(Paint painter)
setPaint( painter );
setLayout( new BorderLayout() );
* Set the image used as the background
public void setImage(Image image)
this.image = image;
repaint();
* Set the style used to paint the background image
public void setStyle(int style)
this.style = style;
repaint();
* Set the Paint object used to paint the background
public void setPaint(Paint painter)
this.painter = painter;
repaint();
* Specify the horizontal alignment of the image when using ACTUAL style
public void setImageAlignmentX(float alignmentX)
this.alignmentX = alignmentX > 1.0f ? 1.0f : alignmentX < 0.0f ? 0.0f : alignmentX;
repaint();
* Specify the horizontal alignment of the image when using ACTUAL style
public void setImageAlignmentY(float alignmentY)
this.alignmentY = alignmentY > 1.0f ? 1.0f : alignmentY < 0.0f ? 0.0f : alignmentY;
repaint();
* Override method so we can make the component transparent
public void add(JComponent component)
add(component, null);
* Override method so we can make the component transparent
public void add(JComponent component, Object constraints)
if (isTransparentAdd)
makeComponentTransparent(component);
super.add(component, constraints);
* Controls whether components added to this panel should automatically
* be made transparent. That is, setOpaque(false) will be invoked.
* The default is set to true.
public void setTransparentAdd(boolean isTransparentAdd)
this.isTransparentAdd = isTransparentAdd;
* Try to make the component transparent.
* For components that use renderers, like JTable, you will also need to
* change the renderer to be transparent. An easy way to do this it to
* set the background of the table to a Color using an alpha value of 0.
private void makeComponentTransparent(JComponent component)
component.setOpaque( false );
if (component instanceof JScrollPane)
JScrollPane scrollPane = (JScrollPane)component;
JViewport viewport = scrollPane.getViewport();
viewport.setOpaque( false );
Component c = viewport.getView();
if (c instanceof JComponent)
((JComponent)c).setOpaque( false );
* Add custom painting
protected void paintComponent(Graphics g)
super.paintComponent(g);
// Invoke the painter for the background
if (painter != null)
Dimension d = getSize();
Graphics2D g2 = (Graphics2D) g;
g2.setPaint(painter);
g2.fill( new Rectangle(0, 0, d.width, d.height) );
// Draw the image
if (image == null ) return;
switch (style)
case SCALED :
drawScaled(g);
break;
case TILED :
drawTiled(g);
break;
case ACTUAL :
drawActual(g);
break;
default:
drawScaled(g);
* Custom painting code for drawing a SCALED image as the background
private void drawScaled(Graphics g)
Dimension d = getSize();
g.drawImage(image, 0, 0, d.width, d.height, null);
* Custom painting code for drawing TILED images as the background
private void drawTiled(Graphics g)
Dimension d = getSize();
int width = image.getWidth( null );
int height = image.getHeight( null );
for (int x = 0; x < d.width; x += width)
for (int y = 0; y < d.height; y += height)
g.drawImage( image, x, y, null, null );
* Custom painting code for drawing the ACTUAL image as the background.
* The image is positioned in the panel based on the horizontal and
* vertical alignments specified.
private void drawActual(Graphics g)
Dimension d = getSize();
Insets insets = getInsets();
int width = d.width - insets.left - insets.right;
int height = d.height - insets.top - insets.left;
float x = (width - image.getWidth(null)) * alignmentX;
float y = (height - image.getHeight(null)) * alignmentY;
g.drawImage(image, (int)x + insets.left, (int)y + insets.top, this);
}Thanks,
Joby -
when I tried to update to the new version of Itunes - message box appears "APSDAEMON.EXE MSVCR80.DLL is missing". Then another box indicates "Error 7 (Windows error 126)". Itunes will not start. Can someone tell me what the problem is and how to fix?
Solving the iTunes Installation Problems in Windows
1. Apple has posted their solution here: iTunes 11.1.4 for Windows- Unable to install or open - MSVCR80 issue.
2. If the Apple article does not fully resolve the problem for you, then try Troubleshooting issues with iTunes for Windows updates - MSVCR80. -
How I can diable in firefox dialog box "download error could not be saved, because the source file could not be read. " standart download manager when file not downloaded
It is possible that anti-virus software is corrupting downloaded files or is interfering otherwise.
Try to disable the real-time (live) scanning of files in your anti-virus software temporarily to see if that makes downloading work.
See:
*http://kb.mozillazine.org/Unable_to_save_or_download_files
You can try to set the browser.download.manager.scanWhenDone pref on the <b>about:config</b> page to false.
*http://kb.mozillazine.org/about:config -
Can you alter, or create your own photo box layouts in iMovie 11. If so how, or where can you do this.
I can't find that option. I don't want to use the canned, preset photo layouts. Any options available?It has been happening to me, but it doesn't change the final video itself, if it is previewed in full screen mode, it will sometimes freeze, but to see the scene that freezes, just play it (in fullscreen mode) and click back a few seconds before it freezes and it should play normally.
You can also bring the mouse over the clip to preview it or:
Duplicate the whole project
2. Export it to Quicktime
Hope this helps -
Hello,
I am having difficulty with my box layouts in my form applet.
I have a JFrame with two panels. The left panel will allow the user to enter some parameters via text boxes, drop down menus, etc for a shape, which will appear on the right panel.
To arrange the form entry boxes on the left panel, I implemented a box layout. Here is where my trouble lies. I am not sure if I am using them correctly.
In the left panel, I added a box objectentitled entrySideBox, which has a createVerticalBox() orientation. I further added 7 boxes to this box layout, which had a createHorizontalBox() orientation. I have the form elements within the array of horizontal boxes. In summary, I hoped to create a box layout column with 7 horizontal rows to house the form entry elements.
Can I do this with the Box Layout? My form elements do not appear to be appearing as expected!
I have my code below. What is wrong?
//import the necessary java classes
import java.awt.*; //for the awt widgets
import javax.swing.*; //for the swing widgets
import java.awt.event.*; //for the event handler interfaces
public class DemoShape extends JFrame
//declare private data members of the DemoShape class
//requires seven control buttons
private JTextField xShapeText, yShapeText, messageText, fontSizeText;
private JComboBox shapeTypeDrop, shapeColorDrop, fontTypeDrop,fontColorDrop;
//declare the entry and display panel containers
private Panel entryPanel;
private Panel displayPanel;
//declare public data members of the DemoShape class
//constructor to initialize private data members
public DemoShape()
//call the superclass (JFrame) constructor with the name argument
//this must be done first (as in C++)
super("DemoShape Applet");
//arrays of string to be used later in combo boxes
//some are used more than once
String fonts[] = {"Dialog", "Dialog Input", "Monospaced",
"Serif", "Sans Serif"};
String shapes[] = {"Rectangle", "Round", "Oval"};
String colors[] = {"Black", "Blue", "Cyan", "Dark Gray",
"Gray", "Green", "Light Gray", "Magenta", "Orange",
"Pink", "Red", "White", "Yellow"};
//get the content pane of the class outside
Container entire = this.getContentPane();
entire.setLayout(new GridLayout(1,2));
//create the entry panel and add it to the entire pane
//this will be 7 rows, 1 column
//each row will have a panel with the form entry elements
entryPanel = new Panel(new FlowLayout());
entire.add(entryPanel);
//create the display panel and add it to the entire pane
//this will display the output
displayPanel = new Panel();
entire.add(displayPanel);
//entry panel code
//use a box layout to add the boxes in a row fashion on the entryPanel
Box boxes[] = new Box[7];
//create a main box for the entry side
Box entrySideBox = Box.createVerticalBox();
//iterively create a box layout for each row
for(int b = 0; b < boxes.length; b++)
{ boxes[b] = Box.createHorizontalBox(); }
//add the form elements to the boxes
//the first row should have the shape label
JLabel shapeHeader = new JLabel("Enter Shape Parameters:");
boxes[0].add(shapeHeader);
//second row should have the shape type and color
JLabel shapeTypeLabel = new JLabel("Select Shape:");
boxes[1].add(shapeTypeLabel);
shapeTypeDrop = new JComboBox(shapes);
boxes[1].add(shapeTypeDrop);
JLabel shapeColorLabel = new JLabel("Select Shape Color:");
boxes[1].add(shapeColorLabel);
shapeColorDrop = new JComboBox(colors);
boxes[1].add(shapeColorDrop);
//third row should have the x and y coords
JLabel xShapeLabel = new JLabel("Enter X:");
boxes[2].add(xShapeLabel);
xShapeText = new JTextField("200", 3);
boxes[2].add(xShapeText);
JLabel yShapeLabel = new JLabel("Enter Y:");
boxes[2].add(yShapeLabel);
yShapeText = new JTextField("200", 3);
boxes[2].add(yShapeText);
//fourth row should have the message label
JLabel messageHeader = new JLabel("Enter Message Parameters:");
boxes[3].add(messageHeader);
//the fifth row should have the message
JLabel messageLabel = new JLabel("Enter Message:");
boxes[4].add(messageLabel);
messageText = new JTextField(50);
boxes[4].add(messageText);
//the sixth row should have the font type and size
JLabel fontTypeLabel = new JLabel("Select Font:");
boxes[5].add(fontTypeLabel);
fontTypeDrop = new JComboBox(fonts);
boxes[5].add(fontTypeDrop);
JLabel fontSizeLabel = new JLabel("Enter Font Size:");
boxes[5].add(fontSizeLabel);
fontSizeText = new JTextField("12", 2);
boxes[5].add(fontSizeText);
//the seventh row should have font color
JLabel fontColorLabel = new JLabel("Select Font Color:");
boxes[6].add(fontColorLabel);
fontColorDrop = new JComboBox(colors);
boxes[6].add(fontColorDrop);
//add the boxes to the entrySideBox
for(int e = 0; e < boxes.length; e++)
{ entrySideBox.add(boxes[e]); }
//add the entrySideBox to the entry panel
entryPanel.add(entrySideBox);
//display panel code
//debugging
JLabel test = new JLabel("Display Output Here");
displayPanel.add(test);
//set the size of the entire window and show the entire applet
this.setSize(800,600);
this.show();
} //end the DemoShape constructor
//call the main class
public static void main(String args[])
//create an instance of the DemoShape class
DemoShape DemoShapeRun = new DemoShape();
//add the window listener to the applet
DemoShapeRun.addWindowListener(
new WindowAdapter()
public void windowClosing(WindowEvent e)
System.exit(0);
} //end main
} //end DemoShape classThe problem with GridLayout is the form elements sizes
change relative to the size of the panel. I want the
form elements to remain in a consistent state.
Should I quit using the box layout?Ok, try to set the layout of the upper content pane to BorderLayout and place the left panel with your components in the WEST part of it (the panel for the drawings goes to CENTER). I don't know if this will produce the result that you want, but it's an idea.
You should use a GridLayout for this panel and only
specify 2 columns (don't specify the number of rowsor
the number of columns will be ignored, see theclass
documentation for further details).
Hope this helps,
Pierre2 Columns? For what?The first column is for the labels (e.g. "Select Font Color") and the second is for the input component (e.g. textarea). -
used BOX LAYOUT
I have two panels, one header having two labels
another panel inside scrollpane,
but first panel by default comes to center
so,
i set panelHeader.setAlignmentX(Component.LEFT);
now first panel comes slightly to left side but still not aligned with second panelJUst Add yout comp[onents on that panel ok
panel2 & panel 3
Panel2 is the left panel & panel3 is the right panel ok
Dear Bye
import javax.swing.*;
class layout
BoxLayout box;
JFrame frame;
JPanel panel1 , panel2 , panel3;
layout()
frame = new JFrame();
panel1 = new JPanel();
panel2 = new JPanel();
Panel3 = new JPanel();
box = new BoxLayout(panel1,BoxLayout.X_AXIS); // horizontal Layout And Y_AXIS For vertical
frame.getContentPane().add(panel1);
panel1.setLayout(box);
panel1.add(panel2);
panel1.add(panel3);
public static void main(String ss[])
layout ll = new layout();
} -
Box Layout, JTextFields, vertical glue, ect
How do you make it so that your text field on a graphics page dose not expand when you use Box Layout and maximise it?
thanks a lot it worked ^_^ my classmates thank you as well
-
i have posted this in the jdbc forum but i have not recieved any responsed yet so im posting it here in the hope that one of you might
have a solution.
I searched this forum, and i was surprised to find that none had this problem. I ll get to the point.
I am using netbeans, so i downloaded the mysql driver , added it to the project library and compiled and ran my program . I did not have any problems.
so i triedt to run the app on a different machine and it gave me the
popular swing layout error. I fixed that error. by adding some lines to the xml file mentioned in the netbeans faq.
Now it gives me another popular error when i try to run the .jar file from command line on the same machine i developed the app
the errror is
System Exception Output : com.mysql.jdbc.Driver
is there a way to avoid this error like the swing layout error
thanks in advanceSo, nothing whatsoever to do with a Swing layout error, then :o)
-
Messge box states "Error Compiling Movie"
Messge box states "Error Compiling Movie" I had already rendered the this file in a longer version earlier
Messge box states "Error Compiling Movie" I had already rendered the this file in a longer version earlier
-
Purchase Order Crystal Report Layout Error
The stock Crystal Report Layout for Purchase Orders is giving me the following error:
A subscript must be between 1 and the size of the array.
Details: errorKind
Error in File POR20002 {b89f97ad-bf1f-447b-8bb4-b3d2e5219269}
{3C375C81-7D37-475D-9BCB-1703CE533B65}.rpt
Error in formula N_Decimal_Places:
'// To get the length of decimals
A subscript must be between 1 and the size of the array.
Details: errorKind
I looked in the Crystal Reports Formula fields and could not find N_Decimal_Places.
Has any one else had the problem with the PO layout that comes with Business One? If so, how did you fix it?Couldn't find how to copy the PO layout over using copy express.
I did compare the RDOC fields for POR20002 in both databases and they are Identical.
In Crystal Reports, I did a formula search for N_Decimal_Places and it found nothing. Then I did a search for 'length' in all formulas and it finds length in N_Decimal_Places. When I double click on N_Decimal_Places it clears the screen and never shows the formula. This happens in both layouts for my test database and SBODemoUS.
Again, SBODemoUS works correctly and AAA_TEST give the error. -
How can i display a message box when error comes in jsp?
Hi,
i need to display a message box whenever an error comes in my jsp. Actually my appln is that i am creating a bar chart using one applet by taking data from the database. When a user does not select a number data for y axis, now in the centre of the web page one java error is coming. "not in number format". it is looking very odd.
so i want to display the error in a message box whenever it comes as above. pls help me how can i do the same...
Regds,
Abhi...Hi,
thanx for ur response. so u mean to say that i can
display the errors in the web page itself instead of
displaying as a message box?Either way. You can have the JSP send a message to the applet to display a message box. Or you can just have the JSP do it. or you can have the applet detremine if the JSP would produce an error and then display the message it would display.
>
actually i am using servlets. jsp pages are used only
as the front end. all the background works are doing
in servlet only.It should be the same in any case. Is the applet connecting to the JSP pages or are you having the browser do it?
>
pls get back... -
HP Pavilion DV6-320 out-of box recovery error: PLEASE HELP!!!!
Hi
I have restored(F11) my laptop to out-of-box factory restore, after fresh installation laptop got rebooted . After entering the system name, location, date.. etc. Before the desktop is loading for the first time i got the error,
' To run this application, you first must install one of the following version of the .NET Framework: v2.0.50727
Conatct your application publisher for instructions about obtaining the appropriate version of .NET Framework'
After clicking OK on the error window desktop loaded with classic theme and explorer.exe was not working.. i am unable to open My computer, there is no IE, on the bottom of the desktop it was written as the copy of windows is not genuine.
Operationg system is windows 7 Home premium
I have restored my laptop to out-of-box 6 months before i did not face any issues.
Please Please some body suggest me !!!Have you tried to restore it again since then? It sounds like something went wrong during the installation and not all of the required files were installed correctly. If that doesn't work, you may want to contact HP and have them send you the recovery discs.
-------------How do I give Kudos? | How do I mark a post as Solved? --------------------------------------------------------
Maybe you are looking for
-
Problem accessing clicksoft webservice in SAP System
Hi All, We are currently integrating SAP system with Clicksoft. For that, we have received WSDL file from Clicksoft and we are trying to create consumer proxy in SAP system. But, getting error " Attribute "Transport" in <SOAPbind:binding> has incorre
-
Trigger calling ctx_ddl.sync_index problem
Dear, In order to keep my context indexes up-to-date, I'm trying to write a trigger calling this PL/SQL procedure on update/insert/delete statement. However, there must be a problem in my trigger definition since it gives compilation errors! I don't
-
Automatic insert of xmlns:xsl during XSLT transformation
I am using the xmlparserv2.jar of dated "12/10/00" to perform a XSLT transformation. I need to insert a xml:space="preserve" attribute to a generated tag. However, there is an addition attribute added : xmlns:xml="http://www.w3/org/XML/1998/namespace
-
Which headphones are better? Apple in ear or Sennheiser i300?
http://store.apple.com/uk/product/H3559ZM/A or http://store.apple.com/uk/product/MA850G/B?fnode=MTc0MjU4ODc&mco=MjA0MjU0NTU Which are better?
-
How do i resort/reorder my two email accounts - they have changed order i view them
I have two email accounts. I am not sure how or why they have changed order on my view screen. When I push the "envelope icon" my email account/inbox is not the one I want to see first. How do I reorder these again - to be account "A" on top of "B