I'm trying to add a Box to a JLayeredPane - jlayeredpane

I declared the Box as: Box caja=Box.createHorizontalBox();
However the first layer the one that says FondoMenu.png is the only one showing and the Box doesnt show unless I put that JOptionPane showing it first, please some help (The BuscaImagen is a method I made that creates JLabel with my specifications)
capas.add(new BuscaImagen("FondoMenu.png", 0, 0), new Integer(0));
caja.add(new BuscaImagen("JUGAR", "FIz.png", 2, 40, 90));
caja.add(Box.createHorizontalStrut(20));
caja.add(new BuscaImagen("SALIR", "FDe.png", 2, 40, 240));
caja.add(Box.createHorizontalStrut(20));
caja.add(new BuscaImagen("INSTRUCCIONES", "FAb.png", 2, 40, 390));
JOptionPane.showMessageDialog(null, caja);
caja.setLocation(60, capas.getHeight() / 2 - 10);
capas.add(caja, new Integer(1));

There is a nice write up on oracle on how to use Layered Panes. I hope this helps with your issue
http://docs.oracle.com/javase/tutorial/uiswing/components/layeredpane.html

Related

Drop-down menu in pine script to choose differents fills background

I'm trying to do a simple thing in my mind, but really I don't know the correct syntax or if it's possible with pine script.
I created the following drop-down menu with 4 options using input.string:
choose_bg= input.string(title = "Choose background", options = ["RVGI", "MACD", "STOCH", "COLOR"], defval="RVGI")
For every option I want to choose a different kind of background fill between two plots, defined as plots, with the conditions I declared. I'll like e.g. if I choose the first option, the background will fill between two plots, as follow:
colors_rvgi= rvgi_value>rvgi_signal ? color.rgb(55, 255, 72, 90) : rvgi_value<rvgi_signal ? color.rgb(255, 0, 0, 90) : na
fill( OBline, OSline , color=colors_rvgi , title="RVGI Background" )
Usually I saw that in pine scrip is possible to do the opposite: when the condition is true, then the program apply the option choosen before by the dip-down menu. I want to do the opposite, that it's simple in a boolean input between two condition (false and true).So how can I specify to pine script the rule "if choose_bg=="RVGI" then fill(as I want)?
thank you in advance
You can test for choose_bg == "RVGI" for the first field in fill() and return na if false :
fill( hline1 = choose_bg == "RVGI" ? OBline : na, hline2 = OSline , color = colors_rvgi , title = "RVGI Background" )

VB.Net make a image in background task using Win2d

Dependency : Win2D
I am trying to generate a Livetile image from background task.
However, the generated PNG file only looks transparent, no single dot is painted at all.
So, I simplified the important code as below to test, yet no result was changed.
I imported Microsoft.Canvas.Graphics(+Effects,+Text),
Dim device As CanvasDevice = New CanvasDevice()
Dim width = 150, height = 150
Using renderTarget = New CanvasRenderTarget(device, width, height, 96)
Dim ds = renderTarget.CreateDrawingSession()
'ds = DrawTile(ds, w, h)
Dim xf As CanvasTextFormat = New CanvasTextFormat()
xf.HorizontalAlignment = CanvasHorizontalAlignment.Left
xf.VerticalAlignment = CanvasVerticalAlignment.Top
xf.FontSize = 12
renderTarget.CreateDrawingSession.Clear(Colors.Red)
ds.Clear(Colors.Blue)
ds.DrawText("hi~", 1, 1, Colors.Black, xf)
renderTarget.CreateDrawingSession.DrawText("hi~", 1, 1, Colors.Black, xf)
Await renderTarget.SaveAsync(Path.Combine(ApplicationData.Current.LocalFolder.Path, "_tile_150x150.png"))
End Using
The file is created, but it's filled with neither Red or Blue. No text at all. It's transparent with only 150x150 pixel canvas.
Is there any problem with the code? or any other reason?
Thanks a lot!
The CanvasDrawingSession ("ds" in your sample) needs to be Closed / Disposed before you call SaveAsync.
You can use "Using ds = renderTarget.CreateDrawingSession()" to do this for you - put the call to SaveAsync after "End Using".
From there you should use the same "ds" rather than call "CreateDrawingSession" multiple times.

