Help - Unwanted resizing buttons!
Hello All:
I want to have tiled buttons in a JScrollPane where the buttons are always the same size. My problem now is that when the main window is resized smaller, the buttons scale themselves down in order to fit in the JPanel. Since the buttons always resize themselves to fit in the pane the scroll bars never appear.
How can I get the following code to display fixed sized buttons (with ImageIcons), so that I can scroll through 2 columns and many rows of the same size button?
package net.nighthawk.iid.viewer;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
public class ImageThumbnailPanel extends JPanel
private JPanel panel;
private GridLayout buttonLayout = new GridLayout();
private int rows = 4;
private static final int COLS = 1;
public ImageThumbnailPanel()
setLayout(new BorderLayout());
panel = new JPanel();
buttonLayout.setColumns(COLS);
buttonLayout.setRows(rows);
panel.setLayout(buttonLayout);
ImageIcon anIcon = new ImageIcon("any.jpg");
// Here's where the problem is, adding more buttons causes them to resize to fit the pane
for(int i = 0; i < rows*COLS; i++)
addButton("hi", anIcon);
Dimension buttonPanelDimension = new Dimension(300,300);
// Setting the size of the panel does not fix the problem
panel.setPreferredSize(buttonPanelDimension);
panel.setSize(buttonPanelDimension);
panel.setMaximumSize(buttonPanelDimension);
panel.setMinimumSize(buttonPanelDimension);
add(panel, BorderLayout.CENTER);
//Create the scroll pane and add the table to it
JScrollPane scrollPane = new JScrollPane();
//Add the scroll pane to this panel.
panel.add(scrollPane);
private void addButton(final String label, ImageIcon icon) // does final work?
JButton button = new JButton(label, icon);
button.addActionListener(new
ActionListener()
public void actionPerformed(ActionEvent event)
System.out.println("Button label:>" + label);
panel.add(button);
public static void main(String[] args)
//Make sure we have nice window decorations.
JFrame.setDefaultLookAndFeelDecorated(true);
//Create and set up the window.
JFrame frame = new JFrame("ImageThumbnailPanel");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Create and set up the content pane.
ImageThumbnailPanel newContentPane = new ImageThumbnailPanel();
newContentPane.setOpaque(true);
frame.setContentPane(newContentPane);
//Display the window.
frame.pack();
frame.setVisible(true);
}
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
class ImageThumbnailPanel extends JPanel
private JPanel panel;
private GridLayout buttonLayout = new GridLayout();
private int rows = 9;
private static final int COLS = 1;
public ImageThumbnailPanel()
setLayout(new BorderLayout());
panel = new JPanel();
buttonLayout.setColumns(COLS);
buttonLayout.setRows(rows);
panel.setLayout(buttonLayout);
ImageIcon anIcon = new ImageIcon("any.jpg");
for(int i = 0; i < rows*COLS; i++)
addButton("hi", anIcon);
Dimension buttonPanelDimension = new Dimension(300,300);
panel.setSize(buttonPanelDimension);
JScrollPane scrollPane = new JScrollPane(panel);
scrollPane.setPreferredSize(buttonPanelDimension);
add(scrollPane);
private void addButton(final String label, ImageIcon icon)
JButton button = new JButton(label, icon);
button.addActionListener(new
ActionListener()
public void actionPerformed(ActionEvent event)
System.out.println("Button label:>" + label);
panel.add(button);
public static void main(String[] args)
JFrame.setDefaultLookAndFeelDecorated(true);
JFrame frame = new JFrame("ImageThumbnailPanel");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
ImageThumbnailPanel newContentPane = new ImageThumbnailPanel();
newContentPane.setOpaque(true);
frame.setContentPane(newContentPane);
frame.pack();
frame.setVisible(true);
}
Similar Messages
-
Close, minimize, resize buttons in top left dissapeared
Any help MUCH appreciated!!... I cannot seem to figure out how i've lost my close, minimize and resize buttons in top left. IT's only in Illustrator. I have a MacBook Pro..
Any thoughts???
Thanks,
ElenaChances are the buttons are merely behind the Control Panel or your'e simply in Full Screen Mode.
If your document is behind the Control panel, tap the Tab key to hide all panel, then move the document down so it's not behind the control panel.
If you are in Full Screen Mode, tap the F key on the keyboard until you see the buttons again. -
NEED HELP IN RADIO BUTTON QUERY
Hi, Friends
I like to query to extract data from my table with the help of radio button but I am not able to think what I should write to query. Plz help.
The radio button select jsp page code is-
<form action="queryservice.jsp" method="post">
<h3><strong>Services Available</strong></h3>
<p>
<label>
<input type="radio" name="service" value="si" />
Institutions</label>
<br />
<label>
<input type="radio" name="service" value="sc" />
Corporate_Offices</label>
<br />
<label>
<input type="radio" name="service" value="sr" />
Restaurent_Cafe</label>
<br />
<label>
<input type="radio" name="service" value="sb" />
Bus_Stop</label>
<br />
<label>
<input type="radio" name="service" value="sa" />
Apartment</label>
<br />
<label>
<input type="radio" name="service" value="sh" />
Hotels</label>
<br />
</p>
<label>
<input type="submit" value="Submit" />
</label>
</form>And queryservice.jsp page is
<%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %>
<sql:query var="xyz" scope="request">
<% String var = request.getParameter("service"); %>
if(var.equals("si")){ SELECT si FROM serviceTable}
else if(var.equals("sc")){ SELECT sc FROM serviceTable}
else if(var.equals("sr")){ SELECT sr FROM serviceTable}
else if(var.equals("sb")){ SELECT sb FROM serviceTable}
else if(var.equals("sa")){ SELECT sa FROM serviceTable}
else if(var.equals("sh")){ SELECT sh FROM serviceTable}
</sql:query>Please correct it.
Thanking youError Report-
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException:
if(var.equals("si")){ SELECT si FROM serviceTable }
else if(var.equals("sc")){ SELECT sc FROM serviceTable}
else if(var.equals("sr")){ SELECT sr FROM serviceTable}
else if(var.equals("sb")){ SELECT sb FROM serviceTable}
else if(var.equals("sa")){ SELECT sa FROM serviceTable}
else if(var.equals("sh")){ SELECT sh FROM serviceTable}
: Non supported SQL92 token at position: 57: SELECT
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:541)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:417)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
javax.servlet.ServletException: javax.servlet.jsp.JspException:
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.14 logs.
Apache Tomcat/6.0.14 -
Hello,
I need help with a button. I created a button and set it up
so that when you click and hold it, the button becomes lighter in
color (I used Alpha). I want the button to stay this light color
after i release the click. Right now it goes back to the normal
color when I release the click. Can somone help we this?
Thanks!rpofclt wrote:
> Hello,
>
> I need help with a button. I created a button and set it
up so that when you
> click and hold it, the button becomes lighter in color
(I used Alpha). I want
> the button to stay this light color after i release the
click. Right now it
> goes back to the normal color when I release the click.
Can somone help we
> this?
you can't use the button itself if you want to maintain the
DOWN state after
release as button automatically resets itself once the mouse
lives the HIT zone.
Use movie clip instead and on press simply send it to a frame
where there
is DOWN state like image.
Best Regards
Urami
<urami>
If you want to mail me - DO NOT LAUGH AT MY ADDRESS
</urami> -
Want to create F1 Help for radio button in my report
Hi All,
I want to create F1 Help for radio button in my report program. Which function module should i call in <b>at selection screen on help-request</b>
Also do I need to define the texts somewhere or I can pass it directly to the function module.Try DYN_FIELD_F1_HELP,
~Suresh
that is only for Dic fields..
Pl take alook at this<a href="http://help.sap.com/saphelp_erp2005vp/helpdata/en/79/34a243d9b511d1950e0000e8353423/frameset.htm">SAP Help</a>
~Suresh
Message was edited by: Suresh Datti -
Help with Resizing LUNS on Hitachi 9980
Hi everyone, I need a little help here resizing my LUNS on our Hitachi 9980. I currently have a 1 TB and I want to increase or resize this to 2 TB. I am wondering if someone can help me here. This is something I haven't done before. Is there a step by step way of doing this. I was told that it could be done off line or online. Which is safer? Do I also need to reboot the Host after the resizing? Thanks for your assistance.
JCHi everyone, I need a little help here resizing my LUNS on our Hitachi 9980. I currently have a 1 TB and I want to increase or resize this to 2 TB. I am wondering if someone can help me here. This is something I haven't done before. Is there a step by step way of doing this. I was told that it could be done off line or online. Which is safer? Do I also need to reboot the Host after the resizing? Thanks for your assistance.
JC -
Hello All,
I am getting F1 help when the radio buttons are in display mode but i am not getting F1 help when the buttons are in input mode. what cud be the problem?
can anyone please help me. required urgerntly
Thanks & Regards
Amarender Reddy BHi,
use event
at selection-screen on HELP-REQUEST FOR
rb_radio
As with the addition ON VALUE-REQUEST the field psel_low_high
is either the name of a report parameter or of the form sel-LOW
or sel-HIGH, where sel is the name of a selection criterion.
When the user presses F1 on the relevant field, the subsequent
processing block is executed. You can thus implement a
self-programmed help for the input/output fields of the
selection screen. If the program contains such an event and the
user presses F1, the system processes this rather than
displaying the documentation of the Dictionary field - even if
the report parameter or the selection option with LIKE or FOR
points to a Dictionary field.
Regards
amole -
ERROR when hitting the "helpful" or "solved" buttons
Here's the message I get, any system admins know how to fix it?
Error
An error in the system has occurred. Please contact the system administrator if the problem persists.KevinC & Others,
This is a wide spread issue, caused by the recent Maintenance on the Discussions system.
See these previously posted Topics in Feedback About Discussions, posted below.
Please review the responses.
Error when attempting to click "Solved" button in forum
Error when trying to mark a reply as "solved"
Thank you for maintenance and another error
This Thread ERROR when hitting the "helpful" or "solved" buttons
ali b -
Help with linking buttons to Scenes
Hey,
Rookie to Flash and AS3. Just needed some help with my buttons. Im making a flash program about pancakes (random I know). I have a "Mainmenu" scene and then a "Recipe" scene. I have a button on my mainmenu which takes me to the recipe page when I click it, the code behind the button is
"stop();btn_recipe.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);function mouseDownHandler(event:MouseEvent):void {
gotoAndStop(1, "Recipe");
Then when I arrive at my recipe page I have a button which will take me back to my MainMenu, the code behind that button is:
"stop();btn_home.addEventListener(MouseEvent.MOUSE_DOWN, mouse5DownHandler);function mouse5DownHandler(event:MouseEvent):void {
gotoAndPlay(1, "MainMenu");
So I run my program and the first button works and takes me to recipe page but the button to get to the main menu does nothing, click it and no response or anything
Please helpFirst, hopefully having all your code mushed onto the same line is a copy/paste error, otherwise it should look like...
stop();
btn_recipe.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
function mouseDownHandler(event:MouseEvent):void {
gotoAndStop(1, "Recipe");
If the intention is to click the buttons to make them work, then you should use CLICK instead of MOUSE_DOWN. MOUSE_DOWN can be a persistent state whereas CLICK involves releasing it afterwards.
As for the code to get you back home, where is it located on the timeline? Are you getting any error messages when you try to use it?
One thing you should learn to use is the trace() function. It is useful for troubleshooting. You can use it now to see if your second button is talking to the function at all...
stop();
btn_home.addEventListener(MouseEvent.CLICK, mouse5DownHandler);
function mouse5DownHandler(event:MouseEvent):void {
trace("the button works okay");
gotoAndPlay(1, "MainMenu");
If you don't get that message in the output panel, you'll know the button is not properly coded to work.
Most folks here will recommend you get away from using scenes in a design that includes navigation--they have a history of being problematic. Instead of using scenes, divide the one main timeline up into sections or use movieclips for the sections and manage their visibility... or do a bit of both. -
Help with Resizing of column widths in a pivot
HI all,
I m working on resizing the pivot coulmn width in a dashboard. Could anyone please help with resizing the pivot width. Autosize() works but user doesnt want that.
Whats the code to do that?I read what was written but still am confused. I am completely lost at this pointWhat is confusing you? A TreeMap is just a HashMap where the key is stored is sorted order.
Read the Collections tutorial found [url http://java.sun.com/docs/books/tutorial/]here. -
Little bit of help[ with a button.
Good day all!
I need help making a button. This is what I want to happen.
I have a bunch of text, One of the words "merino" is bule as
to say there is a link hear! And I want an image of the "merino" to
come up, like a "ALT" box. Or have an image in the "ALT" box?
I know how to do this in "Flash" i.e just drop in the image
on the over state of the button event. Easy as pie! This is why I
cant get to grips with Dreamweaver! I hate it!
But I am willing to learn and maybe in time love???
Thanks all!"satrop" <[email protected]> wrote in
message
news:f0o4t7$954$[email protected]..
> Good day all!
>
> I need help making a button. This is what I want to
happen.
>
> I have a bunch of text, One of the words "merino" is
bule as to say there
> is a
> link hear! And I want an image of the "merino" to come
up, like a "ALT"
> box.
>
> I know how to do this in "Flash" i.e just drop in the
image on the over
> state
> of the button event. Easy as pie! This is why I cant get
to grips with
> Dreamweaver! I hate it!
>
> But I am willing to learn and maybe in time love???
HTML is a lot different from Flash! :-)
I believe you could do this using DW's Show-Hide layer
behavior - have
mousing over the link trigger a layer with the image to
appear. Someone else
may have a better idea.
Just FYI, having to mouse over a link in order to get more
information about
it isn't usually appreciated by users. You *might* want to
re-think this
plan..
Patty Ayers | Adobe Community Expert
www.WebDevBiz.com
Free Articles on the Business of Web Development
Web Design Contract, Estimate Request Form, Estimate
Worksheet -
A line is missing at the bottom of the screen just above the dock window on my macintosh. Using Mac OS X, version 10.6.7
I indicated that I have this problem too, or at least a related one, but I wanted to add some details. In my case, using gmail, the resize button actually isn't even visible. But when I try to put the mouse on the line-scroll arrow at bottom right, the cursor changes to the resize cursor, and I can resize from there (with the mouse a good bit above where the resize button should be). So I think it's the same problem reported by this user. As indicated, it's impossible to use the line-scroll button in this mode. I don't seem to have the problem on other web pages, or at least not that I've noticed. I just obtained Firefox 4, so I think I've got an up-to-date copy, and I'm running on Windows XP, SP2. And other than this, I *really* like FF4--that tab organization feature is absolutely stunning in its usefulness. Oh, and, in case it matters, I'm also running the gmail under the "pinned tab" option.
-
Matchcode in OO (call the search help when the button is pressed )
Hi Guys,
I'm using the class cl_dd_document in order to fill a form that contains a input element (cl_dd_input_element) and a button element (cl_dd_button_element).
What I need to do now is to simulate (or build) a matchcode for the button.
For example, the input field is for entering the name of a table, and with the button i want to show all the tables that are elegibles for that field.
Any suggestion?
Regards,
Eric
Message was edited by:
Eric Hernandez PardoHi Uwe,
What I want to know is how to call the search help when the button is pressed. (Like the one in SE80 Transaction)
Regards,
Eric
Message was edited by:
Eric Hernandez Pardo -
I need help to resize firefox when I go online, Help?
When I go online to FireFox, which is my default browser, it resizes and it is huge. I need help so that it will match the properties that I have setup for my computer. I don't know how this happened. When I first installed it, it worked just fine.
See if this helps you - https://support.mozilla.org/en-US/kb/font-size-and-zoom-increase-size-of-web-pages
If not, please provide screenshots of your issue.
https://support.mozilla.org/en-US/kb/how-do-i-create-screenshot-my-problem
It is best to use a compressed image type like PNG or JPG to save the screenshot and make sure that you do not exceed a maximum file size of 1 MB.
Then use the '''Browse ....''' button below the '''''Post a Reply''''' text box to upload the screenshot. -
I am looking for a way to enable/disable all buttons in a
swf. I found this searching here but I don't understand it, and am
looking for some of the many ways, as mentioned.
http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=15&catid=288&threadid =1240137&highlight_key=y&keyword1=enabled
I am messing with having things load in what I call "windows"
and when you close a window, basically it just collapses the .swf.
The problem I have is that the cursor reacts to roll overs and I
can still rollover buttons in the swf even though its collapsed. To
see this prob go to:
www.custom-differentials.com
and open the gallery, then drag the gallery to the middle of
the screen, close the gallery, then move the mouse around the
outside of the "title bar" and watch the mouse change colors even
though there is nothing there. I put a trace in the rollover
handlers so I know which buttons are causing this. I just would
like a broad sweep disable all buttons while the window is closed.
Thanks in advance for any help.OK, I lied to you. I meant to say I was setting the _height
value of the swf to .1, not the y value. Any way the lie is that I
was actually setting it to 0, which is what was causing my problem.
I changed the resize value to .1 and the problem dissapeared. I am
going to try out your suggestion though, for s&g. Thank you for
the help.
I am not gonna mark this answered cuz I am curious on the
original question. Before your suggestion and me stumbling onto my
own stupidity, I was trying out an array that stored button names
and I would cycle through them enabling and diabling as I opened
and closed. One thing I noticed was that my galleries contained 50+
pics and the latency in my push loop may have become a problem.
Thanks Again.
Maybe you are looking for
-
Hi I want to buy an iPhone 4S in México but i figure out that Siri only function in english french and German my question is if I buy the divice and I set it up in English does Siri will function?
-
Pls urgent reply will be appreciated
A form i enclosed in a jscrollpane doesnt print the full form. It only prints the part visible on the screen. I,ve done all the 2d tricks like clipping, setting my imageable area all as i can... pls urgent reply to this will be appreciated; i attach
-
Problem with aktivation in iPhone4s
I wish you good day. I have a problem with activating my iphone 4s. Still writes me that it can not connect to the server. The problem apparently occurred after update
-
HT201269 Transferring information from current iPhone to new iPhone different carrier
Do I follow the same procedure to backup and restore my iPhone data if I am switching carriers with my new iPhone purchase? I am going from iPhone 4 to iPhone 4s.
-
Presentation catalog deletion - can it be tracked?
Hi All, Presentation catalog is already deleted in our OBIEE (11.1.1.5) envoronment installed on Linux 64bit. Can we track it through some logs like when and with which id it got deleted? your inputs would really help. Thanks.