How to set Width of a JPanel?
I am overwirting paintComponent(Graphics g) method to
draw some g2D in a JPanel.
I want the drawing processing shown on screen (not flashed out after drawn because it is VERY SLOW).
So that I CAN NOT use setsize() or setBound() because to change JPanle.width because this is NOT what I wanted(the graphics is shown AFTER is drawn).
Everytime I call paintComponent(), the width of JPanel is changed.
My question is : How can change JPanel.width without calling method like setsize() or setBound() .
Thanks a lot!!
My code too large, I just show some idea here:
class caller (){
myPanel p;
Graphics2D g2 = (Graphics2D)p.getGraphics();
//I nee to increase the p.width before call my_paint
//I CAN NOT use setsize() or setBound()
//because I want show the drawing process
//on screen( and that is fast)
p.my_paint(g2); // how to set p.width ??
public class myPanel extends JPanel
public void my_paint(Graphics2D g2)
//Do my drawing here ,
// I need to draw thousands of Line2D.
public void paintComponent(Graphics g){
Graphics2D g2 = (Graphics2D)g;
my_paint(g2);
Similar Messages
-
How to set width for this modal dialog box?
Hi All,
How to set width to this modal dialog box:
<input id="btnVote" onclick="javascript:SP.UI.ModalDialog.showModalDialog({ url: '../Lists/Sports%20Activities%20Voting/NewForm.aspx', title: 'User Survey'}); return false;" type="button" value="Vote"/>
Thanks in advance!set as bellow:
<input id="btnVote" onclick="javascript:SP.UI.ModalDialog.showModalDialog({ url: '../Lists/Sports%20Activities%20Voting/NewForm.aspx', title: 'User Survey',width:700,height:350}); return false;" type="button" value="Vote"/>
yaşamak bir eylemdir -
How to set width of apex_item.select_list_from_lov?
Hello experts!
Sorry to bother you but I can't find out how to set the width of a select list generated in my query.
I already had a look at the Oracle Express Api docu but and tried the following to no avail.
apex_item.select_list_from_lov(8, a.lng_arbeitsschritt, 'Auftakt_LOV','.style.width = "300px";',
'%', null,null, null, 'class="combobox"')Do you have a better idea?
Many thanks,
SebastianI just did some more testing and discovered that the following works:
apex_item.select_list_from_lov(8, a.lng_arbeitsschritt, 'Auftakt_LOV','style="width:500px";',
'%', null,null, null, 'class="combobox"')Maybe this helps others as well!
Thanks for having a look!
BR,
Seb -
How to set width of a vertical scrollbar (such as in a combobox)
I have a combox. I have successfully figured out how to set the font name and font size for each time, however as I have increased the normal very tiny size of the combobox items (now more legible), the remaining last problem is the measly 16 pixels for the scrollbar. This might be acceptable on a desktop with a precise cursor positioning system, but for mobile apps I need a way larger scrollbar thickness, perhaps 30 pixels. How does one set the scrollbar thickness for a combobox? I am willing to stick with scaled up icons from whatever is being drawn as a default, so if possible I would just like to set some style number. But can't find any documentation on this. The Apple system has a nasty fixed width scrollbar (20 pixels), and so far it seems Adobe Flash is using only 16. Great for when you are cramped but I am trying to UN-CRAMP the user interface!
any help is greatly appreciated. A free copy of Discus ($40 value) for whomever helps me solve this vexing problem with the least amount of effort!
edjEdit the item and in the HTML Form Elements Attributes field type the following:
style="width:120px";adjust the 120 to whatever width you like
Shunt -
How to set width of a TextField ?
Hi all,
I want to use Polish in my javaME code , so I add //#style style_name before calls of constructor TextField.
The problem is that when I run the application then the textfield is very small in width ! And when I try to enter a value inside then a big textarea is shown in the screen in which I enter the value ; and after that I click the "Ok" command item and I finally return to my form.
I use a polish.css file to define the style.
So how to set a width for a TextField ?
Thank you very much indeednever mind. I forgot a line in my layout manager.
-
How to set width of cfgid in percentage?
I have to make the cfgrid compatible irrespective of screen size. But it is not taking width in perecntage(giving error : Attribute vallidation error, height/width can not be given in percentage.)
I put the cfgrid inside a div and set width of the div as 100%, but it has no effect on the cfgrid.
Can anyone please give me a solution??
I will be thankfull towards any helpfull suggestion.Then you have to find a way to get the browser to send information about screen size to ColdFusion. One way to do it is by means of AJAX. Another, in my opinion much simpler way, is to get Javascript to store the screen size as a cookie, and then to get ColdFusion to read the cookie. I was thinking of something like this
<script type="text/javascript">
var browserWidth = screen.width;
var browserHeight = screen.height;
var expiryDate=new Date();
/*set expiry date tomorrow*/
expiryDate.setDate(expiryDate.getDate()+1);
document.cookie= 'browserWidth='+browserWidth+',browserHeight='+
browserHeight+',expires='+expiryDate;
</script>
<cfset percentWidth = 90>
<cfif isDefined("cookie.browserWidth")>
<cfset browserWidth = cookie.browserWidth>
<cfelse>
<cfset browserWidth = 800>
</cfif>
<cfset gridWidth = int(percentWidth*browserWidth/100)>
<cfform>
<cfgrid format="html" name = "myGrid" width="#gridWidth#">
</cfgrid>
</cfform> -
How to set width to be same as screen size?
Dear all
I want to set the width of my view elements to be same as that of screen size, so that if a user with low resolution monitor runs it, or if a user with high resolution monitor runs it, both see the same.
I tried setting the width to 100%. But it is not working.
My root container layout is Grid layout.
Any suggestions please?
Thanks in adv.Hi,
For ROOTUIELEMENTCONTAINER set the stretchedHorizontally,stretchedVertically to true.
And for the UI element set width as 100%, this will make the UI elem to expand to the complete screen.
Best regards,
Suresh
Message was edited by:
Suresh Honnappanavar -
How to set height of a JPanel ?
Hi.
My JPanel is a tad too high and I'd rather not use
mypanel.setPreferredSize(int xxx, int yyy)
because the breadth is alright.
How do I play around with the height only?
Something like
myjpanel.setHeight(int yyy);
would be nice but the method deoesn't exist.
:-)Set the minimum size and maximum size as well, to force it to work no matter what the layout manager is. You can set the minimum width to something like 1 and the maximum to 2000 to ensure it works properly if the window is resized, but make sure the minimum height is the height you want. The dimensions are in pixels by the way.
-
How to set width/height of iPad app in ipa file
Hello,
I am developing an app for iPad in Flash Builder 4 and Packager for Iphone.
I set the width and height node values in the descriptor XML and compile the application. When I run the same in iPad, I am not able to see any effect on the app's width and height.
Also, in default load, app opens in dimensions as per the iphone view and not specifically for iPad.
Any help?
Tanuhi,
How does your application descriptor file look like? I also had the same problem, when I realised that I had a few things missing in my app desc. file. My file looks like this
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<application xmlns="http://ns.adobe.com/air/application/2.0">
<id>IPadApp</id>
<filename>IPadApp</filename>
<name>IPadApp</name>
<version>v1</version>
<initialWindow>
<content>IPadApp.swf</content>
<fullScreen>true</fullScreen>
<autoOrients>true</autoOrients>
<title>IPadApp</title>
<aspectRatio>portrait</aspectRatio>
<systemChrome>none</systemChrome>
<transparent>false</transparent>
<visible>true</visible>
<!-- Portrait -->
<width>768</width>
<height>1024</height>
<!-- Landscape -->
<!--
<width>1024</width>
<height>768</height>
-->
<!--<x>100</x>
<y>100</y>-->
</initialWindow>
<supportedProfiles>desktop mobileDevice</supportedProfiles>
<iPhone>
<InfoAdditions>
<![CDATA[
<key>UIDeviceFamily</key>
<array>
<string>2</string>
</array>
]]>
</InfoAdditions>
</iPhone>
</application>
Check your desc. file.
-Vrushali -
Hi,
How do we set the width of List Box created dynamically. By default it sizes to the maximum length of the value populated in it.
I need to maintain consistency in the width and trying to set the width.
Any pointers are appreciated.
Thanks,
NareshIt seems to to be sized to the length of the largest value in the list, and disrupts formatting. This is the standard HTML behaviour. The only method available to you is to truncate the values being passed to the poplist. Investigation is underway to determine the impact, on UI and Translation issues, of having the framework truncate automatically.
-
How to set width of a select list?
Hi,
another newbie question from me :-)
When I create a select list the default width is 30, no matter what I set this value to the width of the select list stays the same, it gets as wide as the widest element in the list. This messes the design of the page. I f I have three select lists in a column I want them to have the same width. How do I accomplish that?
/MagnusEdit the item and in the HTML Form Elements Attributes field type the following:
style="width:120px";adjust the 120 to whatever width you like
Shunt -
How to set Tab ordering in JPanel
hi all
i add a JPanel on a JFrame and Various swing Controls on that JPanel. now i want to change tab ordering of components present in my JPanel.
please guide me how can i do this. i have tried setFocusTraversalPolicy but it does not work with JPanel.You should read the article from Sun:
"How to Use the Focus Subsystem"
http://java.sun.com/docs/books/tutorial/uiswing/misc/focus.html
Moshe -
How to set width of a prompt in OBIEE 11g?
Hi,
We have recently upgraded to OBIEE 11G.
In 10g all our prompts were fine. After upgrade, the prompts look distracted. All the prompts are Choice Lists.
The width of the prompts is varying depending on the width of the values that are coming from the DB.
Our requirement demands fixed width for the prompts. Is there any way to do it!!
Thanks!!
Vasantha.P
Edited by: Vasantha Payyavula on Dec 23, 2010 12:36 PMHi vasantha,
Check this out http://www.obinotes.com/2010/12/text-wrapmulti-ine-prompt-caption-in.html and even comment by stijn
Hope helps you.
By,
KK -
Hi to all,
How to set background image to panel in swing?
If anyone knows tell me..Hi,
Just modify and use this..
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import javax.swing.JCheckBox;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JViewport;
import RboJComponents.RboJEmailTextField;
import RboJComponents.RboJPanel;
public class ImagePanel extends JPanel
public static final int TILED = 0;
public static final int SCALED = 1;
public static final int ACTUAL = 2;
private BufferedImage image;
private int style;
private float alignmentX = 0.5f;
private float alignmentY = 0.5f;
public ImagePanel(BufferedImage image)
this(image, TILED);
public ImagePanel(BufferedImage image, int style)
this.image = image;
this.style = style;
setLayout( new BorderLayout() );
public void setImageAlignmentX(float alignmentX)
this.alignmentX = alignmentX > 1.0f ? 1.0f : alignmentX < 0.0f ? 0.0f : alignmentX;
public void setImageAlignmentY(float alignmentY)
this.alignmentY = alignmentY > 1.0f ? 1.0f : alignmentY < 0.0f ? 0.0f : alignmentY;
public void add(JComponent component)
add(component, null);
public void add(JComponent component, Object constraints)
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 );
super.add(component, constraints);
protected void paintComponent(Graphics g)
super.paintComponent(g);
if (image == null ) return;
switch (style)
case TILED :
drawTiled(g);
break;
case SCALED :
Dimension d = getSize();
g.drawImage(image, 0, 0, d.width, d.height, null);
break;
case ACTUAL :
drawActual(g);
break;
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 );
private void drawActual(Graphics g)
Dimension d = getSize();
float x = (d.width - image.getWidth()) * alignmentX;
float y = (d.height - image.getHeight()) * alignmentY;
g.drawImage(image, (int)x, (int)y, this);
public static void main(String [] args)throws Exception
BufferedImage image = javax.imageio.ImageIO.read(new java.io.File("c:\\final.jpg"));
//ImagePanel north = new ImagePanel(image, ImagePanel.ACTUAL);
//north.setImageAlignmentY(1.0f);
//JTextArea text = new JTextArea(5, 40);
//JScrollPane scrollPane = new JScrollPane( text );
//north.add( scrollPane );
ImagePanel south = new ImagePanel(image, ImagePanel.SCALED);
south.setPreferredSize(new Dimension(490, 340));
south.setLayout(null);
RboJPanel buttons = new RboJPanel();
buttons.setBounds(15, 105, 350, 50);
RboJEmailTextField toAddress = new RboJEmailTextField(28);
//toAddress.setBounds(20,20,20,20);
//toAddress.setCaretColor ( toAddress.getBackground () ) ;
buttons.add(toAddress);
//buttons.add(new JButton("Two"));
/*JPanel boxes = new JPanel();
boxes.add( new JCheckBox("One"));
boxes.add( new JCheckBox("Two") );*/
south.add(buttons);
//south.add(boxes, BorderLayout.PAGE_END);
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//frame.getContentPane().add( north, BorderLayout.NORTH );
frame.getContentPane().add( south);
frame.pack();
frame.setVisible(true);
}Regards,
Anees -
Can't figure out how to set a frame width
Noob questions I suppose....our instructor has us creating a
site using only framesets. I realize this isn't the best way to go,
but we are leading our way up to CSS.
If you look at my navbar, it needs to be 125 to be able to
fit my buttons, but I can not for the life of me how to set the
width of that frame.
Also, how do I name the site on the index file from "untitled
document" to what I want. I know how to do it on individual
pages... or normal index pages, but here, it does not seem I can
pull up the index file alone without everything being loaded and no
way to edit the index file.
Edit: Forgot to provide the link:
http://www.webrevamps.com/assignment10/index2.html
And the pages should not scroll. Hopefully I did that right.
Thanks!Your instructor should be relieved of their duties. Nobody
should be
mentioning frames nowadays except to note that they are
antique and should
only be used on special occasions, and that their use will be
left up to the
reader to determine.
> If you look at my navbar, it needs to be 125 to be able
to fit my navbar,
> but
> I can not for the life of me how to set the width of
that frame.
You set the width of a frame the way you'd expect to - in the
frameset page
definition. When you create a framed site, you first create a
frameset page
that defines the width and height of every frame in the
frameset, e.g.,
<frameset rows="80,*" cols="*" frameborder="no" border="0"
framespacing="0">
<frame src="UntitledFrame-112" name="topFrame"
scrolling="No"
noresize="noresize" id="topFrame" />
<frameset cols="80,*" frameborder="no" border="0"
framespacing="0">
<frame src="UntitledFrame-113" name="leftFrame"
scrolling="No"
noresize="noresize" id="leftFrame" />
<frame src="UntitledFrame-114" name="mm_target"
id="mm_target" />
</frameset>
</frameset>
This defines a frameset containing two rows, one of which is
split into two
columns. The top row is 80px tall, and the bottom row is
whatever is needed
to fill the browser's viewport in height. The bottom row
contains two
columns, the leftmost of which is 80px wide, and the
rightmost is whatever
is needed to fill the browser's viewport.
As mentioned, if your instructor hasn't given you this
information they are
doing a double bad job.
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go
- DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs,
Tutorials & Resources
==================
"motleyscrewed" <[email protected]> wrote in
message
news:[email protected]...
> Noob questions I suppose....our instructor has us
creating a site using
> only
> framesets. I realize this isn't the best way to go, but
we are leading our
> way
> up to CSS.
>
> If you look at my navbar, it needs to be 125 to be able
to fit my navbar,
> but
> I can not for the life of me how to set the width of
that frame.
>
> Also, how do I name the site on the index file from
"untitled document" to
> what I want. I know how to do it on individual pages...
or normal index
> pages,
> but here, it does not seem I can pull up the index file
alone without
> everything being loaded and no way to edit the index
file.
>
> Thanks!
>
Maybe you are looking for
-
Windows 8.1 not syncing setting to onedrive
I have windows 8.1 pro and have read and tried to follow the instructions to sync my settings from 8.1 to onedrive but nothing seems to happen, theres no extra files there or anything. please can someone help thanks Dominic
-
I can not upgrade from version 9.1.5 to 9.2.3 on my IMAC free?? I have to pay for this upgrade?
-
How to use total/sum of values obtaind by applying formula on restricted KF
Hi all I am using formula on restricted keyfigure i.e I want to apply formula on quantity for particular material say 100007,100990.I want to use total of values in some other formula,obtained by aaplyin formula on their respective quantities(obtaine
-
G4 not adding HP LaserJet 6/6mp Printer
I have connected this HP LaserJet 6/6mp to my G4 Mac 10.2.8. Nothing happened like " driver not installed " so I went to the HP site and downloaded the drivers. An icon appeared on the desktop. I went to a word document and proceeded to print but the
-
Why won't PC let me back up iTunes onto disc?
I know I am doing it right. I click on Back Up To Disc. It checks..checks..then says it will take 14 discs to back up. Fine. The box says 'Data Disc' or 'Cancel.' I select Data disc as that's what a CD-R is..and it goes in and comes back out. These a