How to copy CellComments to new cell (when copying an entire sheet)

I am trying to copy a CellComment to a new cell (using Apache POI). I know I have to create new comment (as opposed to just setting the old comment in to the new cell), but I can't seem to be able to find out how to duplicate the Anchor.
private void createComment(Cell aNewCell, Comment theOldComment) {
CreationHelper createHelper = aNewCell.getSheet().getWorkbook().getCreationHelper();
ClientAnchor anchor = createHelper.createClientAnchor();
// How to get the old CellComment anchor for x1, c2, y1, y2???
Drawing drawing = aNewCell.getSheet().createDrawingPatriarch();
Comment aNewComment = drawing.createCellComment(anchor);
aNewComment.setString(theOldComment.getString());
aNewCell.setCellComment(aNewComment);
}
Use a Patriarch instead of CreationHelper. Create Anchor from the HSSFPatriarch's object and pass the values as parameters to the createAnchor function. Hope this helps.
HSSFPatriarch drawing = sheet.createDrawingPatriarch();
ClientAnchor anchor = drawing.createAnchor(10, 20, 30, 40, (short)4, 2, (short)6, 5);
Hope this helps.
private void createComment(HSSFCell aNewCell, Comment theOldComment) {
HSSFPatriarch drawing = aNewCell.getSheet().getDrawingPatriarch();
ClientAnchor anchor = drawing.createAnchor(drawing.getChildren().get(0).getAnchor().getDx1(),
drawing.getChildren().get(0).getAnchor().getDx2(), drawing.getChildren().get(0).getAnchor().getDy1(),
drawing.getChildren().get(0).getAnchor().getDy2(), (short)4, 2, (short)6, 5);
Comment aNewComment = drawing.createCellComment(anchor);
aNewComment.setString(theOldComment.getString());
aNewCell.setCellComment(aNewComment);
}

How to set axis margin in WinRT XAML Toolkit line chart?

Answer
Finally I solved my answer with this.
((LineSeries)MyChart.Series[0]).IndependentAxis = new LinearAxis
{
Minimum = 1,
Maximum = 5,
Orientation = AxisOrientation.X,
Interval = 1,
Margin = new Thickness(10, 0, 10, 0)
};
((LineSeries)MyChart.Series[0]).Clip = null;
((LineSeries)MyChart.Series[0]).Margin = new Thickness(10, 0, 10, 0);
I am drawing line chart with help of WinRT XAML Toolkit. I am setting X axis manually, but when I set I am getting wierd start & end point. I tried to set margin and padding but it's not working. Will you please suggest me how can I do that ?
((LineSeries)MyChart.Series[0]).IndependentAxis = new LinearAxis
{
Minimum = 1,
Maximum = 5,
Orientation = AxisOrientation.X,
Interval = 1,
//Margin = .... Not working
//Padding = .... Not working
};
I'd use a visual tree debugger to walk up the visual tree from these data points to see where the Clip property is set. In fact I just did that on the samples project and it is set on the LineSeries. See if it's set as part of its XAML template or if it is done in C# and remove it there. Also you could change the Minimum/Maximum values on your X axis to make more space. I'll add cleaning this all up to my TODO list.

vb - I am trying to print other form but this happens:

(this is my first post so correct me if I'm doing something wrong.)
Here is a bit of my code:
imp.id.Text = globalvars.mdataset.Tables("table1").Rows(0).Item("id")
imp.date.Text = globalvars.mdataset.Tables("table1").Rows(0).Item("date")
imp.hour.Text = globalvars.mdataset.Tables("table1").Rows(0).Item("hour").ToString
imp.PrintForm1.PrinterSettings.DefaultPageSettings.Margins = New Printing.Margins(10, 10, 10, 10)
imp.Show()
imp.Focus()
imp.PrintForm1.PrintAction = Printing.PrintAction.PrintToPreview
imp.PrintForm1.Print()
and what happens is that when it gives me the preview the page is empty... but the weird thing is that when i place a msgbox just before the printing action, the preview goes right and shows me what i want to print....
any tips?
EDIT: imp is the form where the printform is
Try to add this ..
....
Application.DoEvents
imp.PrintForm1.Print()